Home   Help Search Login Register  

Author Topic: Grenades....like hot potatoes......  (Read 2327 times)

0 Members and 1 Guest are viewing this topic.

Offline General Barron

  • Former Staff
  • ****
  • Semper Fi!
Re:Grenades....like hot potatoes......
« Reply #15 on: 26 Apr 2003, 07:47:05 »
That sure isn't true... most hand grenades explode after a preset time.  There are numerous accounts from WW2, Korea and Vietnam of grenades being thrown back by their intended targets (and sometimes even picked up and thrown AGAIN!) and also of grenades going off in the hands overly patient throwers...

just a point, there aren't actually any impact grenades :)

they all go off after a 4-5 second delay with teh exception of the M15 White Phosphorus grenade :)

Yes, its true that they don't explode on impact in real life, but what is being discussed is how grenades behave in the OFP universe. Remember: this is the same universe where tanks drive up sheer cliffs and airplanes stop dead in place when they hit a tree  ;)

Now, as for the script: while LCD's idea will work for cutscenes, I think there is a way to get this to work in game, with "real" grenades as well. What if you used the nearestObject command or an event handler to keep track of a grenade that is thrown. Now, when that grenades Z-pos (this getpos select 2) is, say, .5 meters, you simply execute another script where the player does some nifty animation, then the grenade is setvelocity'ed back at the thrower. You could do things like add an action for the player when the grenade is within ten meters or so, (that way it wouldn't be an automatic defense, and would take some quick thinking to execute).

Sorry for throwing those commands out, Gravedigga. I meant them more for LCD or anyone else reading this thread with more scripting experience  :-*
HANDSIGNALS COMMAND SYSTEM-- A realistic squad-control modification for OFP
kexp.org-- The best radio station in the world, right here at home! Listen to John Richards!

Offline LCD

  • Former Staff
  • ****
    • Everon Cartel
Re:Grenades....like hot potatoes......
« Reply #16 on: 26 Apr 2003, 08:06:45 »
@ GB

u can do it - i know dere was script dat made fast loop nd waited 4 missle 2 b shot from da player (usin da nearestonject) but i donno da class of da grande  :-\

mebe u can get up w/ somin ;D

LCD OUT
"guess being the community has downsides .." - cheetah
Help Perfecting Da Next Best Thing - O-Team Beta

Offline General Barron

  • Former Staff
  • ****
  • Semper Fi!
Re:Grenades....like hot potatoes......
« Reply #17 on: 26 Apr 2003, 09:25:45 »
Okay, done. Try this script out:

The first one should be run at the start of the mission. Nothing is passed to it, so just type [] exec "hot potato.sqs". Of course, you can name this whatever you want.

Code: [Select]
;//hot potato.sqs

actionCounter = 0
catching_grenade = FALSE
_catch_range = 15
? cadetmode : _catch_range = 25

#Top
thrown_grenade = FALSE
@ player distance nearestObject[player, "GrenadeHand"] <= _catch_range
_grenade = nearestObject[player, "GrenadeHand"]
? !catching_grenade : player addaction ["Catch Grenade","grenadecatch.sqs"]
@ player distance _grenade >= _catch_range OR thrown_grenade
player removeaction actionCounter
actionCounter = actionCounter + 1
goto "Top"

Basically, this waits until a grenade is close to the player (the exact distance can be changed; it is called "_catch_range" and is at the top of the script), then adds an action to the player. It won't add another action until the old one is removed. This action calls the next script:

Code: [Select]
;//grenadecatch.sqs

? catching_grenade : exit
catching_grenade = TRUE
_grenade = nearestObject[player, "GrenadeHand"]
@getpos _grenade select 2 <= 1
player switchmove "CombatThrowGrenadeEnd"

_grenade setpos getpos dump
;//NOTE BELOW!

thrown_grenade = TRUE
catching_grenade = FALSE

This script will wait until the grenade almost hits the deck, then makes the player do a little throw move. Now, I don't have resistance, so I can't use the setvelocity command. What I did was place a logic named "dump" on the map, and made the action move the grenade to the dump (see the noted line in the code). This would obviously be better suited for the setvelocity command here. However, like I said, I don't have OFPR (for whatever reason...), so I can't test the setvelocity command (LCD, maybe you would be interested). But I would make it send the grenade in whatever direction the player is facing, and slightly up.

Maybe: _grenade setVelocity [(getpos player select 0) + (10 * sin getdir player), (getpos player select 0) + (10 * cos getdir player, 5]. You could tweak the xy (10) and z (5) values to make it look realistic.

I haven't tested the script with multiple grenades being thrown at me at once, but it should still work in that case. Hope this helps!

--General Barron


HANDSIGNALS COMMAND SYSTEM-- A realistic squad-control modification for OFP
kexp.org-- The best radio station in the world, right here at home! Listen to John Richards!

Offline General Barron

  • Former Staff
  • ****
  • Semper Fi!
Re:Grenades....like hot potatoes......
« Reply #18 on: 27 Apr 2003, 09:24:07 »
Okay, I forgot to upload a sample mission. Here ya go.
HANDSIGNALS COMMAND SYSTEM-- A realistic squad-control modification for OFP
kexp.org-- The best radio station in the world, right here at home! Listen to John Richards!

Offline LCD

  • Former Staff
  • ****
    • Everon Cartel
Re:Grenades....like hot potatoes......
« Reply #19 on: 30 Apr 2003, 02:23:04 »
its kool thing :thumbsup: but dere r som comments i have out it ;D (nd me xepectin u 2 take care of em ::))

1) it seems 2 work even wen dey throw da grande on me form behind - byt in RL it less likly dat da man actualy noticed it ;) (dere is nice function dat determintaes da facin of unit nd if it face object - can b used ;D)

2) m stil waitin 2 c da dump thin movin

i just dont have enough time now but if i get som ill try 2 make da setvelocity thing ;D (but i think it dont work on not vehicle objects  :-\)

LCD OUT
"guess being the community has downsides .." - cheetah
Help Perfecting Da Next Best Thing - O-Team Beta