Jump to content
Sign in to follow this  
rip31st

Help with MP scripting: AI & dead bodies

Recommended Posts

I recently created a mission that spawns opfor AI when a trigger is activated. The problem is when I load it up on a server more then the desired amount of opfor AI spawn. I'm thinking it's a locality issue and I'm new to scripting and having a hard time figuring it out. My trigger settings contain "this" for the condition and "this exec "wave1.sqs" which calls the script that spawns the AI opfor.

The second issue is the dead bodies never go away eventually bogging down the server.

Thx in advance for the help!

Share this post


Link to post
Share on other sites

Hmm i think you should track all AI objects in script and checking thers dead "life" time... tounge2.gif

if life time is excidet and they are dead deleteUnit...or deleteVehicle.

Share this post


Link to post
Share on other sites
?(!isServer) : Exit

Try adding that to the top of the script.

I added that to the top of my .sqs script that spawns the AI and when we put it up on the server about 90 AI showed up for the fight.  Not that it's a bad thing, it's just that all the dead bodies and reccurring unwanted AI.  Only 30 units are in the script.  3 guys logged in, you can do the math.

Heres the code:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

?(!isServer) : ExitWith

_firstGroup = createGroup East;

"SoldierEMG" createUnit [getmarkerpos "wave1", _firstGroup]

"SoldierEMG" createUnit [getmarkerpos "wave1", _firstGroup]

"SoldierEMG" createUnit [getmarkerpos "wave1", _firstGroup]

"SoldierEAT" createUnit [getmarkerpos "wave1", _firstGroup]

"SoldierEAT" createUnit [getmarkerpos "wave1", _firstGroup]

"SoldierEAT" createUnit [getmarkerpos "wave1", _firstGroup]

"SoldierESniper" createUnit [getmarkerpos "wave1", _firstGroup]

"SoldierEMedic" createUnit [getmarkerpos "wave1", _firstGroup]

"SquadLeaderE" createUnit [getmarkerpos "wave1", _firstGroup]

"TeamLeaderE" createUnit [getmarkerpos "wave1", _firstGroup]

"SoldierE" createUnit [getmarkerpos "wave1", _firstGroup]

"SoldierE" createUnit [getmarkerpos "wave1", _firstGroup]

"SoldierE" createUnit [getmarkerpos "wave1", _firstGroup]

"SoldierE" createUnit [getmarkerpos "wave1", _firstGroup]

"SoldierE" createUnit [getmarkerpos "wave1", _firstGroup]

"SoldierEMG" createUnit [getmarkerpos "wave1a", _firstGroup]

"SoldierEMG" createUnit [getmarkerpos "wave1a", _firstGroup]

"SoldierEMG" createUnit [getmarkerpos "wave1a", _firstGroup]

"SoldierEAT" createUnit [getmarkerpos "wave1a", _firstGroup]

"SoldierEAT" createUnit [getmarkerpos "wave1a", _firstGroup]

"SoldierEAT" createUnit [getmarkerpos "wave1a", _firstGroup]

"SoldierESniper" createUnit [getmarkerpos "wave1a", _firstGroup]

"SoldierEMedic" createUnit [getmarkerpos "wave1a", _firstGroup]

"SquadLeaderE" createUnit [getmarkerpos "wave1a", _firstGroup]

"TeamLeaderE" createUnit [getmarkerpos "wave1a", _firstGroup]

"SoldierE" createUnit [getmarkerpos "wave1a", _firstGroup]

"SoldierE" createUnit [getmarkerpos "wave1a", _firstGroup]

"SoldierE" createUnit [getmarkerpos "wave1a", _firstGroup]

"SoldierE" createUnit [getmarkerpos "wave1a", _firstGroup]

"SoldierE" createUnit [getmarkerpos "wave1a", _firstGroup]

_firstGroup addWaypoint [getMarkerPos "wave1x", 0];

_firstGroup setspeedmode "full";

Additionally each time someone new logs onto the server and sets off the trigger, here come 30 more AI.

-Dachevs I tried that without success.

Share this post


Link to post
Share on other sites

Heres the code:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

?(!isServer) : ExitWith

Replace ExitWith with Exit and it will work.

Xeno

Share this post


Link to post
Share on other sites

You have to put the dead bodies sqs into your mission and set time and all in triggers or the description.ext I believe smile_o.gif

also check this out, may help with the AI spawning.

Dynamic Group Creator

Share this post


