• Welcome to the forums on our new hosting setup. Everything should be working the same, but if you run into any problems, please let us know over here.

PYTHON SCRIPT/SCHEME EXCHANGE

Users who are viewing this thread

dunde

Count
WB
It's an update from code I posted here as Warband provide new operations to improve that.
It's a custom camera that put the character at the middle of the screen, and when we aiming for shooting or throwing, it automatically switches to default camera for beter aiming and backs to custom camera after shoot. It allow you to jump from bot to bot, not to control them but for to get their view of battle. By modifying defeat condition and enabling battle continuation after knocked down, this can be used as death camera too.
Credit to
- Rubik (custom camera)
- Martin F (death camera)

Code :
Code:
################################################################
## CUSTOM CAMERA
################################################################

camera_init = (0,0,ti_once,[(get_player_agent_no, "$cam_current_agent"), (gt, "$cam_current_agent", -1)],
                           [(assign,"$cam_mode", 0),(assign, "$shoot_mode",0), (assign, "$cam_free", 0)])

camera_mode = ( 0, 0, 0, [], 
 [(try_begin),
     (eq, "$cam_mode", 1),
     (set_fixed_point_multiplier, 100),
     (agent_get_look_position, pos7, "$cam_current_agent"),
     (position_get_rotation_around_x, ":angle", pos7), 
     (store_sub, ":reverse", 0, ":angle"),
     (position_rotate_x, pos7, ":reverse"),
     (position_move_y, pos7, "$g_camera_y"),
     (position_move_z, pos7, "$g_camera_z"),
     (agent_get_horse, ":horse_agent", "$cam_current_agent"),
     (try_begin),
        (ge, ":horse_agent", 0),
        (position_move_z, pos7, 80),        
     (try_end),
     (store_mul, ":reverse", -1, "$g_camera_y"),
     (store_atan2, ":drop", "$g_camera_z", ":reverse"),
     (convert_from_fixed_point, ":drop"),
     (val_sub, ":angle", ":drop"),
     (position_rotate_x, pos7, ":angle"),
     (mission_cam_animate_to_position, pos7, 100, 0), 
  (else_try),
     (lt, "$cam_mode", 2),
     (main_hero_fallen),
     (agent_get_position, 1, "$cam_current_agent"),     
     (get_player_agent_no, ":player_agent"),
     (agent_set_position, ":player_agent", 1),
  (try_end),])

camera_set      = ( 0, 0, 0,[(key_clicked, "$key_camera_toggle"), (lt, "$cam_mode", 2),(neq, "$shoot_mode", 1)],
# toggling only when came mode =0 or 1 (2=disable) ; shoot_mode=1 temporary diable toggling
 [(try_begin),
     (eq, "$cam_mode", 0), 
     (assign, "$cam_mode", 1),
  (else_try),
     (eq, "$cam_mode", 1),
     (try_begin),
        (neg|main_hero_fallen, 0),
        (get_player_agent_no, "$cam_current_agent"),                  
     (try_end), 
     (assign, "$cam_mode", 0),
  (try_end),
  (mission_cam_set_mode, "$cam_mode"),])

camera_zoom_in         = ( 0, 0, 0,[(key_is_down, "$key_camera_zoom_plus"),  (eq, "$cam_mode", 1)], [(val_add, "$g_camera_y",1),(neg|key_is_down, key_left_shift),(val_add, "$g_camera_y",9),(val_min,"$g_camera_y",-50),])
camera_zoom_out        = ( 0, 0, 0,[(key_is_down, "$key_camera_zoom_min"),   (eq, "$cam_mode", 1)], [(val_sub, "$g_camera_y",1),(neg|key_is_down, key_left_shift),(val_sub, "$g_camera_y",9),])
camera_raise           = ( 0, 0, 0,[(key_is_down, "$key_camera_height_plus"),(eq, "$cam_mode", 1)], [(val_add, "$g_camera_z",1),(neg|key_is_down, key_left_shift),(val_add, "$g_camera_z",9),])
camera_lower           = ( 0, 0, 0,[(key_is_down, "$key_camera_height_min"), (eq, "$cam_mode", 1)], [(val_sub, "$g_camera_z",1),(neg|key_is_down, key_left_shift),(val_sub, "$g_camera_z",9),(val_max,"$g_camera_z", 50),])
camera_cycle_fowards   = ( 0, 0, 0,[(key_clicked, "$key_camera_next"),(call_script, "script_dmod_cycle_forwards") ,], [])      
camera_cycle_backwards = ( 0, 0, 0,[(key_clicked, "$key_camera_prev"),(call_script, "script_dmod_cycle_backwards"),], [])

