Professional Documents
Culture Documents
AI Bandit Tutorial
AI Bandit Tutorial
Today I will be giving you the AI Bandit code to add into your server. This code still needs a lot of work
for the bandit animations but it is a starting point for you to add them into your server. Yes this will be a
copy and paste tutorial.
First you will need to extract the AI Bandit files and put them in the correct folders. I will be using my
directory for reference. Yours may be different than mine, but it should be the same end folders as
mine.
“o let’s add the first folder to e lipse studio. Navigate to your ObjectsCode folder in EclipseStudio.
Place the folder Guard in there.
Now go into your Gameplay folder in the same folder as your Guard folder. Add the following files
to this folder.
No let’s add the files to the ser er folder. Na igate to your ObjectsCode folder in
WO_Ga e“er er folder. Add a folder and name it Guards . In the folder Guards add the following
files.
Now add the following files to your O je tsCode folder were you just made the Guards folder. The
following files should be added.
In solution explorer expand Eclipse Studio so that you can see the folder named Ga e .
Right click on the folder Ga eO je ts Code and navigate to add and then to New filter and add a new
filter and name it Guard .
Now you should see a folder named Guard under Ga eO je ts Code . Now we need to add the files
to the folder we just made. We will add them the same way as we added the folder.
Right click on the folder Guard and navigate to add then Existing Items. Now a window will open up
and you will need to navigate to the guard folder in EclipseStudio.
Now in the Solution Explorer you should see a folder named Guard with the files in it.
Here is where you will set the XP for killing the bandits. I will not explain how to do that in this tutorial.
RWD_SuperZombieKill = 2,
RWD_GuardKill = 3,
#include "ObjectsCode/Gameplay/obj_Zombie.h"
#include "ObjectsCode/Guard/obj_guard.h"
IMPL_PACKET_FUNC(ClientGameLogic, PKT_S2C_UseNetObjectAns)
IMPL_PACKET_FUNC(ClientGameLogic, PKT_S2C_CreateNPC)
{
//r3dOutToLog("obj_Zombie %d\n", n.spawnID);
r3d_assert(GameWorld().GetNetworkObject(n.spawnID) == NULL);
pl->SetNetworkID(n.spawnID);
pl->CurLoadout.HeroItemID = n.HeroItemID;
const HeroConfig* heroConf = g_pWeaponArmory->getHeroConfig(pl-
>CurLoadout.HeroItemID);
pl->CurLoadout.HeadIdx = n.HeadIdx;
pl->CurLoadout.BodyIdx = n.BodyIdx;
pl->CurLoadout.LegsIdx = n.LegsIdx;
pl->CurLoadout.Items[wiCharDataFull::CHAR_LOADOUT_ARMOR].itemID
= n.ArmorPart; //sfag
pl->CurLoadout.Items[wiCharDataFull::CHAR_LOADOUT_HEADGEAR].itemID
= n.HGearPart;
//pl->CurLoadout.Items[0].itemID =
WeaponConfig::ITEMID_Unarmed;
pl->CurLoadout.Items[0].itemID = n.WeaponPart;
//pl->CurLoadout.Items[1].itemID = XX;
pl->CurLoadout.Health = 100;
pl->CurLoadout.Toxic = 0;
pl->CurLoadout.Hunger = 0;
AI Bandit Tutorial
pl->CurLoadout.Thirst = 0;
pl->CurLoadout.MedFeverCold = 0;
pl->CurLoadout.BackpackID = NULL;
pl->CurLoadout.BackpackSize = 28;
pl->netMover.SetStartCell(n.moveCell);
}
DEFINE_PACKET_HANDLER(PKT_S2C_CreateZombie);
DEFINE_PACKET_HANDLER(PKT_S2C_CreateNPC);
DEFINE_PACKET_FUNC(PKT_C2S_ValidateConnectingPeer);
DEFINE_PACKET_FUNC(PKT_S2C_CreateNPC);
PKT_S2C_ZombieSprint,
PKT_S2C_GuardSprint,
PKT_S2C_GroupNotify,
// server notes
//NPC
PKT_S2C_CreateNPC,
PKT_S2C_NPCSetState,
// END
Once you are done compiling WarZ.si you can close out this solution and open WarZ_“er er.si
Now we will add the files to the WarZ_“er er.si just like we did in WarZ.si . In the solutions
Explorer navigate to the folder WarZ Ga e “er er and expand it then scroll down and expand :
“er er and then scroll down and then finally expand the folder Ga eO je ts Code .
Now add the following folder and files just like we did in WarZ.si .
Right li k o Ga eo je ts Code folder a d add e filter. Name the new filter Guard.
Now right click on the new filter and add the following files to it.
Ok now that it is all do e a d o er ith let’s starts addi g the ode to the sour e.
#include "../EclipseStudio/Sources/ObjectsCode/Gameplay/ZombieStates.h"
#include "../EclipseStudio/Sources/ObjectsCode/Gameplay/GuardStates.h"
#include "ObjectsCode/Zombies/sobj_Zombie.h"
#include "ObjectsCode/Guards/sobj_GuardSpawn.h"
#include "ObjectsCode/Guards/sobj_Guard.h"
Now scroll down the page and should come to this include:
#include "../EclipseStudio/Sources/ObjectsCode/Gameplay/ZombieStates.h"
#include "../EclipseStudio/Sources/ObjectsCode/Gameplay/GuardStates.h"
#ifdef VEHICLES_ENABLED
bool ServerGameLogic::ApplyDamageToVehicle(GameObject* fromObj, GameObject*
targetVehicle, const r3dPoint3D& dmgPos, float damage, bool forceDamage,
STORE_CATEGORIES damageSource, uint32_t damageItemId)
return true;
}
#ifdef MISSIONS
if(strncmp(cmd, "/resetmd", 8) == 0 && plr-
>profile_.ProfileData.isDevAccount & wiUserProfile::DAA_DEV_ICON)
return Cmd_ResetMissionData(plr, cmd);
AI Bandit Tutorial
Right below this code add the following code:
#endif
if(strncmp(cmd, "/createai", 9) == 0 && plr-
>profile_.ProfileData.isDevAccount)
{
r3dPoint3D pos = plr->GetPosition();
pos.x += 15;
pos.z += u_GetRandom(0, 1) == 1 ? 15.0f : 0.0f;
obj_Guard* g = (obj_Guard*)srv_CreateGameObject("obj_Guard",
"Guard", pos);
g->spawnObjPos = plr->GetPosition();
g->spawnObjRad = 150.0f;
g->SetNetworkID(GetFreeNetId());
g->NetworkLocal = true;
g->DetectRadius = u_GetRandom(0, 1);
g->SetRotationVector(r3dVector(u_GetRandom(0, 360), 0, 0));
return 0;
}
Just a few lines down you will see the following code:
if (isMeleeGuard)
GuardCount = 1;
if (Terrain3)
position.y = Terrain3->GetHeight(position);
}
char name[28];
sprintf(name, "Guard_%d_%p", spawnObject->numSpawnedGuards++,
this);
obj_Guard* z = (obj_Guard*)srv_CreateGameObject("obj_Guard",
name, position);
z->SetNetworkID(gServerLogic.GetFreeNetId());
z->NetworkLocal = true;
z->spawnObject = spawnObject;
z->DetectRadius = 0;
z->SetRotationVector(r3dVector(u_GetRandom(0, 360), 0, 0));
// z->CanCallForHelp = false;
z->isMeleeGuardForced = isMeleeGuard;
spawnObject->Guards.push_back(z);
}
//LogCheat(plr->peerId_, PKT_S2C_CheatWarning_s::CHEAT_AdminGiveItem, 0,
"Admin Spawn Guard", "%d (%s) spawned %d Guard\n", plr->profile_.CustomerID,
plr->userName, zombieCount);
return 0;
}
AI Bandit Tutorial
No let’s ope up “er erGa eLogi .h
Ok now that all the code for the server side is added you can compile WarZ_“er er.si
While our server is compiling we need to edit one more file. We need to edit our O je ts.dat file in
our data folder.
Open the file in Notepad++ and at the bottom you will see this:
Now all you need to do is to go into your Infestation Studio and add the spawn on whatever map you
want it on.
That should be it. If there are any errors please send me a message on Skype. I know there might be a
few things missing. Not sure. I am in no way shape or form taking credit for this code.
Written By: