• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Compiling Adding percentage of magic damage

8408323

Hoster
Joined
Mar 6, 2009
Messages
432
Reaction score
26
Hello, I'm trying to compile a server by my own.
And now I'm wondering if it is possible somehow to add magic damage, I don't know exactly how to add this code and in which .cpp file. With magic damage I mean that I should be able to write 2.0 and I will have 2.0 times more magic damage.
Or possibly if someone could make it (current magic damage)^1.9, so I just have to type that in config.lua

I've manage to the the same thing for all items, but I didn't succeed with magic attacks

I want this to be for all magic damage

But if someone can help me with that or know how to do that I would be very glad to use your help!

If that is possible I'll add it to config.lua, but isn't hard (I'll mange that by myself)
 
It's kinda easy to copy and paste to make this work with c++.
i am busy atm, but i'll try to publish it here soon as possible :)
 
I guess you could go to the TFS source and find it, since it has this option in xml folder/vocations.
<formula meleeDamage="1.0" distDamage="1.0" wandDamage="1.0" magDamage="2.0" magHealingDamage="1.0" defense="1.0" magDefense="1.0" armor="1.0"/>

I don't know how you're planning to compile your own server, it has to have a base atleast, and if it's tfs it should alredy be in there
 
Thanks, I'll try to search out of that, I'm planning to add a line in config.lua which will look like this:
Lua:
magicDamage = 2.0

Or something like that, it's might possible out of the information you gave me! :)
 
Hmm, if you wanted to make a variable in config.lua then it's not what I thought. I thought you would increase/reduce "magicDamage" phase in vocations.xml with a command. So you can use it in creaturescripts while someone attacks or something :)

But if you want it, here it is: (C++)

Find this in player.cpp
[cpp]lastAttack = idleTime = marriage = blessings = balance = premiumDays = mana = manaMax = manaSpent = 0;[/cpp]

and add this to the pattern:
[cpp]addMagDmg = 0[/cpp]

Find this:
[cpp]void Player::unlearnInstantSpell(const std::string& name)[/cpp]

and add this after the function:
[cpp]uint32_t Player::getAddMagDmg()
{
return vocation->getMultiplier(MULTIPLIER_MAGIC) + getPlayer()->getPlayerMagicDamage();
}
[/Cpp]

at the end of the file (player.cpp)
[cpp]void Player::setPlayerMagicDamage(uint32_t mult)
{
addMagDmg = mult;
}[/cpp]

Now in player.h

Find:
[cpp]uint64_t getSpentMana() const {return manaSpent;}[/cpp]

below it, paste: [cpp]uint32_t getPlayerMagicDamage() const {return addMagDmg;}
void setPlayerMagicDamage(uint32_t mult);[/cpp]

Below:[cpp] uint32_t town;[/cpp]
add this:[cpp]uint32_t addMagDmg;[/cpp]

Now in, luascript.cpp, find this:
[cpp]int32_t LuaScriptInterface::luaGetPlayerMoney(lua_State* L)
{
//getPlayerMoney(cid)
ScriptEnviroment* env = getEnv();
if(Player* player = env->getPlayerByUID(popNumber(L)))
lua_pushnumber(L, g_game.getMoney(player));
else
{
errorEx(getError(LUA_ERROR_PLAYER_NOT_FOUND));
lua_pushboolean(L, false);
}
return 1;
}[/cpp]

and paste this below it:
[cpp]int32_t LuaInterface::luaDoPlayerSetMagicDamage(lua_State *L)
{
uint32_t mult = popNumber(L);
ScriptEnviroment* env = getEnv();
if(Player* player = env->getPlayerByUID(popNumber(L))){
player->setPlayerMagicDamage(mult);
lua_pushnumber(L, true);
}
else{
errorEx(getError(LUA_ERROR_PLAYER_NOT_FOUND));
lua_pushnumber(L, false);
}
return 1;
}[/cpp]

Find:
[cpp] //getPlayerMoney(cid)
lua_register(m_luaState, "getPlayerMoney", LuaScriptInterface::luaGetPlayerMoney);
[/cpp]

And paste this below:
[cpp] //doPlayerAddMagicDamage(cid)
lua_register(m_luaState, "doPlayerSetMagicDamage", LuaScriptInterface::luaDoPlayerSetMagicDamage);
[/cpp]
Now in, luascript.h:

Below: [cpp] static int32_t luaGetPlayerMoney(lua_State* L);[/cpp]
add [cpp] static int32_t luaDoPlayerSetMagicDamage(lua_State* L);[/cpp]

And done!
Now you can use, "doPlayerSetMagicDamage(cid)" :D

Example:
Lua:
function onAttack(cid, target)
	doPlayerSetMagicDamage(cid, 1)
	return true
end

That will add 100% more magic damage :D
I hope you understand the pattern, 1-100% 0.5 = 50% and so on.
 
Last edited:
Code:
Warning	1	warning C4390: ';' : empty controlled statement found; is this the intent?	C:\Users\<user>\Desktop\8.60 source\connection.cpp	237
Warning	2	warning C4390: ';' : empty controlled statement found; is this the intent?	C:\Users\<user>\Desktop\8.60 source\connection.cpp	242
Error	3	error C2653: 'LuaInterface' : is not a class or namespace name	C:\Users\<user>\Desktop\8.60 source\luascript.cpp	4936
Error	4	error C3861: 'popNumber': identifier not found	C:\Users\<user>\Desktop\8.60 source\luascript.cpp	4938
Error	5	error C3861: 'getEnv': identifier not found	C:\Users\<user>\Desktop\8.60 source\luascript.cpp	4939
Error	6	error C3861: 'popNumber': identifier not found	C:\Users\<user>\Desktop\8.60 source\luascript.cpp	4940
Error	7	error C2065: 'mult' : undeclared identifier	C:\Users\<user>\Desktop\8.60 source\luascript.cpp	4941
Error	8	error C3861: 'error': identifier not found	C:\Users\<user>\Desktop\8.60 source\luascript.cpp	4945
Error	9	error C3861: 'getError': identifier not found	C:\Users\<user>\Desktop\8.60 source\luascript.cpp	4945
Error	10	error C2146: syntax error : missing ';' before identifier 'addMagDmg'	C:\Users\<user>\Desktop\8.60  source\player.cpp	71
Error	11	error C2039: 'getAddMagDmg' : is not a member of 'Player'	C:\Users\<user>\Desktop\8.60 source\player.cpp	4191
Error	12	error C2601: 'getAddMagDmg' : local function definitions are illegal	C:\Users\<user>\Desktop\8.60 source\player.cpp	4192
Error	13	error C2065: 'vocation' : undeclared identifier	C:\Users\<user>\Desktop\8.60 source\player.cpp	4193
Error	14	error C2227: left of '->getMultiplier' must point to class/struct/union/generic type	C:\Users\<user>\Desktop\8.60 source\player.cpp	4193
Error	15	error C2227: left of '->getPlayerMagicDamage' must point to class/struct/union/generic type	C:\Users\<user>\Desktop\8.60  source\player.cpp	4193
Error	16	error C3861: 'getPlayer': identifier not found	C:\Users\<user>\Desktop\8.60 source\player.cpp	4193
Warning	17	warning C4244: 'argument' : conversion from 'uint16_t' to 'uint8_t', possible loss of data	c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\boost\bind\bind.hpp	447
Warning	18	warning C4244: 'argument' : conversion from 'uint16_t' to 'uint8_t', possible loss of data	c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\boost\bind\bind.hpp	660
Warning	19	warning C4244: 'argument' : conversion from 'uint16_t' to 'uint8_t', possible loss of data	c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\boost\bind\bind.hpp	660
Warning	20	warning C4244: 'argument' : conversion from 'uint16_t' to 'uint8_t', possible loss of data	c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\boost\bind\bind.hpp	515
Warning	21	warning C4244: 'argument' : conversion from 'uint16_t' to 'uint8_t', possible loss of data	c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\boost\bind\bind.hpp	515
	22	IntelliSense: name followed by '::' must be a class or namespace name	c:\users\<user>\desktop\8.60 source\luascript.cpp	4936
	23	IntelliSense: identifier "popNumber" is undefined	c:\users\<user>\desktop\8.60 source\luascript.cpp	4938
	24	IntelliSense: identifier "getEnv" is undefined	c:\users\<user>\desktop\8.60 source\luascript.cpp	4939
	25	IntelliSense: identifier "mult" is undefined	c:\users\<user>\desktop\8.60 source\luascript.cpp	4941
	26	IntelliSense: identifier "getError" is undefined	c:\users\<user>\desktop\8.60 source\luascript.cpp	4945

Well some are warnings and I believe I had some of the warnings before I changed this above, almost all of them i think.
I'm very thankful for your help, I'm not sure how to fix these errors. Maybe you can help me out with that :)
 
Last edited:
I've tried to solve these error by myself now, but I haven't succeeded yet, I'm still learining c++

B
U
M
P
 
Last edited:
Well, I can do that, but it won't work for all magic damage, right? It will just work for spell damage. I would like to add into config.lua so I have one line there which I can change the damage of all magic.
 
Back
Top