camera_shot   = ( 0, 0, 0,[(key_is_down, key_left_mouse_button), (eq, "$cam_mode", 1)], [(get_player_agent_no, ":player_agent"), (eq, ":player_agent","$cam_current_agent"),(agent_get_wielded_item,":weapon","$cam_current_agent",0), (item_get_type, ":type", ":weapon"), (this_or_next|eq,":type",itp_type_bow),(this_or_next|eq,":type",itp_type_crossbow),(eq,":type",itp_type_thrown),(assign, "$cam_mode", 0),(assign,"$shoot_mode",1),(mission_cam_set_mode, "$cam_mode")])
camera_normal = ( 0, 0, 0,[(neg|key_is_down, key_left_mouse_button), (eq, "$shoot_mode",1)], [(assign, "$cam_mode", 1),(assign,"$shoot_mode",0),(mission_cam_set_mode, "$cam_mode")])                
              
###############################################

Usage :
Code:
      camera_init,
      camera_mode,
      camera_raise,
      camera_lower,
      camera_zoom_out,
      camera_zoom_in,
      camera_set,
      camera_cycle_fowards,
      camera_cycle_backwards,
      camera_shot, camera_normal,

Code:
("init_camera",
 [(assign, "$key_camera_toggle",key_end),                #END button to toggle camera mode
  (assign, "$key_camera_next",key_right),                #right key to jump to next bot
  (assign, "$key_camera_prev",key_left),                 #left key to jump to prev bot
  (assign, "$key_camera_zoom_plus",key_numpad_plus),     #Num + to zoom in
  (assign, "$key_camera_zoom_min",key_numpad_minus),     #Num - to zoom out
  (assign, "$key_camera_height_plus",key_up),
  (assign, "$key_camera_height_min",key_down),
  (assign, "$cam_free", 0),
  (assign, "$g_camera_z", 300),       
  (assign, "$g_camera_y", -1000),
 ]),
Code:
# Modified MartinF's code for DeathCam 
# script_dmod_cycle_forwards
# Output: New $dmod_current_agent
# Used to cycle forwards through valid agents
("dmod_cycle_forwards",
 [(assign, ":agent_moved", 0),
  (assign, ":first_agent", -1),
  (get_player_agent_no, ":player_agent"),
  (agent_get_team, ":player_team", ":player_agent"),
  (agent_get_team, ":prev_team", "$cam_current_agent"),
  (try_for_agents, ":agent_no"),
     (neq, ":agent_moved", 1),
     (agent_is_human, ":agent_no"),
     (agent_is_alive, ":agent_no"),
     (agent_get_team, ":cur_team", ":agent_no"),
     (agent_get_troop_id, ":troop_id", ":agent_no"), 
     (this_or_next|troop_is_hero, ":troop_id"), 
     (neg|key_is_down, key_left_shift),
     (this_or_next|eq, ":cur_team", ":prev_team"),
     (neg|key_is_down, key_left_control),
     (this_or_next|neq, ":cur_team", ":prev_team"), 
     (neg|key_is_down, key_left_alt),             
     (this_or_next|eq, "$cam_free", 1),         
     (eq, ":cur_team", ":player_team"),
     (try_begin),
        (lt, ":first_agent", 0),                         # Find the 1st agent alive and (1 team or free mod)
        (assign, ":first_agent", ":agent_no"),
     (try_end),
     (gt, ":agent_no", "$cam_current_agent"),            # Find next agent  alive and (1 team or free mod)
     (assign, "$cam_current_agent", ":agent_no"),
     (assign, ":agent_moved", 1),
  (try_end),
  (try_begin),
     (eq, ":agent_moved", 0),                            # Next Agent not found, but 1st agent found, then the next is the first one
     (neq, ":first_agent", -1),
     (assign, "$cam_current_agent", ":first_agent"),
     (assign, ":agent_moved", 1),        
  (else_try),
     (eq, ":agent_moved", 0),
     (eq, ":first_agent", -1),
     (display_message, "@No Troops Left."),
  (try_end),
  (try_begin),
     (eq, ":agent_moved", 1),                            # there is next one
     (try_begin),
        (agent_is_alive, ":player_agent"),             # if player is still alive, push to mode 1
        (assign, "$cam_mode", 1),
        (mission_cam_set_mode, "$cam_mode"),
     (try_end),
     (str_store_agent_name, 1, "$cam_current_agent"),
  (try_end),]),
   
# script_dmod_cycle_backwards
# Output: New $dmod_current_agent
# Used to cycle backwards through valid agents
("dmod_cycle_backwards",
 [(assign, ":new_agent", -1),
  (assign, ":last_agent", -1),
  (get_player_agent_no, ":player_agent"),
  (agent_get_team, ":player_team", ":player_agent"),
  (agent_get_team, ":prev_team", "$cam_current_agent"),      
  (try_for_agents, ":agent_no"),
     (agent_is_human, ":agent_no"),
     (agent_is_alive, ":agent_no"),
     (agent_get_team, ":cur_team", ":agent_no"),
     (agent_get_troop_id, ":troop_id", ":agent_no"), 
     (this_or_next|troop_is_hero, ":troop_id"), 
     (neg|key_is_down, key_left_shift),
     (this_or_next|eq, ":cur_team", ":prev_team"),
     (neg|key_is_down, key_left_control),
     (this_or_next|neq, ":cur_team", ":prev_team"),
     (neg|key_is_down, key_left_alt),
     (this_or_next|eq, "$cam_free", 1),    
     (eq, ":cur_team", ":player_team"),
     (assign, ":last_agent", ":agent_no"),          # Ok, the last
     (lt, ":agent_no", "$cam_current_agent"),
     (assign, ":new_agent", ":agent_no"),           # prev agent    
  (try_end),
  (try_begin),
     (eq, ":new_agent", -1),
     (neq, ":last_agent", -1),
     (assign, ":new_agent", ":last_agent"),               
  (else_try),
     (eq, ":new_agent", -1),
     (eq, ":last_agent", -1),
     (display_message, "@No Troops Left."),
  (try_end),
  (try_begin),
     (neq, ":new_agent", -1),                       # There is prev agent
     (assign, "$cam_current_agent", ":new_agent"), 
     (try_begin),
        (agent_is_alive, ":player_agent"),
        (assign, "$cam_mode", 1),
        (mission_cam_set_mode, "$cam_mode"),
     (try_end),
     (str_store_agent_name, 1, "$cam_current_agent"),
  (try_end), ]),

Note :
- $cam_mode=0 -> standard camera
  $cam_mode=1 -> Custom Camera
  $cam_mode=2 -> Standard Camera, disable Custom Camera
- $free_cam=0 -> only can jump for ally bots
  $free_cam=1 -> free jump (I usually switch $free_cam to 1 when player's knocked down)
- You can make own presentation to set the keys overriding the "init_camera" script
- Others :
  * pressing left shift while pressing buttons for zooming  will produce smooth zooming.
  * pressing left shift while pressing buttons to jump to another bot will attempt to jump to next hero
  * pressing left Alt while pressing buttons to jump to another bot will attempt to jump to opposite side bot. (only when free_cam=1 or in death cam)
  * pressing left Ctrl while pressing buttons to jump to another bot will attempt to jump to same side bot.
 

Llew2

Cheap ass bum
Count
M&BWB
kt0 said:
I hate the thought that a highly trained elite troop is just as unhappy about marauding about the countryside in a large party as a newly recruited peasant.  In later portions of the game (mods especially) it is super hard to keep a large army happy because of the dearth of suitable targets and the speed at which morale decays.  The following code attempts to fix this by taking troop level into account when determining morale penalty based on size. 

In module_scripts.py look for get_player_party_morale_values:
# script_get_player_party_morale_values
# Output: reg0 = player_party_morale_target
# kt0: refactored the party size morale values.
("get_player_party_morale_values",
[
# calculate the total number of guys and the cumulative level of the
# party. 
(party_get_num_companion_stacks, ":num_stacks","p_main_party"),
(assign, ":level_total", 0),
(assign, ":num_men", 0),
(try_for_range, ":i_stack", 1, ":num_stacks"),
(party_stack_get_troop_id, ":stack_troop","p_main_party", ":i_stack"),
(store_character_level, ":level", ":stack_troop"),
(try_begin),
(troop_is_hero, ":stack_troop"),
(val_add, ":num_men", 3),
(val_add, ":level_total", ":level"),
(else_try),
(party_stack_get_size, ":stack_size","p_main_party",":i_stack"),
(val_add, ":num_men", ":stack_size"),
(val_mul, ":level", ":stack_size"),
(val_add, ":level_total", ":level"),
(try_end),
(try_end),

# take the total number of guys and put it in the right range to do more
# maths on it.  divide this value by the cumulative level to get our
# morale penalty based on size.  this results in lower level troops
# being more inclined to be unhappy than higher level troops and higher
# level troops can kick guys in line up to a point.
# 5 * (count+5)^2 / (count * level)
(store_add, ":morale_penalty_for_size", ":num_men", 5),
(val_mul, ":morale_penalty_for_size", ":morale_penalty_for_size"),
(val_mul, ":morale_penalty_for_size", 5),
(val_div, ":morale_penalty_for_size", ":level_total"),
     
# the math works great for large numbers but not so great for small ones.
# if we get a value that's more than twice the size, min it to that.
(try_begin),
(store_mul, ":double", ":num_men", 2),
(gt, ":morale_penalty_for_size", ":double"),
(assign, ":morale_penalty_for_size", ":double"),
(try_end),

(assign, "$g_player_party_morale_modifier_party_size", ":morale_penalty_for_size"),

Stuff unchanged for context:
(store_skill_level, ":player_leadership", "skl_leadership", "trp_player"),
(store_mul, "$g_player_party_morale_modifier_leadership", ":player_leadership", 7),
(assign, ":new_morale", "$g_player_party_morale_modifier_leadership"),
(val_sub, ":new_morale", "$g_player_party_morale_modifier_party_size"),
(val_add, ":new_morale", 50),

With this change, higher level troops are more content to be in large bands which makes keeping larger armies far more convenient.  The function is not linear which confounds easy comparisons to the old system but the break even point is around level 5 with lower levels having a far greater penalty and higher levels having far less penalty.  Feel free to tweak for your needs.  As always, credit for use in publically released mods would be swell.

When I implement this script of kt0's, I get an error ingame saying 'SCRIPT WARNING : DIVISION BY ZERO'. I can see where total_level is assigned 0, but what to change that too?
 

MadocComadrin

Water-Borne Annelid
Count
M&BWBWF&S
From the looks of the script, it looks like that value should never be zero. Is the first chunk of the script working correctly?
 

Somebody

Code Pope
Baron
WBWF&S
It only happens when you start out with nobody in your party. Back when that was posted, you always started out with the option of having a bunch of farmers that join your party. Notice the try_for_range beginning from 1, skipping the player's character intentionally.
 

Llew2

Cheap ass bum
Count
M&BWB
Thanks, I see. Setting that 1 to 0 has removed the error, so it should be good to go.  :smile:
 
I was trying to implement Rubik's Troop Ratio Bar to my mod but due to outdated guide which is written in 2008,  it is really complicated and please can someone explain how can i implement it.

regards,
 

Amman d Stazia

Master Knight
here's a challenge to y'all with skills:

I'd like to see the code for the following - I've expressed it as "input - process - output" since there may be various (or none) ways of doing it in python or hex coding....

Agent 1 and Agent 2 are the two combatants, I'm assuming one of them being the player or at least an NPC....

in ALL CASES Agent 1 has no shield equipped.

input                                                                     process                                                  output 1      output 2
Agent 1 has any weapon, agent 2 has shield            attempt to remove shield from agent 2            success+   failure *

Agent 1 has any weapon, Agent 2 has helmet          attempt to remove helmet from Agent 2            success+   failure *

Agent 1 has any weapon, Agent 2 has polearm        attempt to grasp polearm shaft                        success++  failure **



+    - success = shield / helmet respectively un-equipped from Agent 2
++  - success = agent 2 weapon is locked up until Agent 1 has made an attack with their own weapon.
*    - failure = agent 1 suffers knockback effect
**  - failure = agent 1 suffers damage equivalent to a blow from the polearm and knockback






:grin: what's the point of this?


I'm hoping that somebody will provide code for this, and then I will go and trawl the gutters for someone to create animations (even if they are fairly basic) and then I can put it together in a MELEE GRAPPLING mod.  Or rather, someone else can since it would be rude of me to publish something in which I had no input...


 

Somebody

Code Pope
Baron
WBWF&S
Amman de Stazia said:
I'm hoping that somebody will provide code for this
Code:
(agent_get_wielded_item, ":weapon", ":agent1", 0),
(gt, ":weapon", 0), #Agent 1 has any weapon
(agent_get_wielded_item, ":item", ":agent1", 1),
(eq, ":item", -1), #Agent 1 has no shield equipped
(assign, ":output", 0),
(try_begin),
  (agent_get_wielded_item, ":item", ":agent2", 1),
  (gt, ":item", 0), #agent 2 has shield
  #process and assign +-1 to output
(else_try),
  (agent_get_item_slot, ":item", ":agent2", ek_head),
  (gt, ":item", 0), #Agent 2 has helmet
  #process and assign +-1 to output
(else_try),
  (agent_get_wielded_item, ":weapon", ":agent2", 1),
  (gt, ":weapon", 0),
  (item_get_type, ":type", ":weapon"),
  (eq, ":type", itp_type_polearm),
  #process and assign +-2 to output
(try_end),

#results
(try_begin),
  (eq, ":result", 1), #success+
  (agent_unequip_item, ":agent2", ":item"),
(else_try),
  (eq, ":result", 2), #success++
  (agent_set_no_dynamics, ":agent2"), #not sure if it would work
  #make a separate trigger to cancel effect checking agent_get_attack_action for agent1
(else_try),
  (lt, ":result", 0), #failure *
  (agent_set_animation, ":agent1", "anim_knockback"), #can't remember specific anim_id
  (eq, ":result", -2), #failure **
  (agent_deliver_damage_to_agent, ":agent2", ":agent1", ":weapon"), #last parameter > 0
(try_end),
You can modify the logic structure easily enough. success++ might be a bit tricky - you could create a "locked" animation, make the agent2 neutral to agent1 (although it would probably work both ways), or something like that.
 

mr.cool

Master Knight
WB
Hi I will have some questions
1 ) How can a horse in the sky?
2 ) I added a multiplayer item.I gave troops. But When I select that troop,Some items do not appear. Why?
mb39.jpg

3 ) Can I add a fire effect to balrog?
4 ) How do I make foggy and rainy weather to map?(always)
5 ) how can ı change at first that we battle in warfare and number of soldier
I'm sorry for my bad English
 

