Nandonalt
New Member
- Joined
- Aug 4, 2008
- Messages
- 29
- Reaction score
- 0
Don't know if any of you play/played Runescape, but in Runescape, in the Lunar Magiks Spellbook, there's a spell called Vengeance. My spell is based on that one, but a bit more different.
What does when you cast the spell?
For the time you configured, who attack this player(Monster OR Player) will have a certain percent(configurable min and max) of the damage back to him(This will reduce the damage to you).
When the time runs out, the effect end. If the player die/logout, it will end too.
Screenshoot? YEAH:
Bugs: I'm using TFS 0.3.6pl1(I compiled myself) and i have experienced a bug that some characters can't login(random), but when i reload mods they can log again. I posted this to see if someone will experience this bug. In the non-mod version i made everything was fine...if you want the non-mod version, say in this topic.
Let's go then! Create a file named vengeance.xml in your mods folder and paste this:
CONFIGURATION:
First, we will config the spell. Find this:
Deep Sky Blue: The level the player need to cast the spell.
Magenta: The mana that the player will need to cast the spell.
Lime: Seconds of exhaustion * 1000 ( 5 seconds = 5000, 7 = 7000, 60 = 60000)
Now the CONFIG, find this:
Dark Orchid: Time of the effect.
Sea Green: Min percent of the damage (If the attacker hit 100, if percent_min is 30% and percent_max is 50%, he will be hitted 30 to 50.)
Plum: Max percent of the damage. Description above.
Dark Green: Mana used on the spell, must be the same of you edited above.
Now find this on the login function:
------------------------
Please report any bugs, i'm new to this next generation of scripting (2 years scripting with an 8.1 XML Aries)
LUA
Okay... lua then. Config is in each of the scripts(Need all of them to be the same, on vengeance_login you only have to edit the storage), edit like above.
Create a file called "vengeance_stats.lua" in your "creaturescripts/scripts" folder, and paste this:
In the same folder, "vengeance_login.lua":
Now, put this in "creaturescripts.xml":
Now in "spells.xml":
And in spells/scripts, create a file called "vengeance.lua" and paste this:
What does when you cast the spell?
For the time you configured, who attack this player(Monster OR Player) will have a certain percent(configurable min and max) of the damage back to him(This will reduce the damage to you).
When the time runs out, the effect end. If the player die/logout, it will end too.
Screenshoot? YEAH:
Bugs: I'm using TFS 0.3.6pl1(I compiled myself) and i have experienced a bug that some characters can't login(random), but when i reload mods they can log again. I posted this to see if someone will experience this bug. In the non-mod version i made everything was fine...if you want the non-mod version, say in this topic.
Let's go then! Create a file named vengeance.xml in your mods folder and paste this:
PHP:
<?xml version="1.0" encoding="UTF-8"?>
<mod name="Vengeance" version="1.0" author="Nandonalt" contact="[email protected]" enabled="yes">
<config name="vengeconf"><![CDATA[
config = {
storage = 4328,
time = 15,
percent_min = 20,
percent_max = 30,
manaused = 800
}
]]></config>
<event type="statschange" name="VengeanceV" event="script"><![CDATA[
function onStatsChange(cid, attacker, type, combat, value)
domodlib('vengeconf')
if type == STATSCHANGE_HEALTHLOSS and value >= 1 then
local percentage = math.random(config.percent_min, config.percent_max)
local formula = math.floor((percentage * value) / 100)
if getPlayerStorageValue(cid,config.storage) == 1 and isCreature(attacker) then
doSendAnimatedText(getCreaturePosition(attacker),"-"..formula,COLOR_RED)
doCreatureSay(cid,"Taste Vengeance!",19)
doSendMagicEffect(getCreaturePosition(cid),17)
doSendMagicEffect(getCreaturePosition(attacker),29)
doCreatureAddHealth(attacker,-formula)
end
end
return 1
end
]]></event>
<event type="login" name="VengeanceLogin" event="script"><![CDATA[
function onLogin(cid)
registerCreatureEvent(cid,"VengeanceV")
local storage = 4328
if getPlayerStorageValue(cid,storage) == 1 then
doPlayerSendCancel(cid,"Vengeance effect ended.")
setPlayerStorageValue(cid,storage,-1)
doSendMagicEffect(getCreaturePosition(cid),17)
else
end
return 1
end
]]></event>
<instant name="Vengeance" words="vengeance" lvl="85" mana="800" exhaustion="10000" needlearn="0" event="script" ><![CDATA[
domodlib('vengeconf')
local secs = config.time * 1000
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_EFFECT, 17)
function no_vengeance(param)
domodlib('vengeconf')
pid = getPlayerByNameWildcard(param.name)
if(not pid or (isPlayerGhost(pid) and getPlayerGhostAccess(pid) > getPlayerGhostAccess(cid))) then
else
doPlayerSendCancel(pid,"Vengeance effect ended.")
setPlayerStorageValue(pid,config.storage,-1)
doSendMagicEffect(getCreaturePosition(pid),17)
end
return 1
end
function onCastSpell(cid, var)
domodlib('vengeconf')
if getPlayerStorageValue(cid,config.storage) == -1 then
doCreatureSay(cid,"Vengeance!",19)
setPlayerStorageValue(cid,config.storage,1)
addEvent(no_vengeance,secs,{cid = cid, name = getPlayerName(cid)})
doCombat(cid, combat, var)
else
doPlayerSendCancel(cid,"This spell is already active.")
doPlayerAddMana(cid,config.manaused)
end
return 1
end
]]>
</instant></mod>
CONFIGURATION:
First, we will config the spell. Find this:
Blue: The words of the spell, but anyway he will say "Vengeance!" in orange.<instant name="Vengeance" words="vengeance" lvl="85" mana="800" exhaustion="10000" needlearn="0" event="script" >
Deep Sky Blue: The level the player need to cast the spell.
Magenta: The mana that the player will need to cast the spell.
Lime: Seconds of exhaustion * 1000 ( 5 seconds = 5000, 7 = 7000, 60 = 60000)
Now the CONFIG, find this:
Dark Orange: Storage value that will be used.config = {
storage = 4328,
time = 15,
percent_min = 20,
percent_max = 30,
manaused = 800
}
Dark Orchid: Time of the effect.
Sea Green: Min percent of the damage (If the attacker hit 100, if percent_min is 30% and percent_max is 50%, he will be hitted 30 to 50.)
Plum: Max percent of the damage. Description above.
Dark Green: Mana used on the spell, must be the same of you edited above.
Now find this on the login function:
Red: The same storage value you edited above.local storage = 4328
------------------------
Please report any bugs, i'm new to this next generation of scripting (2 years scripting with an 8.1 XML Aries)
LUA
Okay... lua then. Config is in each of the scripts(Need all of them to be the same, on vengeance_login you only have to edit the storage), edit like above.
Create a file called "vengeance_stats.lua" in your "creaturescripts/scripts" folder, and paste this:
Lua:
local config = {
storage = 4328,
time = 15,
percent_min = 20,
percent_max = 30,
manaused = 800
}
function onStatsChange(cid, attacker, type, combat, value)
if type == STATSCHANGE_HEALTHLOSS and value >= 1 then
local percentage = math.random(config.percent_min, config.percent_max)
local formula = math.floor((percentage * value) / 100)
if getPlayerStorageValue(cid,config.storage) == 1 and isCreature(attacker) then
doSendAnimatedText(getCreaturePosition(attacker),"-"..formula,COLOR_RED)
doCreatureSay(cid,"Taste Vengeance!",19)
doSendMagicEffect(getCreaturePosition(cid),17)
doSendMagicEffect(getCreaturePosition(attacker),29)
doCreatureAddHealth(attacker,-formula)
end
end
return 1
end
In the same folder, "vengeance_login.lua":
Lua:
function onLogin(cid)
registerCreatureEvent(cid,"VengeanceV")
local storage = 4328
if getPlayerStorageValue(cid,storage) == 1 then
doPlayerSendCancel(cid,"Vengeance effect ended.")
setPlayerStorageValue(cid,storage,-1)
doSendMagicEffect(getCreaturePosition(cid),17)
else
end
return 1
end
Now, put this in "creaturescripts.xml":
PHP:
<event type="statschange" name="VengeanceV" event="script" value="vengeance_stats.lua">
<event type="login" name="VengeanceLogin" event="script" value="vengeance_login.lua>
Now in "spells.xml":
PHP:
<instant name="Vengeance" words="vengeance" lvl="85" mana="800" exhaustion="10000" needlearn="0" event="script" value="vengeance.lua"></instant>
And in spells/scripts, create a file called "vengeance.lua" and paste this:
Lua:
local config = {
storage = 4328,
time = 15,
percent_min = 20,
percent_max = 30,
manaused = 800
}
local secs = config.time * 1000
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_EFFECT, 17)
function no_vengeance(param)
pid = getPlayerByNameWildcard(param.name)
if(not pid or (isPlayerGhost(pid) and getPlayerGhostAccess(pid) > getPlayerGhostAccess(cid))) then
else
doPlayerSendCancel(pid,"Vengeance effect ended.")
setPlayerStorageValue(pid,config.storage,-1)
doSendMagicEffect(getCreaturePosition(pid),17)
end
return 1
end
function onCastSpell(cid, var)
if getPlayerStorageValue(cid,config.storage) == -1 then
doCreatureSay(cid,"Vengeance!",19)
setPlayerStorageValue(cid,config.storage,1)
addEvent(no_vengeance,secs,{cid = cid, name = getPlayerName(cid)})
doCombat(cid, combat, var)
else
doPlayerSendCancel(cid,"This spell is already active.")
doPlayerAddMana(cid,config.manaused)
end
return 1
end
Last edited: