Hey folks,
I am looking to call a certain script in my map.script-file repeatedly while lockpicking a door.
The goal is to check if any guards (which are spawning as "neutral") are able to see me lockpicking, and change their relation to the player accordingly. Like this:
void witnessCheck(string entity_name)
{
ai theAI = sys.getEntity(entity_name);
if(theAI.canSeeExt($player1, 1, 1))
{
sys.println(theAI.getName() + " has witnessed a crime!");
theAI.lookAt($player1, 3);
theAI.setEntityRelation($player1, -1); // theAI is now hostile
}
else
{
sys.println(theAI.getName() + " didn't see anything suspicious.");
}
}
void crime_lockpick()
{
sys.println("You commited a crime! Check for witnesses...");
// call one check for each guard entity on the map
witnessCheck("atdm_ai_citywatch_1");
// ....
}
with crime_lockpick() being called repeatedly while lockpicking. (It's a simplified version of the code suggested in https://wiki.thedarkmod.com/index.php?title=AI_Ignore_Player )
A frob-response of the door entity with a "run script"-effect is only called once, and I see no way of telling the script if the player is currently lockpicking or not, hence missing the break condition for any while-loop.
Furthermore, there's no distinction between frobbing/opening an unlocked door and lockpicking a locked one using this method. Sadly, the get-method in
void getDoorStatus(entity door)
{
if(door.getBoolKey("locked")) sys.println("This door is locked.");
else sys.println("This door is unlocked.");
}
always returned 0.
A used_action_script as described in https://wiki.thedarkmod.com/index.php?title=Tool,_Key,_custom_used_by_inventory_actions would be neat (calling the func every frame in respect of the used inventory item, i.e. a lockpick), but doesn't work on doors apparently.
I wasn't able to wrap my head around the whole door mechanics yet, and obviously lack knowledge of idtech4 in general. Thus, I hope that any experienced DarkRadiant user might point me in the right direction.
Thanks in advance have a good one