Home   Help Search Login Register  

Author Topic: alternatives to waypoints needed  (Read 2709 times)

0 Members and 1 Guest are viewing this topic.

mrgreaper

  • Guest
alternatives to waypoints needed
« on: 21 Mar 2005, 16:13:48 »
hi the map im making uses the entire island to avoide lag i have it so whan a player comes within 1km of a town the patrols for that town are created using a script from this site but the script only creates men and then random patrols them

what i need is to spawn some jeeps with machineguns that would then follow some game logics around (ie a game logic in each of the towns that the jeeps pick at random and then drive to in a continouse loop) is this possible ?

Offline nominesine

  • Former Staff
  • ****
  • I'm NOT back!
    • The IKB Forum
Re:alternatives to waypoints needed
« Reply #1 on: 21 Mar 2005, 20:49:07 »
I'm at work, so I cannot help you with the syntax, but judging from your question you already understand the basic principles. Here it goes (a very general description)...

You spawn vehicles the same way you spawn soldiers (createVehicle/class name/etc). Make sure you give each created vehicle a name when you createVehicle it on the map. Then you can use move/doMove, etc just as easily as with an editor placed unit.

I don't remember if you can move/doMove a unit to a game logic, but it's possible to move/doMove them to a marker or an object (like the invisible H).
OFPEC | Intel Depot
RETARDED Ooops... Retired!

mrgreaper

  • Guest
Re:alternatives to waypoints needed
« Reply #2 on: 21 Mar 2005, 20:53:57 »
I'm at work, so I cannot help you with the syntax, but judging from your question you already understand the basic principles. Here it goes (a very general description)...

You spawn vehicles the same way you spawn soldiers (createVehicle/class name/etc). Make sure you give each created vehicle a name when you createVehicle it on the map. Then you can use move/doMove, etc just as easily as with an editor placed unit.

I don't remember if you can move/doMove a unit to a game logic, but it's possible to move/doMove them to a marker or an object (like the invisible H).

i`m at the learning stage of scripting but yeah that does help though is there a way to get them to move randomly between the markers? and well i realise that with waypoints if you set one too far away the units wont move to them will the same happen with domove commands ?

Offline nominesine

  • Former Staff
  • ****
  • I'm NOT back!
    • The IKB Forum
Re:alternatives to waypoints needed
« Reply #3 on: 22 Mar 2005, 00:12:38 »
Regarding your last question...

Yes, I have experienced problems using doMove commands that are positioned too far away from the units current position. Also there seems to be a problem if you issue a second doMove command before the unit has finished the previous command. But I've never delved into the problem.
OFPEC | Intel Depot
RETARDED Ooops... Retired!

Offline Terox

  • Former Staff
  • ****
  • Follow the Sappers!
    • zeus-community.net
Re:alternatives to waypoints needed
« Reply #4 on: 22 Mar 2005, 17:35:39 »
best way to do this.

In the mission editor create 1 machine gun jeep and set its fuel to 0

have a trigger or script set its fuel to 1 when you want to use it
(if you dont want the jeep in play at the start, place it somewhere out of the way and use a trigger or script to setpos it to the starting location you require)

create 1 move waypoint for it
have that waypoint run a script when it is reached which basically is used to set the waypoint to another location

the script needed will basically pick at random a gamelogic (1 for each town) and then setpos the waypoint to that gamelogic.

when the jeep reaches the gamelogic (waypoint), the script will run again and set the waypoint to a new location.


as long as there is only 1 waypoint for the jeep, it will continue to run around in a random pattern between the towns.

This works well for a move waypoint, i have never tried another type of waypoint, perhaps a search & destroy waypoint would be just as good.

Thats the theory, here's the practice
*********************************************************
********************************************************
Init.sqs
Quote
tx_townlogicarray = [town1,town2,town3,town4,town5]
;; have the jeep's move waypoint randomly set at the start by running the jeeppatrol.sqs at the start of the mission
?(local server):[] exec "jeepPatrol.sqs"

NB>>> (i take it that the mgjeep is server controlled ai )


********************************************************

Gamelogics
town1
town2
town3
town4
town5


and dont forget to create the "server" gamelogic

NB>>> create as many townlogics as you want, just remember to state each one in the tx_townlogicarray which is in the init.sqs


********************************************************
MGJeep
lets call the mgjeep's group patroljeep
place the following line in the init field of the mgjeep  / group commander
patroljeep = group this

********************************************************
Waypoint
On activation
this exec "jeepPatrol.sqs"
********************************************************
JeepPatrol.sqs
Quote
#INIT
_countlogics = count tx_townlogicarray
_RNDselect = random _countlogics
_RNDselect = (_RNDselect - _RNDselect mod 1)
?(_RNDselect == _countlogics):_RNDselect = 0
_selected = tx_townlogicarray select _RNDselect

#MOVELOGIC
;; see note below for wait period info
;; ~ (random 60) + 120
[jeepPatrol,0] setwpPos getpos _selected
exit

NB>>> if you try to use a search and destroy waypoint, i would place a wait period before you move the waypoint (so that the jeep does a search around the town), eg the commented out example line will wait between 1 and 3 minutes before the waypoint is moved

NB>>> I have scripted the random selection system to work on the number of logics stated in the tx_townlogicarray, so that you dont need to edit the script
« Last Edit: 22 Mar 2005, 22:05:28 by Terox »
Zeus ARMA2 server IP = 77.74.193.124 :2302
Teamspeak IP = 77.74.193.123

mrgreaper

  • Guest
Re:alternatives to waypoints needed
« Reply #5 on: 22 Mar 2005, 18:40:14 »
thankyou this will help so much and yes it will be server side ai that will use this is it possible to call this script on multiple units (ie 3 jeep patrol groups each patroling randomly between the towns ?)

mrgreaper

  • Guest
Re:alternatives to waypoints needed
« Reply #6 on: 22 Mar 2005, 19:05:36 »
cant get the scrip to work followed ur message to the letter but get an error as soon as the server loads up and the jeep will go to the waypoint set on the editor then no further ? any ideas


ok got rid of the error by changing ] for a " in the int but they still wont go to any of the waypoints and they still will only go to the waypoint set in the editor not sure what i`m doing wrong, i`m very new to scripting si i`m having trouble learning this
« Last Edit: 22 Mar 2005, 19:24:16 by mrgreaper »

