vitali-attila
Regular
kalarhan said:vitali-attila said:There is another thing I can't solve. If the ":cur_agent" is the player, the code should remove the ":cur_item"(which he has in one of his weapon slots) from the inventory, of course, forever.
Could you please tell me what is wrong and how to fix it?The code below is what I tried to do. But it does not work...
Code:(try_begin), (eq, ":cur_agent", ":player_agent"), (assign, ":break", 0), (try_for_range, ":slot_no", 0, 4), (eq, ":break", 0), (agent_get_item_slot, ":cur_slot", ":player_agent", ":slot_no"), (eq, ":cur_slot", ":cur_item"), #(troop_remove_item, "trp_player", ":cur_item"), #TEST -> does not work (troop_set_inventory_slot, "trp_player", ":slot_no", -1), #does not work either (assign,":break", 1), (try_end), (try_end),
did you read Caba's text about troops X agents?
about your snippet: you are not showing how you are getting the id's for the agent and the player_agent, so no way to know if they are correct.
If you want to remove the item for the mission duration, use a agent_ operation
If you want to also remove the item forever, then add a extra line for your troop.
Code:troop_remove_item = 1531 # (troop_remove_item, <troop_id>, <item_id>), # Removes an item from the troop equipment or inventory. Operation will remove first matching item it finds.
keep in mind that operation does not take into account the IMOD of a item, and if you have duplicates it will have some weird results :XD
you should get the current item IMOD and look for it on the troop inventory.
You should never assume the agents slots are the same as the troop, not even for weapons. You can drop and pick new gear in a mission, and that will break your script.
Yes, I read it, thank you for the information.
Here is the whole code, I get the parameters from mission_template.py I have written my own mst_ block:
Code:
# 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
vitali_on_couched_lance_damage = (
ti_on_agent_hit, 0, 0, [],
[
(store_trigger_param_1, ":inflicted_agent"),
(store_trigger_param_2, ":cur_agent"),
(store_trigger_param_3, ":inflicted_damage"),
(assign, ":cur_item", reg0),
(call_script, "script_game_event_agent_hit", ":inflicted_agent", ":cur_agent", ":inflicted_damage", ":cur_item"),
(try_end),
])
Then in "script_game_event_agent_hit":
Code:
# Param 1: damage inflicted agent_id
# Param 2: damage dealer agent_id
# Param 3: inflicted damage
# Param 4: damage dealer item_id
# Param 5: position of the blow
# rotation gives the direction of the blow
("game_event_agent_hit",
[
#(store_script_param, ":inflicted_agent", 1), #uncomment the line when will you use this variable
(store_script_param, ":cur_agent", 2),
(store_script_param, ":inflicted_damage", 3),
(store_script_param, ":cur_item", 4),
(get_player_agent_no, ":player_agent"),
(try_begin),
(gt, ":inflicted_damage", 70),
(agent_is_active, ":cur_agent"),
#If a polish hussar lance is used
(this_or_next|eq, ":cur_item", itm_gusar_lanza),
(this_or_next|eq, ":cur_item", itm_gusar_lanza_b),
( eq, ":cur_item", itm_gusar_lance),
(play_sound_at_position, "snd_lance_broken", pos0),
#If it's a player through the lance away(cause it's broken)
(try_begin),
(eq, ":cur_agent", ":player_agent"),
(assign, ":break", 0),
(try_for_range, ":slot_no", 0, 4),
(eq, ":break", 0),
(agent_get_item_slot, ":cur_slot", ":player_agent", ":slot_no"),
(eq, ":cur_slot", ":cur_item"),
#(troop_remove_item, "trp_player", ":cur_item"), #TEST -> does not work
(troop_set_inventory_slot, "trp_player", ":slot_no", -1), #does not work either
(assign,":break", 1),
(display_message, "@The broken lance is removed form the inventory"),
(try_end),
(try_end),
(agent_unequip_item, ":cur_agent", ":cur_item"),
(agent_equip_item, ":cur_agent", "itm_konchar"),
(agent_set_wielded_item, ":cur_agent", "itm_konchar"),
]),
Everything here except removing the lance(":cur_item") from the inventory yet works.
I did know that the IMOD of the item plays role. I thought only item's id is important. And how to get it? With troop_get_inventory_slot_modifier? But it's only for troops, right?