Home   Help Search Login Register  

Author Topic: adding eventhandlers to map objects via id's  (Read 1822 times)

0 Members and 1 Guest are viewing this topic.

Offline Lollypop

  • Members
  • *
  • Noob Alert
adding eventhandlers to map objects via id's
« on: 03 Jun 2009, 16:28:52 »
hai all

i know this is a rly lame question but how would i go about making barrels that are preplaced on map explode

i downloaded the script that blows them up i just need the correct syntax for the hit eventhandler.
It's weird gameplay wise that some barrels (ones i put in) explode and others dont.

tnx in advance

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Re: adding eventhandlers to map objects via id's
« Reply #1 on: 03 Jun 2009, 18:36:36 »
Put a "Game Logics/objects/gamelogic" on the map near the barrel with init code:
Code: (init line) [Select]
((getPos this) nearestObject 1231344) addEventHandler ["HIT", { _barrel = (_this select 0); "HandGrenade" createVehicle (getPos _barrel); _barrel setDamage 1 }];

Might want to use KILLED handler rather than HIT, since even the slightest damage will cause an explosion in this example.

Might not need the hand grenade to make an explosion for this, but added it in case you wanted a bit of whoomp ;) You have a play around with it. There is also an exploding barrels script which might be interesting for the pyrotechnically minded.
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)

Offline Lollypop

  • Members
  • *
  • Noob Alert
Re: adding eventhandlers to map objects via id's
« Reply #2 on: 03 Jun 2009, 19:03:12 »
tnx for the fast reply...is exactly what i was looking for...i have that script too...i meant to do it with it.

ill go try it now and connect this EH to that script :p

do i need 1 gamelogic for each barrel?

#edit:

hmmz..i didnt manage to make it work and im quite sure i did everything right...does the gamelogic need to be physically closest to the barrel?
« Last Edit: 03 Jun 2009, 19:27:46 by Lollypop »

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Re: adding eventhandlers to map objects via id's
« Reply #3 on: 04 Jun 2009, 22:10:39 »
* Doesn't have to be the closest to the world object at all. Just as long as is less than 100m or so away is fine (in Arma2 the engine doesn't complain about the distance until it is > 400m, though it will work at any distance).
* I suspect that you need to use the "killed" handler rather than the "hit" handler on this sort of object, since I'm not sure they would have a hit handler at all. Try hit if you want it to explode immediately, but killed if that doesn't work.
* The number, 1231344, in the example should be changed to the ID number you see in the editor at the barrel's position. Just making that very clear, since it was only implied before. You will need one logic per barrel with the correct ID number in it.
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)

Offline Lollypop

  • Members
  • *
  • Noob Alert
Re: adding eventhandlers to map objects via id's
« Reply #4 on: 05 Jun 2009, 12:27:02 »
Lol still no go...i did everything like you said....is it even possible in arma to do this?

i know it was possible in ofp.

anyway...i uploaded a test mission..only soldier and game logic on rahmadi...i emptied whole mags in it and the only thing it did was to topple over on the side....i guess thats when its "killed".

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Re: adding eventhandlers to map objects via id's
« Reply #5 on: 05 Jun 2009, 18:43:02 »
Ah, sorry, I think I misled you entirely :whistle: You see, some objects in ArmA maps are p3ds (just models) and some are full objects (class with config which is associated with a p3d). Only the latter type is the same as the sort of objects you can place in the editor and those are the only type you can treat as full objects (e.g. add event handlers to). What I've suggested would work fine for "map objects", like buildings, but not for "map scenery", like trees or barrels. I just assumed a barrel would be a proper map object. My fault...sorry!
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)

Offline Lollypop

  • Members
  • *
  • Noob Alert
Re: adding eventhandlers to map objects via id's
« Reply #6 on: 05 Jun 2009, 19:52:41 »
ye thought so  :) that its arma stuff not me doing anything wrong

tnx for the help anyway...very much appreciated