• 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!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

Spell Mod: Vengeance

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:
mainly.png


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:
<instant name="Vengeance" words="vengeance" lvl="85" mana="800" exhaustion="10000" needlearn="0" event="script" >
Blue: The words of the spell, but anyway he will say "Vengeance!" in orange.
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:
config = {
storage = 4328,
time = 15,
percent_min = 20,
percent_max = 30,
manaused = 800

}
Dark Orange: Storage value that will be used.
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:
local storage = 4328
Red: The same storage value you edited above.

------------------------
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:
Looks nice, I think it will be useful, but...
please, reedit this to normal spell becouse i have bugs with 'mods'.

Rep++ ofc
 
ok, i found bug

doPlayerAddMana(cid,config.manaused)

Is possible to train mlvl every time then vegenance is active without wasting mana.
This spell cost 800m and recive back 800m if you already have active this spell.

Free mlvl training
I think you need to choose another way. Make it, like haste works.
 
I don't have any mods folder
I'm using mystic spirit 0.2.8
What can I do now? Where do I have to paste the first part?
 
Last edited:
bump

Do I have to use only the mods folder (I got one now) got TFS 0.4 now
or do I have to use all (creature script etc) because the script is working when I only add the mods part, but it doesn't work that I absorb those 30%

//EDIT

got it working now
 
Last edited:
no, sorry :p I'm not playing it

I just like the spell

//EDIT
I got it working now
 
Last edited:
Back
Top