El Man
«لَا إِلَٰهَ إِلَّا ٱللَّٰهُ»
- Joined
- Mar 23, 2013
- Messages
- 161
- Reaction score
- 33
This is my third post for formula and problem still not fixed .. need someone help me to fix it .. my problem is : damage formula is error in spells and in weapons too like i write this damage in weapons
and after run server and test formula the damage is less than i wrote = ( 900,855 ) i think its work by level players! and spells too have same errors
Version : OTX
combat.cpp
luascript.cpp
Lua:
setCombatFormula(combat, COMBAT_FORMULA_LEVELMAGIC, 0, -14500000, 0, -15500000)
Version : OTX
Post automatically merged:
combat.cpp
C++:
Combat::Combat()
{
params.valueCallback = NULL;
params.tileCallback = NULL;
params.targetCallback = NULL;
area = NULL;
formulaType = FORMULA_UNDEFINED;
mina = 0.0;
minb = 0.0;
maxa = 0.0;
maxb = 0.0;
}
Combat::~Combat()
{
for(std::list<const Condition*>::iterator it = params.conditionList.begin(); it != params.conditionList.end(); ++it)
delete (*it);
params.conditionList.clear();
delete area;
delete params.valueCallback;
delete params.tileCallback;
delete params.targetCallback;
}
bool Combat::getMinMaxValues(Creature* creature, Creature* target, CombatParams& _params, int32_t& min, int32_t& max) const
{
if(creature)
{
if(creature->getCombatValues(min, max))
return true;
if(Player* player = creature->getPlayer())
{
if(params.valueCallback)
{
params.valueCallback->getMinMaxValues(player, _params, min, max);
return true;
}
min = max = 0;
switch(formulaType)
{
case FORMULA_LEVELMAGIC:
{
max = (int32_t)((player->getLevel() * 2 + player->getMagicLevel() * 3) * 1. * mina + minb);
min = (int32_t)((player->getLevel() * 2 + player->getMagicLevel() * 3) * 1. * maxa + maxb);
player->increaseCombatValues(min, max, params.useCharges, true);
return true;
}
case FORMULA_SKILL:
{
Item* item = player->getWeapon(false);
if(const Weapon* weapon = g_weapons->getWeapon(item))
{
_params.element.type = item->getElementType();
if(_params.element.type != COMBAT_NONE)
{
_params.element.damage = weapon->getWeaponElementDamage(player, item, true);
_params.element.damage = random_range((int32_t)0, (int32_t)(_params.element.damage * maxa + maxb), DISTRO_NORMAL);
}
max = (int32_t)(weapon->getWeaponDamage(player, target, item, true) * maxa + maxb);
if(params.useCharges && item->hasCharges() && g_config.getBool(ConfigManager::REMOVE_WEAPON_CHARGES))
g_game.transformItem(item, item->getID(), std::max((int32_t)0, ((int32_t)item->getCharges()) - 1));
}
else
max = (int32_t)maxb;
return true;
}
case FORMULA_VALUE:
{
min = (int32_t)mina;
max = (int32_t)maxa;
return true;
}
default:
min = max = 0;
break;
}
return false;
}
}
if(formulaType != FORMULA_VALUE)
return false;
min = (int32_t)mina;
max = (int32_t)maxa;
return true;
}
luascript.cpp
C++:
int32_t LuaInterface::luaSetCombatFormula(lua_State* L)
{
//setCombatFormula(combat, type, mina, minb, maxa, maxb)
ScriptEnviroment* env = getEnv();
if(env->getScriptId() != EVENT_ID_LOADING){
errorEx("This function can only be used while loading the script");
lua_pushboolean(L, false);
return 1;
}
double maxb = popFloatNumber(L);
double maxa = popFloatNumber(L);
double minb = popFloatNumber(L);
double mina = popFloatNumber(L);
formulaType_t type = (formulaType_t)popNumber(L);
uint32_t combatId = popNumber(L);
Combat* combat = env->getCombatObject(combatId);
if(combat){
combat->setPlayerCombatValues(type, mina, minb, maxa, maxb);
lua_pushboolean(L, true);
}
else{
errorEx(getError(LUA_ERROR_COMBAT_NOT_FOUND));
lua_pushboolean(L, false);
}
return 1;
}
Post automatically merged:
XML:
Vocation.xml
<?xml version="1.0" encoding="UTF-8"?>
<vocations>
<vocation id="0" name="None" description="none" needpremium="0" gaincap="5" gainhp="5" gainmana="5" gainhpticks="6" gainhpamount="1" gainmanaticks="6" gainmanaamount="2" manamultiplier="4.0" attackspeed="2000" soulmax="100" gainsoulticks="120" fromvoc="0" attackable="no">
<formula meleeDamage="1.0" distDamage="1.0" wandDamage="1.0" magDamage="1.0" magHealingDamage="1.0" defense="1.0" magDefense="1.0" armor="1.0"/>
<skill fist="1.5" club="2.0" sword="2.0" axe="2.0" distance="2.0" shielding="1.5" fishing="1.1" experience="1.0"/>
</vocation>
<vocation id="1" name="Sorcerer" description="a sorcerer" needpremium="0" gaincap="10" gainhp="5" gainmana="30" gainhpticks="6" gainhpamount="1" gainmanaticks="1" gainmanaamount="100" manamultiplier="1.158" attackspeed="450" soulmax="100" gainsoulticks="120" fromvoc="1">
<formula meleeDamage="1.0" distDamage="1.0" wandDamage="1.0" magDamage="1.0" magHealingDamage="1.0" defense="1.0" magDefense="1.0" armor="1.0"/>
<skill fist="1.5" club="2.0" sword="2.0" axe="2.0" distance="2.0" shielding="1.5" fishing="1.1" experience="1.0"/>
</vocation>
<vocation id="2" name="Druid" description="a Druid" needpremium="0" gaincap="10" gainhp="8" gainmana="30" gainhpticks="6" gainhpamount="1" gainmanaticks="1" gainmanaamount="100" manamultiplier="1.158" attackspeed="450" soulmax="100" gainsoulticks="120" fromvoc="2">
<formula meleeDamage="1.0" distDamage="1.0" wandDamage="1.0" magDamage="1.0" magHealingDamage="1.0" defense="1.0" magDefense="1.0" armor="1.0"/>
<skill fist="1.5" club="2.0" sword="2.0" axe="2.0" distance="2.0" shielding="1.5" fishing="1.1" experience="1.0"/>
</vocation>
<vocation id="3" name="Paladin" description="a Paladin" needpremium="0" gaincap="20" gainhp="12" gainmana="17" gainhpticks="4" gainhpamount="1" gainmanaticks="1" gainmanaamount="100" manamultiplier="2.0" attackspeed="450" soulmax="100" gainsoulticks="120" fromvoc="3">
<formula meleeDamage="1.0" distDamage="1.0" wandDamage="1.0" magDamage="1.0" magHealingDamage="1.0" defense="1.0" magDefense="1.0" armor="1.0"/>
<skill fist="1.5" club="2.0" sword="2.0" axe="2.0" distance="2.0" shielding="1.5" fishing="1.1" experience="1.0"/>
</vocation>
<vocation id="4" name="Knight" description="a knight" needpremium="0" gaincap="25" gainhp="18" gainmana="5" gainhpticks="3" gainhpamount="100" gainmanaticks="1" gainmanaamount="10" manamultiplier="3.2" attackspeed="450" soulmax="100" gainsoulticks="120" fromvoc="4">
<formula meleeDamage="1.0" distDamage="1.0" wandDamage="1.0" magDamage="1.0" magHealingDamage="1.0" defense="1.0" magDefense="1.0" armor="1.0"/>
<skill fist="1.1" club="1.1" sword="1.3" axe="1.1" distance="1.4" shielding="1.1" fishing="1.1" experience="1.0"/>
</vocation>
<vocation id="5" name="Master Sorcerer" description="a master sorcerer" needpremium="0" gaincap="10" gainhp="5" gainmana="30" gainhpticks="4" gainhpamount="10" gainmanaticks="1" gainmanaamount="100" manamultiplier="1.158" attackspeed="325" soulmax="200" gainsoulticks="15" fromvoc="1" >
<formula meleeDamage="1.0" distDamage="1.0" wandDamage="1.0" magDamage="1.0" magHealingDamage="1.0" defense="1.0" magDefense="1.0" armor="1.0"/>
<skill fist="1.5" club="2.0" sword="2.0" axe="2.0" distance="2.0" shielding="1.5" fishing="1.1" experience="1.0"/>
</vocation>
<vocation id="6" name="Elder Druid" description="a Elder Druid" needpremium="0" gaincap="15" gainhp="5" gainmana="30" gainhpticks="4" gainhpamount="10" gainmanaticks="1" gainmanaamount="100" manamultiplier="1.158" attackspeed="325" soulmax="200" gainsoulticks="15" fromvoc="2">
<formula meleeDamage="1.0" distDamage="1.0" wandDamage="1.0" magDamage="1.0" magHealingDamage="1.0" defense="1.0" magDefense="1.0" armor="1.0"/>
<skill fist="1.5" club="2.0" sword="2.0" axe="2.0" distance="2.0" shielding="1.5" fishing="1.1" experience="1.0"/>
</vocation>
<vocation id="7" name="Royal Paladin" description="a royal paladin" needpremium="0" gaincap="20" gainhp="12" gainmana="17" gainhpticks="3" gainhpamount="10" gainmanaticks="100" gainmanaamount="100" manamultiplier="2.0" attackspeed="300" soulmax="200" gainsoulticks="15" fromvoc="3">
<formula meleeDamage="1.0" distDamage="1.0" wandDamage="1.0" magDamage="1.0" magHealingDamage="1.0" defense="1.0" magDefense="1.0" armor="1.0"/>
<skill fist="1.1" club="1.1" sword="1.1" axe="1.1" distance="1.1" shielding="1.1" fishing="1.1" experience="1.0"/>
</vocation>
<vocation id="8" name="Elite Knight" description="an elite knight" needpremium="0" gaincap="30" gainhp="18" gainmana="5" gainhpticks="2" gainhpamount="10" gainmanaticks="100" gainmanaamount="100" manamultiplier="3.2" attackspeed="290" soulmax="200" gainsoulticks="15" fromvoc="4">
<formula meleeDamage="1.0" distDamage="1.0" wandDamage="1.0" magDamage="1.0" magHealingDamage="1.0" defense="1.0" magDefense="1.0" armor="1.0"/>
<skill fist="1.1" club="1.1" sword="1.1" axe="1.1" distance="1.4" shielding="1.1" fishing="1.1" experience="1.0"/>
</vocation>
Last edited: