Equipment randomizing

Users who are viewing this thread

dia151

Knight at Arms
So i want a script that dose the following:

When you select a troop in multiplayer, instead of choosing equipment, you immediately spawn with a random equipment avalible form the troops inventory.

My coding skill are limited and i curently dont posses that much knowledge to do this by myself. Can anyone help me?
 
The Hunt mod had a script for setting the beasts to have their equipment, it can be used in the way you wanted. Yoshi was kind enough to release the source for his mod.
 
Kazzan said:
The Hunt mod had a script for setting the beasts to have their equipment, it can be used in the way you wanted. Yoshi was kind enough to release the source for his mod.

Thanks, ill look it up!
 
I've found the source code, but i cant seem to find where exactly is that script. I'm sorry if I'm asking stupid questions, but its the only way to get better.

Thank you
 
It's in Module templates, if you head downwards to the Hunt game mode.

Look for:

Code:
							 (player_add_spawn_item,":player_no",4,"itm_beast_hood"),
 
i think i found this code, it was moudule_mission_templeates

# HUNT ADDTIONS. FORCE BEASTS TO USE ITEMS

#equipment slots (copied from header_items)
# ek_item_0 = 0
# ek_item_1 = 1
# ek_item_2 = 2
# ek_item_3 = 3
# ek_head  = 4
# ek_body  = 5
# ek_foot  = 6
# ek_gloves = 7
# ek_horse  = 8
# ek_food  = 9
(try_begin),
(eq,":player_troop","trp_beast_multiplayer"),
(player_add_spawn_item,":player_no",5,"itm_beast_pilgrim_disguise"),

                #highelf randomized beast type hood/fur
(store_random_in_range,":random",0,8),
(try_begin),
(eq,":random", 0),
(player_add_spawn_item,":player_no",4,"itm_beast_hood"),
(else_try),
(eq,":random", 1),
(player_add_spawn_item,":player_no",4,"itm_beast_hood1"),
(else_try),
(eq,":random", 2),
(player_add_spawn_item,":player_no",4,"itm_beast_hood2"),
(else_try),
(eq,":random", 3),
(player_add_spawn_item,":player_no",4,"itm_beast_hood3"),
(else_try),
(eq,":random", 4),
(player_add_spawn_item,":player_no",4,"itm_beast_hood4"),
(else_try),
(eq,":random", 5),
(player_add_spawn_item,":player_no",4,"itm_beast_hood5"),
(else_try),
(eq,":random", 6),
(player_add_spawn_item,":player_no",4,"itm_beast_hood6"),
(else_try),
(eq,":random", 7),
(player_add_spawn_item,":player_no",4,"itm_beast_hood7"),
(try_end),


Im not really familiar with the code, so im not sure what to change to suit my mods needs. Do you perhaps now what  exactly  some of the terms represent in this code.

Correct me if im wrong
As i understand it; itm_beast_hood 0-7 are variants of a certain item; hood that beasts use. But i dont understand thinghs  i highlighted in red.

Thank you for help  :smile:
 
Refer to header_operations.py

Code:
store_random_in_range  = 2136	# gets random number in range [range_low,range_high] excluding range_high 

...

player_add_spawn_item                = 410 # (player_add_spawn_item, <player_id>, <item_slot_no>, <item_id>),

player_no is just the player number, quite self explanatory :smile:. It should be assigned somewhere above the code you mentioned (a loop for all players?? or just a trigger parameter from ti_on_agent_spawn??).
 
It should be for all players using the trp_beast_multiplayer class. The items added should be changeable to whatever item you want the troop to have.
 
A BIG Thank you for your help guys, im beginning to understand that script

So, first its
store_random_in_range,":random",0,8 so it generates a number; minimum-0 max 7 and then, depending on which number did it generata it links it to appropriate line bellow so if it generated 5 it would link it to
(eq,":random", 5),
(player_add_spawn_item,":player_no",4,"itm_beast_hood5"), Am i right?

Im not sure about "player_no" is this the part that i shouldnt change if i'm for example adding this to my mod?

My mod has 7 faction, each of them has about 5 troop classes, on avarage, each class would have 6 eqipment slots filled(head, body, legs, gloves, melee 1, melee 2) and each slot would have an avrage pool of 15 items to choose randomly from. That means a big script, right? 7*5*6*15=3150 lines of code. Would that lower perfformance of my mod?

 
A simpler solution would be to use the game's own randomizing algorithm, and spawn a troop that has the predefined loadout. You can then either use player_control_agent (but that would interfere with next round's spawning), or use the following
Code:
(spawn_agent, "trp_template"),
(assign, ":agent", reg0),
(try_for_range, ":item_slot", ek_item_0, ek_horse),
  (agent_get_item_slot, ":item", ":agent", ":item_slot"),
  (gt, ":item", -1),
  (player_add_spawn_item, ":player_no", ":item_slot", ":item"),
(try_end),
(try_begin),
  (agent_get_horse, ":horse", ":agent"),
  (gt, ":horse", -1),
  (player_add_spawn_item, ":player_no", ek_horse, ":horse"),
(try_end),
(remove_agent, ":agent"),
 
Back
Top Bottom