Home   Help Search Login Register  

Author Topic: Alert when firing?  (Read 835 times)

0 Members and 1 Guest are viewing this topic.

Offline Wildebeest

  • Contributing Member
  • **
  • The time the wildebeest ruled the Earth.
Alert when firing?
« on: 23 Oct 2002, 09:56:56 »
Hi, I'm trying to make a mission in which a guy that has been set to "setcaptive true" will infiltrate an enemy base. I want to set his condition to "setcaptive false" as he opens fire in the base, no matter what he's firing at or who. I know how to do this by using "not alive" and "ammo", but thing is I wan't him to be able to fire before he enters the camp. Let's say that the guy has 100 cartridges from start and that the enemies will be alerted when he has less than that. Thing is, the guy might just as well have 73 cartridges left, alerting the guards disregarding of whether he started shoting there or not. Please help guys, you are the best  ;D
Weeee...

david-p

  • Guest
Re:Alert when firing?
« Reply #1 on: 23 Oct 2002, 14:48:30 »
so you say you already know the script to use? then a trigger over the area where u want him to cease fire, grouped with the unit, repeatedly, with the:
OnAct execing your script
OnDeAct: keepgoing = false
.. in your script you will probably have a loop to keep checking the ammo, so at the start of that loop put
!(keepgoing):exit and put at the first line of the script, or in init.sqs, keepgoing = true
so all the time the unit is in the area it will keep checking your script, and when he leaves it will exit the script. he can the reenter and rerun the script.

Offline Wildebeest

  • Contributing Member
  • **
  • The time the wildebeest ruled the Earth.
Re:Alert when firing?
« Reply #2 on: 23 Oct 2002, 18:42:54 »
Sorry, but I just can't get it to work.  :'(
I typed this in the script:

keepgoing = true

#loop

!(keepgoing):exit

?(ap ammo "gmp40" < 32): ap setdammage 1

goto "loop"

("Ap setdammage 1" is for testing purposes only, to see if it works.) The game keeps telling me that the "!(keepgoing):exit" is an uknown operator. In the trigger I typed OnAct: [this] exec "keepgoing.sqs", DeAct: keepgoing = false. I also linked it with the guy. Sorry but, I'm not too good at scripting, maybe you guys may enlighten me further?  :)
Weeee...

Offline MI_Fred

  • Members
  • *
  • AA
    • OFP Team Finlanders
Re:Alert when firing?
« Reply #3 on: 23 Oct 2002, 20:33:06 »
You don't have to use such a complicated way since 1.85 has eventhandlers. What you wanna do is give the guy an eventhandler "Fired" when he enters the trigger and remove it when he exits it.

On Act.: guy addEventHandler ["Fired",{_this exec "guyfired.sqs"}]

On deact.: guy removeAllEventHandlers "Fired"; guy setcaptive true

guyfired.sqs
Quote
_guy = _this select 0
_weapon = _this select 1
_muzzle = _this select 2
_mode = _this select 3
_ammo = _this select 4

_guy setcaptive false
exit
As you notice there's a lot of stuff passed into the script with "Fired" eventhandler. Use _weapon for instance in this way:
Quote
? _weapon != "HK" : guy setcaptive false
so that when he fires any other weapon than a silenced one, he's spotted.

Check out the new Comref for more details if that's not enuf.
There's gooks over there, there's mines over there, and watch out those goddamn monkeys talk, I'll bite ya.

Offline Wildebeest

  • Contributing Member
  • **
  • The time the wildebeest ruled the Earth.
Re:Alert when firing?
« Reply #4 on: 23 Oct 2002, 21:34:45 »
Wow, thank you guys. The "EventHandler" spell worked just fine.  :D
Weeee...