Jump to content
Sign in to follow this  
KilEKarl

Spawn a ENEMY Ai ??

Recommended Posts

There's a script that I found, that spawn's a friendly AI, But I want the AI to be an enemy who will shoot me on sight, Can someone please have a look and change it so the AI will attack me? I've looked around on the web for some help but can't get it to work..

TitleText [format["AI Player spawned"], "PLAIN DOWN"];

private["_spawnAIS", "_plrGroup"];

CIVILIAN setFriend [WEST,0];

WEST setFriend [CIVILIAN,0];

player addRating 50000;

_plrGroup = (group player);

_plrGroup allowFleeing 0;

_plrGroup setFormation "LINE";

"SurvivorW2_DZ" createUnit [[(getpos player select 0), (getpos player select 1), 50], _plrGroup, "_spawnAIS = this;"];

_spawnAIS enableAI "TARGET";

_spawnAIS enableAI "AUTOTARGET";

_spawnAIS enableAI "MOVE";

_spawnAIS enableAI "ANIM";

_spawnAIS enableAI "FSM";

_spawnAIS allowDammage true;

_spawnAIS setCombatMode "RED";

_spawnAIS setBehaviour "COMBAT";

_spawnAIS addweapon "G36_C_SD_camo";

_spawnAIS addMagazine "30Rnd_556x45_StanagSD";

_spawnAIS addMagazine "30Rnd_556x45_StanagSD";

_spawnAIS addMagazine "30Rnd_556x45_StanagSD";

_spawnAIS addMagazine "30Rnd_556x45_StanagSD";

_spawnAIS addMagazine "30Rnd_556x45_StanagSD";

_spawnAIS addMagazine "30Rnd_556x45_StanagSD";

_spawnAIS addMagazine "30Rnd_556x45_StanagSD";

_spawnAIS selectWeapon "G36_C_SD_camo";

_spawnAIS setSkill ["aimingAccuracy",1];

_spawnAIS setSkill ["aimingShake",1];

_spawnAIS setSkill ["aimingSpeed",1];

_spawnAIS setSkill ["endurance",1];

_spawnAIS setSkill ["spotDistance",1];

_spawnAIS setSkill ["spotTime",1];

_spawnAIS setSkill ["courage",1];

_spawnAIS setSkill ["reloadSpeed",1];

_spawnAIS setSkill ["commanding",1];

_spawnAIS setSkill ["general",1];

[_spawnAIS] join _plrGroup;

_spawnAIS addEventHandler ["Fired", {_this call player_fired;}];

while {alive _spawnAIS} do

{

{

_x addRating -200000;

} forEach allMissionObjects "zZombie_Base";

sleep 0.1;

};

Share this post


Link to post
Share on other sites

There is a Youtube video where an example is given. I don't have a link - you will need to search

Share this post


Link to post
Share on other sites

From glancing over it atleast 85% of that code is just unnecessary and/or unusable without contexts. It's also for a DayZ-like game mode (or even for DayZ itself). If you want to use it for DayZ head over to their forums.

Otherwise, use something like this:

_cnt = createCenter EAST;
_grp = createGroup EAST;
_unit = _grp createUnit ["RU_Soldier",getmarkerpos "somewhere",[],0,"NONE"];

This will create an OPFOR unit at a marker called "somewhere" (change this to an appropriate marker name, or if you want him to spawn at a position, use getpos). If the player is a BLUFOR unit he'll be attacked once the spawned unit has eyes on him.

Share this post


Link to post
Share on other sites
From glancing over it atleast 85% of that code is just unnecessary and/or unusable without contexts. It's also for a DayZ-like game mode (or even for DayZ itself). If you want to use it for DayZ head over to their forums.

Otherwise, use something like this:

_cnt = createCenter EAST;
_grp = createGroup EAST;
_unit = _grp createUnit ["RU_Soldier",getmarkerpos "somewhere",[],0,"NONE"];

This will create an OPFOR unit at a marker called "somewhere" (change this to an appropriate marker name, or if you want him to spawn at a position, use getpos). If the player is a BLUFOR unit he'll be attacked once the spawned unit has eyes on him.

I'm not using it for DayZ,

that "} forEach allMissionObjects "zZombie_Base";" - Only works for Dynamic Zombie Sandbox mission.

I'm using it for my own missions that me and a few mates play, like team deathmatch or just those small type missions, but thanks I will try it out (:

Edited by KilEKarl

Share this post


Link to post
Share on other sites
From glancing over it atleast 85% of that code is just unnecessary and/or unusable without contexts. It's also for a DayZ-like game mode (or even for DayZ itself). If you want to use it for DayZ head over to their forums.

Otherwise, use something like this:

_cnt = createCenter EAST;
_grp = createGroup EAST;
_unit = _grp createUnit ["RU_Soldier",getmarkerpos "somewhere",[],0,"NONE"];

This will create an OPFOR unit at a marker called "somewhere" (change this to an appropriate marker name, or if you want him to spawn at a position, use getpos). If the player is a BLUFOR unit he'll be attacked once the spawned unit has eyes on him.

How would I spawn him few metres away from me ?

I changed ..

_unit = _grp createUnit ["RU_Soldier", getpos player,[],0,"NONE"];

But he spawn's right next to me..

Share this post


Link to post
Share on other sites

Just change the 0 to about 20 or more then he will spawn in a 20 meter radius around your position.

Share this post


Link to post
Share on other sites
Just change the 0 to about 20 or more then he will spawn in a 20 meter radius around your position.

Thanks I thought I tried that, but didn't see any changes, works now :)

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  

×