Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

[Release] Full Bandit AI Tutorial(Not my newest Code)

Status
Not open for further replies.
Joined
May 18, 2013
Messages
852
Reaction score
323
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:
Code:
// server notes
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/[B][U]DIRECTORY[/U][/B]/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
Credits to:
m70b1jr @GigaToni
 
Joined
May 18, 2013
Messages
852
Reaction score
323

(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.




(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
 
Joined
May 18, 2013
Messages
852
Reaction score
323
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



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


GigaToni It would be better if you made your own tutorial :)



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.
 
Status
Not open for further replies.
Back
Top