Link to post
Share on other sites

Heres the code:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

?(!isServer) : ExitWith

Replace ExitWith with Exit and it will work.

Xeno

Thanks Xeno! That worked out great. Now I've got to tackle the mortuary

Share this post


Link to post
Share on other sites

Ok dead body removal work status:

I'm using the deletebody.sqs & deletebody2.sqs. One gets rid of the units, the other rids the vehicles. I've placed two triggers that cover the entire map (sahrani). Each trigger's condition field has : IsServer. The onactivation field calls the script with : [0] exec "deletebody.sqs" or alternately : [0] exec "deletebody2.sqs"

Here's a copy of the code:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

;Mr-Murray 2006

;www.mr-murray.de.vu

;www.mapfact.net

_W=_this select 0

_L=[]+thislist

_A=[]

_G=[]

_T="Land"

{ if (_T counttype [_x] == 1) then {_G=_G+[_x]} } foreach _L

#Check

{ if (not alive _x) then {_A=_A+[_x]} } foreach _G

_G=_G-_A

? count _A > _W :_P=_A select 0;_A=_A-[_P]

(Gravedigger) action ["hidebody",_P]

~6

deletevehicle _P

? count _A == _W and count _G == 0 :exit

goto "Check"

Can't figure why it;s not working. I can get it to work in the mission editor in a single player environment, but not on a server.

Share this post


Link to post
Share on other sites

OK we just figured out that after we get killed our bodies bury themselves but not the ai. Do I need to place this script inside the init.sqf file for the mission to get it to work?

Share this post


Link to post
Share on other sites

could be yes, but you would have to switch the Init.sqf to sqs

Because GoTo commands only work in sqs. Otherwise it will crash.

Share this post


Link to post
Share on other sites

Something's strange here. When I place triggers on the map depending when I place them, is how they get initialized in the mission.sqm file?!? help.gif Or atleast that's a thought. I'm not sure yet. I've got about 6 or so of theses above mentioned waves of AI placed around the map with identical triggers. When I used the condition of "this" for each trigger they would spawn over and over for each player that hit the trigger causing excessive AI to show up until I added the ?(!isServer) : exit command to each script for each wave of AI. Now the proper amount of AI are rendered once, BUT...Now they just automatically run as soon as the mission is started bogging down the server. No need to trigger them. Doesn't matter if I'm using "this" or "isServer" for the condition of the triggers.

I found inside the Evolution mission in the editor the condition "local server and ("Land" countType thislist > 0) or local server and ("Helicopter"" countType thislist > 0)";" added to each trigger made the AI work properly only running the script when the trigger was activated.

But for the life of me I can't get the AI to go away after we kill them. I was able to get it to work only once when I had the first wave of AI set to "isServer" for the condition and the rest of the triggers set to "this". It was the only way I could get it to work. I couldn't replicated it a second time even after setting it up the same way because I have a suspicion the way things are saved in the editor in what order they are initialized in the mission.sqm. We killed the first wave of AI, they deleted themselves. We went to the second wave and dead bodies lay scattered everywhere for the duration of the mission. I couldn't get it to work for the other waves when the condition was set to "isServer" either. But when "isServer" is set you can toss the triggers out the window because the scripts just automatically run. banghead.gif

Is my condition wrong for my delete vehicle trigger? I've got it set to "isServer" I know its active because I added a text alert. But the darn body deleter doesn't do squat.

banghead.gif

I tried changing the condition for the body delete script to local server as well.

Share this post


Link to post
Share on other sites

try adding a gamelogic called server.

and in the script put--

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">?(local Server): [] exec "deletebodies.sqs"

or whatever the script is named.

try this other body removing script:

Body Remove

and this AI spawn script:

Spawn

Share this post


Link to post
Share on other sites

I ended up using the dyn_br body remover. I found that if you created a universal trigger that covered the entire map running the removal script from the get go DID NOT WORK in a multiplayer server environment - meaning triggered by anyone at the start of the mission. It just ran the script, found no dead AI and quit. I tried every which way from here to China with various trigger settings to get it to work.

I found that if you create AI after the mission starts then you need to create trigger areas that detect the those AI and run the body remover after the trigger is set off. Additionally you can't have AI preplaced in the editor when the mission begins in those trigger areas where the body removal script is run. If you do the script only deletes those AI that were there from the start and not the ones you triggered to spawn after the mission starts.

Summary - it's all about the initialization sequence.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×