[Release] Full Bandit AI Tutorial(Not my newest Code)
So, i'm using GigaToni's original code for this tutorial and not mine.
His code causes server crashes, and they will not die (at least in my case)
So lets begin
Search for:
Code:
DEFINE_PACKET_FUNC(PKT_S2C_CheatWarning);
Below that, add:
Code:
DEFINE_PACKET_FUNC(PKT_S2C_CreateNPC);
Search for:
Below it add:
Code:
//NPC
PKT_S2C_CreateNPC,
PKT_S2C_NPCSetState,
// END
Now Search for
Code:
struct PKT_S2C_SetNoteData_s : public DefaultPacketMixin<PKT_S2C_SetNoteData>
Below that add
Code:
struct PKT_S2C_CreateNPC_s : public DefaultPacketMixin<PKT_S2C_CreateNPC>
{
gp2pnetid_t spawnID;
r3dPoint3D spawnPos;
float spawnDir;
r3dPoint3D moveCell; // cell position from PKT_C2C_MoveSetCell
DWORD HeroItemID; // ItemID of base character
BYTE HeadIdx;
BYTE BodyIdx;
BYTE LegsIdx;
BYTE State; // ENPCStates
float WalkSpeed;
float RunSpeed;
DWORD HGearPart; // HGear
DWORD ArmorPart; // Armor
DWORD BackPackPart; // Backpack
DWORD WeaponPart; // WEAPON?
};
// NPC's AI
struct PKT_S2C_NPCSetState_s : public DefaultPacketMixin<PKT_S2C_NPCSetState>
{
BYTE State; // ZombieStates::EZombieStates
};
/*struct PKT_S2C_NPCAttack_s : public DefaultPacketMixin<PKT_S2C_NPCAttack>
{
gp2pnetid_t targetId;
};*/
Now search
Code:
IMPL_PACKET_FUNC(ClientGameLogic, PKT_S2C_SetNoteData)
Below that add
Code:
IMPL_PACKET_FUNC(ClientGameLogic, PKT_S2C_CreateNPC)
{
//r3dOutToLog("obj_Zombie %d\n", n.spawnID);
r3d_assert(GameWorld().GetNetworkObject(n.spawnID) == NULL);
/*obj_Guard* obj = (obj_Guard*)srv_CreateGameObject("obj_Guard", "obj_Guard", n.spawnPos);
obj->SetNetworkID(n.spawnID);
obj->NetworkLocal = false;
memcpy(&obj->CreateParams, &n, sizeof(n));
obj->OnCreate();
obj->netMover.SetStartCell(n.moveCell);*/
obj_Player* pl = (obj_Player *)srv_CreateGameObject("obj_Player", "Guard", n.spawnPos);
pl->NetworkLocal = false; // so it will be always in 3rd person mode. with disabled physics
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;
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;
pl->CurLoadout.Thirst = 0;
pl->CurLoadout.BackpackID = 20185;
pl->CurLoadout.BackpackSize = 28;
pl->m_fPlayerRotationTarget = pl->m_fPlayerRotation = u_GetRandom(0.0f, 360.0f);
pl->OnCreate();
pl->UpdateLoadoutSlot(pl->CurLoadout);
pl->netMover.SetStartCell(n.moveCell);
}
Now:
Code:
DEFINE_PACKET_HANDLER(PKT_S2C_CheatWarning);
Add this below it
Code:
DEFINE_PACKET_HANDLER(PKT_S2C_CreateNPC);
Now last but not least:
Code:
#include "ObjectsCode/Zombies/sobj_Zombie.h"
And below it add
Code:
#include "ObjectsCode/DIRECTORY/sobj_Guard.h"
And the command to spawn them in:
Code:
if(strncmp(cmd, "/spawnnpc", 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;
}
Heres the files you will need, remember to add in object explorer.
for all you newbs out there, any thing starting with OBJ is client, and SOBJ is server sided
Link to the files HERE
Credits to:
m70b1jr @GigaToni
Re: [Release] Full Bandit AI Tutorial(Not my newest Code)
HeHe glad that you're putting in my Credit. I've a newer version of the code and on my side it's not crashing :D! gl with that, ;)
Re: [Release] Full Bandit AI Tutorial(Not my newest Code)
Quote:
Originally Posted by
GigaToni
HeHe glad that you're putting in my Credit. I've a newer version of the code and on my side it's not crashing :D! gl with that, ;)
Be a boss and release it :)
Re: [Release] Full Bandit AI Tutorial(Not my newest Code)
http://yunpan.cn/QhLTiTdNNJfVz
(It's not the newest one. It's A newer one but not newest.)
DL Pw:
7574
Password is:
gofuckyourself but as an Internet address ;)
Re: [Release] Full Bandit AI Tutorial(Not my newest Code)
Quote:
Originally Posted by
GigaToni
http://yunpan.cn/QhLTiTdNNJfVz
(It's not the newest one. It's A newer one but not newest.)
DL Pw:
7574
Password is:
gofuckyourself but as an Internet address ;)
Yay! Japaneses! lol.
- - - Updated - - -
Quote:
Originally Posted by
GigaToni
http://yunpan.cn/QhLTiTdNNJfVz
(It's not the newest one. It's A newer one but not newest.)
DL Pw:
7574
Password is:
gofuckyourself but as an Internet address ;)
Error 7 error C3861: 'u_GetRandomMaxMin': identifier not found c:\DeadNation\src\server\WO_GameServer\Sources\ObjectsCode\Guards\sobj_Guard.cpp 865 WarZ Game Server
Same errors with your old code, i just gonna comment it out like a NEWB
Re: [Release] Full Bandit AI Tutorial(Not my newest Code)
r3dsys_win.cpp:
search:
Quote:
float u_GetRandom(float r1, float r2)
{
return r1 + (u_GetRandom() * (r2-r1));
}
after add:
Quote:
int u_GetRandomMaxMin(int low, int high) {
return rand() % (high - low + 1) + low;
}
Re: [Release] Full Bandit AI Tutorial(Not my newest Code)
Quote:
Originally Posted by
GigaToni
r3dsys_win.cpp:
search:
after add:
Still not working, im also getting more errors.
Ill post all of them as i get them.
Im still getting the U_GetRandomMaxMin error.
Along with
Code:
Error 5 error C2660: 'ServerGameLogic::AddPlayerReward' : function does not take 2 arguments c:\DeadNation\src\server\WO_GameServer\Sources\ObjectsCode\Guards\sobj_Guard.cpp 1062 WarZ Game Server
- - - Updated - - -
Quote:
Originally Posted by
m70b1jr
Still not working, im also getting more errors.
Ill post all of them as i get them.
Im still getting the U_GetRandomMaxMin error.
Along with
Code:
Error 5 error C2660: 'ServerGameLogic::AddPlayerReward' : function does not take 2 arguments c:\DeadNation\src\server\WO_GameServer\Sources\ObjectsCode\Guards\sobj_Guard.cpp 1062 WarZ Game Server
And
Code:
Error 1 error C2027: use of undefined type 'r3dstatic_assert::STATIC_ASSERT_FAILURE<__formal>' c:\DeadNation\src\server\WO_GameServer\Sources\ObjectsCode\Guards\sobj_Guard.cpp 344 WarZ Game Server
- - - Updated - - -
@GigaToni It would be better if you made your own tutorial :)
- - - Updated - - -
UPDATE:
Got it to work
But now Bandit Ai just wreak me, even with god mode i take damage.
But they do not take damage, i'll try my best to fix it.
Re: [Release] Full Bandit AI Tutorial(Not my newest Code)
I Do Not want this thread deleted. Anyone that bothers the OP regarding this thread will deal directly with me. And it will not be nicely.
Enough Crap!
Thank him by clicking the Like button.