[Tutorial] Woodbox (fully working)

Joined
May 4, 2013
Messages
269
Reaction score
129
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:

Code:
int            LootID;

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:

Code:
int        LootID;

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
 
Don't you need to add these items in Loot Data ?

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 ?

And this....



I tried this and have no boxes......


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 {
 
Last edited:
Don't you need to add these items in Loot Data ?



So they are like there own loot spawn ?

Like this ?

And this....



I tried this and have no boxes......


Here there also spawns box
If you can tell patch
 
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!
 
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 ?
 
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?
 

Attachments

  • UE6Panr - [Tutorial] Woodbox (fully working) - RaGEZONE Forums
    UE6Panr.webp
    125 KB · Views: 69
I'm use the lootbox is error kick me out of server and error in logss is baditemid 301138

Code:
000484.618| cmd: /gi 301138 admin:126
000484.628| !!! cheat: peer00, r:Admin Spawn Item 1000000 (DEV InSIDE) spawned 301138 with quantity 1 on server Clearview 02
, CID:1000000 [DEV InSIDE], ip:xxx.xxx.xx.xxx
000489.043| !!! cheat: peer00, r:baditemid 301138, CID:1000000 [DEV InSIDE], ip:xxx.xxx.xx.xxx
000489.043| peer00 player DEV InSIDE is updating his data
000489.043| DeletePlayer: DEV InSIDE, playerIdx: 0

How to fix It ?
 
Back