OFPEC Forum
Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: nominesine on 26 May 2006, 13:24:20
-
Here's the problem:
- I have a mine placed on the ground.
- I put this addaction ["Clear Mine","cleared.sqs"] in it's init field.
- I write a script that deletes the object the action is attatched to, thus I can give my player the option to disarm any mines he finds on the ground.
- It doesn't work.
This is not a syntax problem. My technique works beautifully if I put the addAction syntax in the init line of any other objects - but it doesn't work with mines.
Can someone:
1) Explain why?
2) Think of a simple solution to the problem (remembering that there will be many unnamed mines in the mission, and that i would like to find a solution that is also MP safe)???
-
The simplest solution would be to make the player engineer class, I believe they can disarm mines without any scripting whatsoever. Have you tried running the addAction from inside a script rather than the editor? What is the actual code? Would make it mich easier to spot the problem ::)
-
The addAction starts a script that goes something like this (ad hoc syntax):
_mine = _this select 0
_engineer = _this select 1
~1
_engineer playMove "takeFlag"
~1
deleteVehicle _mine
exit
This should make the player fall to his knees, and then the mine should disapear. (I cannot remember if the mine or the player is this select 0 right now, but as I said... it's not a syntax that's the problem.) It works with any other object/vehicle/unit except mines.
The problem is that when the player aproaches the mine, he doesn't even get the option to "Clear Mines". It seems like "addAction" doesn't work if you put in the init field of a mine.
-
I've encountered a similar problem months ago and if I'm not wrong i searched the solution through the old posts here at OFPEC. If my mind doen't betrays me the mines are impossible to delete and it's impossible to do anything with 'em apart to deactivate 'em with engineers and specops. Its an OFP bug.
Klavan
-
Bugger :-[
Have to start all over again then, with engineers :-\
-
What if you don't put the mine there from the mission editor's menu but create it in a script? I recall that a mine placed from the editor couldn't be moved with setPos but a mine created could. Maybe it's something similar which is blocking your stuff from working.
Edit I mean of course, if the mine can't be deleted at all then just move it underground.
-
Entering un-bugger-mode :D
Thank's. I'll try that
-
indeed. unfortunately you still can't add an action to the camcreated mine.
decide how many mines you're going to have and create a global variable minenum. in this example i've used 10. place empty markers where you want the mines to be and name the markers mk_mymine1 - mk_mymine10. camcreate the mines using something like this
minenum = 10
_i = 1
#loop
call format [{mymine%1 = "mine" camcreate getmarkerpos "mk_mymine%1"}, _i]
~0.1
_i = _i + 1
?not (_i>minenum):goto "loop"
that way you have 10 mines named mymine1 - mymine10 at the corresponding marker positions.
place the same number of radios on the map somewhere, name them mine_radio1 - mine_radio10. add the action to the radios. in the init file move all the radios to the x/y pos of the mines, but 1 metre underground
_i = 1
#loop2
call format [{mine_radio%1 setpos [getpos mymine%1 select 0, getpos mymine%1 select 1]}, _i]
_i = _i + 1
?not (_i>minenum):goto "loop2"
now when the action attached to a particular radio is activated, _this select 0 is the object the action was added to. it's then easy to find the corresponding mine
_whichradio = _this select 0
_i = 1
#loop3
_radiocheck = call format [{mine_radio%1},_i]
?_whichradio == _radiocheck : call format [{mymine%1 setpos [0,0,0]}, _i]
_i = _i + 1
?not (_i > minenum):goto "loop3"
exit
missionette to illustrate attached.
[attachment deleted by admin]
-
@bedges
Aha... Now I see what you're trying to do. Took me a while to understand. Will try your missionette when I have a little more time. I would have prefered a simple solution, that could be ported to MP-mode without to much fuzz, but since it's setPos commands it shouldn't be that difficult even if there's more scritping than I wanted. Thank you Bedges.
-
You could simply create a game logic underneath the mine, and add the action to that. Similar to bedges' way, yet you can free up the radio for other more important things.