Somebody

Code Pope
Baron
WBWF&S
Not the right topic.
[list type=decimal]
[*]Move the horse on top of a scene prop with the proper collision mesh, and move the scene prop
[*]Use (item_set_slot, "itm_whatever", slot_item_multiplayer_item_class, multi_item_class_type_whatever), before making it available to the troop
[*]Use particle_system_add_new in the ti_on_init_item trigger on one of its equipment
[*]Use set_rain and set_fog_distance inside a ti_before_mission_start trigger inside a mission template after checking the output of store_current_scene
[*]Use the battlesizer
[/list]
 
He is talking about some kind of Flying Simulation for Nazgul and Fellbeasts but i guess too hard, eh?

As the fifth question, he meant to change the scene with troops(Shortly make a Battle of Helms Deep or Dead Marshes) where you first spawn and kill a bandit.
 

Amman d Stazia

Master Knight
Somebody said:
Amman de Stazia said:
I'm hoping that somebody will provide code for this
Code:
You can modify the logic structure easily enough. success++ might be a bit tricky - you could create a "locked" animation, make the agent2 neutral to agent1 (although it would probably work both ways), or something like that.

many thanks!  You will be credited, if anything ever comes of it, in bold type!
 

mastercheff

Sergeant
Hi guys ,
i know this isn't the right thread but i didn't find anyplace else to post.
so here we go:
is it possible to adjust morale system more to food?

