Home   Help Search Login Register  

Author Topic: AddAction to map objects  (Read 2674 times)

0 Members and 1 Guest are viewing this topic.

Offline Dash5

  • Members
  • *
AddAction to map objects
« on: 12 Aug 2007, 21:59:27 »
A search turned up nothin', so maybe I'm wording this wrong... :confused:

Is it possible to use addAction on map objects (fences, houses, buildings, etc.)?

Assuming it is...I'm trying to make a function that allows the player to destroy a fence. What am I doing wrong?

from init.sqs:
Code: [Select]
ActFence = ((getPos player) nearestObject 262162) addAction ["Break Fence", "BreakFence.sqf"];
from BreakFence.sqf:
Code: [Select]
_object = _this select 0;
_id = _this select 2;
//remove the action
_object removeAction _id;
//destroy fence
_object = (getPos player) nearestObject 262162;
if (!isNull _object) then _object setDamage 1;
« Last Edit: 12 Aug 2007, 22:02:47 by Dash5 »

Offline johnnyboy

  • OFPEC Patron
  • ****
  • Matan los Pantalones!!!
Re: AddAction to map objects
« Reply #1 on: 12 Aug 2007, 22:37:13 »
That looks clean to me.  Maybe it only works on editor placed objects.  If that is the case, you could place a hidden H object on the fence, and add the action to that instead.  Worth a try anyway...

This "break fence" idea is a good one, by the way.   
El Cojon: "Do you like to Tango?"
You: "Only in Bagango."
Download Last Tango in Bagango and discover how El Cojon earned his name...

Offline JasonO

  • OFPEC Patron
  • ****
  • Oh no...
    • The New Life RPG
Re: AddAction to map objects
« Reply #2 on: 13 Aug 2007, 02:50:43 »
It's been discussed before that things like vegetation and fences arn't actually objects, they are only island objects. They can't be selected even with nearestobject etc. Therefore you would have no way of defining what you want the action on in a script.

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: AddAction to map objects
« Reply #3 on: 13 Aug 2007, 03:15:09 »
You may try also adding the action to a gamelogic placed near the desired object.

Offline JasonO

  • OFPEC Patron
  • ****
  • Oh no...
    • The New Life RPG
Re: AddAction to map objects
« Reply #4 on: 13 Aug 2007, 03:43:53 »
But you still won't be able to actually destroy the fence?

Offline johnnyboy

  • OFPEC Patron
  • ****
  • Matan los Pantalones!!!
Re: AddAction to map objects
« Reply #5 on: 13 Aug 2007, 06:43:45 »
If they have object ids you may be able to destroy them.  I have successfully destroyed hand rail objects that line the streets of Bagango. 
El Cojon: "Do you like to Tango?"
You: "Only in Bagango."
Download Last Tango in Bagango and discover how El Cojon earned his name...

Offline Dash5

  • Members
  • *
Re: AddAction to map objects
« Reply #6 on: 13 Aug 2007, 06:54:47 »
Yes, fences are destroyable...just gotta figure out how to link it to addAction.

Does anyone know how this was done in Evolution? For example, certain buildings have actions like 'Recruit Soldier'.
« Last Edit: 13 Aug 2007, 07:06:51 by Dash5 »

Offline Nixer6

  • Members
  • *
Re: AddAction to map objects
« Reply #7 on: 13 Aug 2007, 15:08:09 »
It's gotta be a trigger for Evo, as it's touchy as to where you are at the entrance to the recruitment building. Can't find my decoded mission.sqm for it ATM, so I am not sure though.
Why do I have to be a Rocket Scientist to make a good mission?

Offline johnnyboy

  • OFPEC Patron
  • ****
  • Matan los Pantalones!!!
Re: AddAction to map objects
« Reply #8 on: 13 Aug 2007, 16:33:42 »
Here's another option:  Collect the fence object ids you need into an array.  Then set up a script that loops through the array and tests the distance of the player to the object.   When player is close enough, add the action to the player, and register the near object id in a global variable (so the destroy action knows which object to destroy).  When player moves away (or fence section destroyed), remove action from player, and remove object id from global variable.  Be sure to sleep in the loop so it doesn't use up too much cpu.

If you want many different possible fence breakpoints, this approach may be cleaner, as your Destroy script is simple:  It destroys the object whose object ID is in the global variable.

If you have to place hidden objects or game logics for each fence break point, your destroy script becomes more complex, as it must be able to know which object id corresponds to which placed object/logic.
El Cojon: "Do you like to Tango?"
You: "Only in Bagango."
Download Last Tango in Bagango and discover how El Cojon earned his name...

Offline LeeHunt

  • Former Staff
  • ****
  • John 21:25
Re: AddAction to map objects
« Reply #9 on: 13 Aug 2007, 17:14:22 »
Along the lines of Johnnyboy's comment, see this post with Mr. Peanut's advice as well:

http://www.ofpec.com/forum/index.php?topic=29632.0

Offline Dash5

  • Members
  • *
Re: AddAction to map objects
« Reply #10 on: 14 Aug 2007, 04:05:49 »
hm...any way to extract the numerical object ID from the string returned from nearestObject?