Home   Help Search Login Register  

Author Topic: Ammo low  (Read 706 times)

0 Members and 1 Guest are viewing this topic.

TC

  • Guest
Ammo low
« on: 22 Nov 2005, 00:46:27 »
hello

i have created a set of scripts which enable a unit to hurl abuse towards the enemy, when firing, throwing grenades and when aware.

The following is the script detailing when the unit is aware, and what speeech lists he should use in differing situations:

Quote
_b = _this select 0
_d = group _b
BenSpeakAware = true

#1
~ 1
?behaviour ben  == "combat" && (BenSpeakAware): goto "speak"
~2
Goto "1"
#speak
?ben ammo "Wbt_Tommy" < 5: goto "AmmoLow"
?!someAmmo ben : goto "AmmoLow"
_voices  = ["Ben_JamesNoseyStarbord","ben_rear","Ben_Da","Ben_ShaunShootingWrongWay","ben_Scream", "ben_Scream2","Ben_MyGodTwats","Ben_UglyBastards","Ben_Ambush","Ben_OhShit", "Ben_TcBadPlanning","Ben_Shit","Ben_FuckRightOff","Ben_Shit2"]
_r = random 14
_re = _r mod 1
_r = _r -_re
_v = _voices select _r
ben say _v
BenSpeakAware = false
~ random 10
BenSpeakAware = true
goto "1"

#AmmoLow
hint "ammo Low"
_voicesAmmo = ["Ben_NewMagTC","Ben_PassMeTheClip","Ben_Blanks"]
_rAmmo = random 3
_reAmmo = _rAmmo mod 1
_rAmmo = _rAmmo -_reAmmo
_vAmmo = _voicesAmmo select _rAmmo

ben say _vAmmo
BenSpeakAware = false
~ random 20
BenSpeakAware = true
goto "1"

this works well, untill we reach the bit regarding whether the unit is reloading: "?ben ammo "Wbt_Tommy" < 1: goto "AmmoLow""

he does speak when he has less than one shot in his magazine for the weapon "wbt_tommy", when he would be reloading, but i was wondering if there is any way of putting in a generic weapon doo dah in the place of "wbt_tommy" so he would say it with each weapon he fires without having to make a huge script detailing each weapon in my campaign individually.

Also the line "?!someAmmo ben : goto "AmmoLow"" doesnt work at all. I was thinking this would detect the unit has no ammo left at all, but it doesnt want to work... How would i get this to workl, or better, detect when the unit has only 1 magazine left for his weapon?

And fina;;y, is it possible to detect the unit has no weapon at all? Otherwise he's going to be banging on about being low on ammo when he doesnt even have a weapon!

As always, any help appreciated

Regards
« Last Edit: 22 Nov 2005, 09:43:41 by bedges »

Offline Tyger

  • Former Staff
  • ****
  • I was at OFPEC when it still had dirt floors...
    • OFPEC
Re:Ammo low
« Reply #1 on: 22 Nov 2005, 01:43:51 »
Part of your problem is the fact that the command ammo returns how many rounds are left in a magazine, not how magazines are left with a player.

Change it to magazines <unit>. This will return an array of all magazines the player has. You can then count the number of a magazine class in that array.
"People sleep soundly at night only because rough men stand ready to do violence on their behalf." - George Orwell

MSG Mike Everret - We Will Never Forget - '75-'08

Offline alimag

  • Contributing Member
  • **
  • I'm a llama!
Re:Ammo low
« Reply #2 on: 22 Nov 2005, 15:41:50 »
Hi,

Instead of using a weapon specific name, use:
ben ammo (primaryWeapon ben)
So if he changes (ben) for an M16 it will work anyway.

By the way, counting the magazines will not really help you either. If you change magazine every time you have 1 bullet left in it and you have 5 magazines, you only have 5 bullets despite the fact that you have 5 magazines.

The only way to know exactly how many bullets left is to store in a variable the total amount in the beginning of the mission and then use the "FIRED" event handler to decrease that variable every time a bullet is fired.

Good luck

TC

  • Guest
Re:Ammo low
« Reply #3 on: 22 Nov 2005, 17:55:24 »
Cheers AliMag, got that bit to work properly now.

Tyger, i cant get your bit to work, "magazines <unit>", could you give me an example?