for example: i wanted my different factions to have faction specific food(halbroggen for Luxembourg)(that will only be available in the factions towns/cities,villages) and this food will add the morale of the different parties.
for example: if a Luxembourg party buys halbroggen they get a morale for +8; but if a party of another faction buys the same food only will receive a bonus +4 or so.

So i wanted faction specific food i guess which changes the morale system depending on your own faction.
is this doable or did anyone already did it? i saw a thread for new morale system/calculation but nothing i needed.

Ty in advance for your help
 

Somebody

Code Pope
Baron
WBWF&S
Use this topic next time.
Code:
          (item_get_slot, ":food_bonus", ":item_no", slot_item_food_bonus),
          (assign, reg1, ":food_bonus"),
          #modify reg1 here
          (try_begin), #do stuff with reg1
            (eq, ":item_no", "itm_halbroggen"),
            (eq, "$players_kingdom", "fac_luxembourg"),
            (assign, reg1, 8),
          (try_end),
          (set_result_string, "@+{reg1} to party morale"),
          (set_trigger_result, 0x4444FF),
Code:
      (try_for_range, ":cur_edible", food_begin, food_end),      
        (call_script, "script_cf_player_has_item_without_modifier", ":cur_edible", imod_rotten),
        (item_get_slot, ":food_bonus", ":cur_edible", slot_item_food_bonus),
        #do stuff with food_bonus
        (val_mul, ":food_bonus", 3),
 

mastercheff

Sergeant
Use this topic next time.
ok, sorry thought this would be more appropriate for scripts.
And ty very much for the answer.

Is this script from you, or did it already exist?(so i know who to thank if i ever get my mod finished)
thx again
 

Somebody

