Home   Help Search Login Register  

Author Topic: Scud  (Read 1786 times)

0 Members and 1 Guest are viewing this topic.

Offline Trigger9Happy

  • Members
  • *
Scud
« on: 09 Jun 2007, 04:55:44 »
Hi, I am having some trouble with these scuds scripts...

Code: [Select]
; 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.

Code: [Select]
_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.

Code: [Select]
_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:

Code: [Select]
_unit = this select 0|#|': Error select: Type Bool, Expected Array
« Last Edit: 09 Jun 2007, 05:19:24 by Trigger9Happy »

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Re: Scud
« Reply #1 on: 09 Jun 2007, 05:28:26 »
You'll kick yourself for this one:
Code: [Select]
_unit = this select 0You forgot an underscore. Should be:
Code: [Select]
_unit = _this select 0
urp!

Offline Trigger9Happy

  • Members
  • *
Re: Scud
« Reply #2 on: 09 Jun 2007, 06:07:18 »
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:

Code: [Select]
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:

Code: [Select]
_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?:

Code: [Select]
_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.
« Last Edit: 09 Jun 2007, 06:08:50 by Trigger9Happy »

Offline bedges

  • Administrator
  • *****
    • OFPEC The Editing Center
Re: Scud
« Reply #3 on: 09 Jun 2007, 12:56:38 »
small improvement to the script. instead of all the timebomb camcreates (which only go off in one direction), try this -

Code: [Select]
; 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
« Last Edit: 09 Jun 2007, 12:58:36 by bedges »

Offline Trigger9Happy

  • Members
  • *
Re: Scud
« Reply #4 on: 09 Jun 2007, 18:54:12 »
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:


Code: [Select]
_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

Code: [Select]
_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.

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Re: Scud
« Reply #5 on: 09 Jun 2007, 21:43:16 »
Change:
Code: [Select]
_unit = this select 0
onmapsingleclick {[_unit,_pos] exec "scudlaunch.sqs"}
exit
to
Code: [Select]
_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:
Code: [Select]
_unit = _this select 0
_pos = _this select 1
_scud = scud
to
Code: [Select]
_scud = _this select 0
_pos = _this select 1

To incorporate bedges code, just use it to replace all your camcreate commands.
« Last Edit: 09 Jun 2007, 21:50:00 by Mr.Peanut »
urp!

Offline Blacknite

  • Members
  • *
  • Chiefs runs the navy!
Re: Scud
« Reply #6 on: 09 Jun 2007, 21:47:43 »
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.

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Re: Scud
« Reply #7 on: 09 Jun 2007, 21:50:52 »
Dutchboy's script is excellent but I wanted to help him get his own code working.
urp!

Offline Trigger9Happy

  • Members
  • *
Re: Scud
« Reply #8 on: 10 Jun 2007, 02:36:37 »
 :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?

Offline Trigger9Happy

  • Members
  • *
Re: Scud
« Reply #9 on: 11 Jun 2007, 19:38:16 »
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:


Code: [Select]
_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

Code: [Select]
_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


Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Re: Scud
« Reply #10 on: 11 Jun 2007, 21:43:14 »
From Ed Depot(ED) tutorials/scripting, OnMapSingleClick  tutorial:
Quote
This is an important point. If you want the onmapsingleclick to activate only once, you must deactivate it with:
onMapSingleClick {}

So:
Code: [Select]
onmapsingleclick {[_unit,_pos] exec "TH\scudlaunchW.sqs";onmapsingleclick {}}should do it. If not add the onmapsingleclick{} at the very top of your scudlaunch.sqs

« Last Edit: 12 Jun 2007, 18:35:03 by Mr.Peanut »
urp!

Offline Trigger9Happy

  • Members
  • *
Re: Scud
« Reply #11 on: 11 Jun 2007, 23:02:18 »
All right thanks again, I should have taken a closer look at that tutorial first... thanks for the help everyone.