Lua Function Change Existing Monster Name In-Game

Moj mistrz

Monster Creator
Joined
Feb 1, 2008
Messages
926
Best answers
8
Reaction score
271
Location
Poland
Does it work for TFS[1.2]?
If not (can't confirm myself, because I never compiled anything) then can someone update it?
 

Codex NG

Recurrent Flamer
Joined
Jul 24, 2015
Messages
2,998
Best answers
11
Reaction score
1,526
Does it work for TFS[1.2]?
If not (can't confirm myself, because I never compiled anything) then can someone update it?
Printer said some time ago that it is possible you just need to update the spectators list, however he did not go into much more detail than that.
 

Flatlander

Species Developer
Joined
Feb 17, 2009
Messages
2,458
Best answers
3
Reaction score
1,284
Location
Texas
From what I remember, the client saves the creature name when the creature first appears.

This means, the only way to update the creature's name is to have it teleport off screen, and back on screen (Or maybe just teleport at all). Unless you want to edit the client source parse, and tfs protocol, so it can send updated names each time it updates the character.
 

Black123

Member
Joined
Nov 17, 2011
Messages
32
Best answers
0
Reaction score
0
From what I remember, the client saves the creature name when the creature first appears.

This means, the only way to update the creature's name is to have it teleport off screen, and back on screen (Or maybe just teleport at all). Unless you want to edit the client source parse, and tfs protocol, so it can send updated names each time it updates the character.
I've got errors while compiling.. tried 3 times and everytime errors :/
 

Itutorial

Premium User
Premium User
Joined
Dec 23, 2014
Messages
1,478
Best answers
32
Reaction score
326
For this to work on TFS 1.2

Monster.h

find
Code:
const std::string& getName() const final {
replace the 3 codes with this:
Code:
const std::string& getName() const final {
            return name;
        }
        const std::string& getNameDescription() const final {
            return nameDescription;
        }
        std::string getDescription(int32_t) const final {
            return nameDescription + '.';
        }
Luascript.h

find
Code:
static int luaSetItemOutfit(lua_State* L);
add this under it:
Code:
static int luaSetCreatureName(lua_State* L);
luascript.cpp

find:
Code:
int LuaScriptInterface::luaSetCreatureOutfit(lua_State* L)
{
    //doSetCreatureOutfit(cid, outfit, time)
    Creature* creature = getCreature(L, 1);
    if (!creature) {
        reportErrorFunc(getErrorDesc(LUA_ERROR_CREATURE_NOT_FOUND));
        pushBoolean(L, false);
        return 1;
    }

    Outfit_t outfit = getOutfit(L, 2);
    int32_t time = getNumber<int32_t>(L, 3);
    pushBoolean(L, Spell::CreateIllusion(creature, outfit, time) == RETURNVALUE_NOERROR);
    return 1;
}
Under that paste this:

Code:
int LuaScriptInterface::luaSetCreatureName(lua_State* L)
{
    //setCreatureName(cid, newName, newDescription)
    Creature* creature = getCreature(L, 1);
    if (creature) {
        Monster* monster = (Monster*)creature;
        std::string newName = getString(L, 2);
        std::string newDesc = getString(L, 3);
        monster->name = newName;
        monster->nameDescription = newDesc;
        pushBoolean(L, false);
    }
    else {
        reportErrorFunc(getErrorDesc(LUA_ERROR_CREATURE_NOT_FOUND));
        pushBoolean(L, false);
    }
    return 1;
}

find
Code:
//doSetCreatureOutfit(cid, outfit, time)
    lua_register(luaState, "doSetCreatureOutfit", LuaScriptInterface::luaSetCreatureOutfit);
Under add this:
Code:
//setCreatureName(cid, name, description)
    lua_register(luaState, "setCreatureName", LuaScriptInterface::luaSetCreatureName);

Enjoy... Works the same.
 

Itutorial

Premium User
Premium User
Joined
Dec 23, 2014
Messages
1,478
Best answers
32
Reaction score
326
Make sure you still add

Code:
std::string name, nameDescription;
In the same spot.
 

Itutorial

Premium User
Premium User
Joined
Dec 23, 2014
Messages
1,478
Best answers
32
Reaction score
326
could you help me please?
where should i put this?

thanks in advice!!
Look on the thread owners tutorial and look for where its placed. Put it in the same spot as he did.
 

Ovnyx

Member
Joined
Jul 25, 2017
Messages
153
Best answers
2
Reaction score
7
Look on the thread owners tutorial and look for where its placed. Put it in the same spot as he did.
firstable thanks for your answer, going to take a look, bless!
 

ConAn Edujawa

Member
Joined
Feb 23, 2015
Messages
303
Best answers
0
Reaction score
4
anyone know why ?? when use this monster wont spawn again when die ??? tfs 0.4
 

ConAn Edujawa

Member
Joined
Feb 23, 2015
Messages
303
Best answers
0
Reaction score
4
anyone know why ??
when use this monster wont spawn again ??? im use tfs 0.4
 
Top