PYTHON SCRIPT/SCHEME EXCHANGE

Berserker Pride

Grandmaster Knight
WB
Best answers
0
For all of you making some kind of fantasy mod.  Most fantasy games have health regeneration of some kind.  So using the weapons on any paticular troop you can make him heal either quickly or slowly.
Code:
ogre_regeneration = (1, 0, 1,[],
    [
  (try_for_agents,":agent"),
    (agent_get_wielded_item,":wielded_item",":agent",0),
    (this_or_next|eq,":wielded_item","itm_ogre_plank"),
    (eq,":wielded_item","itm_thrown_plank"),
    (get_player_agent_no, ":player_agent"),
    (agent_is_alive,":agent"),
    (agent_is_human,":agent"), 
    (neq,":agent",":player_agent"),
    (store_agent_hit_points,":life",":agent",1),
    (val_add,":life",40),
    (agent_set_hit_points,":agent",":life",1),
  (try_end),
   ])
This guy has a really fast health regeneration because he is a boss but the regeneration can be any speed you want.  I put a line in there to prevent the player from regenerating if he has the weapon but you could remove it if you wanted the player to heal too. I did some testing and you don't need a val_min operation in there.  The game seems to remember what a troop's max health is.

This is a trigger for mission templates.  It can go in any of the combat templates you want.
 

Rongar

Master Knight
M&BWB
Best answers
0
Remove lances in assaults

Here the code that forbids AI to use large pike in assaults (if troop has other melee weapon).
This code can be easily extended on any situation then it is required to have different equipment for different mission.

1. In  module_constatns.py somewhere after
Code:
#Rebellion changes begin
slot_troop_discussed_rebellion = 140
slot_troop_support_base = 141
add
Code:
slot_troop_weapon_store = 142
2. In module_scripts.py add following scripts (tune weapon checks ad gustum)

Code:
#script_troop_remove_pikes
#remove lances from troop inventory if troop has other type of weapon
#input: arg1=troop
#output : none
("troop_remove_pikes",
 [
	 (try_begin), 
 	 	(store_script_param_1,":troop"),
 	 
	 	(troop_slot_eq,":troop",slot_troop_weapon_store,0), 
	 	(troop_get_inventory_capacity,":cap",":troop"),
	 	(assign,":has_choice",0),
	 	(try_for_range,":i",0,":cap"),	  	  
		  	(troop_get_inventory_slot,":item",":troop",":i"),
#here should check if item is allowed in assaults i.e.
		  	(is_between,":item","itm_wooden_stick","itm_jousting_lance"),	
		  	(assign,":has_choice",1),
	    	  	(assign,":cap",0),#break 
	 	(try_end),
	  (try_begin), 
	 	(eq,":has_choice",1),# troop has melee non-lance
	 	(troop_get_inventory_capacity,":cap",":troop"),
	 	(assign,":removed",0),
	 	(try_for_range,":i",0,":cap"),	  	  
		  	(troop_get_inventory_slot,":item",":troop",":i"),
#here should check if item is not allowed in assaults i.e.
		  	(is_between,":item","itm_jousting_lance","itm_wooden_shield"),	
 		            (val_add,":removed",1),
		  	(store_add,":shift",":removed",slot_troop_weapon_store),
		  	(troop_set_slot,":troop",":shift",":item"),
	     		(troop_set_inventory_slot,":troop",":i",-1),
		 (try_end),	  
	         (troop_set_slot,":troop",slot_troop_weapon_store,":removed"),
         (else_try),
		 (troop_set_slot,":troop",slot_troop_weapon_store,-1),
	 (try_end),
	  (try_end),
	 
	  ]),  	  	  	  	  	  
	  
#script_troop_restore_pikes
#restore troop equipment
#input: arg1=troop
#output : none
("troop_restore_pikes",
 [
 	(store_script_param_1,":troop"),
        (troop_get_slot,":removed",":troop",slot_troop_weapon_store),
 	(try_for_range,":i",0,":removed"),	  	  
	     (store_add,":shift",":i",slot_troop_weapon_store+1),
	     (troop_get_slot,":item",":troop",":shift"), 
	     (troop_add_item,":troop",":item"),
        (try_end),
	(troop_set_slot,":troop",slot_troop_weapon_store,0), 
	  ]),  	  	  	  	  	  	  
	  
#script_all_restore_pikes
#
#input: none	  
#output : none	  
("all_restore_pikes",
 [
 	(try_for_range,":troop","trp_farmer","trp_kidnapped_girl"),#instead all troops here can be for instance only knights 
	     (call_script,"script_troop_restore_pikes",":troop"),	     
        (try_end),
	 
	  ]),  	  	  
	  
#script_all_remove_pikes
#input: none	  
#output : none	  	  
("all_remove_pikes",
 [
 	(try_for_range,":troop","trp_farmer","trp_kidnapped_girl"),#instead all troops here can be for instance only knights 
	     (call_script,"script_troop_remove_pikes",":troop"),	     
        (try_end),
	 
	  ]),  	  	  	 
3. In module_game_menus.py

