OFPEC Forum
Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: Trigger9Happy on 09 Jun 2007, 04:55:44
-
Hi, I am having some trouble with these scuds scripts...
; args: [vehicle, type, si]
_v = _this select 0
~1
? !(local _v) || !(alive _v) : exit
_v addaction ["Launch Scud","scud.sqs"]
This part works fine... the action shows up on the scud.
_unit = this select 0
onmapsingleclick {[_unit,_pos] exec "scudlaunch.sqs"}
exit
When I click "Launch Scud" ingame I get an error message for this script, am I doing anything wrong? I am trying to have it so the scud has the action, when the player clicks the action he can go to the map and target an area, the scud launches and this script makes an explosion.
_scud = _this select 0
_pos = _this select 1
launchcount = launchcount + 1
?launchcount > maxlaunch:exit
_x = _pos select 0
_y = _pos select 1
_z = _pos select 2
~2
_scud action ["SCUD Launch"]
~15
_scud action ["SCUD Start"]
~5
_shell = "TimeBomb" CamCreate [_x, _y, _z]
_shell = "TimeBomb" CamCreate [_x+20, _y, _z]
_shell = "TimeBomb" CamCreate [_x, _y+20, _z]
_shell = "TimeBomb" CamCreate [_x+20, _y+20, _z]
_shell = "TimeBomb" CamCreate [_x+30, _y, _z]
_shell = "TimeBomb" CamCreate [_x, _y+30, _z]
_shell = "TimeBomb" CamCreate [_x+30, _y+30, _z]
_shell = "TimeBomb" CamCreate [_x+40, _y, _z]
_shell = "TimeBomb" CamCreate [_x, _y+40, _z]
_shell = "TimeBomb" CamCreate [_x+40, _y+40, _z]
_shell = "TimeBomb" CamCreate [_x+50, _y, _z]
_shell = "TimeBomb" CamCreate [_x, _y+50, _z]
_shell = "TimeBomb" CamCreate [_x+50, _y+50, _z]
_shell = "TimeBomb" CamCreate [_x+60, _y, _z]
_shell = "TimeBomb" CamCreate [_x, _y+60, _z]
_shell = "TimeBomb" CamCreate [_x+60, _y+60, _z]
_shell = "TimeBomb" CamCreate [_x-60, _y, _z]
_shell = "TimeBomb" CamCreate [_x, _y-60, _z]
_shell = "TimeBomb" CamCreate [_x-60, _y-60, _z]
_shell = "TimeBomb" CamCreate [_x-50, _y, _z]
_shell = "TimeBomb" CamCreate [_x, _y-50, _z]
_shell = "TimeBomb" CamCreate [_x-50, _y-50, _z]
_shell = "TimeBomb" CamCreate [_x-40, _y, _z]
_shell = "TimeBomb" CamCreate [_x, _y-40, _z]
_shell = "TimeBomb" CamCreate [_x-40, _y-40, _z]
_shell = "TimeBomb" CamCreate [_x-30, _y, _z]
_shell = "TimeBomb" CamCreate [_x, _y-30, _z]
_shell = "TimeBomb" CamCreate [_x-30, _y-30, _z]
_shell = "TimeBomb" CamCreate [_x-20, _y, _z]
_shell = "TimeBomb" CamCreate [_x, _y-20, _z]
_shell = "TimeBomb" CamCreate [_x-20, _y-20, _z]
_shell = "TimeBomb" CamCreate [_x, _y, _z]
_shell = "TimeBomb" CamCreate [_x, _y, _z]
_shell = "TimeBomb" CamCreate [_x, _y, _z]
exit
Am I missing something? Any help appreciated.
Edit: This is the error message:
_unit = this select 0|#|': Error select: Type Bool, Expected Array
-
You'll kick yourself for this one:
_unit = this select 0You forgot an underscore. Should be:
_unit = _this select 0
-
Thanks for catching that, that did get rid of the error message. When I click "Launch Scud" and click on the map nothing happens... this is what I have in my init.sqs:
launchcount = 0
maxlaunch = 1
I have a feeling I did something wrong there, because I get no error message at all now. Here is the launch script again:
_unit = _this select 0
_pos = _this select 1
_scud = scud
launchcount = launchcount + 1
?launchcount > maxlaunch:exit
_x = _pos select 0
_y = _pos select 1
_z = _pos select 2
~2
_scud action ["SCUD Launch"]
~15
_scud action ["SCUD Start"]
~5
_shell = "TimeBomb" CamCreate [_x, _y, _z]
_shell = "TimeBomb" CamCreate [_x+20, _y, _z]
_shell = "TimeBomb" CamCreate [_x, _y+20, _z]
_shell = "TimeBomb" CamCreate [_x+20, _y+20, _z]
_shell = "TimeBomb" CamCreate [_x+30, _y, _z]
_shell = "TimeBomb" CamCreate [_x, _y+30, _z]
_shell = "TimeBomb" CamCreate [_x+30, _y+30, _z]
_shell = "TimeBomb" CamCreate [_x+40, _y, _z]
_shell = "TimeBomb" CamCreate [_x, _y+40, _z]
_shell = "TimeBomb" CamCreate [_x+40, _y+40, _z]
_shell = "TimeBomb" CamCreate [_x+50, _y, _z]
_shell = "TimeBomb" CamCreate [_x, _y+50, _z]
_shell = "TimeBomb" CamCreate [_x+50, _y+50, _z]
_shell = "TimeBomb" CamCreate [_x+60, _y, _z]
_shell = "TimeBomb" CamCreate [_x, _y+60, _z]
_shell = "TimeBomb" CamCreate [_x+60, _y+60, _z]
_shell = "TimeBomb" CamCreate [_x-60, _y, _z]
_shell = "TimeBomb" CamCreate [_x, _y-60, _z]
_shell = "TimeBomb" CamCreate [_x-60, _y-60, _z]
_shell = "TimeBomb" CamCreate [_x-50, _y, _z]
_shell = "TimeBomb" CamCreate [_x, _y-50, _z]
_shell = "TimeBomb" CamCreate [_x-50, _y-50, _z]
_shell = "TimeBomb" CamCreate [_x-40, _y, _z]
_shell = "TimeBomb" CamCreate [_x, _y-40, _z]
_shell = "TimeBomb" CamCreate [_x-40, _y-40, _z]
_shell = "TimeBomb" CamCreate [_x-30, _y, _z]
_shell = "TimeBomb" CamCreate [_x, _y-30, _z]
_shell = "TimeBomb" CamCreate [_x-30, _y-30, _z]
_shell = "TimeBomb" CamCreate [_x-20, _y, _z]
_shell = "TimeBomb" CamCreate [_x, _y-20, _z]
_shell = "TimeBomb" CamCreate [_x-20, _y-20, _z]
_shell = "TimeBomb" CamCreate [_x, _y, _z]
_shell = "TimeBomb" CamCreate [_x, _y, _z]
_shell = "TimeBomb" CamCreate [_x, _y, _z]
exit
And will this still work correctly if it's in the scud's menu and not the players?:
_unit = _this select 0
onmapsingleclick {[_unit,_pos] exec "scudlaunch.sqs"}
exit
Thanks again.
Edit: The scud is created later in the mission so it has no name.
-
small improvement to the script. instead of all the timebomb camcreates (which only go off in one direction), try this -
; set up some variables
_expandto = 60
_expandfrom = 0
_piecut = 60
_piecount = 0
; begin loop
#big_baddaboom
; wait just a small amount, save the engine some extra work
~0.25
; create the shell
_shell = "TimeBomb" CamCreate [_x + (_expandfrom*sin(_piecount)), _y + (_expandfrom*cos(_piecount)),0]
; change the variables
_piecount = _piecount + _piecut
; if the shells have completed a circle, reset the counter and expand the radius by 10 metres
?_piecount >= 360 : _piecount = 0; _expandfrom = _expandfrom + 10
; if the radius hasn't reached the maximum keep going, otherwise exit
?_expandfrom < _expandto : goto "big_baddaboom"
exit
-
Thanks bedges, but I'm not sure how to put that into my script. Ok, I took out the launchcount stuff, and the action shows up on the scud, and the explosion happens where I clicked 20 seconds after I clicked on the map. This is good. The problems that remain are 1) The scud doesn't actually launch it's missile at all, or even raise it. 2) The action remains after I used it once, enabling me to launch it an infinite many times. I guess it's not telling the scud to do anything, and since I can't name the scud because it doesn't exist until later in the game, I don't know how to make it raise and fire. I took out the launchcount stuff because I thought it would be easier to just remove the action after launching. This is the only script that is causing problems I assume:
_unit = _this select 0
_pos = _this select 1
_scud = scud
_x = _pos select 0
_y = _pos select 1
_z = _pos select 2
~2
_scud action ["SCUD Launch"]
~15
_scud action ["SCUD Start"]
~5
_shell = "TimeBomb" CamCreate [_x, _y, _z]
_shell = "TimeBomb" CamCreate [_x+20, _y, _z]
_shell = "TimeBomb" CamCreate [_x, _y+20, _z]
_shell = "TimeBomb" CamCreate [_x+20, _y+20, _z]
_shell = "TimeBomb" CamCreate [_x+30, _y, _z]
_shell = "TimeBomb" CamCreate [_x, _y+30, _z]
_shell = "TimeBomb" CamCreate [_x+30, _y+30, _z]
_shell = "TimeBomb" CamCreate [_x+40, _y, _z]
_shell = "TimeBomb" CamCreate [_x, _y+40, _z]
_shell = "TimeBomb" CamCreate [_x+40, _y+40, _z]
_shell = "TimeBomb" CamCreate [_x+50, _y, _z]
_shell = "TimeBomb" CamCreate [_x, _y+50, _z]
_shell = "TimeBomb" CamCreate [_x+50, _y+50, _z]
_shell = "TimeBomb" CamCreate [_x+60, _y, _z]
_shell = "TimeBomb" CamCreate [_x, _y+60, _z]
_shell = "TimeBomb" CamCreate [_x+60, _y+60, _z]
_shell = "TimeBomb" CamCreate [_x-60, _y, _z]
_shell = "TimeBomb" CamCreate [_x, _y-60, _z]
_shell = "TimeBomb" CamCreate [_x-60, _y-60, _z]
_shell = "TimeBomb" CamCreate [_x-50, _y, _z]
_shell = "TimeBomb" CamCreate [_x, _y-50, _z]
_shell = "TimeBomb" CamCreate [_x-50, _y-50, _z]
_shell = "TimeBomb" CamCreate [_x-40, _y, _z]
_shell = "TimeBomb" CamCreate [_x, _y-40, _z]
_shell = "TimeBomb" CamCreate [_x-40, _y-40, _z]
_shell = "TimeBomb" CamCreate [_x-30, _y, _z]
_shell = "TimeBomb" CamCreate [_x, _y-30, _z]
_shell = "TimeBomb" CamCreate [_x-30, _y-30, _z]
_shell = "TimeBomb" CamCreate [_x-20, _y, _z]
_shell = "TimeBomb" CamCreate [_x, _y-20, _z]
_shell = "TimeBomb" CamCreate [_x-20, _y-20, _z]
_shell = "TimeBomb" CamCreate [_x, _y, _z]
_shell = "TimeBomb" CamCreate [_x, _y, _z]
_shell = "TimeBomb" CamCreate [_x, _y, _z]
exit
_scud = scud I guess "scud" is supposed to be the name of the scud? Again, I can't name it so this will have to be changed. Thanks for the help so far.
-
Change:
_unit = this select 0
onmapsingleclick {[_unit,_pos] exec "scudlaunch.sqs"}
exitto
_unit = _this select 0
_action = _this select 2
_unit removeAction _action
onmapsingleclick {[_unit,_pos] exec "scudlaunch.sqs"}
exit
To remove the action.
And in the last script change:
_unit = _this select 0
_pos = _this select 1
_scud = scudto
_scud = _this select 0
_pos = _this select 1
To incorporate bedges code, just use it to replace all your camcreate commands.
-
There is already a scud that does this, what you can do is get the scud that does this, and unpack it via pbo, and find out how they did it. And get rid of or addon the things you want and dont want. This one should work: http://ofp.gamepark.cz/index.php?showthis=8574
As an example.
-
Dutchboy's script is excellent but I wanted to help him get his own code working.
-
:D Everything works perfectly, thank you for the help Mr. Peanut, and bedges for the script, it's much better and easier to modify. Should I lock this thread since my problem has been solved?
-
After messing with it for awhile I figured out I could click as many times as I wanted too and it would launch infinitely many times... the action disappears but I'm still able to launch. Here are the scripts again:
_unit = _this select 0
_action = _this select 2
_unit removeAction _action
W1 sideChat "Scud armed. LEFT CLICK on the map to target."
onmapsingleclick {[_unit,_pos] exec "TH\scudlaunchW.sqs"}
exit
_scud = _this select 0
_pos = _this select 1
_x = _pos select 0
_y = _pos select 1
_z = _pos select 2
W1 sideChat "Missile targeted, get into the vehicle and launch scud."
~80
; Bedges:
; set up some variables
_expandto = 120
_expandfrom = 0
_piecut = 32
_piecount = 0
; begin loop
#big_baddaboom
; wait just a small amount, save the engine some extra work
~0.25
; create the shell
_shell = "LaserGuidedBomb" CamCreate [_x + (_expandfrom*sin(_piecount)), _y + (_expandfrom*cos(_piecount)),0]
; change the variables
_piecount = _piecount + _piecut
; if the shells have completed a circle, reset the counter and expand the radius by 10 metres
?_piecount >= 360 : _piecount = 0; _expandfrom = _expandfrom + 8
; if the radius hasn't reached the maximum keep going, otherwise exit
?_expandfrom < _expandto : goto "big_baddaboom"
exit
-
From Ed Depot(ED) tutorials/scripting, OnMapSingleClick tutorial:
This is an important point. If you want the onmapsingleclick to activate only once, you must deactivate it with:
onMapSingleClick {}
So:
onmapsingleclick {[_unit,_pos] exec "TH\scudlaunchW.sqs";onmapsingleclick {}}should do it. If not add the onmapsingleclick{} at the very top of your scudlaunch.sqs
-
All right thanks again, I should have taken a closer look at that tutorial first... thanks for the help everyone.