Jump to content
The Dark Mod Forums

Recommended Posts

Posted (edited)

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

Edited by x0nic
  • x0nic changed the title to How to call a script repeatedly while lockpicking?
Posted

Just a quick note, the method for determining if something is locked is IsLocked(). So your getDoorStatus method should be calling door.IsLocked(), not door.getBoolKey("locked").

 

Posted

do what joebarnin said the .getBoolKey(string), or .getKey(string), etc, are used to get key value pares, also called spawn arguments or spawn args that you defined in the entity definition file the .def file.

Is not a hard rule but those functions/methods should be used at entity spawn/init, why, because is way faster, to save the spawn arg value into a script variable and then use that during real gameplay, than opening from disk, a entire text file to read, loop through it and get data from it, that is obviously slower than just reading a float from memory. 

Posted

If you've already tried used_by scripts I don't see anything obvious down that route.

The way I'd approach it then is:

1) Make a looping script that checks every 0.5s what category of inv_item the player currently has selected. If it's lockpicks...

2) Check what entity the player currently has highlighted. If its classname key is that of a door and it's locked...

3) Loop through all AIs in the map, checking if they can see the player. Can look at the A to Z Scripting guide for a method to do this.

 

Apart from that, you could derive a new scriptobject from the lockpick scriptobject which has a modified "activate" function that sets a global float variable for when the lockpicks were last used using sys.getTime(), and apply this scriptobject to your lockpicks via the spawnarg. Then you could have a global looping script check if the player very recently used his lockpicks, and if so check whether any AIs can see him.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recent Status Updates

    • JackFarmer

      "The Year of the Rat." 
      😄

      Al Stewart must be proud of you!
      Happy testing!
      @MirceaKitsune
      · 1 reply
    • datiswous

      I posted about it before, but I think the default tdm logo video looks outdated. For a (i.m.o.) better looking version, you can download the pk4 attached to this post and plonk it in your tdm root folder. Every mission that starts with the tdm logo then starts with the better looking one. Try for example mission COS1 Pearls and Swine.
      tdm_logo_video.pk4
      · 2 replies
    • JackFarmer

      Kill the bots! (see the "Who is online" bar)
      · 3 replies
    • STiFU

      I finished DOOM - The Dark Ages the other day. It is a decent shooter, but not as great as its predecessors, especially because of the soundtrack.
      · 5 replies
    • JackFarmer

      What do you know about a 40 degree day?
      @demagogue
      · 4 replies
×
×
  • Create New...