3.1 Search for "battle_debrief" (with quotes)
Add the call for script_all_restore_pikes, the result should look like
Code:
  (
    "battle_debrief",mnf_scale_picture|mnf_disable_all_keys,
    "{s11}^^Your Casualties:{s8}{s10}^^Enemy Casualties:{s9}",
    "none",
    [
     (call_script,"script_all_restore_pikes"), #restore lances 
     (try_begin),

3.2 Search for  "join_siege_with_allies" (with quotes)
Add the call for script_all_remove_pikes at the end of menu item code before (change_screen_mission), the result should look like

Code:
	   (call_script,"script_all_remove_pikes"), #remove lances
           (jump_to_menu, "mnu_battle_debrief"),
           (change_screen_mission),
          ]),
      ("join_siege_stay_back",

3.3 Search for  "castle_lead_attack" (with quotes)
Add the call for script_all_remove_pikes at the end of menu item code before (change_screen_mission), the result should look like

Code:
             (call_script,"script_all_remove_pikes"), #remove lances from troops in sieges
             (jump_to_menu, "mnu_battle_debrief"),
             (change_screen_mission),
           (try_end),
       ]),
      ("attack_stay_back",
3.4 Search for  "siege_attack_meets_sally" (with quotes)
Add the call for script_all_remove_pikes at the end of menu item code before (change_screen_mission), the result should look like

Code:
    [
      ("continue",[],
       "Continue...",
       [
             (call_script,"script_all_remove_pikes"), #remove lances
             (jump_to_menu, "mnu_battle_debrief"),
             (change_screen_mission),
       ]),
3.5 Search for  "castle_besiege_inner_battle" (with quotes)
Add the call for script_all_remove_pikes at the end of "continue"  menu item code before (change_screen_mission), the result should look like

Code:
       (assign, "$g_next_menu", "mnu_castle_besiege_inner_battle"),
           (call_script,"script_all_remove_pikes"), #remove lances
           (jump_to_menu, "mnu_battle_debrief"),
           (change_screen_mission),
       ]),
    ]
  ),

  
  (
    "construct_ladders",0,
 

ArRiad

Sergeant at Arms
Best answers
0
Rongar said:
Here the code that forbids AI to use large pike in assaults (if troop has other melee weapon).
Hello, Rongar.

Thank you very mach for the code. Now we may fix one of the most annoying AI bugs.
I add your code to my modfiles and all compiled well. But I found a strange bug in my game in the test with khergit lancers. In field battles all seemed to be OK, but in siege some of my lancers used to fight with shield and "no_item" - practice_sword (normally they have two sabres, one mace, two lances and a shield). I was able to use practice_swords from killed  khergit lancers during the battle.
Moreover, in the loot of the defeated vaegir town I found about 10 no_items (practice_swords). That is some vaegirs also used them.
What do you think about it? What may be the reason?

Thank you.

P.S. I tested vaegir knights and found that if before any siege their equipment in the battle was OK, then after one siege all of them in all battles had no lances at all! Instead of lances they have no_items, practice_swords and even heavy_practice_swords!
Moreover, after a siege some swadian knights, I fight with, have lances, but other have no_items.

"khergit_lancer" ... [itm_steel_shield,itm_awlpike,itm_ashwood_pike,itm_sword_khergit_4,itm_sword_khergit_4,itm_sword_khergit_3,
itm_kataphract_armor,itm_magyar_helmet_a,itm_khergit_helmet,itm_scale_gauntlets,itm_mail_boots,itm_warhorse,itm_warhorse]

"vaegir_knight" ... itm_tab_shield_kite_cav_b,itm_tab_shield_kite_cav_a,itm_sword_viking_1,itm_sword_viking_2,itm_sword_viking_3,itm_lance,itm_lance,itm_lance,itm_winged_mace,
itm_lamellar_armor,itm_guard_helmet,itm_khergit_war_helmet,itm_mail_mittens,itm_mail_boots,itm_warhorse
 

Rongar

Master Knight
M&BWB
Best answers
0
Sorry, folks.
Instead of
Code:
  	(troop_set_slot,":troop",":shift",":item"),
	     		(troop_set_inventory_slot,":troop",":i",0),
		 (try_end),
should be
Code:
  	(troop_set_slot,":troop",":shift",":item"),
	     		(troop_set_inventory_slot,":troop",":i",-1),
		 (try_end),
and instead of
Code:
(try_for_range,":i",0,":removed"),	  	  
	     (store_add,":shift",":i",slot_troop_weapon_store),
	     (troop_get_slot,":item",":troop",":shift"),
should be
Code:
(try_for_range,":i",0,":removed"),	  	  
	     (store_add,":shift",":i",slot_troop_weapon_store+1),
	     (troop_get_slot,":item",":troop",":shift"),
I updated my previous post.

PS ArRiad, thanks for feedback.
 

rorschach82

Veteran
Best answers
0
Mirathei said:
In that case it should be more like this:

For player:
ti_on_whatever_pressed calls the following script:

Code:
(get_player_agent_no,":player"),
(agent_get_position,1,":player"),
(assign,":mindist",100),
(assign,":shield_equipped",0),
(try_for_range,":shield",shields_begin,shields_end), #fill in the appropriate item names
   (agent_has_item_equipped,":player",":shield"),
   (assign,":shield_equipped",1),
(end_try),
(neq,":shield",0),
(try_for_agents,":agent"),
    (agent_is_alive,":agent"),
    (agent_is_human,":agent"),
    (neg|agent_is_ally,":agent"),
    (agent_get_position,2,":agent"),
    (neg|position_is_behind_position,2,1),
    (get_distance_between_positions,":dist",1,2),
    (lt,":dist",":mindist"),
    (assign,":mindist",":dist"),
    (assign,":chosen",":agent"),
(end_try),
(agent_set_animation, ":player", anim_shield_bash),  # someone would have to make this animation.
(agent_set_animation, ":chosen", anim_strike_fall_back_rise),
(agent_store_health,":health",":chosen"),
(val_sub,":health",10),
(agent_set_health,":chosen",":health"),
For ai:
Every second during battle call the following script:
Code:
(get_player_agent_no,":player"),
(try_for_agents,":basher"),
    (agent_is_human,":basher"),
    (agent_is_alive,":basher"),
    (neq,":player",":basher"),
    (assign,":shield_equipped",0),
    (try_for_range,":shield",shields_begin,shields_end), #fill in the appropriate item names
        (agent_has_item_equipped,":basher",":shield"),
        (assign,":shield_equipped",1),
    (end_try),
    (neq,":shield_equipped",0),
    (try_begin),
          (agent_is_ally,":basher"),
          (agent_get_position,1,":basher"),
          (assign,":mindist",100),
          (try_for_agents,":agent"),
                (agent_is_alive,":agent"),
                (agent_is_human,":agent"),
                (neg|agent_is_ally,":agent"),
                (agent_get_position,2,":agent"),
                (neg|position_is_behind_position,2,1),
                (get_distance_between_positions,":dist",1,2),
                (lt,":dist",":mindist"),
                (assign,":mindist",":dist"),
                (assign,":chosen",":agent"),
           (end_try),
           (store_random_in_range,":random",1,10),
           (eq,":random",7),                                          #this line and the one before it would keep to agents from simultaneously shield bashing one another save in rare instances.
           (agent_set_animation, ":basher", anim_shield_bash),  # someone would have to make this animation.
           (agent_set_animation, ":chosen", anim_strike_fall_back_rise),
           (agent_store_health,":health",":chosen"),
           (val_sub,":health",10),
           (agent_set_health,":chosen",":health"),
    (else_try),
          (neg|agent_is_ally,":basher"),
          (agent_get_position,1,":basher"),
          (assign,":mindist",100),
          (try_for_agents,":agent"),
                (agent_is_alive,":agent"),
                (agent_is_human,":agent"),
                (agent_is_ally,":agent"),
                (agent_get_position,2,":agent"),
                (neg|position_is_behind_position,2,1),
                (get_distance_between_positions,":dist",1,2),
                (lt,":dist",":mindist"),
                (assign,":mindist",":dist"),
                (assign,":chosen",":agent"),
           (end_try),
           (store_random_in_range,":random",1,10),
           (eq,":random",7),                                          #this line and the one before it would keep to agents from simultaneously shield bashing one another save in rare instances.
           (agent_set_animation, ":basher", anim_shield_bash),  # someone would have to make this animation.
           (agent_set_animation, ":chosen", anim_strike_fall_back_rise),
           (agent_store_health,":health",":chosen"),
           (val_sub,":health",10),
           (agent_set_health,":chosen",":health"),
    (end_try),
(end_try),

That would fix it, unless you forgot to fill in the correct items for shields_begin and shields_end.

Highlander said:
I'm pretty sure it has to be in hand.
I've never played around with the command. You're probably right.


EDIT: fixed an error in the player script.

EDIT2: DarkAnd, did it succsessfully take ten hit points from you when you were bashed?

may i ask what python script in the module should i add this script in?
 

ligerteeth

Regular
Best answers
0
PaperJack said:
I'm pretty much a newbie in M&B modding, and I've been wondering how can I make a crossbow shoot a unique projectile instead of the default bolt. Can somebody please enlighten me ?
This is very simple. Just create the new "unique projectile" item in module_items:
Code:
 ["unique_projectile","Unique Projectile", [("bolt",0),("flying_missile",ixmesh_flying_ammo),("bolt_bag", ixmesh_carry),("bolt_bag_b", ixmesh_carry|imodbit_large_bag)], itp_type_bolts, itcf_carry_quiver_right_vertical, 0,weight(2.25)|weapon_length(55)|max_ammo(49),imodbits_missile],
Modify this however you like, change damage, speed, etc, even give it a mesh other than some kind of crossbow bolt, but as long as it has itp_type_bolts, it will fire out of a crossbow. Simply buy the new item and equip it. BTW, if you're new i suggest you read the module system documentation http://forums.taleworlds.com/index.php/board,12.0.html
 

DuoGum

Recruit
Best answers
0
Garnier said:
Garnier's Bank of Calradia code -- written for 0.960!

I put together some code for a central bank of Calradia, where you can store money or take loans.  The specifics are;
You go to a town, and click "visit the bank".
To take a loan, you pay 100 denars immediately, and 1000 in debt to the bank.  You can repay the loan at any time.  Interest on the loan is 200% per year, so each week you pay 40 denars interest on each 1000 denar loan.
You have to have 100 real denars to take a loan, real meaning your total cash minus your total debt has to be 100 or more.  So you can't keep taking out loans forever.
If you cannot pay the interest on your loans in a given week, the unpaid sum is added to your debt, and next week you are expected to pay interest again, which in turn is added to the debt if you can't pay. 
You can deposit money at the bank, and gain 20% per year in interest, so 4 d/week on a 1000 deposit.  You can withdraw the deposit at any time.

Global Variables created;

$g_player_debt
$g_player_deposit


Add this to the game start script;  #Defines the global variables used.
Code:
      (store_add, "$g_player_debt",0,0),
      (store_add, "$g_player_deposit",0,0),
Add these menus to game_menus.py;  #The first menu is a weekly interest payment menu, and the second is the bank menu where you handle deposits/loans.
Code:
  (
    "debt_interest",mnf_scale_picture|mnf_disable_all_keys,
    "{s2}",
    "none",
    [

	  (store_div, ":debt_interest","$g_player_debt",25),
          (assign, reg11, ":debt_interest"),
          (store_troop_gold, ":player_wealth", "trp_player"),
          (assign, reg8, ":player_wealth"),
	(try_begin),
	  (ge,"$g_player_debt",1),
	  (try_begin),
            (ge, ":player_wealth", ":debt_interest"),
            (troop_remove_gold, "trp_player",":debt_interest"),
            (store_sub, reg9, reg8, reg11),
            (str_store_string, s2, "@You paid {reg11} of your {reg8} denars in interest on your debt. You have {reg9} denars left."),
          (else_try),
	    (gt, ":debt_interest",":player_wealth"),
	    (gt, ":player_wealth",0),
	    (store_sub, ":unpaid_interest", ":debt_interest",":player_wealth"),
            (troop_remove_gold, "trp_player",":player_wealth"),
            (assign, reg10, ":unpaid_interest"),
            (val_add, "$g_player_debt",":unpaid_interest"),
            (str_store_string, s2, "@You paid all of your {reg8} denars in interest on your debt.  There were still {reg10} denars of the interest unpaid, which has been added to your debt.  You have 0 denars left."),
          (else_try),
	    (gt, "$g_player_debt",0),
	    (eq, ":player_wealth",0),
	    (store_sub, ":unpaid_interest", ":debt_interest",":player_wealth"),
            (val_add, "$g_player_debt",":unpaid_interest"),
            (str_store_string, s2, "@You had 0 denars left to pay the interest on your debt.  The interest of {reg10} denars has been added to your debt."),
          (else_try),
            (str_store_string, s2, "@You have no debts to pay interest on."),
	  (try_end),
	(try_end),
    ],
    [
      ("continue",[],"Continue...",
       [
        (change_screen_return,0),
        ]
       ),
    ]
  ),
  (
    "bank",0,
    "You visit the bank.\
 Here you can deposit money and earn interest over time, or take a loan.\
 You currently have {reg6} denars deposited here.\
 You currently have {reg7} denars borrowed from the bank.",
    "none",
    [
    (assign, reg6, "$g_player_deposit"),
    (assign, reg7, "$g_player_debt"),
    ],
    [
      ("take_loan",[(store_troop_gold, ":player_wealth", "trp_player"),(store_sub, ":player_real_wealth", ":player_wealth", "$g_player_debt"),(gt,":player_real_wealth",100)],"Take a loan of 1000 denars.",
       [
	   (troop_remove_gold, "trp_player", 100),
           (troop_add_gold, "trp_player", 1000),
           (val_add, "$g_player_debt", 1000),
        ]),
      ("give_loan",[(store_troop_gold, ":player_wealth", "trp_player"),(gt,":player_wealth",1000),(gt,"$g_player_debt",1000)],"Repay 1000 denars of your debt.",
       [
	   (troop_remove_gold, "trp_player", 1000),
           (val_sub, "$g_player_debt", 1000),
        ]),
      ("give_loan_all",[(store_troop_gold, ":player_wealth", "trp_player"),(gt,":player_wealth","$g_player_debt"),(gt,"$g_player_debt",0)],"Repay all of your debt.",
       [
	   (troop_remove_gold, "trp_player", "$g_player_debt"),
           (val_sub, "$g_player_debt", "$g_player_debt"),
        ]),
      ("give_deposit",[(store_troop_gold, ":player_wealth", "trp_player"),(gt,":player_wealth",1000)],"Deposit 1000 denars in the bank.",
       [
	   (troop_remove_gold, "trp_player", 1000),
           (val_add, "$g_player_deposit", 1000),
        ]),
      ("take_deposit",[(ge,"$g_player_deposit",1000)],"Withdraw 1000 denars from your deposit.",
       [
	   (troop_add_gold, "trp_player", 1000),
           (val_sub, "$g_player_deposit", 1000),
        ]),
      ("take_deposit_all",[(ge,"$g_player_deposit",1)],"Withdraw your entire deposit.",
       [
	   (troop_add_gold, "trp_player", reg6),
           (val_sub, "$g_player_deposit", reg6),
        ]),
      ("back_to_town_menu",[],"Head back.",
       [
           (jump_to_menu,"mnu_town"),
        ]),
    ]
  ),
And this again to game_menus.py, just after the "visit the tavern" entry;  ##This is the text "Visit the bank" when you are in a town.
Code:
      ("town_bank",
       [],
       "Visit the bank.",
       [
           (jump_to_menu,"mnu_bank"),
        ]),
And this to simple_triggers.py,  ##These trigger the interest on debt payment menu, and the automatic interest on deposits
Code:
  #Interest on deposits.
  (24 * 7,
   [
    (try_begin),
       (gt, "$g_player_deposit", 0),
       (store_div,":interest_deposit","$g_player_deposit",250),
       (troop_add_gold, "trp_player",":interest_deposit"),
    (try_end),
    ]),
  #Interest on debts.
  (24 * 7,
   [
     (try_begin),
       (gt, "$g_player_debt", 0),
       (jump_to_menu,"mnu_debt_interest"),
     (try_end),
    ]),
This is just the basic code, I probably will add random events like the bank being robbed and your deposits being cut, and perhaps a debtors prison where you serve time if you can't pay interest after 8 weeks or something.  (In my mod you lost more renown, as well as weapon proficiencies over time, so spending time in prison would not be good).
Hi, i have a problem in the script :


Initializing...
Traceback (most recent call last):
  File "process_global_variables.py", line 7, in <module>
    from module_simple_triggers import *
  File "D:\Moutn & Blade - MODDING\ModuleSystem\module_simple_triggers.py", line
2625, in <module>
    (try_end),
TypeError: 'tuple' object is not callable
Exporting strings...
Exporting skills...
Exporting tracks...
Exporting animations...
Exporting meshes...
Exporting sounds...
Exporting skins...
Exporting map icons...
Creating new tag_uses.txt file...
Creating new quick_strings.txt file...
Exporting faction data...
Exporting item data...
Exporting scene data...
Exporting troops data
Exporting particle data...
Exporting scene props...
Exporting tableau materials data...
Exporting presentations...
Exporting party_template data...
Exporting parties
Traceback (most recent call last):
  File "process_parties.py", line 69, in <module>
    save_parties(parties)
  File "process_parties.py", line 51, in save_parties
    add_tag_use(tag_uses,tag_troop,member[0])
TypeError: 'int' object is unsubscriptable
Exporting quest data...
Exporting scripts...
Exporting mission_template data...
Exporting game menus data...
Traceback (most recent call last):
  File "process_simple_triggers.py", line 2, in <module>
    from module_simple_triggers import *
  File "D:\Moutn & Blade - MODDING\ModuleSystem\module_simple_triggers.py", line
2625, in <module>
    (try_end),
TypeError: 'tuple' object is not callable
exporting triggers...
exporting dialogs...
Checking global variable usages...

______________________________

Script processing has ended.
Press any key to exit. . .





??
 
Best answers
0
The M&B version does not cause problems with the MS since the changes between 0.960 and 1.01x concerns gameplay. Not the MS structure.

Correct the first error spawned :

TypeError: 'tuple' object is not callable
It is a pure Python error, not a MS one.
You have certainly forgotten something somewhere in your typo...
 

Jezze

Baron
WBM&BNWVC
Best answers
0
I got it working on a V1.011 and I just copied everything acoording to the manual :smile: So it isn't that hard.
 

cdvader

I was playing Warcraft III and suddenly it striked into my head: Why not try to do something like "Fog of War" on the map? My idea was that at first, everything on the map would be hidden, and as you do quests, talk to troops or just explore, you'll eventually uncover the whole map.

I believe this has been done before, by HardCore, in his Overlord mod, but I don't think he released the source for it. Anyway, here are the stuff.

#---------------------------------------
#Party Hiding by cdvader.

#script_hide_center
#Input: center to hide.
#Output: center hidden.
("hide_center",
[
    (store_script_param, ":center", 1),
    (party_set_flags, ":center", pf_disabled, 1),
]),

#script_hide_centers_in_range
#Input 1: center to disable BEGIN.
#Input 2: center to disable END.
#Output: Disables centers.
("hide_centers_in_range",
[
    (store_script_param, ":center_begin", 1),
(store_script_param, ":center_end", 2),
(assign, ":temp_val", ":center_end"),
(val_add, ":temp_val", 1),
(try_for_range, ":center", ":center_begin", ":temp_val"),
    (party_set_flags, ":center", pf_disabled, 1),
(try_end),
]),

#script_hide_all_centers
#Input: None.
#Output: centers hidden.
("hide_all_centers",
[
    (try_for_range, ":center", centers_begin, centers_end),
    (party_set_flags, ":center", pf_disabled, 1),
(try_end),
]),

#script_enable_center
#Input: center to enable.
#Output: Enables the given center.
("enable_center",
[
    (store_script_param, ":center", 1),
(party_set_flags, ":center", pf_disabled, 0),
]),

#script_enable_centers_in_range
#Input 1: centers to enable BEGIN.
#Input 2: centers to enable END.
#Output: Enables centers.
("enable_centers_in_range",
[
    (store_script_param, ":center_begin", 1),
(store_script_param, ":center_end", 2),
(assign, ":temp_val", ":center_end"),
(val_add, ":temp_val", 1),
(try_for_range, ":center", ":center_begin", ":temp_val"),
    (party_set_flags, ":center", pf_disabled, 0),
(try_end),
]),

#script_enable_all_centers
#Input: None.
#Output: None.
("enable_all_centers",
[
    (try_for_range, ":center", centers_begin, centers_end),
    (party_set_flags, ":center", pf_disabled, 0),
(try_end),
]),

#---------------------------------------
#---------------------------------------
#Party Hiding by cdvader.

(0.1,
[
    (try_for_range, ":center", centers_begin, centers_end),
    (store_distance_to_party_from_party, ":dist", ":center", "p_main_party"),
(party_get_skill_level, ":skl_level", "p_main_party", skl_spotting),
(val_sub, ":dist", ":skl_level"),
(lt, ":dist", 10),
(assign, ":chosen_center", ":center"),
(party_set_flags, ":chosen_center", pf_disabled, 0),
(try_end),
])

#---------------------------------------
Scripts & how to use them.

script_hide_center
(call_script, "script_hide_center", "<center_no>"),
Hides the given center.

script_hide_centers_in_range
(call_script, "script_hide_centers_in_range", "<center_no_begin>", "<center_no_end>"),
Hides all centers from 'center_no_begin' to 'center_no_end'.

script_hide_all_centers
(call_script, "script_hide_all_centers"),
Hides all centers. This probably should go to script_game_init or something.


script_enable_center
(call_script, "script_enable_center", "<center_no>"),
Shows the given center.

script_enable_centers_in_range
(call_script, "script_enable_centers_in_range", "<center_no_begin>", "<center_no_end>"),
Shows all centers from 'center_no_begin' to 'center_no_end'.

script_enable_all_centers
(call_script, "script_enable_all_centers"),
Enables all centers. Good when the player buys a map or something.
 

Jezze

Baron
WBM&BNWVC
Best answers
0
Wooh! Awesome, so actually you wouldn't see any towns or villages until you reached for a certain distance?

I will think of it to put in my mod if you would allow me.
 

cdvader

I was at my friends house and he was playing World of Warcraft. He had some kind of epic items or something, which had "slots". Basically, when you have, for example, Chaos Armor on and Chaos Helmet on, it will grant you some kind of a bonus.

Now, I know this has been done before, particulary by KON_Air. Props to him for doing it first, but I just couldn't resist to give it a shot, too. You can also set new values to the items in the middle of the game by simply re-setting new item slots (shown later), in a middle of a quest, finishing a quest, by a trigger or whatever, there are many possibilities.

The bad thing is, though, that these scripts might be a bit too complicated... And I haven't done any comments, really, so if you run into errors, I won't take responsibility. :razz:

#-----------------------------
#Item Sets by cdvader.
slot_ironflesh_bonus  = 150 #Body.
slot_powerstrike_bonus = 151 #Hand.
slot_athletics_bonus  = 152 #Leg.
slot_leadership_bonus  = 153 #Head.

guardian_set_begin = "itm_guardian_body"
guardian_set_end  = "itm_guardian_end"
#-----------------------------
#----------------------------------
#Item Sets by cdvader.
(item_set_slot, "itm_guardian_head", slot_leadership_bonus, 4),
(item_set_slot, "itm_guardian_body", slot_ironflesh_bonus, 6),
(item_set_slot, "itm_guardian_hand", slot_powerstrike_bonus, 5),
(item_set_slot, "itm_guardian_leg", slot_athletics_bonus, 7),
#----------------------------------
#----------------------------------
#Item Sets by cdvader.
(else_try),
    (is_between, ":item_no", guardian_set_begin, guardian_set_end),
    (try_begin),
    (eq, ":extra_text_id", 0),
(set_result_string, "@The Plate Set of the powerful Guardians"),
(set_trigger_result, 0xDAA520), #Gold.
(try_end),
(try_begin),
    (eq, ":item_no", "itm_guardian_body"),
(eq, ":extra_text_id", 1),
(set_result_string, "@This armorpiece was a source of great vitality."),
    (set_trigger_result, 0xDAA520), #Gold.
(else_try),
    (eq, ":item_no", "itm_guardian_hand"),
(eq, ":extra_text_id", 1),
(set_result_string, "@Men felt much more strength in their arms with this gauntlet."),
(set_trigger_result, 0xDAA520), #Gold.
(else_try),
    (eq, ":item_no", "itm_guardian_leg"),
(eq, ":extra_text_id", 1),
(set_result_string, "@These boots were specially designed to grant great mobility to the user."),
(set_trigger_result, 0xDAA520), #Gold.
(else_try),
    (eq, ":item_no", "itm_guardian_head"),
(eq, ":extra_text_id", 1),
(set_result_string, "@The helmet gave the owner a much more charismatic personality and voice."),
(set_trigger_result, 0xDAA520), #Gold.
(try_end),
(try_begin),
    (eq, ":item_no", "itm_guardian_body"),
(eq, ":extra_text_id", 2),
(item_get_slot, ":slot", "itm_guardian_body", slot_ironflesh_bonus),
(assign, reg1, ":slot"),
(set_result_string, "@+{reg1} to Ironflesh"),
    (set_trigger_result, 0xDAA520), #Gold.
(else_try),
    (eq, ":item_no", "itm_guardian_hand"),
(eq, ":extra_text_id", 2),
(item_get_slot, ":slot", "itm_guardian_hand", slot_powerstrike_bonus),
(assign, reg1, ":slot"),
(set_result_string, "@+{reg1} to Power Strike"),
(set_trigger_result, 0xDAA520), #Gold.
(else_try),
    (eq, ":item_no", "itm_guardian_leg"),
(eq, ":extra_text_id", 2),
(item_get_slot, ":slot", "itm_guardian_leg", slot_athletics_bonus),
(assign, reg1, ":slot"),
(set_result_string, "@+{reg1} to Athletics"),
(set_trigger_result, 0xDAA520), #Gold.
(else_try),
    (eq, ":item_no", "itm_guardian_head"),
(eq, ":extra_text_id", 2),
(item_get_slot, ":slot", "itm_guardian_head", slot_leadership_bonus),
(assign, reg1, ":slot"),
(set_result_string, "@+{reg1} to Leadership"),
(set_trigger_result, 0xDAA520), #Gold.
(try_end),
(try_begin),
    (eq, ":extra_text_id", 3),
(set_result_string, "@_"), #Blank string.
(set_trigger_result, 0xFFEEDD),
(try_end),
(try_begin),
    (eq, ":extra_text_id", 4),
(troop_get_inventory_slot, ":slot", "$g_talk_troop", ek_head),
(eq, ":slot", "itm_guardian_head"),
(set_result_string, "@Guardian Plate Helmet"),
(set_trigger_result, 0xFFD700), #Bright gold.
(else_try),
    (eq, ":extra_text_id", 4),
    (set_result_string, "@Guardian Plate Helmet"),
(set_trigger_result, 0xC0C0C0), #Silver.
(try_end),
(try_begin),
    (eq, ":extra_text_id", 5),
(troop_get_inventory_slot, ":slot", "$g_talk_troop", ek_body),
(eq, ":slot", "itm_guardian_body"),
(set_result_string, "@Guardian Plate Body"),
(set_trigger_result, 0xFFD700), #Bright gold.
(else_try),
    (eq, ":extra_text_id", 5),
    (set_result_string, "@Guardian Plate Body"),
(set_trigger_result, 0xC0C0C0), #Silver.
(try_end),
(try_begin),
    (eq, ":extra_text_id", 6),
(troop_get_inventory_slot, ":slot", "$g_talk_troop", ek_gloves),
(eq, ":slot", "itm_guardian_hand"),
(set_result_string, "@Guardian Plate Gauntlets"),
(set_trigger_result, 0xFFD700), #Bright gold.
(else_try),
    (eq, ":extra_text_id", 6),
    (set_result_string, "@Guardian Plate Gauntlets"),
(set_trigger_result, 0xC0C0C0), #Silver.
(try_end),
(try_begin),
    (eq, ":extra_text_id", 7),
(troop_get_inventory_slot, ":slot", "$g_talk_troop", ek_foot),
(eq, ":slot", "itm_guardian_leg"),
(set_result_string, "@Guardian Plate Leggings"),
(set_trigger_result, 0xFFD700), #Bright gold.
(else_try),
    (eq, ":extra_text_id", 7),
    (set_result_string, "@Guardian Plate Leggings"),
(set_trigger_result, 0xC0C0C0), #Silver.
(try_end),
(try_begin),
    (eq, ":extra_text_id", 4),
(troop_get_inventory_slot, ":slot", "trp_player", ek_head),
(eq, ":slot", "itm_guardian_head"),
(set_result_string, "@Guardian Plate Helmet"),
(set_trigger_result, 0xFFD700), #Bright gold.
(else_try),
    (eq, ":extra_text_id", 4),
    (set_result_string, "@Guardian Plate Helmet"),
(set_trigger_result, 0xC0C0C0), #Silver.
(try_end),
(try_begin),
    (eq, ":extra_text_id", 5),
(troop_get_inventory_slot, ":slot", "trp_player", ek_body),
(eq, ":slot", "itm_guardian_body"),
(set_result_string, "@Guardian Plate Body"),
(set_trigger_result, 0xFFD700), #Bright gold.
(else_try),
    (eq, ":extra_text_id", 5),
    (set_result_string, "@Guardian Plate Body"),
(set_trigger_result, 0xC0C0C0), #Silver.
(try_end),
(try_begin),
    (eq, ":extra_text_id", 6),
(troop_get_inventory_slot, ":slot", "trp_player", ek_gloves),
(eq, ":slot", "itm_guardian_hand"),
(set_result_string, "@Guardian Plate Gauntlets"),
(set_trigger_result, 0xFFD700), #Bright gold.
(else_try),
    (eq, ":extra_text_id", 6),
    (set_result_string, "@Guardian Plate Gauntlets"),
(set_trigger_result, 0xC0C0C0), #Silver.
(try_end),
(try_begin),
    (eq, ":extra_text_id", 7),
(troop_get_inventory_slot, ":slot", "trp_player", ek_foot),
(eq, ":slot", "itm_guardian_leg"),
(set_result_string, "@Guardian Plate Leggings"),
(set_trigger_result, 0xFFD700), #Bright gold.
(else_try),
    (eq, ":extra_text_id", 7),
    (set_result_string, "@Guardian Plate Leggings"),
(set_trigger_result, 0xC0C0C0), #Silver.
(try_end),
#----------------------------------
#----------------------------------
#Item Sets by cdvader.
(try_begin),
    (troop_get_inventory_slot, ":head", ":troop_no", ek_head),
(eq, ":head", "itm_guardian_head"),
(item_get_slot, ":head_slot", "itm_guardian_head", slot_leadership_bonus),
(assign, reg1, ":head_slot"),
(gt, reg1, 0),
(eq, ":skill_no", "skl_leadership"),
(val_add, ":modifier_value", reg1),
(else_try),
    (troop_get_inventory_slot, ":body", ":troop_no", ek_body),
(eq, ":body", "itm_guardian_body"),
(item_get_slot, ":body_slot", "itm_guardian_body", slot_ironflesh_bonus),
(assign, reg1, ":body_slot"),
(gt, reg1, 0),
(eq, ":skill_no", "skl_ironflesh"),
(val_add, ":modifier_value", reg1),
(else_try),
    (troop_get_inventory_slot, ":hand", ":troop_no", ek_gloves),
(eq, ":hand", "itm_guardian_hand"),
(item_get_slot, ":hand_slot", "itm_guardian_hand", slot_powerstrike_bonus),
(assign, reg1, ":hand_slot"),
(gt, reg1, 0),
(eq, ":skill_no", "skl_power_strike"),
(val_add, ":modifier_value", reg1),
(else_try),
    (troop_get_inventory_slot, ":leg", ":troop_no", ek_foot),
(eq, ":leg", "itm_guardian_leg"),
(item_get_slot, ":leg_slot", "itm_guardian_leg", slot_athletics_bonus),
(assign, reg1, ":leg_slot"),
(gt, reg1, 0),
(eq, ":skill_no", "skl_athletics"),
(val_add, ":modifier_value", reg1),
(try_end),
#----------------------------------
["guardian_body", "Guardian Plate Armor", [("plate_armor",0)], itp_unique| itp_type_body_armor  |itp_covers_legs ,0, 6553 , weight(27)|abundance(100)|head_armor(0)|body_armor(72)|leg_armor(46)|difficulty(0) ,imodbits_plate ],
["guardian_head", "Guardian Plate Helmet", [("great_helm_a",0)], itp_unique| itp_type_head_armor|itp_covers_head,0, 5200 , weight(14)|abundance(100)|head_armor(64)|body_armor(0)|leg_armor(0)|difficulty(0) ,imodbits_plate ],
["guardian_hand", "Guardian Plate Gauntlets", [("gauntlet_a_L",0),("gauntlet_b_L",imodbit_reinforced)], itp_unique|itp_type_hand_armor,0, 4940, weight(12)|abundance(100)|body_armor(22)|difficulty(0),imodbits_armor],
["guardian_leg", "Guardian Plate Greaves", [("iron_greaves",0)], itp_unique| itp_type_foot_armor | itp_attach_armature,0, 6374 , weight(14)|abundance(100)|head_armor(0)|body_armor(0)|leg_armor(64)|difficulty(0) ,imodbits_armor ],
["guardian_end", "Guardian Plate Greaves", [("iron_greaves",0)], itp_unique| itp_type_foot_armor | itp_attach_armature,0, 4374 , weight(3.5)|abundance(100)|head_armor(0)|body_armor(0)|leg_armor(33)|difficulty(0) ,imodbits_armor ],

Clean version (in .py files): http://www.2shared.com/file/8143193/7d672b0f/Item_Sets.html.
 

cdvader

Berserker Pride's agent regeneration is good, it's item based, but I thought I'd make one which would be slot based (more optimized, IMO). Thought and done.

What my script does is that every time a agent spawns somewhere, it checks if it's a king, lord, companion or you, the player, and gives the regeneration rate modifier. Then, every 3 seconds in the game, it adds the regeneration rate modifier to the HP.

It's very simple, too, so you probably won't have any troubles implementing it in. All you have to do is add 'regeneration_info,' and 'regeneration' to your battle mission templates.

#------------------------------------
#Regeneration Script by cdvader.

slot_regeneration_rate = 155

#------------------------------------
#------------------------------------
#Regeneration Script by cdvader.

regeneration_info = (
    ti_on_agent_spawn, 0, 0, [],
[
    (store_trigger_param_1, ":agent"),
(try_begin),
    (is_between, ":agent", kings_begin, kings_end),
(agent_set_slot, ":agent", slot_regeneration_rate, 3),
(try_end),
(try_begin),
    (is_between, ":agent", kingdom_heroes_begin, kingdom_heroes_end),
(agent_set_slot, ":agent", slot_regeneration_rate, 2),
(try_end),
(try_begin),
    (is_between, ":agent", companions_begin, companions_end),
(agent_set_slot, ":agent", slot_regeneration_rate, 1),
(try_end),
(try_begin),
    (get_player_agent_no, ":player"),
    (agent_set_slot, ":player", slot_regeneration_rate, 1),
(try_end),
])

regeneration = (
    3, 0, 0, [],
[
    (try_for_agents, ":agent"),
    (agent_get_slot, ":rate", ":agent", slot_regeneration_rate),
(store_agent_hit_points, ":hp", ":agent", 1),
(val_add, ":hp", ":rate"),
(agent_set_hit_points, ":agent", ":hp", 1),
(try_end),
])

#------------------------------------

You can also get all the scripts (clean version) here: http://www.2shared.com/file/8156078/7f4a6cbc/Regeneration.html.
 

ragnarokk1966

Sergeant
M&BWBWF&S
Best answers
0
Hello All,

I love the script that cdvader put up for adding stats to items.  I am going to mess around with it once I get home from work.  Is there anyway to add exp to the items so they will level up on their own?  Like the item you get in the Conquest mod.  Any ideas on how to do this? 

Thanks in advance
 

DuoGum

Recruit
Best answers
0
André de Cuyne said:
The M&B version does not cause problems with the MS since the changes between 0.960 and 1.01x concerns gameplay. Not the MS structure.

Correct the first error spawned :

TypeError: 'tuple' object is not callable
It is a pure Python error, not a MS one.
You have certainly forgotten something somewhere in your typo...
I don't understand  :cry: