unknownRanger
Banned User
- Joined
- Aug 7, 2016
- Messages
- 4
- Reaction score
- 14
Ever wanted to create your own monsters but just too damn lazy to create a new file?
Well now you can rename any monster in the game and just call it something else... great for those illusionist scripts.. more on that later
There is 2 options and both work, you can use either
or you can use
------------------------------------
monster.h
find this
place this right under it
next find this function
and replace it with this
next find this function
and replace it with this
next find this function
and replace it with this
Now underneath all that code place these functions
---------------------------------------
luascript.cpp
find this
and place this right underneath
find this
and place this right underneath
find this function
and place this right underneath
-----------------------------------
luascript.h
You can place these together in the monster section e.g. // Monster
Well now you can rename any monster in the game and just call it something else... great for those illusionist scripts.. more on that later
There is 2 options and both work, you can use either
Code:
setCreatureName(cid, name, description)
Code:
monster:setName(name, description)
------------------------------------
monster.h
find this
Code:
class Monster final : public Creature
{
public:
place this right under it
Code:
std::string name, nameDescription, altStrDesc;
next find this function
Code:
const std::string& getName() const final {
return mType->name;
}
and replace it with this
Code:
const std::string& getName() const final {
if (!name.empty()) {
return name;
}
return mType->name;
}
next find this function
Code:
const std::string& getNameDescription() const final {
return mType->nameDescription;
}
and replace it with this
Code:
const std::string& getNameDescription() const final {
if (nameDescription.empty()) {
return mType->nameDescription;
}
return nameDescription;
}
next find this function
Code:
std::string getDescription(int32_t) const final {
return strDescription + '.';
}
and replace it with this
Code:
std::string getDescription(int32_t) const final {
if (!altStrDesc.empty()) {
return altStrDesc + '.';
}
return strDescription + '.';
}
Now underneath all that code place these functions
Code:
void setName(std::string n) {
name = n;
}
void setDescription(std::string desc) {
nameDescription = desc;
}
void setStrDescription(std::string altdesc) {
altStrDesc = altdesc;
}
luascript.cpp
find this
Code:
registerMethod("Monster", "searchTarget", LuaScriptInterface::luaMonsterSearchTarget);
Code:
// monster:setName(name, description)
registerMethod("Monster", "setName", LuaScriptInterface::luaMonsterSetName);
find this
Code:
lua_register(luaState, "sendGuildChannelMessage", LuaScriptInterface::luaSendGuildChannelMessage);
Code:
//setCreatureName(cid, newName, newDescription)
lua_register(luaState, "setCreatureName", LuaScriptInterface::luaSetCreatureName);
find this function
Code:
int LuaScriptInterface::luaMonsterSearchTarget(lua_State* L)
and place this right underneath
Code:
int LuaScriptInterface::luaSetCreatureName(lua_State* L)
{
// setCreatureName(cid, name, description)
std::string newDesc = getString(L, 3);
std::string newName = getString(L, 2);
Creature* creature = getCreature(L, 1);
if (!creature) {
reportErrorFunc(getErrorDesc(LUA_ERROR_CREATURE_NOT_FOUND));
pushBoolean(L, false);
return 1;
}
Monster* monster = (Monster*)creature;
monster->setName(newName);
monster->setDescription(newDesc);
monster->setStrDescription(newDesc);
lua_pushboolean(L, true);
return 1;
}
int LuaScriptInterface::luaMonsterSetName(lua_State* L)
{
// monster:setName(name, description)
std::string newDesc = getString(L, 3);
std::string newName = getString(L, 2);
Monster* monster = getUserdata<Monster>(L, 1);
if (!monster) {
reportErrorFunc(getErrorDesc(LUA_ERROR_CREATURE_NOT_FOUND));
pushBoolean(L, false);
return 1;
}
monster->setName(newName);
monster->setDescription(newDesc);
monster->setStrDescription(newDesc);
lua_pushboolean(L, true);
return 1;
}
luascript.h
You can place these together in the monster section e.g. // Monster
Code:
// monster:setName(name, description)
static int luaMonsterSetName(lua_State* L);
//setCreatureName(cid, newName, newDescription)
static int luaSetCreatureName(lua_State* L);
Last edited: