LUA command creation help
Posted: Sun Jul 08, 2012 12:04 pm
Hello devs, I didn't see a lua command that would allow me to change the npc's equipment, so I figured I'd give it a stab even though I have never done C++ before. I was using the SpawnSet command as a guide and saw that I need a few things, the actual command in the luafunctions.cpp, to add it into the luafunctions.h, some slot values pre-set in the commands.cpp and a commands::setspawnequipment entry into the commands.cpp. Hoenstly, I have no idea if this is even remotely close to what should actually happen, but that was my analysis. Carrying on assuming I'm at least partially right, this is what I GUESSED might go in the LuaFunctions.cpp.
NOTE: I have never coded in C++ before and am totally unfamiliar with it, coder rage-mode inc. from devs xD
In LuaFunctions.h
In Commands.cpp
NOTE: I have never coded in C++ before and am totally unfamiliar with it, coder rage-mode inc. from devs xD
Code: Select all
int EQ2Emu_lua_SpawnEquip(lua_State* state){
if(!lua_interface)
return 0;
Spawn* spawn = lua_interface->GetSpawn(state);
string slot = commands.GetSpawnEquipmentID(variable);
string appid = lua_interface->GetStringValue(state, 2);
if(slot != 0xFFFFFFFF && appid.length() > 0 && spawn)
commands.SetSpawnEquipment(0, spawn, slot, appid.c_str());
return 0;
}
Code: Select all
int EQ2Emu_lua_SpawnEquip(lua_State* state);
Code: Select all
spawn_equip_values["1"] = SPAWN_SET_EQUIPMENT_PRIMARY;
spawn_equip_values["2"] = SPAWN_SET_EQUIPMENT_SECONDARY;
spawn_equip_values["4"] = SPAWN_SET_EQUIPMENT_HEAD;
spawn_equip_values["8"] = SPAWN_SET_EQUIPMENT_CHEST;
spawn_equip_values["16"] = SPAWN_SET_EQUIPMENT_SHOULDERS;
spawn_equip_values["32"] = SPAWN_SET_EQUIPMENT_FOREARMS;
spawn_equip_values["64"] = SPAWN_SET_EQUIPMENT_HANDS;
spawn_equip_values["128"] = SPAWN_SET_EQUIPMENT_LEGS;
spawn_equip_values["256"] = SPAWN_SET_EQUIPMENT_FEET;
spawn_equip_values["512"] = SPAWN_SET_EQUIPMENT_LRING;
spawn_equip_values["1024"] = SPAWN_SET_EQUIPMENT_RRING;
spawn_equip_values["2048"] = SPAWN_SET_EQUIPMENT_EAR1;
spawn_equip_values["4096"] = SPAWN_SET_EQUIPMENT_EAR2;
spawn_equip_values["8192"] = SPAWN_SET_EQUIPMENT_NECK;
spawn_equip_values["16384"] = SPAWN_SET_EQUIPMENT_LWRIST;
spawn_equip_values["32768"] = SPAWN_SET_EQUIPMENT_RWRIST;
spawn_equip_values["65536"] = SPAWN_SET_EQUIPMENT_RANGE;
spawn_equip_values["131072"] = SPAWN_SET_EQUIPMENT_AMMO;
spawn_equip_values["262144"] = SPAWN_SET_EQUIPMENT_WAIST;
spawn_equip_values["524288"] = SPAWN_SET_EQUIPMENT_CLOAK;
spawn_equip_values["1048576"] = SPAWN_SET_EQUIPMENT_CHARM1;
spawn_equip_values["2097152"] = SPAWN_SET_EQUIPMENT_CHARM2;
spawn_equip_values["4194304"] = SPAWN_SET_EQUIPMENT_FOOD;
spawn_equip_values["8388608"] = SPAWN_SET_EQUIPMENT_DRINK;
spawn_equip_values["16777216"] = SPAWN_SET_EQUIPMENT_TEXTURES;
Code: Select all
bool Commands::SetSpawnEquipment(Client* client, Spawn* target, int32 slot, int8 appid, bool send_update)
Not sure how to code the actual code of this ;p