OFPEC Forum
Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: 456820 on 14 Jun 2005, 17:59:44
-
how can i check if a grenade has been thrown by an enemy and was targeting at a player or group then make a 50% 50% chance of the player yelling "GRENADE" to warn the player and add to realism and atmosphere
is it possible i know there is an eh called incoming but only works for targets that can be locked with a missile is there anything wich detects if a soldier is targetting another soldier
EDIT - Also how do i make random chances of things happening ?
-
you could try adding a fast looping script which would centre on the player's position and find any nearest object of type grenade. then give a random (http://www.ofpec.com/editors/comref.php?letter=R#random) number a spin, divide it by two, and use it to decide whether or not to yell 'incoming'.
that's how i'd do it at any rate.
-
not bad that could work but 2 things 1) i dont know anything at all really about the nearest object command ill look in the com ref right now 2) i dont know how to make random chaces
-
how do i make random chances of things happening
if (75 > random 100) then {this will happen 75% of the time} else {this will happen 25% of the time}
Is one of many ways
-
so how about this
#loop
nearestObject [player, "HandGrenade"] then if (50 > random 100) goto "shout"
~1
goto "loop"
#shout
player say "GRENADE"
by any chance is that right even though im pretty sure it isnt.
Also thanks for the quick replys
-
No. Well, no-ish. Get it clear in your head.
IF a is true and b is true THEN c ELSE d
-
I did that last year, but I have to find the script in my huge ofpfolder;
The thrower shouts "fire in the hole", the possible reciever shouts "grenaaaade!!!!"
OK, I've found it. It a old script so maybe things could be done easier and better.
I made a list of all the units who could recieve a grenade. With a trigger WEST/EAST, whatever... present, once, covering the whole map.
Onactivation :
Allunits = thislist
in the init of all throwers :
this addEventHandler ["fired",{_this exec "throwcheck.sqs"}]
throwcheck.sqs
_shooter = _this select 0
_ammotype = _this select 4
?_ammotype == "grenadehand": _shooter say "gren1"
~1
_nade = nearestobject [_shooter,_ammotype]
~0.2
_i = 0
#Lp
_x = allunits select _i
?_x distance _nade < 70 && "man" counttype [_x] > 0 : _x say "gren_r1"
_i= _i + 1
?_i < count allunits : goto "lp"
gren1 and gren_r1 are two custom sounds
I've wrote it for a cutscene and it did the job, I doubt it will work in all situations
Here you go, it's funny to hear my own voice :P
http://users.telenet.be/blanco/Scripts/DVE.Intro.zip
-
A random comment on a point above
if (50 > random 100) goto "shout"
needs a then - as 6q pointed out. It also needs some {} and so should be:
if (50 > random 100) then {goto "shout"}
-
cool thanks guys im just going to try Blacno's script thanks for it also is it okay if i can edit it so i can give it the random chance because if the player throws a grenaded when the enemy arent aware and shouts GRENADE it would seem abit stupid
-
Offcourse you can, it was just an example :)
-
well ive tweaked the script so it now has chances and checged the distacne the grenade needs to be and its pretty good.
but now how would i do the same but for east for example so if they throw a grenade there is a 40 percent checnce of west shouting grenade but the east dont say it atall
thanks for the script aswell
-
this is great works fine actually no need for the west getting grenades thrown at them but if it is important later on ill unsolve this and say so
thanks alot blanco