Feature [TFS 1.3] Monster Levels

Piquenoelmal

I'm in an eternal depression
Joined
Dec 1, 2009
Messages
28
Reaction score
4
Location
Void
You have to change this piece of code:

C++:
float ConfigManager::getGlobalFloat(lua_State* L, const char* identifier, [B]const float defaultValue = 0.0f[/B])
For this one:
C++:
float ConfigManager::getGlobalFloat(lua_State* L, const char* identifier, [B]const float defaultValue[/B])
The function is already receiving the float defaultValue, so it does not have to pass it again. Well, at least in my VS showed me this error and I fixed in that way.

i couldn't ind it at all :S
Pretty sure that @Vulcan_ is talking about this one, just go to Branch and found the "master" and download.
 

delita123

Member
Joined
Mar 7, 2017
Messages
102
Reaction score
18
Hey @Vulcan_ , how are you ?
I'm trying to compile your system in my tfs 1.3, and everything seems to run well until the final moment. Can you help me ?

Code:
1>------ Rebuild All started: Project: theforgottenserver, Configuration: Release x64 ------
1>otpch.cpp
1>account.cpp
1>actions.cpp
1>ban.cpp
1>baseevents.cpp
1>bed.cpp
1>chat.cpp
1>combat.cpp
1>condition.cpp
1>configmanager.cpp
1>connection.cpp
1>container.cpp
1>creature.cpp
1>creatureevent.cpp
1>cylinder.cpp
1>database.cpp
1>databasemanager.cpp
1>databasetasks.cpp
1>depotchest.cpp
1>depotlocker.cpp
1>events.cpp
1>fileloader.cpp
1>game.cpp
1>gamestore.cpp
1>globalevent.cpp
1>groups.cpp
1>guild.cpp
1>house.cpp
1>inbox.cpp
1>ioguild.cpp
1>iologindata.cpp
1>iomap.cpp
1>iomapserialize.cpp
1>iomarket.cpp
1>item.cpp
1>items.cpp
1>luascript.cpp
1>mailbox.cpp
1>map.cpp
1>modules.cpp
1>monster.cpp
1>monsters.cpp
1>mounts.cpp
1>movement.cpp
1>networkmessage.cpp
1>npc.cpp
1>otserv.cpp
1>outfit.cpp
1>outputmessage.cpp
1>party.cpp
1>player.cpp
1>position.cpp
1>protocol.cpp
1>protocolgame.cpp
1>protocolgamebase.cpp
1>protocollogin.cpp
1>protocolold.cpp
1>protocolspectator.cpp
1>protocolstatus.cpp
1>quests.cpp
1>raids.cpp
1>reward.cpp
1>rewardchest.cpp
1>rsa.cpp
1>scheduler.cpp
1>scriptmanager.cpp
1>server.cpp
1>signals.cpp
1>spawn.cpp
1>spells.cpp
1>talkaction.cpp
1>tasks.cpp
1>teleport.cpp
1>thing.cpp
1>tile.cpp
1>tools.cpp
1>trashholder.cpp
1>vocation.cpp
1>waitlist.cpp
1>weapons.cpp
1>wildcardtree.cpp
1>monster.obj : error LNK2001: unresolved external symbol "public: virtual bool __cdecl Monster::getCombatValues(int &,int &)" ([email protected]@@[email protected])
1>C:\Users\holy\Desktop\projeto342\vc14\x64\Release\theforgottenserver.exe : fatal error LNK1120: 1 unresolved externals
1>Done building project "theforgottenserver.vcxproj" -- FAILED.
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========
 

Fresh

Quack!
Joined
Oct 21, 2009
Messages
1,539
Reaction score
129
Location
Poland
Is there any way to add bonus experience when monster got his level?
 

silveralol

Veteran OT User
Joined
Mar 16, 2010
Messages
1,465
Reaction score
182
Is there any way to add bonus experience when monster got his level?
just an idea, you can make a function to use: monster:getLevel(), then you create a condition in events
function Player:eek:nGainExperience(source, exp, rawExp)
so, here are, one way...
 

Fresh

Quack!
Joined
Oct 21, 2009
Messages
1,539
Reaction score
129
Location
Poland
i want to do it. but....
no idea :z
One of i think few ways of adding experience based on thread author code

data/events/events.xml
Code:
<event class="Player" method="onGainExperience" enabled="1" />
data/events/scripts/player.lua
Change or Add (idk. depends on your choice and reading of whole function etc.) in Player:eek:nGainExperience(source, exp, rawExp) function:
Code:
    if source:isMonster() and source:getLevel() > 0 then
    exp = (((exp * Game.getExperienceStage(self:getLevel()))/2) * source:getLevel())
    else
    exp = exp * Game.getExperienceStage(self:getLevel())
    end

Code:
exp = (((exp * Game.getExperienceStage(self:getLevel()))/2) * source:getLevel())
It will return formula: Original Exp that you set in monster.xml file * YourStagedCharacterLevel / 2 * killedmonsterLevel
Else if monster dont have level it will return normal exp that you set in monster.xml file.

Of course you can edit this formula by yourself.
 

tatibano

New Member
Joined
Jul 18, 2012
Messages
10
Reaction score
0
wow. very good
I'm trying to implement here but the "source: getLevel ()" returns nil

attempt to call method 'getLevel' (a nil value)
stack traceback:



One of i think few ways of adding experience based on thread author code

data/events/events.xml
Code:
<event class="Player" method="onGainExperience" enabled="1" />
data/events/scripts/player.lua
Change or Add (idk. depends on your choice and reading of whole function etc.) in Player:eek:nGainExperience(source, exp, rawExp) function:
Code:
    if source:isMonster() and source:getLevel() > 0 then
    exp = (((exp * Game.getExperienceStage(self:getLevel()))/2) * source:getLevel())
    else
    exp = exp * Game.getExperienceStage(self:getLevel())
    end

Code:
exp = (((exp * Game.getExperienceStage(self:getLevel()))/2) * source:getLevel())
It will return formula: Original Exp that you set in monster.xml file * YourStagedCharacterLevel / 2 * killedmonsterLevel
Else if monster dont have level it will return normal exp that you set in monster.xml file.

Of course you can edit this formula by yourself.
 

Fresh

Quack!
Joined
Oct 21, 2009
Messages
1,539
Reaction score
129
Location
Poland
wow. very good
I'm trying to implement here but the "source: getLevel ()" returns nil

attempt to call method 'getLevel' (a nil value)
stack traceback:
You added in C++ (Sources) the whole code from first post in this thread? It seems that you won't added it.
 

tatibano

New Member
Joined
Jul 18, 2012
Messages
10
Reaction score
0
yea.
here is the look of an ordinary player:

15:07 You see a rotworm, it is level 79.
15:07 You see a rotworm, it is level 5.

here is the look of gm:

15:09 You see a rotworm, it is level 21.
Health: 747 / 747.
Position: 32369, 32195, 8

and here the "error" on kill a monster:

data/events/scripts/player.lua:938: attempt to call method 'getLevel' (a nil value)
stack traceback:
[C]: in function 'getLevel'
data/events/scripts/player.lua:938: in function <data/events/scripts/player.lua:925>
 

Westwol

Member
Joined
Sep 19, 2018
Messages
47
Reaction score
12
yea.
here is the look of an ordinary player:

15:07 You see a rotworm, it is level 79.
15:07 You see a rotworm, it is level 5.

here is the look of gm:

15:09 You see a rotworm, it is level 21.
Health: 747 / 747.
Position: 32369, 32195, 8

and here the "error" on kill a monster:

data/events/scripts/player.lua:938: attempt to call method 'getLevel' (a nil value)
stack traceback:
[C]: in function 'getLevel'
data/events/scripts/player.lua:938: in function <data/events/scripts/player.lua:925>
luascript.cpp
Below:
Code:
registerMethod("Monster", "getType", LuaScriptInterface::luaMonsterGetType);
Add:
Code:
registerMethod("Monster", "getMonsterLevel", LuaScriptInterface::luaMonsterGetLevel);
Below:
Code:
int LuaScriptInterface::luaMonsterGetType(lua_State* L)
{
    // monster:getType()
    const Monster* monster = getUserdata<const Monster>(L, 1);
    if (monster) {
        pushUserdata<MonsterType>(L, monster->mType);
        setMetatable(L, -1, "MonsterType");
    } else {
        lua_pushnil(L);
    }
    return 1;
}
Add:
Code:
int LuaScriptInterface::luaMonsterGetLevel(lua_State* L)
{
    // monster:getMonsterLevel()
    const Monster* monster = getUserdata<const Monster>(L, 1);
    if (monster) {
        lua_pushnumber(L, monster->getLevel());
    } else {
        lua_pushnil(L);
    }
    return 1;
}
luascript.h
Below:
Code:
static int luaMonsterGetType(lua_State* L);
Add:
Code:
static int luaMonsterGetLevel(lua_State * L);
events/scripts/player.lua in
Code:
function Player:onGainExperience(source, exp, rawExp)
Code:
if source:isMonster() then
        local bonusExperience = source:getMonsterLevel() * 0.03
        if source:getMonsterLevel() > 0 and bonusExperience > 1 then
            exp = exp * bonusExperience
        end
    end
 

tatibano

New Member
Joined
Jul 18, 2012
Messages
10
Reaction score
0
It work. yayyy :)))

luascript.cpp
Below:
Code:
registerMethod("Monster", "getType", LuaScriptInterface::luaMonsterGetType);
Add:
Code:
registerMethod("Monster", "getMonsterLevel", LuaScriptInterface::luaMonsterGetLevel);
Below:
Code:
int LuaScriptInterface::luaMonsterGetType(lua_State* L)
{
    // monster:getType()
    const Monster* monster = getUserdata<const Monster>(L, 1);
    if (monster) {
        pushUserdata<MonsterType>(L, monster->mType);
        setMetatable(L, -1, "MonsterType");
    } else {
        lua_pushnil(L);
    }
    return 1;
}
Add:
Code:
int LuaScriptInterface::luaMonsterGetLevel(lua_State* L)
{
    // monster:getMonsterLevel()
    const Monster* monster = getUserdata<const Monster>(L, 1);
    if (monster) {
        lua_pushnumber(L, monster->getLevel());
    } else {
        lua_pushnil(L);
    }
    return 1;
}
luascript.h
Below:
Code:
static int luaMonsterGetType(lua_State* L);
Add:
Code:
static int luaMonsterGetLevel(lua_State * L);
events/scripts/player.lua in
Code:
function Player:onGainExperience(source, exp, rawExp)
Code:
if source:isMonster() then
        local bonusExperience = source:getMonsterLevel() * 0.03
        if source:getMonsterLevel() > 0 and bonusExperience > 1 then
            exp = exp * bonusExperience
        end
    end
 

ScorpionOT

uber n00b
Joined
Mar 28, 2015
Messages
233
Reaction score
42
this missing lot of things, such sa spell increase mod for instance ... and loot stats. there are better codes about this
 
OP
Stigma

Stigma

Veteran OT User
Joined
Feb 14, 2015
Messages
4,401
Reaction score
1,977
"did not work" tells me nothing
i can't help if you don't show any errors or any other information about why it doesn't work
 

RoyalYeta

New Member
Joined
Sep 28, 2018
Messages
25
Reaction score
2
after adding the code to sources, I do not want to compile
I do not have SS. I use otx 3
 
Top