Getting NPC to Trip an Alarm
Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. This forum is archived - please use this set of forums to ask new questions.
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. This forum is archived - please use this set of forums to ask new questions.
Getting NPC to Trip an Alarm
For my project I'm trying to get an enemy to run to an alarm and trip it when he sees the player. Once that happens guards arrive and attack the player. Also more guards spawn at other areas of the map to simulate a heightened state of security. I wouldn't even know where to start. Is it an ACS script activated in the NPC's "See" state in DECORATE?
Re: Getting NPC to Trip an Alarm
The way to handle this is as follows:Liberator wrote:For my project I'm trying to get an enemy to run to an alarm and trip it when he sees the player. Once that happens guards arrive and attack the player. Also more guards spawn at other areas of the map to simulate a heightened state of security. I wouldn't even know where to start. Is it an ACS script activated in the NPC's "See" state in DECORATE?
1. Set up the "trigger" mechanism to run a script. Best way to do this may be to have the player trigger the script (e.g., entering a secure area).
2. Use Patrol Points and Path Nodes to make the NPC run or walk to the alarm and set it off.
3. Have the rest of the script spawn the guards.
4. [OPTIONAL:]Use a cutscene to show the player's capture.
You won't need to mess with DECORATE if you use the general method outlined above. Post here or PM/email me if you want additional details.
Re: Getting NPC to Trip an Alarm
But I guess he wants the guard to do it when he see the player.
He could prevent the guard from really seeing the player with an invisible wall and use Rex's method however. o.õ
He could prevent the guard from really seeing the player with an invisible wall and use Rex's method however. o.õ
Re: Getting NPC to Trip an Alarm
Well I want to prevent the player from having to cross a linedef. It would give them the chance to drop the guard before crossing the line, then continue, thus making what i'm trying to do moot.
I don't know a whole lot about ACS, but couldn't I just execute the script when the enemy enters the "See" state? the script being the one that instructs the enemy to follow the patrol points or path node to the alarm
I don't know a whole lot about ACS, but couldn't I just execute the script when the enemy enters the "See" state? the script being the one that instructs the enemy to follow the patrol points or path node to the alarm
Re: Getting NPC to Trip an Alarm
It can be done, the problem is that the guard may try to fire the player until he gets to the alarm. It coul be prevented, however, using some "A_jump" kludes. Le'ts say your guard is a zombieman and you have made a script like Rex's one (that send the guard to a path to the alarm. I'd make a zombieman variant, like the following:
1º I'd make a dummy [wiki]custominventory[/wiki] in DECORATE. It'd serve for the zombieman/guard "know" if he can shoot or not.
2º I'd make my guard to execute Rex's script when seeing player, and to avoid 'missiling' if it has the dummy item. It would be a new special guard type, not a change to make in your ordinary guard's decorate.
It could be done in many ways, I'd prefer to use [wiki]A_LookEx[/wiki] instead of A_Look in its Spawn label/state and send the monster to a custom label/state:
3º In the map, give the intem to your guard via acs with [wiki]GiveActorInventory[/wiki] at the very beginnig of the map. At the script that sounds the alarm, take it with [wiki]TakeActorInventory[/wiki], so it can shoot players again.

edit: maybe there are better ways of doing this o.õ I'm a 'kludge guy' :S
1º I'd make a dummy [wiki]custominventory[/wiki] in DECORATE. It'd serve for the zombieman/guard "know" if he can shoot or not.
Code: Select all
Actor CanIShoot : CustomInventory {}
It could be done in many ways, I'd prefer to use [wiki]A_LookEx[/wiki] instead of A_Look in its Spawn label/state and send the monster to a custom label/state:
Code: Select all
ACTOR SecurityGuard : ZombieMan
{
(...)
States
{
Spawn:
POSS AA 10 A_LookEx (0, 0, 0, 0, 180, "ISeeYou") //Monster will go to "Iseeyou" label instead of "see" when gets a target,
Loop
ISeeYou:
TNT1 A 0 ACS_ExecuteAlways (999, 0, 0, 0, 0) //Executes Rex's script (999) and goes to See label
Goto See
(...)
Missile:
TNT1 A A_JumpIfInventory ("CanIShoot", 1, "See") // If it has the dummy inventory, it jums back to "see" label.
POSS E 10 A_FaceTarget
POSS F 8 A_PosAttack
POSS E 8
Goto See
}
}

edit: maybe there are better ways of doing this o.õ I'm a 'kludge guy' :S
Re: Getting NPC to Trip an Alarm
nah seems to me that you hit the nail on the head lol
but how would I command the monster to flip the alarm switch once he's completed his path
but how would I command the monster to flip the alarm switch once he's completed his path
-
- Posts: 5043
- Joined: Sun Nov 14, 2010 12:59 am
Re: Getting NPC to Trip an Alarm
Use [wiki=Classes:Inventory]Inventory[/wiki], not [wiki=Classes:CustomInventory]CustomInventory[/wiki]. CustomInventory items don't stay in the actor's inventory when given/picked up, unless they have a Use state, but you don't need a Use state in this case.Ravick wrote:1º I'd make a dummy [wiki]custominventory[/wiki] in DECORATE. It'd serve for the zombieman/guard "know" if he can shoot or not.
Code: Select all
Actor CanIShoot : CustomInventory {}
Re: Getting NPC to Trip an Alarm
Unless you create custom sprites showing the guard reach for the alarm, your best bet would be to have the alarm triggered when the guard reaches a specific nodal point. Say the alarm handle is at spot X on a wall. Set your final path node right in front of the alarm handle at spot X. Set the node to trigger your ACS script (e.g., audio alarm, flashing lights, spawning guards, etc.), and have the node facing the alarm handle. When the guard reaches the path node, the guard will turn towards the alarm handle and appear to trigger the alarm.Liberator wrote:but how would I command the monster to flip the alarm switch once he's completed his path
If you want to show the guard reach for the alarm handle, in addition to the custom sprites, you'll need to create some more DECORATE definitions. Probably not worth the additional effort to show the action in fully realistic detail.