Due to a request I created the code to be able to add sockets manually via item creation in LUA or via CPP. Right now I have it set to 4 as max, due to the maxSockets Variable also being 4. That can easily be changed.
Files to modify:
src/server/zone/objects/tangible/wearables/WearableObject.idl
src/server/zone/objects/tangible/LuaTangibleObject.h
src/server/zone/objects/tangible/LuaTangibleObject.cpp
How to Use:
LUA EXAMPLE:
Files to modify:
src/server/zone/objects/tangible/wearables/WearableObject.idl
C++:
public void setMaxSockets(int maxSockets) {
if (maxSockets <0) {
maxSockets = 0;
} else if (maxSockets > MAXSOCKETS) {
maxSockets = MAXSOCKETS
}
socketCount = maxSockets;
socketsGenerated = true;
}
// NEW CODE BELOW
public void setSockets(int count)
{
socketCount = count;
}
C++:
int isSliced(lua_State* L);
int isNoTrade(lua_State* L);
// NEW CODE BELOW
int setSocketCount(lua_State* L);
C++:
#include "server/zone/objects/player/FactionStatus.h"
//NEW INCLUDE BELOW
#include "server/zone/objects/tangible/wearables/WearableObject.h"
----------------------------------------------------------------------
{ "isSliced", &LuaTangibleObject::isSliced},
{ "isNoTrade", &LuaTangibleObject::isNoTrade},
// NEW CODE BELOW
{ "setSocketCount", &LuaTangibleObject::setSocketCount},
----------------------------------------------------------------------
int LuaTangibleObject::isNoTrade(lua_State* L){
bool noTrade = realObject->isNoTrade();
lua_pushboolean(L, noTrade);
return 1;
}
// NEW CODE BELOW
int LuaTangibleObject::setSocketCount(lua_State* L){
int count = lua_tointeger(L, -1);
if (realObject->isWearableObject() && realObject != nullptr)
{
Locker locker(realObject);
WearableObject* wo = cast<WearableObject*>(realObject);
// Prevent over 4 sockets
if (count > 4)
{ count = 4; }
// Prevent trying to set negative sockets
if (count < 0)
{ count = 0; }
wo->setSockets(count);
}
return 0;
}
How to Use:
LUA EXAMPLE:
Code:
local pInventory = CreatureObject(pPLayer):getSlottedObject("inventory")
if (pInventory == nil) then
return 0
end
local pItem = giveItem(pInventory, "object/tangible/wearables/goggles/goggles_s01.iff", -1)
TangibleObject(pItem):setSocketCount(4);