Home   Help Search Login Register  

Author Topic: edditing a spawn script  (Read 1948 times)

0 Members and 3 Guests are viewing this topic.

Offline penguinman

  • Contributing Member
  • **
  • Money is worthless, just paper, ink, and threads
edditing a spawn script
« on: 03 Feb 2005, 05:07:15 »
hello i need to edit this script so that the enemys are only spawned infront of the object.

once again, i have a base i want continuosly attacked by spawned enemys but only from the front. If u cant set it so they attack from the front then the north works to because the front of the base is to the north


Code: [Select]
;  AI Respawn Script by angusjm
;  5th March 2004
;
;  Call this script using the following syntax:
;
;  [1,unit to converge around,array of groups,units per group,type of unit,skill of units,radius around unit to converge around,body disapear on or off (1 on, 0 off)]
;
;  The AI will be created of a random one of the type specified and will head towards the unit to converge around
;
;Example [1,player,[east1,east2],12,["SoldierEB","SoldierEMG"],0.1,50,1] exec "ajmrespawn.sqs"




_wtd = _this select 0
_aUnit = _this select 1

? _wtd == 0: goto "missemall"
_agroups = _this select 2
_apg = _this select 3
_askill = _this select 5
_aradius = _this select 6
_thon = _this select 7
_list=_this select 4;
_ntotal=count _list;




_c = 0
#loop
   #gloop
      _rg = count units (_agroups select _c)
      ? _rg >= _apg : goto "misscreate"
      _rg = _apg - _rg
      #iloop
         _rnum = random ((360))
         _num = _rnum - (_rnum mod 1)
         _d1 = getpos _aunit select 0
         _d2 = getpos _aunit select 1
         _d3 = 0
         _random=random(_ntotal);
         _result=_random - ((_random) mod (1));
         if (_result==_ntotal) then {_result=_result-1};
         _utype = (_list select _result);

         _d1 = _d1 + _aradius * sin(_rnum)
         _d2 = _d2 + _aradius * cos(_rnum)
         _utype createunit [[_d1,_d2,_d3],_agroups select _c,"",_askill,"PRIVATE"]
        ? _thon == 1 : {_x addeventhandler [{killed},{[0,_this] exec {AJMRespawn.sqs}}]} foreach units (_agroups select _c)
         _agroups select _c move getpos _aunit
         leader (_agroups select _c) move getpos _aunit
         _rg = _rg - 1
         ? _rg == 0 : goto "misscreate"
      goto "iloop"
      #misscreate
      _c = _c + 1
      ? _c == count _agroups : _c = 0; goto "eloop"
   goto "gloop"
   #eloop
   ~0.5
goto "loop"

#missemall
~30
deletevehicle (_aunit select 0)
#alll
exit

thanks

CopyrightPhilly

  • Guest
Re:edditing a spawn script
« Reply #1 on: 03 Feb 2005, 12:22:25 »
ok from what i know...

Respawn Base: Just make the respawn maker v small were u want them to repsawn.

Scripted: OFP seems to get a little thick when it comes to creating an object were u want it. If you have a another object near the respawn point then it will move it "close" to were the pos you set was.
I tryed making a respawn script for my bikes on my mission by setdammage 0 and setpos. this seemed to work a little better then creating a new object.

example:
Code: [Select]
_object=_this select 0
_pos=getpos _object
_dir=getdir _object

#loop
_dam=getdammage _object
?_dam>0.9:goto "spawn"
~0.1
goto "loop"

#spawn
~15
_object setpos _pos
_object setdir _dir
_object setdammage 0
~0.1
goto "loop"

Usage:
Unit/Vehicle/Object Init Line:
[this] exec "scriptname.sqs"
« Last Edit: 03 Feb 2005, 12:26:31 by CopyrightPhilly »

Offline Platoon Patton

  • Members
  • *
  • "Barbecue" CreateVehicle getpos LLama
Re:edditing a spawn script
« Reply #2 on: 03 Feb 2005, 19:00:52 »
I think most mapmakers use createvehicle,certainly when AI is involved.

The reason is that AI wont board in repaired vehicles. :-\
http://www.platoon-clan.com/ We always wellcome dedicated OFP players :)

http://www.european-combat-league.com/index.php To play with us in the best OFP league ;)

Offline penguinman

  • Contributing Member
  • **
  • Money is worthless, just paper, ink, and threads
Re:edditing a spawn script
« Reply #3 on: 04 Feb 2005, 01:36:43 »
but that wont make them attack from the front.

I want 2 have an AI unit i can just have sit of to the side, with his group named like g1  and i want just regular east soldiers spawned in group"g1" but i want them spawned like 250 meters to the east of a certain thing(also can be infront of it)" it can be anything just make sure u tell me what. IE: a marker or a radio or a man or vehicle.

and i want them to be do moved (or whatever is used)to the object or markers postion. When they are killed i want it to repeate the process over and over until

Spawn = false(or what ever u use) is activated

does that make it a little more clear. sorry

thanks everybody in advance

Seabiscuit

  • Guest
Re:edditing a spawn script
« Reply #4 on: 04 Feb 2005, 21:49:08 »
Best option I can think of is using 2 markers, an event handler and a script.

Markers: 1 spawn, 1 attack locale
EventHandler: put a kill handler on each spawned unit so that when that unit dies it automatically calls your spawn script
Script: Does a create unit at the spawn locale, sets their speed and behaviours, and then does a move, commandMove or doMove(have to test to see which works best).

The script could have something like:
                                    ? !(spawn) : goto "exit"
to test whether or not to spawn.
If you want these guys in a specific group I think you have to create a unit with his init field set to the group name and then deleteVehicle him and assign units to his group.
I'n not sure if having so many potential eventhandlers will cause lag though.
Another option would be to have a script which simply counts the number of units on a particular side and spawns more when the count gets too low.
Hope that gives you some idea at least.

SB...

Offline Triggerhappy

  • Contributing Member
  • **
  • Llama, it's what's for dinner.
Re:edditing a spawn script
« Reply #5 on: 04 Feb 2005, 22:55:25 »
this little bit right here:
Code: [Select]
_rnum = random ((360))
 _num = _rnum - (_rnum mod 1)

