Home   Help Search Login Register  

Author Topic: Creating a unit, then moving him to OnMapsingleclick  (Read 1122 times)

0 Members and 1 Guest are viewing this topic.

Offline birdy

  • Members
  • *
Hello again, Friendly community!

I have a 1vs1 CTI-type mission set up, and want to know how to get a group spawned and move to a specified marker with the onsinglemapclick command.

I have the fort set up, and a script that has everything else set up, such as creating single units, vehicles and squads that all start out in the player's group (the player that activates the action)

Averything else works fine, I just need to know how to set it up so a squad spawns that is outside the players group, then moves to a location specified by the map click.

My script starts out like this:
Code: [Select]
_base = _this select 0

?! (local server) : exit
#Start
_player = s1
Purchase = 0
publicvariable "Purchase"
~1

@Purchase > 0
_player = s1
_location = getpos _base
_x = _location select 0
_y = _location select 1

?Purchase == 10 : goto "Attack"

hint "Invalid selection"
goto "Start"


#Attack
hint format["Points Available: %1",Eastcash]
? (Westcash < 12) : goto "Start"
publicvariable "Westcash"
~0.1
_x = _x + (random 20)
_y = _y + (random 20)
_location = [_x,_y,0]
"wgl_soldierWTL" createUnit [_location, geast, "Newunit = this"]
[Newunit] join GrpNull
_Newgroup = group Newunit
"wgl_SoldierWMG" createUnit [_location, _Newgroup]
"wgl_SoldierWG" createUnit [_location, _Newgroup]
"wgl_SoldierWMAT" createUnit [_location, _Newgroup]
"wgl_SoldierWB" createUnit [_location, _Newgroup]
"wgl_SoldierWB" createUnit [_location, _Newgroup]
"wgl_SoldierWG" createUnit [_location, _Newgroup]
"wgl_SoldierWMAT" createUnit [_location, _Newgroup]
"wgl_SoldierWB" createUnit [_location, _Newgroup]
"wgl_SoldierWB" createUnit [_location, _Newgroup]
"wgl_SoldierWAR" createUnit [_location, _Newgroup]
"wgl_SoldierWMedic" createUnit [_location, _Newgroup]
_Newgroup setCombatMode "RED"
_Newgroup setskill "0.8"
Westcash = Westcash - 12
s1 Sidechat "Attack sent to Marker position."
goto "start"

What more do I have to add? (besides the actual comand to move.) Do I have to make the new squad named something? Please help me out on this guys, thanks!   ;)


Please use code tags for large slabs of code (fixed) - Planck
« Last Edit: 28 Jul 2008, 13:37:13 by Planck »

Offline Luke

  • Members
  • *
  • Thank God! The OFPEC Staff are here!
Re: Creating a unit, then moving him to OnMapsingleclick
« Reply #1 on: 29 Jul 2008, 01:53:44 »
try adding this:
Code: [Select]
onMapSingleClick {group domove _pos{}};
that's if you want them to walk.

If you want them to be set there then do:
Code: [Select]
onMapSingleClick {"_x setpos _pos" foreach group {}};
my mapclick expertise is rusty, and I'm an arma guy, with some dabble in OFP

I think the move command you mentioned is the only thing your missing!

Luke
Pesky Human!!
Wort Wort Wort.

Offline Kendo J

  • Members
  • *
  • Britain Has more varieties of cheese than France
Re: Creating a unit, then moving him to OnMapsingleclick
« Reply #2 on: 30 Jul 2008, 15:23:08 »
As I am not at my PC I cannot remember the exact syntax but you can try this.

add a unit for the group you want and put in the init line "Group1 = group this; deletevehicle this"
give him a waypoint move and cycle

1 script for spawning
1 script for onmapsingleclick and movement.

The script for moving should have a marker that is empty and moves to the location of your onmapsingleclick
It should then change the marker type so you can see where your guys are going.
In the script you should have for moving your guys there
[Group1, 0] setWaypointPosition getMarkerPos "Markermove"  (moves the move waypoint to the marker)
[Group1, 1] setWaypointPosition getMarkerPos "Markermove" (moves the cycle waypoint to the marker)

the reason I use a cycle waypoint is so the unit will always move to it's first waypoint no matter what, even if it has been there before.

BUT I have written a script that does exactly this BUT I don't have it here so I can't remember exactly what I did if you want it send me your email on the msg service on this forum and I will email you scripts i use for spawning and moveing....

Regards
Kendo

Offline birdy

  • Members
  • *
Re: Creating a unit, then moving him to OnMapsingleclick
« Reply #3 on: 01 Aug 2008, 06:10:02 »
Thanks very much guys, means alot to me.  :yes:

But, unfortunately there was a bad storm here in east canada, and it happened over night... The storm knocked out my computer, and I had to do a system restore, losing the mission... so I've dropped that Idea.  >:(

Thanks anyways though guys, big help.  :good: