Modding Q&A [For Quick Questions and Answers]

Users who are viewing this thread

Status
Not open for further replies.
Hello everbody,
how to make troop name appears on a message?? something like:

"trp_thetroop broke his lance"

i tought we could use this operation:
Code:
add_troop_note_from_sreg        = 1117 # (add_troop_note_from_sreg,<troop_id>,<note_slot_no>,<string_id>, <value>), #There are maximum of 8 slots value = 1 -> shows when the note is added
but i don't know where to put it, after the display_message or before.. please help :grin:
 
Like this?

Code:
(agent_get_troop_id, ":troop", ":agent"),
            (str_store_troop_name,s1,":troop"),
            (display_message, "@{s1} broke his spear.",0x66FF33),
 
Okay thank you, but i have another problem now, i've tried to make a script who makes the troops who lost their spear to have a sword instead of. but i have script opcode warnings in game, and the agents holds theirs swords from the beggining of the battle.
i think the problem come from the "store_trigger_param_1" but i don't know how to assign the ":agent" variable to the normal troops, here is the code if someone can help me out :

Module_mission_template
Code:
common_weapon_break =  (
         0.4, 0, 0,
       [
      
       #(player_get_agent_id, ":player_agent", ":player_no"),
       (store_trigger_param_1, ":agent"),
       (get_player_agent_no, ":player_agent"),
      (agent_get_attack_action, ":playeraction", ":player_agent"), #returned values: free = 0, readying_attack = 1, releasing_attack = 2, completing_attack_after_hit = 3, attack_parried = 4, reloading = 5, after_release = 6, cancelling_attack = 7
      (agent_get_attack_action, ":action", ":agent"),
        (try_begin),
             (eq,":playeraction",3),
             (eq,":action",3),
          (agent_get_wielded_item,":breakweapon",":agent",0),
          (agent_get_wielded_item,":breakweapon",":player_agent",0),   
          (gt,":breakweapon",2),
            (item_get_type, ":spearlance", ":breakweapon"),
           (agent_get_horse,":playermounted",":player_agent"),
           (agent_get_horse,":mounted",":agent"),
           (store_random_in_range,":weaponbreakchance",1,100),
         (try_begin),            
         (try_for_range,":spearlance","itm_jousting_lance","itm_awlpike_long"),
         (eq,":spearlance",":breakweapon"),
         #   (display_message, "@Spear or Lance"),
            (val_mul,":weaponbreakchance",102),
            (val_div,":weaponbreakchance",100),
          (try_end),
        (try_begin),   
            (ge,":weaponbreakchance",88),
            (agent_unequip_item,":agent",":breakweapon"),
            (play_sound,"snd_shield_broken",),
            (lt,":mounted",0),
            (agent_set_animation, ":agent", "anim_strike_chest_front"),
            (agent_get_troop_id, ":troop", ":agent"),
            (str_store_troop_name,s1,":troop"),
            (display_message, "@{s1} broke his spear.",0x66FF33),
            (agent_set_slot,":agent", slot_spear_loster, 1),
        (else_try),
            (agent_unequip_item,":player_agent",":breakweapon"),
            (troop_remove_item, "trp_player", ":breakweapon"),
            (play_sound,"snd_shield_broken",),
            (display_message, "@You broke your spear.",0xFF0000), 
            (lt,":playermounted",0),
             (agent_set_animation, ":player_agent", "anim_strike_chest_front"),
        (try_end),
       (try_begin),
            (agent_slot_eq, ":agent", slot_spear_loster, 1),
            (agent_set_wielded_item,":agent","itm_sword_medieval_c"),
        (try_end),
       (try_end),          
      ], [])
 
Use ti_on_agent_hit and store parameter 2, ignoring the special case for the player altogether other than displaying a message. Ignore everything above (gt,":breakweapon",2), and use (assign, ":breakweapon", reg0). Replace the try_for_range with a is_between.
 
With 1.134, you don't need the nearly constant running of the weapon break trigger (the check for every 0.4 seconds), rather put the check time to ti_on_agent_hit so the trigger is only called when an agent is hit by a weapon.

Look in header_triggers for the various parameters that trigger passes (who did the hitting, what agent was hit, etc), like so:
Code:
ti_on_agent_hit          = -28.0 #can only be used in module_mission_templates triggers
# Trigger Param 1: damage inflicted agent_id
# Trigger Param 2: damage dealer agent_id
# Trigger Param 3: inflicted damage
# Register 0: damage dealer item_id
# Position Register 0: position of the blow
#                      rotation gives the direction of the blow
and you can use them in the code that follows by using the operation
(store_trigger_param_1, ":destination"),  #where _1 is replaced by the parameter number, 1, 2, or 3.
 
