OFPEC Forum

Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: Mr.Peanut on 17 May 2005, 00:23:25

Title: AddAction bug with vehicles
Post by: Mr.Peanut on 17 May 2005, 00:23:25
Recipe:

Take multiple empty vehicles and AddAction to each of them:
i.e. in Init field for each put this AddAction ["piss","piss.sqs"]

Place the vehicles very close to each other.
Now add one player unit.  Preview the mission.  When you approach any one of the vehicles you will see multiple pisses in the action menu.
Now mount one of the vehicles and drive away from the other vehicles. You will still see multiple pisses. Now dismount and remount vehicle.  Now there is only a single piss.

This is pissing me off.  Any suggestions other than place the vehicles far apart from each other?   I have several vehicles to be stolen from a confined area.  This bug is buggering me up! ???

See demo attached below...

 
Title: Re:AddAction bug with vehicles
Post by: THobson on 17 May 2005, 09:02:47
How about using a getIn EH to add the action to the vehicle, and removing the action when you get out.  That way there will be no more than one action active at a time.  But you will need to be in the vehicle.
Title: Re:AddAction bug with vehicles
Post by: Mr.Peanut on 17 May 2005, 13:41:08
Here is the problem.  I have added two actions to each vehicle, a nitro action and a repair action.  The repair action can only be used when dismounted.  I will just spread the vehicles out a bit more, which is a drag since the action menu seems to pop up about 10m away from a vehicle.  Now I need a pen 120m long to hold them all.  That won't look very pretty.

I wanted to know if anyone else had encountered this bug or found a work  around.
Title: Re:AddAction bug with vehicles
Post by: THobson on 17 May 2005, 14:58:37
I did have that problem and the above was my work around - only allowing the action to be available when the player is inthe vehicle.  
Title: Re:AddAction bug with vehicles
Post by: bedges on 17 May 2005, 15:29:51
my suggestion - which seems a tedious workaround - is to have separate actions for each vehicle, all pointing to the same script copy/pasted. which, thinking about it, wouldn't stop the actions popping up in the player's menu.

an even more lengthy workaround would be to have a script running in the background when the player enters the pen, tracking said player's progress and continuously monitoring his/her distance from the given vehicles. when s/he is close enough to one, add the action, further away, remove the action.

it does seem very pissy doesn't it. the third alternative is to go with THobson's suggestion, and alter your logic accordingly to fit with the game limitations - i.e. repair is called from inside the vehicle, but also triggers a 'get out' animation.... also makes some limited sense, as you're going to know when the vehicle needs repairing only on getting into it.

unless it has wheels missing, or is on fire...
Title: Re:AddAction bug with vehicles
Post by: Mr.Peanut on 17 May 2005, 17:26:17
Urp...

The reason I AddAction'd twice directly on the vehicles was for simplicity.  I guess BIS didn't properly reinitialise the Action list when a player enters a vehicle.  Thanks for the suggestions...   :-X
Title: Re:AddAction bug with vehicles
Post by: Grendel on 17 May 2005, 19:51:09
you could try another workaround...

Have a script that runs a loop (initiated by a trigger while in the car pen maybe) checking the distance of the player to each vehicle (in an array) every second or so.  if the distance is less than say, 1.5, then add the action passing the closest vehicle into the script. If the distance is less, run removeaction to get rid of it.  If you want I could probably do one up, did something similar to do a script to climb on a tank.

-Grendel
Title: Re:AddAction bug with vehicles
Post by: Mr.Peanut on 17 May 2005, 22:45:00
With 12 vehicles and 12 players (it is a coop mission) that is a lot of looping...

I will probably try a mix of the above suggestions i.e. have a looping script running for each vehicle and an event handler.

Thanks for the help.
Title: Re:AddAction bug with vehicles
Post by: KTottE on 18 May 2005, 11:01:39
I had a similar problem once. What I ended up doing was I placed a trigger over each vehicle.

It would fire when a player was inside of it, and add an action to the appropriate vehicle. When the player left the area, the action was removed from the vehicle.

Then I used a simple script to setpos each trigger to the position of the appropriate vehicle. I did all the setpos'ing inside of a single script, so I didn't have tons of looping scripts.

It worked out quite well actually.
Title: Re:AddAction bug with vehicles
Post by: General Barron on 29 May 2005, 21:01:17
I've heard of this bug before. Apparently OFP doesn't remove actions properly when you enter a vehicle, then drive away. So you aren't alone.

Good ideas about adding the action via an EH though. Perhaps you could do the same thing with the 'repair' action: that is, add it to the vehicle when the player gets out ("getout" EH). Or possibly add it when the vehicle gets damaged ("dammaged" EH).

Of course... the problem would still occur if the player has 2 vehicles that he keeps near each other, but the chances of this happening are slim.
Title: Re:AddAction bug with vehicles
Post by: Artak on 30 May 2005, 17:25:35
It's a real bug in OFP. The game doesn't isn't able to remove the actions from you when you arent you but have become the vehicle. When boarding a vehicle you become that vehicle and it's actions are not removed.
You could try scripting it to check if unit != vehicle unit or something like that and remove the actions. If everything fails you at least can do a check in the begining of your actionscript about who it was that launched the action and if it's not the guy who should have had the action, then it's not performed.

Kind of confusing when you write it out loud, isn't it  ;D
Title: Re:AddAction bug with vehicles
Post by: Mr.Peanut on 07 Jun 2005, 15:20:37
In the end, I simply used an event handler to add and remove the actions from the vehicle when the player got in and out of the driver's seat.  Since a player becomes the  vehicle, the addAction id's can be stored as global variables on the player's machine, making it all multiplayer friendly and allowing for multiple vehicles, each with its own event handler.  The repair script can only be called from inside the vehicle, but that is the necessary sacrifice to get it all to work with a minimum of fuss and processing.

Addendum:
To get this to work properly in MP, the actions should only be added when the driver of the vehicle is local.