change it to(I'll use north):
Code: [Select]
_rnum = 0
then they will spawn (in this example) to the north of whatever it is they're  spawning at. then just set the radius to the distance you want from the base

Offline penguinman

  • Contributing Member
  • **
  • Money is worthless, just paper, ink, and threads
Re:edditing a spawn script
« Reply #6 on: 05 Feb 2005, 00:53:52 »
oh ok so,

north is 0, then east would be 90? south 180? and west, i think either 270, or 240? right?

thanks abunch trigg, and thanks everybody else too
so, then the finished product would be this? Right??

Code: [Select]
;  AI Respawn Script by angusjm
;  5th March 2004
;
;  Call this script using the following syntax:
;
;  [1,unit to converge around,array of groups,units per group,type of unit,skill of units,radius around unit to converge around,body disapear on or off (1 on, 0 off)]
;
;  The AI will be created of a random one of the type specified and will head towards the unit to converge around
;
;Example [1,player,[east1,east2],12,["SoldierEB","SoldierEMG"],0.1,50,1] exec "ajmrespawn.sqs"




_wtd = _this select 0
_aUnit = _this select 1

? _wtd == 0: goto "missemall"
_agroups = _this select 2
_apg = _this select 3
_askill = _this select 5
_aradius = _this select 6
_thon = _this select 7
_list=_this select 4;
_ntotal=count _list;




_c = 0
#loop
   #gloop
      _rg = count units (_agroups select _c)
      ? _rg >= _apg : goto "misscreate"
      _rg = _apg - _rg
      #iloop
         _rnum = 0
         
         _d1 = getpos _aunit select 0
         _d2 = getpos _aunit select 1
         _d3 = 0
         _random=random(_ntotal);
         _result=_random - ((_random) mod (1));
         if (_result==_ntotal) then {_result=_result-1};
         _utype = (_list select _result);

         _d1 = _d1 + _aradius * sin(_rnum)
         _d2 = _d2 + _aradius * cos(_rnum)
         _utype createunit [[_d1,_d2,_d3],_agroups select _c,"",_askill,"PRIVATE"]
        ? _thon == 1 : {_x addeventhandler [{killed},{[0,_this] exec {AJMRespawn.sqs}}]} foreach units (_agroups select _c)
         _agroups select _c move getpos _aunit
         leader (_agroups select _c) move getpos _aunit
         _rg = _rg - 1
         ? _rg == 0 : goto "misscreate"
      goto "iloop"
      #misscreate
      _c = _c + 1
      ? _c == count _agroups : _c = 0; goto "eloop"
   goto "gloop"
   #eloop
   ~0.5
goto "loop"

#missemall
~30
deletevehicle (_aunit select 0)
#alll
exit


 
 
 
 

OFPEC Forums | Powered by YaBB SE

« Last Edit: 05 Feb 2005, 00:55:51 by penguinman »

Offline penguinman

  • Contributing Member
  • **
  • Money is worthless, just paper, ink, and threads
Re:edditing a spawn script
« Reply #7 on: 05 Feb 2005, 01:47:31 »
nm it works  but i have 1 more problem,

easy

how do i make all the units spawned with setUnitPos"UP"



thanks

Offline Triggerhappy

  • Contributing Member
  • **
  • Llama, it's what's for dinner.
Re:edditing a spawn script
« Reply #8 on: 05 Feb 2005, 06:55:52 »
find this line:
Code: [Select]
_utype createunit [[_d1,_d2,_d3],_agroups select _c,"",_askill,"PRIVATE"]
inbetween the empty "", put:
this setunitpos {up}

so it would be:
Code: [Select]
_utype createunit [[_d1,_d2,_d3],_agroups select _c,"this setunitpos {up}",_askill,"PRIVATE"]or:
Code: [Select]
_utype createunit [[_d1,_d2,_d3],_agroups select _c,{this setunitpos {up}},_askill,"PRIVATE"]or
Code: [Select]
_utype createunit [[_d1,_d2,_d3],_agroups select _c,{this setunitpos "up"},_askill,"PRIVATE"]
all of those do the same thing

you could also add it as an argument, but that would be a waste unless you didn't want to do it with all of the spawning units

Offline penguinman

  • Contributing Member
  • **
  • Money is worthless, just paper, ink, and threads
Re:edditing a spawn script
« Reply #9 on: 05 Feb 2005, 23:55:09 »
thanks Triggerhappy

by the way, did u know theres another triggerhappy on this site, only his name is spelled Trigger Happy.

Offline Triggerhappy

  • Contributing Member
  • **
  • Llama, it's what's for dinner.
Re:edditing a spawn script
« Reply #10 on: 06 Feb 2005, 06:03:44 »
theres like 3 of them
 ;D

Offline penguinman

  • Contributing Member
  • **
  • Money is worthless, just paper, ink, and threads
Re:edditing a spawn script
« Reply #11 on: 13 Feb 2005, 02:45:52 »
ok i have one final problem with this script also pretty easy.

the units that r spawned are walking to where they are suposed to go. how do i make them run. it may help if i tell you that they are going up a slight hill.






Rokket

  • Guest
Re:combat/full speed
« Reply #12 on: 13 Feb 2005, 03:13:00 »
I've only got ideas, nothing tested...

you might be able to put combat mode in the createunit line (no clue how, as when I tried to setface in there, it wouldn't work no matter what, and I had to do it as additional lines), or maybe variation of this usaing "_x setcombat mode for each..."

one more idea - give them a waypoint right in front of them, that sets speed and combat

?

Offline Triggerhappy

  • Contributing Member
  • **
  • Llama, it's what's for dinner.
Re:edditing a spawn script
« Reply #13 on: 13 Feb 2005, 05:04:33 »
Quote
_utype createunit [[_d1,_d2,_d3],_agroups select _c,"this setunitpos {up}",_askill,"PRIVATE"]

see where it says "this setunitpos {up}" ?

that is the init line (used as a string in createunit)
so just add
this setbehaviour {combat}

_utype createunit [[_d1,_d2,_d3],_agroups select _c,"this setunitpos {up};this setbehaviour {combat}",_askill,"PRIVATE"]

Rokket

  • Guest
Re:edditing a spawn script
« Reply #14 on: 13 Feb 2005, 08:04:56 »
There you go, I knew someone would know the syntax!

Trig - thanks, maybe Ican make "setface" work on created units w/out resorting to lo-tech.