I can't understand this well, now i'm just getting this:
common_weapon_break =  (
        ti_on_agent_hit, 0, 0,
      [
     
      #(player_get_agent_id, ":player_agent", ":player_no"),
      (store_trigger_param_1, ":agent"),
      (get_player_agent_no, ":player_agent"),
      (agent_get_attack_action, ":playeraction", ":player_agent"), #returned values: free = 0, readying_attack = 1, releasing_attack = 2, completing_attack_after_hit = 3, attack_parried = 4, reloading = 5, after_release = 6, cancelling_attack = 7
      (agent_get_attack_action, ":action", ":agent"),
        (try_begin),
            (eq,":playeraction",3),
            (eq,":action",3),
          (agent_get_wielded_item,":breakweapon",":agent",0),
          (agent_get_wielded_item,":breakweapon",":player_agent",0), 
          (gt,":breakweapon",2),
            (item_get_type, ":spearlance", ":breakweapon"),
          (agent_get_horse,":playermounted",":player_agent"),
          (agent_get_horse,":mounted",":agent"),
          (store_random_in_range,":weaponbreakchance",1,100),
        (try_begin),           
        (is_between ,":spearlance","itm_jousting_lance","itm_military_scythe"),
        (eq,":spearlance",":breakweapon"),
        #  (display_message, "@Spear or Lance"),
            (val_mul,":weaponbreakchance",102),
            (val_div,":weaponbreakchance",100),
          (try_end),
        (try_begin), 
            (ge,":weaponbreakchance",8:cool:,
            (agent_unequip_item,":agent",":breakweapon"),
            (play_sound,"snd_shield_broken",),
            (lt,":mounted",0),
            (agent_set_animation, ":agent", "anim_strike_chest_front"),
            (agent_get_troop_id, ":troop", ":agent"),
            (str_store_troop_name,s1,":troop"),
            (display_message, "@{s1} broke his spear.",0x66FF33),
            (agent_set_slot,":agent", slot_spear_loster, 1),
        (else_try),
            (agent_unequip_item,":player_agent",":breakweapon"),
            (troop_remove_item, "trp_player", ":breakweapon"),
            (play_sound,"snd_shield_broken",),
            (display_message, "@You broke your spear.",0xFF0000),
            (lt,":playermounted",0),
            (agent_set_animation, ":player_agent", "anim_strike_chest_front"),
        (try_end),
      (try_begin),
            (agent_slot_eq, ":agent", slot_spear_loster, 1),
            (agent_set_wielded_item,":agent","itm_sword_medieval_c"),
        (try_end),
      (try_end),         
      ], [])

Sorry, i'm a begginer
 
Is it possible to make a scene prop where you can input a number (same as for the entry points) in the map-editor and depending on the number, something different happens when you use it ingame.
 
@Sayd

A possible rewrite:
Code:
common_weapon_break =  (
    ti_on_agent_hit, 0, 0,  
       #First number is how frequently to call the trigger (here, whenever an agent is hit), second number is the delay between the conditions block and the consequences block (here, no delay), third number is the re-arm delay or how long until the trigger can be called again after the conditions block passes (here, no delay)
       [], #That was the conditions block. The consequences block only runs if it is true. So always runs in this case.
       [     
        (store_trigger_param_2, ":agent"), #Trigger parameter 2 for this trigger is the attacker agent. Parameter 1 is the hit agent.
        (agent_get_wielded_item,":breakweapon", ":agent", 0),   
        (gt,":breakweapon",2),
        (item_get_type, ":spearlance", ":breakweapon"), #You never use the item type...currently all weapons can break
        (store_random_in_range,":weaponbreakchance",1,100),
        
        (try_begin),           
            (is_between,":breakweapon","itm_jousting_lance","itm_military_scythe"),
            #   (display_message, "@Spear or Lance"),
            (val_mul,":weaponbreakchance",102),
            (val_div,":weaponbreakchance",100),
        (try_end),
        
        (ge,":weaponbreakchance",88),
        (agent_unequip_item, ":agent",":breakweapon"),
        (play_sound, "snd_shield_broken",),
        (try_begin),
            (get_player_agent_no, ":player_agent"),
            (eq, ":agent", ":player_agent"),
            (troop_remove_item, "trp_player", ":breakweapon"),
            (display_message, "@You broke your spear.",0xFF0000),
        (else_try),
            (agent_get_troop_id, ":troop", ":agent"),
            (str_store_troop_name,s1,":troop"),
            (display_message, "@{s1} broke his spear.",0x66FF33),
            (agent_set_slot,":agent", slot_spear_loster, 1), #Unless you use this slot elsewhere, it is unnecessary
            (agent_set_wielded_item,":agent","itm_sword_medieval_c"), #This will only work if that agent has that item equipped
        (try_end),
        (agent_get_horse, ":mounted", ":agent"),
        (lt,":mounted",0),
        (agent_set_animation, ":agent", "anim_strike_chest_front"),     
      ]),
 
Another possible rewrite:
Code:
       [(gt, reg0, 0),], #That was the conditions block. The consequences block only runs if it is true. So always runs in this case.
       [     
        (assign, ":breakweapon", reg0),
        (store_random_in_range,":weaponbreakchance",1,100),
        (try_begin),           
            (is_between,":breakweapon","itm_jousting_lance","itm_military_scythe"),
            (val_mul,":weaponbreakchance",102),
            (val_div,":weaponbreakchance",100),
        (try_end),
        (ge,":weaponbreakchance",88),
        (store_trigger_param_2, ":agent"), #Trigger parameter 2 for this trigger is the attacker agent. Parameter 1 is the hit agent.
        (agent_unequip_item, ":agent",":breakweapon"),
        (agent_play_sound, ":agent", "snd_shield_broken"),
        (str_store_item_name, s1, ":breakweapon"),
        (try_begin),
            (get_player_agent_no, ":player_agent"),
            (eq, ":agent", ":player_agent"),
            (troop_remove_item, "trp_player", ":breakweapon"),
            (display_message, "@You broke your {s1}.",0xFF0000),
        (else_try),
            (agent_get_troop_id, ":troop", ":agent"),
            #check allied status, if hero, whatever
            (troop_get_type, reg0, ":troop"),
            (str_store_troop_name,s0,":troop"),
            (display_message, "@{s0} broke h{reg0?er:is} {s1}.",0x66FF33),
            (assign, ":end", ek_head),
            (try_for_range, ":slots", 0, ":end"), #fetch agent equipment
              (agent_get_item_slot, ":item", ":agent", ":slots"),
              (eq, ":item", "itm_sword_medieval_c"), #or whatever condition
              (agent_set_wielded_item, ":agent", ":weapon"),
              (assign, ":end", 0),
            (try_end),
        (try_end),
        (agent_get_horse, ":mounted", ":agent"),
        (lt,":mounted",0),
        (agent_set_animation, ":agent", "anim_strike_chest_front"),     
      ]),
 