Offline Terox

  • Former Staff
  • ****
  • Follow the Sappers!
    • zeus-community.net
Re:alternatives to waypoints needed
« Reply #7 on: 22 Mar 2005, 22:03:47 »
try changing the waypoint script exwecution line to

[] exec "jeepPatrol.sqs"

and i noticed an error in my script

the groupname of the patrolling jeep is patroljeep

however the setwaypoint command line reads

[jeepPatrol,0] setwpPos getpos _selected


***************************************************

[jeepPatrol,0] setwpPos getpos _selected


syntax error

[jeepPatrol,0] is an array
the first element of this array is the group name of the waypoint you wish to change
the second element is the waypoint number, the first waypoint being 0

the groupname in this array should be the same as the groupname of the actual patrolling jeep


line should read

[Patroljeep,0] setwpPos getpos _selected
Zeus ARMA2 server IP = 77.74.193.124 :2302
Teamspeak IP = 77.74.193.123

Offline Terox

  • Former Staff
  • ****
  • Follow the Sappers!
    • zeus-community.net
Re:alternatives to waypoints needed
« Reply #8 on: 22 Mar 2005, 22:12:15 »
thankyou this will help so much and yes it will be server side ai that will use this is it possible to call this script on multiple units (ie 3 jeep patrol groups each patroling randomly between the towns ?)

yes the script execution line would read

[groupname] exec "jeeppatrol.sqs"
groupname being the individual groupname of each unit, so basically if you had 3 groups, the init .sqs would run the script 3 times, once for each unit and each unit's waypoints would have a slightly different [groupname] exec "jeepPatrrol.sqs"

and you would have the following script
JeepPatrol.sqs
Quote
_group = _this select 0
#INIT
_countlogics = count tx_townlogicarray
_RNDselect = random _countlogics
_RNDselect = (_RNDselect - _RNDselect mod 1)
?(_RNDselect == _countlogics):_RNDselect = 0
_selected = tx_townlogicarray select _RNDselect

#MOVELOGIC
;; see note below for wait period info
;; ~ (random 60) + 120
[_group,0] setwpPos getpos _selected
exit

i have highlighted the additions and changes to the script for you
« Last Edit: 22 Mar 2005, 22:14:06 by Terox »
Zeus ARMA2 server IP = 77.74.193.124 :2302
Teamspeak IP = 77.74.193.123

mrgreaper

  • Guest
Re:alternatives to waypoints needed
« Reply #9 on: 22 Mar 2005, 23:38:22 »
once again thank you i continue to be amazed by the knowledge and speed of replys from this site and others in reference to this game i assure you when i tried map making on other games i recieved none of this help i thank you very much

