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

Bonus damage on all attacks if event is triggered

Karain

Jack of all trades
Joined
Jul 9, 2009
Messages
338
Solutions
3
Reaction score
147
Location
Egypt
Hello Otlanders, i'd like to make a request if possible, or ask for help if that's easier.

I'd like to have a script that would add a bonus percentage of damage to all of my attacks (by spells or by weapons/melee) if i have a value in my storage.

i tried to use that with creaturescript and onstatschange, but i ran into a ton of problems because it needed to be registered on the creature and not on the player and somewhat caused the script to loop since it attempts to add more damage on itself and trigger the script again which led to overflow of executeCombat.

i'd like to stay as far away from C++ as possible, but i wont mind if that's my last choice.

here is my old attempts, if you can figure out what to do, then please do! it would be very much appreciated


Code:
function onStatsChange(cid, attacker, type, combat, value)
if isPlayer(attacker) then
	if type == STATSCHANGE_HEALTHLOSS then
		if getPlayerStorageValue(attacker,16000) then
				local perc = (((getPlayerStorageValue(attacker,16000) + 1 )/ 100) ) * 5 + 1
				local newdamage = value * perc	
				doTargetCombatHealth(attacker, cid, combat, -newdamage, -newdamage, CONST_ME_DRAWBLOOD)  -- this line will trigger onStatsChange which will trigger itself over and over, even with return false but does not do any damage to target at all!
-- another note is if i replaced "attacker" with cid, the script works fine except the new damage value will never be used
-- last note is if i replaced "attacker" with 0, the script works just great as intended, but that will remove all link between the player and the monster (you won't get exp on kills, or skulls on PVP since you are not the actual "attacker")
			return false  --if this line is removed, the damage will be enabled and will most likely kill everything in 1 hit because it attacks about 30 or more times in an instant till the server stops it and shows a stack overflow error.
                end
	end
end
	return true
end




Thank you alot.
 
I have a similar system on my server, however it affects only the power of spells which means I edited every spell script to have an enhanced effect if you have a certain value of storage. (not sure how to make melee/distance combat damage increased too, I guess that could be easier done via c++).

Note; the following code is just a part of an 'exori flam' script, but it will give you the general idea:
Code:
function onCastSpell(cid, var) 
local parameters = { cid = cid, var = var, combat1 = combat1, combat2 = combat2, combat3 = combat3 } 
[B]if getCreatureStorage(cid, 29042) == 1 then[/B]
[COLOR="#A52A2A"]addEvent(onCastSpell1, 0, parameters) //
addEvent(onCastSpell2, 100, parameters) //
addEvent(onCastSpell3, 200, parameters) // 1st hit[/COLOR]
[COLOR="#008000"]addEvent(onCastSpell1, 300, parameters) //
addEvent(onCastSpell2, 400, parameters) //
addEvent(onCastSpell3, 500, parameters) // 2nd hit[/COLOR]
[B]else[/B]
[COLOR="#A52A2A"]addEvent(onCastSpell1, 0, parameters) 
addEvent(onCastSpell2, 100, parameters) 
addEvent(onCastSpell3, 200, parameters) [/COLOR]
[B]end[/B]
return true
end

So, this is how you could do it with spells at least. Also instead of storage, you can use some other condition, like: if player has something equipped, or if player is in certain area, etc... This gives you a variety of way to power up players' spells based on them fulfilling some condition.

Edit: You could power up the melee/distance attacks by boosting the skills of player temporarily (as seen in spells such as utito tempo san, etc..)
 
I have a similar system on my server, however it affects only the power of spells which means I edited every spell script to have an enhanced effect if you have a certain value of storage. (not sure how to make melee/distance combat damage increased too, I guess that could be easier done via c++).

Note; the following code is just a part of an 'exori flam' script, but it will give you the general idea:
Code:
function onCastSpell(cid, var) 
local parameters = { cid = cid, var = var, combat1 = combat1, combat2 = combat2, combat3 = combat3 } 
[B]if getCreatureStorage(cid, 29042) == 1 then[/B]
[COLOR="#A52A2A"]addEvent(onCastSpell1, 0, parameters) //
addEvent(onCastSpell2, 100, parameters) //
addEvent(onCastSpell3, 200, parameters) // 1st hit[/COLOR]
[COLOR="#008000"]addEvent(onCastSpell1, 300, parameters) //
addEvent(onCastSpell2, 400, parameters) //
addEvent(onCastSpell3, 500, parameters) // 2nd hit[/COLOR]
[B]else[/B]
[COLOR="#A52A2A"]addEvent(onCastSpell1, 0, parameters) 
addEvent(onCastSpell2, 100, parameters) 
addEvent(onCastSpell3, 200, parameters) [/COLOR]
[B]end[/B]
return true
end

So, this is how you could do it with spells at least. Also instead of storage, you can use some other condition, like: if player has something equipped, or if player is in certain area, etc... This gives you a variety of way to power up players' spells based on them fulfilling some condition.

Edit: You could power up the melee/distance attacks by boosting the skills of player temporarily (as seen in spells such as utito tempo san, etc..)

i was going for that script at first, but i saw that it would require editing to each and every spell XD, but i guess i have no choice now.

is it possible to make a weapon script that will automatically get the weapon's attack and player's skill and use the weapon formula * the percentage?
 
Here is the simplest melee weapon script, for example:
Code:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_BLOCKARMOR, 1)
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
setCombatParam(combat, COMBAT_PARAM_EFFECT, 98)

function onGetFormulaValues(cid, level, skill, attack, factor)
	local skillTotal, levelTotal = skill + attack, level / 5
	return -(skillTotal / 3 + levelTotal), -(skillTotal + levelTotal)
end

setCombatCallback(combat, CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues")

function onUseWeapon(cid, var)
	return doCombat(cid, combat, var)
end

On every hit, it will deliver the 'combat'. It's up to you how you defined that 'combat'. I've taken the formula from exori hur script, you probably wanna change some values. I deem it unnecessary for me to explain each parameter of the formula here, as they're pretty self explanatory.

Also here's how you define it in weapons.xml if you need that:
Code:
	<melee id="xxxx" level="xx" enabled="1" event="script" value="scriptname.lua">
		<vocation id="xx"/>
	</melee>
 
Back
Top