Somebody said:By use of the troop_set_note_available operation.
Art of Justice said:What's the safest way to remove all the pretenders from the mod completely? Except for commenting every single line and script mentioning them.
La Grandmaster said:I was wondering if someone could point me in the right direction into how I would code it so that troops spawned in certain "special" locations only attack the player when he is close to them. Any help is much appreciated
(1,0,0,[],
[
(try_for_agents, ":cur_agent"),
(agent_is_non_player, ":cur_agent"),
(agent_is_alive,":cur_agent"),
(try_begin),
(agent_get_slot,":spawned_special",":cur_agent",slot_agent_special_spawn),
(eq,":spawned_special",1),
(try_begin),
(agent_get_position,pos1,":cur_agent"),
(agent_get_position,pos2,":my_agent"), # (note that my agent is the agent id of the player...)
(get_distance_between_positions,":dist",pos1,pos2),
(lt,":dist", 100), # (100 or less is the distance that will trigger the atack target,you can change it...100 means 1 meter)
(agent_set_look_target_agent, ":cur_agent", ":my_agent"), #i am not 100% sure that this operation will make it to atack
(try_end),
(try_end),
(try_end),
]
The_dragon said:do you mean when you are in the free map(single player) or in a battle/siege?
# Run through this every second. You don't want to do this in scenes with tons of agents.
(1,0,0,[],
[
(try_for_agents, ":cur_agent"),
(agent_is_non_player, ":cur_agent"),
(agent_is_alive,":cur_agent"),
(try_begin),
# Get (supposedly) the spawn location of agent selected by our loop.
# Not sure this will work as is, might have to add a spawn trigger to set this manually as it is set in another (potentially unrelated) trigger.
(agent_get_slot,":spawn_loc",":cur_agent", slot_agent_spawn_entry_point),
# Replace <number> with the spawn location that is your "special spawn location" number.
(eq,":spawn_loc", <number>),
(try_begin),
# Position of agent currently selected by our loop.
(agent_get_position,pos1,":cur_agent"),
# Position of player.
(agent_get_position,pos2,":my_agent"),
# Get distance between agent and player.
(get_distance_between_positions,":dist", pos1, pos2),
# Check to see if agent is in aggro range.
# <aggro range> is the range the player has to be under before the NPC decides to attack. 100 = 1m, so 1000 = 10m.
(lt,":dist", <aggro range>),
# Check to see if agent can "see" player. You don't want them spotting you through buildings.
(agent_is_in_line_of_sight, ":my_agent", pos1), # rotation of the position register is not used.
# Agent can see player and is in range, set player as their enemy.
# You may need a spawn trigger to make sure all NPC agents spawned in this location have relation to player set as 0 (neutral).
(agent_add_relation_with_agent, ":cur_agent", ":my_agent", -1), #-1 = enemy, 0 = neutral (no friendly fire at all), 1 = ally
# You may need a spawn trigger to make sure all NPC agents spawned in this location have alarmed set to 0.
(agent_set_is_alarmed, ":cur_agent", 1), # 1 for enable, 0 for disable
(try_end),
(try_end),
(try_end),
]
So it's working now then? Brilliant! Happy to have helped even in a small way.La Grandmaster said:@derek_custer & the_dragon, thanks a lot, I managed to get most of it working myself but I couldnt get the attack part to work, I was using the agent set team operation when they had discovered the player which meant that all other units would also attack this unit as he was now on a different team. Never thought to use agent_add_relation_with_agent. Thanks alot anyway
(
"salt_mine", mnf_auto_enter,
"You enter the salt mine.",
"none",
[
(reset_price_rates,0),
## Tocan
#(set_price_rate_for_item, "itm_salt", 50),
(call_script, "script_game_get_item_buy_price_factor", "itm_salt"),
(assign, reg0, 50),
(troop_clear_inventory, "trp_salt_mine_merchant"),
(store_random_in_range, ":rand", 9, 21),
(gt, ":rand", 0),
(troop_add_items,"trp_salt_mine_merchant", "itm_salt",":rand"),
## Tocan end
],
[
("enter",[],"Enter.",[(set_jump_mission,"mt_town_center"),(jump_to_scene,"scn_salt_mine"),(change_screen_mission)]),
("leave",[],"Leave.",[(leave_encounter),(change_screen_return)]),
]
),