Offline Malm

  • Members
  • *
  • I'm a llama!
Re:alternatives to waypoints needed
« Reply #10 on: 11 Apr 2005, 14:21:21 »
Alternative you can use the skill level of the GL to mark it as current waypoint.
You need a trigger that "scriptmoves" to the new distination of your jeep so that when your jeep arrives he trigger the same script once again. The script then finds the next waypoint, gives move commando to your jeep and relocates the trigger. That way you can make your jeep follow your GL path for infinity.

I got a script that moves a boat along a virtual path created by GL's only. Please excuse me for not making it fit this forum so some lines may splitup.


-Malm



;*************************************************************************************************
;**
;** Title       : zMoveUnit
;** Function    : Move _zVehicle along a path created by an array of GameLogics _zLogic.
;** Parameters  : _zVehicle - Object of Vehicle
;**             : _zLogic   - Array of GameLogics preferable initialized in Init.sqs
;** Requirements: A virtual path created by GameLogics all with skill level set to zero.
;**               A repeatedly 50x50 trigger named distination triggering this script on activation.
;**               A vehicle object.
;**               A predefined array of the same GameLogics defined in the init file ..
;**               _zLogics=["GL1","GL2"..]
;**
;** Created by Henrik Malmvig @ 21ST VIKING BATTALION (www.21vb.dk)
;**
;*************************************************************************************************

?!(local Server) : exit

PRIVATE ["_zDist","_zCount","_zCounter","_zVehicle","_zLogic","_zMove"];
PRIVATE ["_zX","_zY","_zRa","_zRy","_zRz","_zL","_zM","_zFire"];

;** INIT SECTION **

_zVehicle  = _this SELECT 0;
_zLogic    = _this SELECT 1;
_zCounter  = 0;
_zCount    = count _zLogic;
_zVehicle SETCOMBATMODE "YELLOW";
_zVehicle SETSPEEDMODE "FULL";
distination SETPOS [0,0,0];


;**************************************************************************************************

;**************************************************************************************************


~1
   
#FindCurrentWP
?(_zCounter >= _zCount) : GOTO "ExitFind";
   _zMove = _zLogic SELECT _zCounter;
   ?((Skill _zMove) == 1): GOTO "ExitFind";
   ;*** we uses skill to mark current wp ***
   _zCounter = _zCounter + 1;
   GOTO "FindCurrentWP"

#ExitFind

_zMove setSkill 0;

?(_zCounter < _zCount): GOTO "NotEOA";
   _zMove = _zLogic SELECT _zCount;
   _zMove setSkill 0;
   _zMove = _zLogic SELECT 0;
   distination SETPOS [GETPOS _zMove SELECT 0, GETPOS _zMove SELECT 1, 0];

   _zVehicle MOVE GETPOS _zMove;
   _zMove = _zLogic SELECT 1;
   _zMove setSkill 1;
   EXIT;
   
#NotEOA

_zVehicle MOVE GETPOS _zMove;

distination SETPOS [GETPOS _zMove SELECT 0, GETPOS _zMove SELECT 1, 0];


?(_zCounter > (_zCount - 1)): GOTO "ExitScript"
   _zCounter = _zCounter + 1;
   _zMove = _zLogic SELECT _zCounter;
   _zMove setSkill 1;

#ExitScript

EXIT




« Last Edit: 11 Apr 2005, 14:22:21 by Malm »

Offline Malm

  • Members
  • *
  • I'm a llama!
Re:alternatives to waypoints needed
« Reply #11 on: 11 Apr 2005, 14:33:30 »
Oh I forgot

Remember to set the skill level of all your GL's to zero on the map.


Init.sqs

zBoatL = [logic1,logic2,logic3,logic4,logic5,logic6,logic7,logic8,logic9,logic10];

Trigger:

class Item13
      {
         position[]={1438.070923,0.528174,12044.265625};
         activationBy="EAST";
         repeating=1;
         age="UNKNOWN";
         name="distination";
         expActiv="[boat1,zBoatL] exec ""zMoveBoat.sqs""";
         class Effects
         {
         };
      };

One of many GL's:


class Item23
      {
         side="LOGIC";
         class Vehicles
         {
            items=1;
            class Item0
            {
               position[]={1494.748657,1.270795,11674.148438};
               azimut=95.000000;
               id=225;
               side="LOGIC";
               vehicle="CBTLogic";
               leader=1;
               lock="UNLOCKED";
               skill=0.200000;
               text="logic1";
            };
         };
      };


-Malm