Home   Help Search Login Register  

Author Topic: grenade  (Read 885 times)

0 Members and 2 Guests are viewing this topic.

Offline 456820

  • Contributing Member
  • **
grenade
« 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 ?
« Last Edit: 14 Jun 2005, 18:01:20 by 456820 »

Offline bedges

  • Administrator
  • *****
    • OFPEC The Editing Center
Re:grenade
« Reply #1 on: 14 Jun 2005, 18:03:28 »
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 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.
« Last Edit: 14 Jun 2005, 18:04:23 by bedges »

Offline 456820

  • Contributing Member
  • **
Re:grenade
« Reply #2 on: 14 Jun 2005, 18:05:18 »
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

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re:grenade
« Reply #3 on: 14 Jun 2005, 18:05:45 »
Quote
how do i make random chances of things happening


Code: [Select]
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

Offline 456820

  • Contributing Member
  • **
Re:grenade
« Reply #4 on: 14 Jun 2005, 18:09:41 »
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

qqqqqq

  • Guest
Re:grenade
« Reply #5 on: 14 Jun 2005, 22:25:38 »
No.   Well, no-ish.    Get it clear in your head.

IF a is true and b is true THEN c ELSE d

Offline Blanco

  • Former Staff
  • ****
Re:grenade
« Reply #6 on: 14 Jun 2005, 23:29:29 »
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 :
Code: [Select]
this addEventHandler ["fired",{_this exec "throwcheck.sqs"}]
throwcheck.sqs
Code: [Select]
_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







« Last Edit: 15 Jun 2005, 00:11:56 by Blanco »
Search or search or search before you ask.

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re:grenade
« Reply #7 on: 15 Jun 2005, 08:47:50 »
A random comment on a point above

Code: [Select]
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"}




Offline 456820

  • Contributing Member
  • **
Re:grenade
« Reply #8 on: 15 Jun 2005, 16:51:00 »
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

Offline Blanco

  • Former Staff
  • ****
Re:grenade
« Reply #9 on: 15 Jun 2005, 17:21:31 »
Offcourse you can, it was just an example :)
Search or search or search before you ask.

Offline 456820

  • Contributing Member
  • **
Re:grenade
« Reply #10 on: 15 Jun 2005, 18:09:07 »
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

Offline 456820

  • Contributing Member
  • **
Re:grenade
« Reply #11 on: 16 Jun 2005, 16:39:05 »
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