[Tutorial] Woodbox (fully working)
I decided to post this tutorial on how to do the item box like I:SS
PS: All these codes were removed from the @CodexPo source
====================== WarZ_Server.sln ======================
--------------------------- obj_ServerItemSpawnPoint.cpp: -----------------------------
Search for:
Code:
if(m_DestroyItemTimer > 0.0f)
You have this:
Code:
obj->m_DestroyIn = r3dGetTime() + m_DestroyItemTimer;
obj->m_SpawnObj = GetSafeID();
obj->m_SpawnIdx = spawnIndex;
obj->m_Item = wi;
return;
Make ti look like this:
Code:
obj->m_DestroyIn = r3dGetTime() + m_DestroyItemTimer;
obj->m_SpawnObj = GetSafeID();
obj->m_SpawnIdx = spawnIndex;
obj->m_Item = wi;
obj->LootID = (int)m_LootBoxID;
return;
--------------------------- sobj_DroppedItem.cpp: -----------------------------
Search for:
Code:
DefaultPacket* obj_DroppedItem::NetGetCreatePacket(int* out_size)
You have this:
Code:
DefaultPacket* obj_DroppedItem::NetGetCreatePacket(int* out_size)
{
static PKT_S2C_CreateDroppedItem_s n;
n.spawnID = toP2pNetId(GetNetworkID());
n.pos = GetPosition();
n.Item = m_Item;
*out_size = sizeof(n);
return &n;
}
Make it look like this:
Code:
DefaultPacket* obj_DroppedItem::NetGetCreatePacket(int* out_size)
{
static PKT_S2C_CreateDroppedItem_s n;
n.spawnID = toP2pNetId(GetNetworkID());
n.pos = GetPosition();
n.Item = m_Item;
n.SpawnedItem = false;
n.LootID = 0;
*out_size = sizeof(n);
return &n;
}
--------------------------- sobj_DroppedItem.h: -----------------------------
Search for:
Code:
wiInventoryItem m_Item;
Add below:
Like:
Code:
public:
wiInventoryItem m_Item;
float m_expireTime;
int LootID;
--------------------------- sobj_SpawnedItem.cpp: -----------------------------
Search for:
Code:
DefaultPacket* obj_SpawnedItem::NetGetCreatePacket(int* out_size)
You have this:
Code:
DefaultPacket* obj_SpawnedItem::NetGetCreatePacket(int* out_size)
{
static PKT_S2C_CreateDroppedItem_s n;
n.spawnID = toP2pNetId(GetNetworkID());
n.pos = GetPosition();
n.Item = m_Item;
*out_size = sizeof(n);
return &n;
}
Make it like look this:
Code:
DefaultPacket* obj_SpawnedItem::NetGetCreatePacket(int* out_size)
{
static PKT_S2C_CreateDroppedItem_s n;
n.spawnID = toP2pNetId(GetNetworkID());
n.pos = GetPosition();
n.Item = m_Item;
n.SpawnedItem = true;
n.LootID = LootID;
*out_size = sizeof(n);
return &n;
}
--------------------------- sobj_SpawnedItem.h: -----------------------------
Search for:
Code:
// time when item should be de-spawned
Add below:
Like:
Code:
wiInventoryItem m_Item;
float m_DestroyIn; // time when item should be de-spawned
int LootID;
--------------------------- P2PMessages.h: -----------------------------
PS: Edit this part of the server to the client when you do not need more!
Search for:
Code:
struct PKT_S2C_CreateDroppedItem_s : public DefaultPacketMixin<PKT_S2C_CreateDroppedItem>
Make it like look this:
Code:
struct PKT_S2C_CreateDroppedItem_s : public DefaultPacketMixin<PKT_S2C_CreateDroppedItem>
{
gp2pnetid_t spawnID;
r3dPoint3D pos;
wiInventoryItem Item;
bool SpawnedItem;
int LootID;
};
====================== WarZ.sln ======================
--------------------------- obj_DroppedItem.cpp: -----------------------------
Search for:
Code:
obj_DroppedItem::OnCreate()
Make it look like:
Code:
BOOL obj_DroppedItem::OnCreate()
{
r3d_assert(m_Item.itemID);
const char* cpMeshName = "";
if(m_Item.itemID == 'GOLD')
{
cpMeshName = "Data\\ObjectsDepot\\Weapons\\Item_Money_Stack_01.sco";
}
else
{
const ModelItemConfig* cfg = (const ModelItemConfig*)g_pWeaponArmory->getConfig(m_Item.itemID);
switch(cfg->category)
{
case storecat_Account:
case storecat_Boost:
case storecat_LootBox:
case storecat_HeroPackage:
r3dError("spawned item is not model");
break;
}
if (SpawnedItem == true)
{
switch(LootID) // Specific lootID WoodBox
{
case 301138:
cpMeshName = "data/objectsdepot/Weapons/item_lootcrate_01.sco";
break;
case 301139:
cpMeshName = "data/objectsdepot/Weapons/item_lootcrate_01.sco";
break;
default:
cpMeshName = cfg->m_ModelPath;
SpawnedItem=false;
}
}
else {
cpMeshName = cfg->m_ModelPath;
}
}
if(!parent::Load(cpMeshName))
return FALSE;
if(m_Item.itemID == 'GOLD')
{
m_ActionUI_Title = gLangMngr.getString("Money");
m_ActionUI_Msg = gLangMngr.getString("HoldEToPickUpMoney");
}
else if (SpawnedItem == true)
{
m_ActionUI_Title = gLangMngr.getString("ITEM");//$FR_PAUSE_USE_ITEM");
m_ActionUI_Msg = gLangMngr.getString("HoldEToPickUpMoney");
}
else
{
const BaseItemConfig* cfg = g_pWeaponArmory->getConfig(m_Item.itemID);
m_ActionUI_Title = cfg->m_StoreNameW;
m_ActionUI_Msg = gLangMngr.getString("HoldEToPickUpItem");
}
ReadPhysicsConfig();
PhysicsConfig.group = PHYSCOLL_TINY_GEOMETRY; // skip collision with players
PhysicsConfig.requireNoBounceMaterial = true;
PhysicsConfig.isFastMoving = true;
SetPosition(GetPosition()+r3dPoint3D(0,0.25f,0));
m_spawnPos = GetPosition();
parent::OnCreate();
UpdateObjectPositionAfterCreation();
return 1;
}
PS: Here, the LootBoxID with ID 301138 and 301139 will spawn with the texture of the box (you can / should change to what you want)
Search for:
Code:
obj_DroppedItem::AppendRenderables( RenderArray ( & render_arrays )[ rsCount ], const r3dCamera& Cam )
Make it look like this:
Code:
void obj_DroppedItem::AppendRenderables( RenderArray ( & render_arrays )[ rsCount ], const r3dCamera& Cam )
{
MeshGameObject::AppendRenderables( render_arrays, Cam );
if( GetHighlight() )
{
MeshObjDeferredHighlightRenderable rend;
rend.Init( MeshGameObject::GetObjectLodMesh(), this );
rend.SortValue = 0;
if (SpawnedItem == true)
rend.Parent->SetScale(r3dPoint3D(1.15,1.15,1.15));
render_arrays[ rsFillGBufferEffects ].PushBack( rend );
}
}
--------------------------- obj_DroppedItem.h: -----------------------------
Search for:
Code:
wiInventoryItem m_Item;
Add below:
Code:
bool SpawnedItem;
int LootID;
Like:
Code:
public:
wiInventoryItem m_Item;
bool SpawnedItem;
int LootID;
--------------------------- ClientGameLogic.cpp: -----------------------------
Search for:
Code:
IMPL_PACKET_FUNC(ClientGameLogic, PKT_S2C_CreateDroppedItem)
Make it look like this:
Code:
IMPL_PACKET_FUNC(ClientGameLogic, PKT_S2C_CreateDroppedItem)
{
//r3dOutToLog("obj_DroppedItem %d %d\n", n.spawnID, n.Item.itemID);
r3d_assert(GameWorld().GetNetworkObject(n.spawnID) == NULL);
GameObject* obj1 = GameWorld().GetNetworkObject(n.spawnID);
if (obj1)
{
GameWorld().DeleteObject(obj1);
}
obj_DroppedItem* obj = (obj_DroppedItem*)srv_CreateGameObject("obj_DroppedItem", "obj_DroppedItem", n.pos);
obj->SetNetworkID(n.spawnID);
obj->m_Item = n.Item;
obj->SpawnedItem = n.SpawnedItem;
obj->LootID = n.LootID;
obj->OnCreate();
}
Okay, end of the tutorial XD Now missing only compile WarZ.sln in Final build and WarZ_Server.sln in Release build and run RSBuild XD
Re: [Tutorial] Woodbox (fully working)
Help WarZTHv2
000027.593| !!! ERROR: spawned item is not model
000027.593| ... exiting
Re: [Tutorial] Woodbox (fully working)
Quote:
Originally Posted by
robson154
Help WarZTHv2
000027.593| !!! ERROR: spawned item is not model
000027.593| ... exiting
The item you selected to spawn has not been added in the game... Or just try to comment this line in the client :P
Re: [Tutorial] Woodbox (fully working)
No spawns boxes on the floor
OMG
Re: [Tutorial] Woodbox (fully working)
Quote:
Originally Posted by
robson154
No spawns boxes on the floor
OMG
Maybe you've forgotten something, redo the tutorial
Re: [Tutorial] Woodbox (fully working)
Don't you need to add these items in Loot Data ?
Quote:
case 301138:
cpMeshName = "data/objectsdepot/Weapons/item_lootcrate_01.sco";
break;
case 301139:
cpMeshName = "data/objectsdepot/Weapons/item_lootcrate_01.sco";
So they are like there own loot spawn ?
Like this ? http://prntscr.com/57g6ip
And this.... http://prntscr.com/57g7gn
I tried this and have no boxes......
Quote:
if (SpawnedItem == true)
{
switch(LootID) // Specific lootID WoodBox
{
case 301138:
cpMeshName =
"data/objectsdepot/Weapons/Loot_Drop_Premium_01.sco";
break;
case 301139:
cpMeshName =
"data/objectsdepot/Weapons/Loot_Drop_Premium_02.sco";
break;
default:
cpMeshName = cfg->m_ModelPath;
SpawnedItem=
false;
}
}
else {
Re: [Tutorial] Woodbox (fully working)
Quote:
Originally Posted by
MrGrimm
Here there also spawns box
If you can tell patch
Re: [Tutorial] Woodbox (fully working)
Quote:
Originally Posted by
robson154
Here there also spawns box
If you can tell patch
What?
Re: [Tutorial] Woodbox (fully working)
Google Translate mother********
Not Spawn Woodbox Here
Re: [Tutorial] Woodbox (fully working)
Quote:
Originally Posted by
robson154
Google Translate mother********
Not Spawn Woodbox Here
First of all there wasn't anything to translate asshole.....You had a bunch of garbled up ENGLISH. Learn how to speak proper English or don't post!!!!
Re: [Tutorial] Woodbox (fully working)
Quote:
Originally Posted by
MrGrimm
First of all there wasn't anything to translate asshole.....You had a bunch of garbled up ENGLISH. Learn how to speak proper English or don't post!!!!
MrGrimm why are you insulting him ? He just need help and you are rude..
I already saw you creating post in help section like crazy and getting help why when someone ask you for help you are rude ?
This is why nobody cares about others...
Today you get help, tomorrow you help others!
Re: [Tutorial] Woodbox (fully working)
Quote:
Originally Posted by
rollwow
MrGrimm why are you insulting him ? He just need help and you are rude..
I already saw you creating post in help section like crazy and getting help why when someone ask you for help you are rude ?
This is why nobody cares about others...
Today you get help, tomorrow you help others!
Did you not read his reply ?
"Google Translate Mother******" And im being rude ?
Re: [Tutorial] Woodbox (fully working)
Re: [Tutorial] Woodbox (fully working)
Re: [Tutorial] Woodbox (fully working)
Quote:
Originally Posted by
MrGrimm
I have the same problem
I added new cases with loot_drop_reg_01.sco
but the model does not appear, just item.
how to fix?