OFPEC Forum
Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: OFPfreak on 08 Sep 2005, 08:02:59
-
I'm going to create a simple litle script (just for my self) wich allows you to make an airplane bomb a specific target selected on the map. I want to know how to add waypoints with the OnMapSingleClick command.
If the above isn't possible, ONLY if it's not possible, answer this:
is it possible to MOVE waypoints with an OnMapSingleClick command? If it is, how?
-
did you look in the comref (http://www.ofpec.com/editors/comref.php?letter=S#setWPPos)?
-
It's not possible to create waypoints directly. However, the move command effectively creates a waypoint.
Moving a waypoint is easy as bedges implies. Check the online comref for information on onmapsingleclick.
-
Ok I looked but I can't sort it out my self since im a rookie in scripting. Two more questions:
Can somone make a pre-made onmapsingleclick code line that makes a single unit move at the
Is it possible to name the waypoint you create with the Onmapsingleclick command so I can execute a script when the unit reaches its target?
-
this addaction ["Call Airstrike","airstrike.sqs"]
airstrike.sqs
_obj = _this select 0
_unit = _this select 1
_ID = _this select 2
? _obj != _unit : exit
_obj removeaction _ID
_plane = Plane1
MapClicker = _unit
MapClick = []
_n = 0
onMapSingleClick {[MapClicker,_pos,_units,_shift,_alt] exec "MapClick.sqs"}
#WaitForMapClick
~1
_n = _n + 1
? _n > 30 : goto "Expired"
? format ["%1",MapClick] == "[]" : goto "WaitForMapClick"
_pos = MapClick select 1
_target = "logic" createvehicle _pos
_target setpos _pos
_plane flyinheight 70
#MoveToTarget
~0.5
_plane domove (getpos _target)
_distance = _plane distance _target
_zpos = (getpos _plane select 2)
? _distance <= (_zpos*2) : goto "DropBomb"
goto "MoveToTarget"
#DropBomb
_plane selectweapon "LaserGuidedBombLauncher"
_plane fire "LaserGuidedBombLauncher"
_plane dofollow (leader group _plane)
exit
#Expired
hint "You failed to select a target in time, you must try again."
_ID = _obj addaction ["Call Airstrike","airstrike.sqs"]
exit
MapClick.sqs
MapClick = _this
exit
Not tested, but it should work, all you have to do is figure out the proper bomb tradjectory and change the public variables and classnames to suit your needs.
-
:O that is the exact thing I need! Thank you ;D! I was actually going to make a larger bomber execute another script wich makes it drop about 20 bombs but this is good enough.
I'm not going to solve this yet till I test it.
-
Hm it doesn't seem to work. No errors show up but nothing happens. Can you also add hints so I know when the script activates? Also, do the player and the plane have to be named?
-
for hints, just add
Hint [i]"My Hint"[/i]
where ever you want a hint.
Yes, player and plane have to be named.
-
Hm it doesn't seem to work. No errors show up but nothing happens. Can you also add hints so I know when the script activates? Also, do the player and the plane have to be named?
Yes you have to replace _plane = Plane1 with _plane = <nameofyourplane> for it to work correctly, and make sure you add the action to the player.
-
lol hints. why the tags?
-
lol hints. why the tags?
I think Tyger forgot that you can't italicize code... ::)