Jump to content
The Dark Mod Forums

Newbie DarkRadiant Questions


demagogue

Recommended Posts

If the scene calls for knowing whether the player is in the act of lockpicking the door, you can use isHighlighted() in your script. That returns three values:

 

 

#define FROB_UNHILIGHTED 0 // Entity isn't hilighted.

#define FROB_INDIRECT 1 // Entity is hilighted via peer hilighting.

#define FROB_DIRECT 2 // Entity is hilighted directly.

 

So if your door's name is 'FrontGate', then the request in your script would be

 

float result = $FrontGate.isHighlighted();

 

Then you check 'result' for the three values and act accordingly.

 

Combine that with checking that your current inventory item is a lockpick, and that should be enough info to know that the player is attempting to pick open the door. (Or is at least thinking about it, because lockpicking doesn't occur until keys/buttons are pressed.)

Link to comment
Share on other sites

I experimenting with new map, and I have big water brush rising in city sector, so lower floors become completely flooded.

AI don't respond to that situation, he just walk underwater and get deadly hiccup till he die.

My question: is there any swimming animation for AI? Is there any scripted "it is to deep! run for your life!". Or how to make AI floats on surface?

S2wtMNl.gif

Link to comment
Share on other sites

My question: is there any swimming animation for AI? Is there any scripted "it is to deep! run for your life!". Or how to make AI floats on surface?

 

No work has been done for AI to properly react to this situation. They would need a new task to find a way out of the water. There was some discussion about preventing them from walking into water that was more than waist deep, so it's a problem that's been recognized.

 

Making them float wouldn't work either, because--unless AI are dead or knocked out--they can only be vertical, sleeping, or sitting. None of those would look realistic when floating on the surface of the water. Well, sleeping would, but then they have their eyes closed.

Link to comment
Share on other sites

You might instead, trigger the AI to run to a path corner on higher ground once the water starts rising. If pathing remains working underwater and becomes a problem then you can block it with a dynamic blocker. I forget the name but look at elevator setups.

Link to comment
Share on other sites

Grayman gave a good way for a script to let AI react to lockpicking.

 

But Fidcal made the bigger point. We really should have new AI code specifically for friendly AI to switch teams to hostile (or maybe two different versions, friendly->warning->hostile & friendly->hostile), according to illicit things they see the player doing: pickpocketing, lockpicking, frobbing loot, being inside a tagged location, maybe some arbitrary tagged event to allow custom things, etc (also by direct script cueing). And maybe the possibility for them to go back to friendly if the illicit thing stops (or via another hardwired cue or script cue). There should be some spawnargs you could set on the AI that runs through some variations. It's a common enough mechanic it shouldn't need to be hacked.

What do you see when you turn out the light? I can't tell you but I know that it's mine.

Link to comment
Share on other sites

Indeed, being able as a mapper to set up a fully functioning neutral AI with a few spawnargs would be incredibly useful; by fully functioning I mean exactly what Demagogue described, a npc that has common sense (and degrees of) reactions to assault and signs of agression/dishonesty, instead of the pretty much "braindead" neutral character currently present that basicly just ignores the player even exists (they are not useful right now for anything more than being scenery).

Link to comment
Share on other sites

Does someone have a trick how to rotate prefab-brush based-doors correctly?

I inserted the Barret Vault door from the prefab list and rotated it with the translation dialogue. This resulted in completely wrong door moving when used.

Then I changed the origin of the door but this also didn't change it.

After this I used the 'rotation' spawnarg and the door alignes and moves correctly but now the lever is gone and also the door makes no sounds when opened / closed.

"Einen giftigen Trank aus Kräutern und Wurzeln für die närrischen Städter wollen wir brauen." - Text aus einem verlassenen Heidenlager

Link to comment
Share on other sites

Since you were moving the origin around, I think a door can make no sound if the origin gets put behind a visportal (that closes & shuts off sound) or buried in geometry or something like that. As for the lever, I haven't looked at it so not sure. Could you just attach a new lever to the door like you would with doorknobs on normal doors?

What do you see when you turn out the light? I can't tell you but I know that it's mine.

Link to comment
Share on other sites

... but now the lever is gone ...

 

The lever is still there. Look in the neighborhood for it, move it to the position on the door where it belongs, make sure it's perpendicular to the door face, and check its translation spawnarg to make sure it will translate properly when the door is frobbed.

 

The best way to know where the lever belongs is to import another prefab vault door (don't rotate it!) and study the orientation of the lever to the door and how it translates. When you have your good door set up, delete the prefab you imported for study.

 

Unfortunately, DR has a known issue with rotating multiple func_statics and maintaining their relationships, and rotating a single func_static and maintaining its origin. We all just live with it. It's always best when rotating things to double-check the new origins to make sure they make sense. Many times origins will rotate right out of the map, and then can't dmap because dmap thinks the object is sitting in the void. So you always have to check.

Link to comment
Share on other sites

If the scene calls for knowing whether the player is in the act of lockpicking the door, you can use isHighlighted() in your script. That returns three values:

 

 

#define FROB_UNHILIGHTED 0 // Entity isn't hilighted.

#define FROB_INDIRECT 1 // Entity is hilighted via peer hilighting.

#define FROB_DIRECT 2 // Entity is hilighted directly.

 

So if your door's name is 'FrontGate', then the request in your script would be

 

float result = $FrontGate.isHighlighted();

 

Then you check 'result' for the three values and act accordingly.

 

Combine that with checking that your current inventory item is a lockpick, and that should be enough info to know that the player is attempting to pick open the door. (Or is at least thinking about it, because lockpicking doesn't occur until keys/buttons are pressed.)

 

This seems interresting. In clear words, it means that I will receive a number according to if the door in question is highlighted or not. But when should this script be run? Should I run it at map start and then keep it running? Is this good performance vice?

Link to comment
Share on other sites

Longshot...but failed...

 

I get this error:

 

Error: file maps\naog\naog.script, line 25: Unknown value "isHighlighted"

 

How shall I define the isHighlighted value?

___________________________________________________

 

#define FROB_UNHILIGHTED 0 // Entity isn't hilighted.

#define FROB_INDIRECT 1 // Entity is hilighted via peer hilighting.

#define FROB_DIRECT 2 // Entity is hilighted directly.

 

// To make lockpicking trigger guard alerts.

 

void main()

{

while(1) // This script shall run at map start and loop

float door1highlighted = $room1door.isHighlighted();

 

 

if (door1highlighted == 1) // CHECKS IF THE PLAYER IS HIGHLIGHTING THE DOOR

{

sys.print("\nDoor 1 is highlighted!\n"); // debug text

}

 

}

Link to comment
Share on other sites

My bad.

 

It's supposed to be isHilighted(), not isHighlighted().

 

Sorry.

 

Anyhoo, your script as written will put you in an endless loop right at the start, because it will continuously run the first line after the while(1) statement.

 

What I would do is create a trigger_multiple brush next to the door with these spawnargs:

 

"call" "CheckLockPicking"

"wait" "1"

 

Then create a routine in your script file that does something like this:

 

void CheckLockPicking()
{
  float door1highlighted = $room1door.isHilighted();

  if (door1highlighted != 0)
  {
     // door is highlighted

     // add some code that checks the current inventory item being a lockpick (see upthread)

     if ( that code says the current inventory item is a lockpick)
     {
         // do whatever you need to do to bust the player. sound an alarm. notify nearby guards. change relationships.
      }
  }
}

Link to comment
Share on other sites

Nice, the highlight works :)

 

I'm terribly sorry but I don't know how to implement the "scriptEvent string getCurInvItemName();" in the script

 

 

This is my vision in words:

 

Extract the current inventoryitem name (snake or triangular) and put it in a string like "this_is _in_your_hands"

 

then an if string to check if "this_is _in_your_hands" is snake OR triangular THEN change teams

 

But I don't know the syntax :/

 

 

I have a working plan for the team changing though so that's not a problem

Edited by Fieldmedic
Link to comment
Share on other sites

Try this:

 


entity player = sys.getEntity("player1");
entity item = player.getCurInvItemEntity();

boolean usingPick = 0;

if ( item != $null_entity)
{
  string classname = item.getKey("classname");
  if ( ( classname == "atdm:playertools_lockpick_snake" ) || ( classname == "atdm:playertools_lockpick_triangle" )
  {
     usingPick = 1;
  }
}

if ( ( usingPick == 1) && ( door is highlighted, determined by code upthread ) )    
{
  // bust player
}

Link to comment
Share on other sites

wow...should the be included?

 

Must have been the explorer fiddling up...

 

 

 

When I try the whole block it says:

 

 

Error: file maps\naog\naog.script, line 1: Type mismatch on redeclaration of player

 

Shall test...

Edited by Fieldmedic
Link to comment
Share on other sites

But when should this script be run? Should I run it at map start and then keep it running? Is this good performance vice?

 

There are things you can do to minimize the performance hit.

 

One of the options for locations is running a script when you enter and exit a location -- read the location wiki entry about it -- so you can run the script when you enter the location at issue & keep it running. I don't recall if you can kill a script with another script (if you could, then you'd just use an exit-script to kill it, then the exit-script kills itself). But even if you can't do that, the original script itself can make a "whie" location check whie it's cycling ("as long as I'm still in location X"; just like the darkmod location script does; just copy that code from it), and as soon as you move into another location the script can kill itself. Then it's not a resource hog for the rest of the mission, only in the single location where the action is happening.

 

Two other performance tips are (1) have conditional statements at the top so it skips over all the processing unless the conditions are in place (edit: I don't know if this will be applicable for you or not), and (2) put a little wait somewhere for each round, like .2 sec or whatever (experiment), so it's not re-triggering so fast it sucks processing unnecessarily. The darkmod location script itself is again a model you can copy from.

What do you see when you turn out the light? I can't tell you but I know that it's mine.

Link to comment
Share on other sites

Type mismatch on redeclaration of player

 

 

 

void CheckLockPicking()

{

entity player = sys.getEntity("player1");

entity item = player.getCurInvItemEntity();

 

boolean usingPick = 0;

 

float door1highlighted = $room1door.isHilighted();

 

if (door1highlighted != 0)

{

// door is highlighted

 

if (item != $null_entity)

{

string classname = item.getKey("classname");

if ( ( classname == "atdm:playertools_lockpick_snake" ) || ( classname == "atdm:playertools_lockpick_triangle" )

{

usingPick = 1;

}

}

 

if ( ( usingPick == 1) && (door1highlighted != 0))

{

sys.print("\n\nAI is seeing you pick the lock!\n\n");

 

}

Link to comment
Share on other sites

Yes...the script accepts that line now...but the script doesn't like the if string

 

 

if ( ( classname == "atdm:playertools_lockpick_snake" ) || ( classname == "atdm:playertools_lockpick_triangle" )

{

usingPick = 1;

}

 

 

Get the error expected ')', found '{'

 

Remove the first ( after 'if'

 

if ( classname == "atdm:playertools_lockpick_snake" ) || ( classname == "atdm:playertools_lockpick_triangle" )

{

usingPick = 1;

}

 

 

 

get the error '||' is not a name

 

I guess the || is the 'OR' command? (The game didn't recognize 'OR')

Edited by Fieldmedic
Link to comment
Share on other sites

In the line that compares the strings, a right parenthesis is missing from the right.

 

 

if ( ( classname == "atdm:playertools_lockpick_snake" ) || ( classname == "atdm:playertools_lockpick_triangle" ))

 

 

Sorry. It probably got lopped off when I had to manually remove all the html crap that this editor stuck into my original post of the script.

Link to comment
Share on other sites

Cool! That's a subtle thing to get working that I didn't think would work at first. Really cool that we cracked it.

What do you see when you turn out the light? I can't tell you but I know that it's mine.

Link to comment
Share on other sites

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

    • Petike the Taffer

      I've finally managed to log in to The Dark Mod Wiki. I'm back in the saddle and before the holidays start in full, I'll be adding a few new FM articles and doing other updates. Written in Stone is already done.
      · 4 replies
    • nbohr1more

      TDM 15th Anniversary Contest is now active! Please declare your participation: https://forums.thedarkmod.com/index.php?/topic/22413-the-dark-mod-15th-anniversary-contest-entry-thread/
       
      · 0 replies
    • JackFarmer

      @TheUnbeholden
      You cannot receive PMs. Could you please be so kind and check your mailbox if it is full (or maybe you switched off the function)?
      · 1 reply
    • OrbWeaver

      I like the new frob highlight but it would nice if it was less "flickery" while moving over objects (especially barred metal doors).
      · 4 replies
    • nbohr1more

      Please vote in the 15th Anniversary Contest Theme Poll
       
      · 0 replies
×
×
  • Create New...