Thank's to you two, i have another version here with the help of ritter dummbatz:

Code:
common_weapon_break =  (
         0.4, 0, 0,
       [],
	[   												 
		(try_for_agents, ":agent"),
			(agent_is_human, ":agent"),
			(agent_is_alive, ":agent"),
        
			
			(agent_get_attack_action, ":action", ":agent"),
			(try_begin),
				
				(eq,":action",3),
				(agent_get_wielded_item,":breakweapon",":agent",0),
				
				(is_between,":breakweapon","itm_jousting_lance","itm_awlpike_long"),  				
				(agent_get_horse,":mounted",":agent"),								# ok, you need the check for horses
				(gt, ":mounted", -1), 												#but you can stop this check right here if the agent is mounted.
				(store_random_in_range,":weaponbreakchance",1,100),						 
				(val_mul,":weaponbreakchance",102),
				(val_div,":weaponbreakchance",100),
				(try_begin),   
					(ge,":weaponbreakchance",28),
					(agent_unequip_item,":agent",":breakweapon"),
					(agent_get_troop_id,":troop", ":agent"),
					(troop_remove_item, ":troop", ":breakweapon"),										
					(play_sound,"snd_shield_broken"),					
					(agent_set_animation, ":agent", "anim_strike_chest_front"),
					(agent_get_troop_id, ":troop", ":agent"),
					(str_store_troop_name,s1,":troop"),
					(display_message, "@{s1} broke his spear.",0x66FF33),					
					(assign, ":spear_broke", 1),									# a simple variable suffices and uses less memory AND is less confusing
				(try_end),
			(try_begin),				
				(eq, ":spear_broke", 1),											
				(agent_set_wielded_item,":agent","itm_sword_medieval_c"),
				(assign, ":spear_broke", 0),
			(try_end),
		(try_end),
    ])

 
Status
Not open for further replies.
Back
Top Bottom