PDA

View Full Version : How to check to see if a spell is on you or someone else?



Intel
05-02-2014, 08:13 PM
I need to know how to check to see if a spell is on someone else (haste for example), and if not auto cast it on them.

I need to know how to check and see if a spell is on me. I don't want to just have a 'waitfor' waiting for the spell to wear off. I need to have a script that unhides once a spell wears off via checking spells through the lich system.

It has been years since I played, I forgot.

Thanks!

Tillmen
05-02-2014, 11:20 PM
To check spells on someone else, use something like:

LNet.get_data(name, 'spells')

This returns a hash where the keys are spell numbers (as strings) and the values are the number of minutes remaining. So to cast haste it might look something like this:



name = 'Tillmen'
foo = LNet.get_data(name, 'spells')
unless foo['506'].to_f > 0
cast(506, 'Tillmen')
end

This may not be the best way to go about doing it if you're trying to keep haste on someone all the time. Each call to LNet.get_data causes a transfer of data over LNet, and LNet will kick you off for spamming if you do it often enough to keep haste up.

Here's a quick script I wrote to keep some lousy picker hasted.


target = 'Baswab'
last_haste = Time.now - 70

while (line = get)
if line =~ /^#{target} begins moving faster than you thought possible\./
last_haste = Time.now
elsif line =~ /^#{target} returns to normal speed\./
loop {
break unless Spell[506].affordable?
result = cast 506, target, /^Your magic clashes with that which is already there!/
unless result =~ /^\[Spell Hindrance for/
last_haste = Time.now
break
end
}
elsif GameObj.pcs.any? { |pc| pc.noun == target } and ((last_haste + 70) < Time.now) and Spell[506].affordable?
loop {
break unless Spell[506].affordable?
result = cast 506, target
unless result =~ /^\[Spell Hindrance for/
last_haste = Time.now
break
end
}
end
end


To check spells on yourself, you can do stuff like this:

Spell[506].cast if Spell[506].affordable? and not Spell[506].active?
cast(401) unless Spell['Elemental Defense I'].timeleft > 60

You might find more helpful stuff by looking at the code of a spellup script like waggle.