• 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!

Lua Lua Check if is offencive/balanced/defensive fight

dudie

Member
Joined
May 23, 2016
Messages
128
Reaction score
12
I wanna control damages in LUA scripts like
How to check if player attack mode is offencive,balanced and defensive like this script?

Code:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_BLOCKARMOR, 1)
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)

function onGetFormulaValues(cid, level, skill, attack, factor)
   local formulamin = 0.01
   local formulamax = 0.02

   if player fight mode == offensive then
     formulamin = formulamin * 3
     formulamax = formulamax * 3
   elseif player fight mode == balanced then
     formulamin = formulamin * 2
     formulamax = formulamax * 2
   elseif player fight mode == defensive then
     formulamin = formulamin * 1
     formulamax = formulamax * 1
   min = ((formulamin) * (attack) * (skill)) * -1
   max = ((formulamax) * (attack) * (skill)) * -1
   return min, max
end
setCombatCallback(combat, CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues")

function onUseWeapon(cid, var)
   return doCombat(cid, combat, var)
end
 
I wanna control damages in LUA scripts like
How to check if player attack mode is offencive,balanced and defensive like this script?

Code:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_BLOCKARMOR, 1)
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)

function onGetFormulaValues(cid, level, skill, attack, factor)
   local formulamin = 0.01
   local formulamax = 0.02

   if player fight mode == offensive then
     formulamin = formulamin * 3
     formulamax = formulamax * 3
   elseif player fight mode == balanced then
     formulamin = formulamin * 2
     formulamax = formulamax * 2
   elseif player fight mode == defensive then
     formulamin = formulamin * 1
     formulamax = formulamax * 1
   min = ((formulamin) * (attack) * (skill)) * -1
   max = ((formulamax) * (attack) * (skill)) * -1
   return min, max
end
setCombatCallback(combat, CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues")

function onUseWeapon(cid, var)
   return doCombat(cid, combat, var)
end
There is no such function you have to create it.
 
I made... If other want to use:
protocolgame.cpp
Code:
void ProtocolGame::parseFightModes(NetworkMessage& msg)
{
   uint8_t rawFightMode = msg.get<char>(); //1 - offensive, 2 - balanced, 3 - defensive
   uint8_t rawChaseMode = msg.get<char>(); //0 - stand while fightning, 1 - chase opponent
   uint8_t rawSecureMode = msg.get<char>(); //0 - can't attack unmarked, 1 - can attack unmarked

   chaseMode_t chaseMode = CHASEMODE_STANDSTILL;
   if(rawChaseMode == 1)
     chaseMode = CHASEMODE_FOLLOW;


   fightMode_t fightMode = FIGHTMODE_ATTACK;
   if(rawFightMode == 2)
   {
     fightMode = FIGHTMODE_BALANCED;
     player->setStorage(2000, "2");
   }
   else if(rawFightMode == 3)
   {
     fightMode = FIGHTMODE_DEFENSE;
     player->setStorage(2000, "3");
   }
   else
   {
     fightMode = FIGHTMODE_ATTACK;
     player->setStorage(2000, "1");
   }


   secureMode_t secureMode = SECUREMODE_OFF;
   if(rawSecureMode == 1)
     secureMode = SECUREMODE_ON;

   addGameTaskTimed(DISPATCHER_TASK_EXPIRATION, &Game::playerSetFightModes, player->getID(), fightMode, chaseMode, secureMode);
}


after just check storage... ty all from forum, i made searching here
 
Check the number value of the paramter factor in:
Code:
onGetFormulaValues(cid, level, skill, attack, factor)

If the number value of factor is 2 then the mode is Defensive.
If the number value of factor is 1.2 then the mode is Balanced.
If the number value of factor is 1 then the mode is Offensive.

There's also this: https://github.com/otland/forgottenserver/pull/1564
 
There is no such function you have to create it.

No offense man, but next time, say only if you really know

Check the number value of the paramter factor in:
Code:
onGetFormulaValues(cid, level, skill, attack, factor)

If the number value of factor is 2 then the mode is Defensive.
If the number value of factor is 1.2 then the mode is Balanced.
If the number value of factor is 1 then the mode is Offensive.

There's also this: https://github.com/otland/forgottenserver/pull/1564

Ty, its the way :)
 
No offense man, but next time, say only if you really know



Ty, its the way :)
And what was wrong in what I said? I said there isn't a function in Lua to get the fightMode of a player... and there isn't.

That is a PARAMETER and it may work for your case as it's a spell.
 
Back
Top