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

Add damage

Sherice

Sky&Wind
Joined
Jan 20, 2012
Messages
183
Reaction score
7
Location
Sweden
Hey!

How can I add damage to normal attacks without adding damage to weapon or increasing the skills?
Is there any way to get the total damage value?

For example, in D3 there is a total damage value, tho it shows total damage of crit chance, dmg and atk speed too.



Ty for the help! :)
 
Yeah but it can't really add more damage to the actual damage. I need a function, something like "doPlayer/CreatureAddDamage".
I'm ready to source edit if someone can help me.

Is there no way to check your total damage value?
 
Yeah, but it seems that it's the damage value you hit and since the damage is different every hit, I don't know what the real damage value is. :/ (correct me if I'm wrong tho)
There must be some kind of math thing (don't know what it's called) to calculate out what damage you have right?

Like if you use a sword, check your sword fighting and the swords damage + level.
 
Bump, checked at weapon.cpp and found this max melee/weapon damage thing, but no minimum. Does this mean that you can damage from 0/miss-maxdamage?
Or maybe it's not that.
 
Yes, melee attacks can (but is most unlikely to) pop a zero.

See weapons.cpp:

Max Damage:
Code:
int32_t Weapons::getMaxMeleeDamage(int32_t attackSkill, int32_t attackValue)
{
	return (int32_t)std::ceil((attackSkill * (attackValue * 0.05)) + (attackValue * 0.5));
}

int32_t Weapons::getMaxWeaponDamage(int32_t level, int32_t attackSkill, int32_t attackValue, float attackFactor)
{
	return (int32_t)std::ceil((2 * (attackValue * (attackSkill + 5.8) / 25 + (level - 1) / 10.)) / attackFactor);
}

Min damage (melee):
Code:
	int32_t ret = (int32_t)std::floor(maxValue);
	if(maxDamage)
		return -ret;

	return -random_range(0, ret, DISTRO_NORMAL);
Min damage (distance):
Code:
	int32_t ret = (int32_t)std::floor(maxValue);
	if(maxDamage)
		return -ret;

	int32_t minValue = 0;
	if(target)
	{
		if(target->getPlayer())
			minValue = (int32_t)std::ceil(player->getLevel() * 0.1);
		else
			minValue = (int32_t)std::ceil(player->getLevel() * 0.2);
	}

	return -random_range(minValue, ret, DISTRO_NORMAL);

Min damage (wand, where minChange is the "min" attribute):
Code:
	int32_t minValue = (int32_t)(minChange * multiplier);
	return random_range(-minValue, -maxValue, DISTRO_NORMAL);
 
Ah, thanks!

on this line:
Code:
    return -random_range(0, ret, DISTRO_NORMAL);
what does "ret" and "distro_normal" do?

Also, do you know if I can add more damage by using a function?
 
ret is the max damage (floorrounded). See cast:

Code:
int32_t ret = (int32_t)std::floor(maxValue);

DISTRO_NORMAL is a defined constant.

There is no function where you can add it just by using a function call, you can however hook onStatsChange and alter or/and block the incoming health change.

Example:

Lua:
function onStatsChange(cid, attacker, type, combat, value)
	if type == STATSCHANGE_HEALTHLOSS then
		if combat == COMBAT_PHYSICALDAMAGE then
			-- add 25 damage
			local value = (value + 25)
			-- doTargetCombatHealth(cid, target, type, min, max, effect)
			doTargetCombatHealth(attacker, cid, combat, -value, -value, CONST_ME_DRAWBLOOD)
			
			-- return false to block stat changes
			return false
		end
	end
	return true
end

Note that if you would want only a single player to be able to have +damage you would have to make a player check, either with storage values or making a variable that can be shared with the other events (through the usage of combined lua_State).
 
ret is the max damage (floorrounded). See cast:

Code:
int32_t ret = (int32_t)std::floor(maxValue);

DISTRO_NORMAL is a defined constant.

There is no function where you can add it just by using a function call, you can however hook onStatsChange and alter or/and block the incoming health change.

Example:

Lua:
function onStatsChange(cid, attacker, type, combat, value)
    if type == STATSCHANGE_HEALTHLOSS then
        if combat == COMBAT_PHYSICALDAMAGE then
            -- add 25 damage
            local value = (value + 25)
            -- doTargetCombatHealth(cid, target, type, min, max, effect)
            doTargetCombatHealth(attacker, cid, combat, -value, -value, CONST_ME_DRAWBLOOD)
            
            -- return false to block stat changes
            return false
        end
    end
    return true
end

Note that if you would want only a single player to be able to have +damage you would have to make a player check, either with storage values or making a variable that can be shared with the other events (through the usage of combined lua_State).

ok, Ty very much :D
 
Back
Top