Jump to content

Spawning non-bandit AI


Recommended Posts

On OpenDayz.net, I found a dance party script. It adds a party where music is playing, there's a campfire and dancers. Using that as a base, I created an Epoch event that spawns it randomly. Now, I want to take it a step further and make a DZMS mission where bandits spawn as well as "hookers". So far I've done this:

 

Copied the DZMSAISpawn.sqf and renamed it DZMSHookerSpawn.sqf. I made these changes to it:

 

Assigned new skins:

_aiskin = ["Hooker1","Hooker2","Hooker3","Hooker4"] call BIS_fnc_selectRandom;

Changed the behavior to match those for the dance party. This is to make them dance, and to make them invincible:

//Add the behaviour
_unit enableAI "TARGET";
_unit enableAI "AUTOTARGET";
_unit enableAI "MOVE";
_unit enableAI "ANIM";
_unit enableAI "FSM";
_unit allowDammage false;
_unit addEventHandler ["handleDamage", {false}];
_unit setBehaviour "CARELESS";

Next, I created a mission and tried to spawn the hookers:

//DZMSAISpawn spawns AI to the mission.
//Usage: [_coords, count, skillLevel, unitArray]
[_coords,2,1,"DZMSUnitsMinor"] call DZMSAISpawn;
sleep 5;
[_coords,2,1,"DZMSUnitsMinor"] call DZMSAISpawn;
sleep 5;
[_coords,2,1,"DZMSUnitsMinor"] call DZMSHookerSpawn;
sleep 5;
The bandits are spawning, but not the hookers. The log says this: "Warning Message: Script Scripts\DZMSHookerSpawn.sqf not found" but the DZMSHookerSpawn.sqf is most definitely in the Scripts folder.
 
Any ideas?
Link to comment
Share on other sites

You're calling DZMSHookerSpawn and unless you have that defined as a location, nothing will happen.

 

Read the top of DZMSFunctions.sqf

 

So I do this in DZMSFunctions.sqf?

DZMSAISpawn = compile preprocessFileLineNumbers "\z\addons\dayz_server\DZMS\Scripts\DZMSAISpawn.sqf";
DZMSHookerSpawn = compile preprocessFileLineNumbers "\z\addons\dayz_server\DZMS\Scripts\DZMSHookerSpawn.sqf"
Link to comment
Share on other sites

 

On OpenDayz.net, I found a dance party script. It adds a party where music is playing, there's a campfire and dancers. Using that as a base, I created an Epoch event that spawns it randomly. Now, I want to take it a step further and make a DZMS mission where bandits spawn as well as "hookers". So far I've done this:

 

Copied the DZMSAISpawn.sqf and renamed it DZMSHookerSpawn.sqf. I made these changes to it:

 

Assigned new skins:

_aiskin = ["Hooker1","Hooker2","Hooker3","Hooker4"] call BIS_fnc_selectRandom;

Changed the behavior to match those for the dance party. This is to make them dance, and to make them invincible:

//Add the behaviour
_unit enableAI "TARGET";
_unit enableAI "AUTOTARGET";
_unit enableAI "MOVE";
_unit enableAI "ANIM";
_unit enableAI "FSM";
_unit allowDammage false;
_unit addEventHandler ["handleDamage", {false}];
_unit setBehaviour "CARELESS";

Next, I created a mission and tried to spawn the hookers:

//DZMSAISpawn spawns AI to the mission.
//Usage: [_coords, count, skillLevel, unitArray]
[_coords,2,1,"DZMSUnitsMinor"] call DZMSAISpawn;
sleep 5;
[_coords,2,1,"DZMSUnitsMinor"] call DZMSAISpawn;
sleep 5;
[_coords,2,1,"DZMSUnitsMinor"] call DZMSHookerSpawn;
sleep 5;
The bandits are spawning, but not the hookers. The log says this: "Warning Message: Script Scripts\DZMSHookerSpawn.sqf not found" but the DZMSHookerSpawn.sqf is most definitely in the Scripts folder.
 
Any ideas?

 

 

Vid when you are done? :D

Link to comment
Share on other sites

Hmm.. now I'm getting 1 hooker spawning in instead of 4 and she just won't dance.

 

Here's what I have in the mission sqf:

//DZMSAISpawn spawns AI to the mission.
//Usage: [_coords, count, skillLevel, unitArray]
[_coords,6,1,"DZMSUnitsMinor"] call DZMSAISpawn;
sleep 3;
[_coords,4,1,"DZMSUnitsMinor"] call DZMSHookerSpawn;
sleep 3;

This is my DZMSHookerSpawn.sqf: http://pastebin.com/RC2Kx46d

 

No errors are being logged in my RPT.

Link to comment
Share on other sites

You have a while inside a for loop.

 

What this means is it spawns the first hooker, hits the while loop, and until that loop reaches 50 it won't go on to spawn the second hooker.

 

Change the while into a spawn, and move it outside the for loop.

 

Most of what I've done has been by looking at other scripts and basing it on that. I'm not sure how to fix that. Any chance you could help me out with that? :)

Link to comment
Share on other sites

[] Spawn {
    while {(_barOpen < 50)} do {

        crueDanceLight1C = [1,0,0];

        _light1 = "#lightpoint" createVehicleLocal _unitpos;
        _light1 setLightBrightness 0.1;
        crueDanceLight1 setLightColor crueDanceLight1C;
        crueDanceLight1 setLightAmbient crueDanceLight1C;

        sleep _rndNum;
        _aiunit playMove "ActsPercMstpSnonWnonDnon_DancingStefan";
        sleep _rndNum2;
        
        deleteVehicle crueDanceLight1;
        _barOpen = _barOpen + 1;
    };
};

And put that outside the For loop.

Link to comment
Share on other sites

So, like this?

//Probably unnecessary, but prevents client AI stacking
if (!isServer) exitWith {};


for "_x" from 1 to _unitcount do {


//Lets pick a skin from the array
_aiskin = ["Hooker1","Hooker2","Hooker3","Hooker4"] call BIS_fnc_selectRandom;


//Lets spawn the unit
_unit = _unitGroup createUnit [_aiskin, [(_position select 0),(_position select 1),(_position select 2)], [], 10, "PRIVATE"];


//Make him join the correct team
[_unit] joinSilent _unitGroup;


//Add the behaviour
_unit enableAI "TARGET";
_unit enableAI "AUTOTARGET";
_unit enableAI "MOVE";
_unit enableAI "ANIM";
_unit enableAI "FSM";
_unit allowDammage false;
_unit addEventHandler ["handleDamage", {false}];
_unit setBehaviour "CARELESS";


//Remove the items he spawns with by default
removeAllWeapons _unit;
removeAllItems _unit;


_barOpen = 0;
_rndNum = floor(random 20);
_rndNum2 = floor(random 20);


//Lets prepare the unit for cleanup
_unit addEventHandler ["Killed",{ [(_this select 0), (_this select 1)] ExecVM DZMSAIKilled; }];
_unit setVariable ["DZMSAI", true];
};


while {(_barOpen < 50)} do {


crueDanceLight1C = [1,0,0];


_light1 = "#lightpoint" createVehicleLocal _unitpos;
_light1 setLightBrightness 0.1;
crueDanceLight1 setLightColor crueDanceLight1C;
crueDanceLight1 setLightAmbient crueDanceLight1C;


sleep _rndNum;
_aiunit playMove "ActsPercMstpSnonWnonDnon_DancingStefan";
sleep _rndNum2;


deleteVehicle crueDanceLight1;
_barOpen = _barOpen + 1;
 }; 


//diag_log text format ["[DZMS]: Spawned %1 Hooker at %2",_unitcount,_position];
Link to comment
Share on other sites

  • 2 weeks later...
  • 2 weeks later...
  • 5 months later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement
  • Discord

×
×
  • Create New...