Home   Help Search Login Register  

Author Topic: Integrating Bremmer's AI-script and Spawnscript  (Read 1377 times)

0 Members and 1 Guest are viewing this topic.

Mox2002

  • Guest
Integrating Bremmer's AI-script and Spawnscript
« on: 15 May 2005, 21:57:22 »
Hi,

Can the following be done in MP???
Im searching for a sollution to integrate Bremmer's AI-Script and/or Keycat's
grouplinkscript into a suitable AI-(re)spawnscript (or vice versa).
I was wondering if anyone know's about a mission in wich this has been done before.
The goal is to have several AI-groups working together in a attack or defence situation, respawning continuously or for a specific amount of time
thus creating a ongoing battle (with the obvious advantages of named scripts incorporated) in which the playerS need to fullfill their objectives.
Creating just 1 of these 2 (Spawning AI OR using units wich use the AI-scipts) isnt the problem, Im just wondering if the 2 can be combined.

Any help on this would be extremely appriciated!
If someone with a more advanced perspective on scripting could take a look at what I've got sofar then he or she would earn my eternal grattitude!


« Last Edit: 15 May 2005, 21:59:56 by Mox2002 »

RONIN =ASP=

  • Guest
Re:Integrating Bremmer's AI-script and Spawnscript
« Reply #1 on: 17 May 2005, 03:53:11 »
Yes It is Indeed Possible...Respawning and the Use of Bremmers AI Script is possible...Infact, I working on a mission @ the moment tht does spawn enemy groups, and when it does, the AI Script is activated on the Squad..
Not sure how you can get KeyCats Script to work though - I think it may be possible, but I haven't looked into it as of yet...

Do you already know how to create an Enemy Squad? Below is a Snippet from one of my Scripts. This script will spawn 4 enemy soldiers in a group and are res soldiers from the VITAPC Pack V1.4.
The added event handlers you can see, executes a further script which adds weapon dispersion when the AI fires the Weapon (h8 JAM Dispersion  >:( )
And the killed event handler executes a furtherscript, which will execute when the unit dies. (All it does is remove the deadunits EventHandlers - It used to also remove dead units, but I like to see battlefield littered with the Bodies of the Fallen  ;D )

For example:-

Code: [Select]
?!(Local Server):goto "exit"

;You can take these out before making an SQS out of this. Below is to spawn the Group. I will also tell you the Anatomy of the below.

;"Classname" createunit [getpos position,nameofgroup,"units init Field",Skill,"Rank"]

"VIT_REBEL8" createunit [getpos ds1, drpatgrp1, "drpc1=this; this AddEventHandler [{fired},{_this Exec {disperse.sqs}}]; this addeventhandler [ {killed} , {_this exec {curelag.sqs}} ]", 1, "LIEUTENANT"]
"VIT_REBEL9" createunit [getpos ds1, drpatgrp1, "drpc2=this; this AddEventHandler [{fired},{_this Exec {disperse.sqs}}]; this addeventhandler [ {killed} , {_this exec {curelag.sqs}} ]", 1, "SERGEANT"]
"VIT_REBEL21" createunit [getpos ds1, drpatgrp1,"drpc3=this; this AddEventHandler [{fired},{_this Exec {disperse.sqs}}]; this addeventhandler [ {killed} , {_this exec {curelag.sqs}} ]", 1, "SERGEANT"]
"VIT_REBEL5" createunit [getpos ds1, drpatgrp1, "drpc4=this; this AddEventHandler [{fired},{_this Exec {disperse.sqs}}]; this addeventhandler [ {killed} , {_this exec {curelag.sqs}} ]", 1, "CORPORAL"]

;This is the AI Activation.

[drpatgrp1,[],[],[],[],1,1] exec "ai.sqs"


To create a squad, You have to place a single unit on the map, and type this into their init field:-

Code: [Select]
whateveryoucallyourgrp = group this;deletevehicle this

This sets up the unit as a placeholder, and will not be visible when the mission starts, but when the spawn script executes (through a trigger), it will use the unit as a placeholder for the spawned squad.   This script creates four Units - and then it will execute the AI Script on them - Bear in mind tht you do need to set-up the editor correctly, By placing 3 triggers on the map - 1 activated by west, 1 activated by east and 1 by resistance.

In the West Trigger:-

Radius = As big as mission area, or map
West present
Condition:- this
Onactivation :- aiwest = thislist

Radius = As big as mission area, or map
East present
OnActivation :- aieast = thislist

Radius = As big as mission area, or map
Resistance Present
Condition :- this
OnActivation :- aiguer = thislist

Also be aware tht units from both sides need to be present on the map @ mission start up, otherwise it will error - 1 squad from each side.

1 west side (Playable Squad)
1 AI East or Res side

Or vice versa, then just set up triggers to call your spawn scripts:-

West present
Onactivation :- this
Condition:- [] exec "spawn.sqs"

Here is the "Disperse.sqs"

Code: [Select]
_shooter = _this select 0
_weapon  = _this select 1
_muzzle  = _this select 2
_mode    = _this select 3
_shell   = _this select 4

;Obtain the bullet and details.
_bullet = NearestObject [_shooter,_shell]

;Creating velocity array.
_velocity = Velocity _bullet
_x1 = _velocity Select 0
_y1 = _velocity Select 1
_z1 = _velocity Select 2


;New x value.
_variable1 = Random 10

?(_variable1 > 5): _polarity1 = -2
?(_variable1 < 5): _polarity1 = +2

_x2 = _x1 + ((Random 20) * _polarity1)


;New y value.
_variable2 = Random 10

?(_variable2 > 5): _polarity2 = -2
?(_variable2 < 5): _polarity2 = +2

_y2 = _y1 + ((Random 20) * _polarity2)


;New y value.
_variable3 = Random 10

?(_variable3 > 5): _polarity3 = -1
?(_variable3 < 5): _polarity3 = +1

_z2 = _z1 + ((Random 30) * _polarity3)


;New velocity.
_velocity2 = [_x2,_y2,_z2]

_bullet SetVelocity _velocity2
~0

Exit

And this is the "curelag.sqs"

Code: [Select]
_unit = _this select 0
_unit removealleventhandlers "killed"

exit

I hope this answers the question  :-[
« Last Edit: 17 May 2005, 04:02:57 by Ronin =ASP= »

pazuzu

  • Guest
Re:Integrating Bremmer's AI-script and Spawnscript
« Reply #2 on: 17 May 2005, 07:09:49 »
I'm making a mission for Tonal right now using Keycats grouplink II script & AI respawn & it works great.

Sure makes the AI alot smarter & the repsawn really helps prevent lag by having too many units on map...