Code Pope
Baron
WBWF&S
Again, ask your question in the Q&A thread (2 posts above), not here.
To answer your question, troops are templates from which agents are spawned. You cannot give a template extra stats without affecting all agents spawned (in the player's party for example) thereafter. You can, however, code a ti_on_agent_hit to take into account the agent's leader and increase damage accordingly.
 

Ikaguia

Grandmaster Knight
WBWF&SNW
A simple code I made to fix the problem that if you enable killing npc's, player could kill them all.

it will change the npc stats, skills, wp, renown, name... so that it seems to be another person.
Code:
# script_make_son_take_dead_fathers_place
# input = troop
# output = s0 father's name s1 son's name
  ("make_son_take_dead_fathers_place",
   [(store_script_param, ":troop", 1),
    #name
	(str_store_troop_name,s0,":troop"),
	(call_script, "script_fimp_name_hero", ":troop"),
	(store_troop_faction,":faction_no",":troop"),
	#(call_script, "script_troop_set_title_according_to_faction_gender_and_lands", ":troop", ":faction_no"), this is a script from Floris Mod Pack
	(str_store_troop_name,s1,":troop"),
	#message
	(try_begin),
		(troop_get_slot, ":age", ":troop", slot_troop_age),
		(gt, ":age", 45),
		(display_message,"@{s1} has taken over his grandfather's place."),
	(else_try),
		(display_message,"@{s1} has taken over his father's place."),
	(try_end),
	#skills
	(assign, ":skill_number", 0),
	(try_for_range, ":skill", "skl_trade", "skl_reserved_18"),#trade is the first skill, reserved 18 is the last, but is not used.
		(store_skill_level,":skill_level",":skill",":troop"),
		(store_random_in_range, ":random", 0, ":skill_level"),#son has skills similar to father
		(val_add, ":skill_number", ":random"),
		(val_mul, ":random", -1),
		(troop_raise_skill,":troop",":skill",":random"),
	(try_end),
	(try_for_range, ":unused", 0, ":skill_number"),
		(assign, ":bignum", 2),
		(try_for_range, ":unused", 0, ":bignum"),
			(store_random_in_range, ":skill", "skl_trade", "skl_reserved_18"),
			#TODO: check if skill is inactive
		(else_try),
			(val_add, ":bignum", 1),
		(try_end),
		(troop_raise_skill,":troop",":skill",1),
	(try_end),
	#attributes
	(assign, ":att_number", 0),
	(try_for_range, ":att", 0, 4),
		(store_attribute_level, ":att_level", ":troop", ":att"),
		(store_random_in_range, ":random", 0, ":att_level"),#son has attributes similar to father
		(val_add, ":att_number", ":random"),
		(val_mul, ":random", -1),
		(troop_raise_attribute,":troop",":att",":random"),
	(try_end),
	(try_for_range, ":unused", 0, ":att_number"),
		(store_random_in_range, ":att", 0, 4),
		(troop_raise_attribute,":troop",":att",1),
	(try_end),
	#weapon proficiences
	(assign, ":wp_number", 0),
	(try_for_range, ":wp", 0, 6),#set to 7 if you want firearms
		(store_proficiency_level, ":wp_level", ":troop", ":wp"),
		(store_random_in_range, ":random", 0, ":wp_level"),#son has proficiences similar to father
		(val_add, ":wp_number", ":random"),
		(val_mul, ":random", -1),
		(troop_raise_proficiency_linear,":troop",":wp",":random"),
	(try_end),
	(try_for_range, ":unused", 0, ":wp_number"),
		(store_random_in_range, ":wp", 0, 6),#set to 7 if you want firearms
		(troop_raise_proficiency_linear,":troop",":wp",1),
	(try_end),
	#age
	(store_random_in_range, ":age", 15, 25),
	(troop_set_slot, ":troop", slot_troop_age, ":age"),
	(troop_set_slot, ":troop", slot_troop_age_appearance, ":age"),
	(troop_set_age, ":troop", ":age"),
	#health
	(troop_set_health,":troop",100),
	#renown
	(troop_get_slot, ":renown", ":troop", slot_troop_renown),
	(val_max, ":renown", 1),
	(val_div, ":renown", ":renown"),
	(troop_set_slot, ":troop", slot_troop_renown, ":renown"),
  ]),

Code:
# script_fimp_name_hero
  ("fimp_name_hero",
   [(store_script_param, ":hero", 1),
	(troop_get_type,":gender",":hero"),
	(val_mod, ":gender", 2),
	(assign, ":big", 1),
	(try_for_range, ":unused", 0,":big"),
		(eq, ":gender", 0),#if it is male
		(store_random_in_range, ":name", "str_male_name_001", "str_male_name_end"),
		(neg|troop_slot_eq, troop_hero_end, ":name", 1),
	(else_try),
		(eq, ":gender", 1),#if it is female
		(store_random_in_range, ":name", "str_female_name_001", "str_female_name_end"),
		(neg|troop_slot_eq, troop_hero_end, ":name", 1),
	(else_try),
		(val_add, ":big", 1),
	(try_end),
	(troop_set_slot, troop_hero_end, ":name", 1),
	(troop_set_name, ":hero", ":name"),
	(troop_set_plural_name, ":hero", ":name"),
   ]),

Code:
  ("male_name_001",  "Marcus"),
#bunch of names here
  ("male_name_099",  "Ripertus"),
  ("male_name_end",  "End"),
  ("female_name_001",  "Anachorita"),
#bunch of names here
  ("female_name_099",  "Bryde"),
  ("female_name_end",  "End"),

Code:
troop_hero_end = "trp_dummy_troop"
You need to make "trp_dummy_troop" in module_troops

___________________________
had posted in the wrong thread...
removed there and posted here
 
Top Bottom