Spell Scripts - what is needed?

Discussions of the design and development of in-game content.

Moderator: Team Members

Post Reply
User avatar
John Adams
Retired
Posts: 9684
Joined: Thu Jul 26, 2007 6:27 am
EQ2Emu Server: EQ2Emulator Test Center
Characters: John
Location: Arizona
Contact:

Spell Scripts - what is needed?

Post by John Adams » Fri Aug 08, 2008 1:37 pm

Why are all these posts started by me? :)
I'd like to open a discussion on what names/types of spell scripting we are going to need to handle every kind of spell/ability in the game. I do not mean the difference between slash and crush damage, but the difference between damage and heal, or buff and nuke, etc.
I am envisioning there being a small number of scripts (maybe a dozen or so) that are written in a way that can handle all our castings. I do not see us creating one script for every spell/ability name - do you?
Take the "Sprint.lua" as an example - because that is what it was, just an example. I do not believe it needs to be named that, but could instead be Speed.lua so it can also process any other movement enhancement/detriments as well. Not that I do not like Sprint.lua. :) I am just wondering if it can be used more 'generically'? Same with Damage. My Damage.lua can process Lightning Strike and Faithful Swing, depending on the params passed.
So what I am thinking is, what else do we need? Direct Heals, Heal or Damage-over-time, Self/Group Buffs? I'd like to create a list of "generic" LUA script names that will handle all spell/ability processing, and get them written so we can start shoving spell_data through them. Specialty scripts can be created where generic or general is simply not enough.
My ideas (please correct me if I don't get it):
Heals.lua - process direct heals
HoTs.lua - process heal over time
Damage.lua - process direct damage
DoTs.lua - process damage over time
Buffs.lua - process personal buffs
Debuffs.lua - process personal debuffs
GroupBuffs.lua - process group/raid/NPC debuffs
GroupDebuffs.lua - process group/raid/NPC debuffs
Any others? Are these too many already? Let's design. :)

User avatar
Zcoretri
Team Member
Posts: 1642
Joined: Fri Jul 27, 2007 12:55 pm
Location: SoCal

Post by Zcoretri » Fri Aug 08, 2008 2:15 pm

I think it needs to be more refined than just a few generics.
Your generic lua is gonna have 5 million parameters to cover all the bases, with 90% of the paramters not being used.
Take Faithful Swing...it has divine damge plus it heals the caster.
Quick thrust...inflicts melee damage and decreases attack speed of target.
Swipe...inflicts melee damage and decreases DPS of target.
Deafening Strike...inflict mental damage and decreases power of target.
I envisioned it being like the generic damage one would be where the spell/CA only deals damage.
You would have another for dealing damage/Heal self, another for damage/Decrease some stat.
I'm I making sense here? :)

bobbydole
Posts: 32
Joined: Mon Jul 28, 2008 1:10 pm

Post by bobbydole » Fri Aug 08, 2008 2:20 pm

Zcoretri wrote:I think it needs to be more refined than just a few generics.
Your generic lua is gonna have 5 million parameters to cover all the bases, with 90% of the paramters not being used.
I'm I making sense here? :)
Yeah.. Maybe take a look at the quest lines and see how they stack up to each other.
Would something like this help:
http://eq2.wikia.com/wiki/Category:Spell_Type

User avatar
John Adams
Retired
Posts: 9684
Joined: Thu Jul 26, 2007 6:27 am
EQ2Emu Server: EQ2Emulator Test Center
Characters: John
Location: Arizona
Contact:

Post by John Adams » Fri Aug 08, 2008 4:01 pm

Zcoretri wrote:I'm I making sense here? :)
Yup, perfectly. That's why I started the discussion because I think it's going to be a tad more complex that we initially thought - tho still very configurable and easy to use.
What I am after is those "base" scripts, and laying out each type and what spell or ability it will cover before we need a new one more finely tuned.
Bobby, score again. I like that list! It might be something to consider as our base scripts, then go from there. Thanks!

User avatar
John Adams
Retired
Posts: 9684
Joined: Thu Jul 26, 2007 6:27 am
EQ2Emu Server: EQ2Emulator Test Center
Characters: John
Location: Arizona
Contact:

Post by John Adams » Sun Aug 10, 2008 5:23 pm

So I am trying my hand at scripting spells. So far, I have locked up my client, crashed it, caused the screen to go black, rebooted my PC, crashed the world numerous ways, and not once got a self-heal off.
Should this not work?

Code: Select all

function cast(Caster)
	maxHP = GetMaxHP(Caster)
	SetCurrentHP(Caster, maxHP)
end
Console reports:

Code: Select all

Error running Spells/BetaHeal.lua:11: attempt to call global 'SetCurrentHP' (a nil value)
(see/fix the script on my script editor page)
I simply wanted a way for our testers to be able to self heal instantly to their max HP. When this casts, I get some error about SetCurrentHP() getting a nil value. (nil, null, wtf?)
Secondly, I tried making a Quick Strike damage for my assassin to use, and set spell ID 40000 in my database to send slashing damage of 9. Which works, using the existing Damage.lua example. But upon second cast, I crash my world and client. I am waiting til cooldown (visually anyway). Dunno what's up.
Can anyone give me a quick tutorial on how to make a multi-damage Damage script, and a self-heal script? By multi-damage, I mean that I slash you for 'x' damage, then have a second effect of 'y' more damage (over time or not, doesn't matter right now). i just want the 2 damage types coming out of the script.
Thanks, I am in your debt.

LethalEncounter
Team: Zombie
Posts: 2717
Joined: Wed Jul 25, 2007 10:10 pm

Post by LethalEncounter » Sun Aug 10, 2008 5:57 pm

John Adams wrote:So I am trying my hand at scripting spells. So far, I have locked up my client, crashed it, caused the screen to go black, rebooted my PC, crashed the world numerous ways, and not once got a self-heal off.
Should this not work?

Code: Select all

function cast(Caster)
	maxHP = GetMaxHP(Caster)
	SetCurrentHP(Caster, maxHP)
end
Console reports:

Code: Select all

Error running Spells/BetaHeal.lua:11: attempt to call global 'SetCurrentHP' (a nil value)
(see/fix the script on my script editor page)
I simply wanted a way for our testers to be able to self heal instantly to their max HP. When this casts, I get some error about SetCurrentHP() getting a nil value. (nil, null, wtf?)
Secondly, I tried making a Quick Strike damage for my assassin to use, and set spell ID 40000 in my database to send slashing damage of 9. Which works, using the existing Damage.lua example. But upon second cast, I crash my world and client. I am waiting til cooldown (visually anyway). Dunno what's up.
Can anyone give me a quick tutorial on how to make a multi-damage Damage script, and a self-heal script? By multi-damage, I mean that I slash you for 'x' damage, then have a second effect of 'y' more damage (over time or not, doesn't matter right now). i just want the 2 damage types coming out of the script.
Thanks, I am in your debt.
It is SetHP not SetCurrentHP. The list of functions and their names are in LuaInterface::RegisterFunctions in LuaInterface.cpp

User avatar
John Adams
Retired
Posts: 9684
Joined: Thu Jul 26, 2007 6:27 am
EQ2Emu Server: EQ2Emulator Test Center
Characters: John
Location: Arizona
Contact:

Post by John Adams » Sun Aug 10, 2008 6:04 pm

Hmm. I just updated this function list the other night with info from the Luafunctions code... Maybe I was sleepy and missed that.
Edit: Dopey me, I used LuaFunctions.h not the Register. I see what you mean now. I'll fix the function list eventually.

User avatar
Zcoretri
Team Member
Posts: 1642
Joined: Fri Jul 27, 2007 12:55 pm
Location: SoCal

Post by Zcoretri » Sun Aug 10, 2008 6:29 pm

My generic heal spell

Code: Select all

function cast(Caster, Target, PowerCost, Heal, HealMax)
     power_left = GetPower(Caster)
     total_power = GetMaxPower(Caster)
     if (power_left - PowerCost) < power_left then
          Healed = math.random(Heal,HealMax)
          ModifyHP(Caster, Healed)
     end
     new_power = GetPower(Caster) - PowerCost
     if new_power > 0 then
          SetPower(Caster, new_power)
     end
     return
end
My generic damage spell

Code: Select all

function cast(Caster, Target, PowerCost, DamageType, Damage, DamageMax)
     power_left = GetPower(Caster)
     total_power = GetMaxPower(Caster)
     if (power_left - PowerCost) < power_left then
          Damage = math.random(Damage,DamageMax)
          SpellDamage(Target, DamageType, Damage)
     end
     new_power = GetPower(Caster) - PowerCost
     if new_power > 0 then
          SetPower(Caster, new_power)
     end
     return
end

User avatar
John Adams
Retired
Posts: 9684
Joined: Thu Jul 26, 2007 6:27 am
EQ2Emu Server: EQ2Emulator Test Center
Characters: John
Location: Arizona
Contact:

Post by John Adams » Sun Aug 10, 2008 6:40 pm

I notice you have 3 params there... are you setting up 3 values for spell_data then? Index 0,1,2? I tried that and failed miserably, but I'll try with your script. My LUA might have been the problem before.

User avatar
Zcoretri
Team Member
Posts: 1642
Joined: Fri Jul 27, 2007 12:55 pm
Location: SoCal

Post by Zcoretri » Sun Aug 10, 2008 7:27 pm

yeah...3 for the heal, and 4 for the damage one.

User avatar
John Adams
Retired
Posts: 9684
Joined: Thu Jul 26, 2007 6:27 am
EQ2Emu Server: EQ2Emulator Test Center
Characters: John
Location: Arizona
Contact:

Post by John Adams » Tue Aug 12, 2008 6:33 pm

Zcoretri, I cannot seem to get the heal to work. Since "John" Is currently not regenerating HP either (stuck at 42HP), I am not sure if it's the LUA or the server.
Can you check out my params on the Spells Editor (Commoner, Beta Heal)? I think those are the right params.
Thank you for the scripts though. It has helped me better understand some of the script options.

User avatar
Zcoretri
Team Member
Posts: 1642
Joined: Fri Jul 27, 2007 12:55 pm
Location: SoCal

Post by Zcoretri » Wed Aug 13, 2008 3:30 pm

John Adams wrote:Zcoretri, I cannot seem to get the heal to work. Since "John" Is currently not regenerating HP either (stuck at 42HP), I am not sure if it's the LUA or the server.
Can you check out my params on the Spells Editor (Commoner, Beta Heal)? I think those are the right params.
Thank you for the scripts though. It has helped me better understand some of the script options.
I changed the power requirement field in the spells table to 5, and then changed the first parameter in the spell_data table to 5.
I just just set up my healing spell again on my sever and tested and it is working.
I do see some things about the spells though that may need attention.
1.) There seems to be a delay between casting the spell and when it takes effect.
2.) I don't see any green numbers above th PC showing healed amount (like the damage numbers)
3.) I don't see heal amounts in the chat text, though I probably don't have that set up right so I might need some enlightenment on that.

Tyr
Posts: 32
Joined: Tue Jul 15, 2008 7:13 am

Post by Tyr » Wed Aug 13, 2008 3:48 pm

Ok would it be possible to have one spell use more than one script?
Let’s use Faithful Swing as an example.
Instead of creating a script for a spell that deals damage and heals the caster you write two generic scripts and call them both. DivineDamage.lua & HealSelf.lua
You could get the same effect that way, and lower the overall number of scripts, instead of having one script for each spell, you have a number of generic scripts that could be called in combination to get any type of spell desired.
Allowing 10 scripts per spell maximum should cover it, I don’t recall ANY spells in eq2 that use more than 10 effects, so that would cover live, and “shouldâ€

User avatar
John Adams
Retired
Posts: 9684
Joined: Thu Jul 26, 2007 6:27 am
EQ2Emu Server: EQ2Emulator Test Center
Characters: John
Location: Arizona
Contact:

Post by John Adams » Wed Aug 13, 2008 5:26 pm

Tyr, I was thinking the same thing - when Scatman asked me if LUA scripts can make references to external scripts - and I am not sure. If that's the case, then #including another (common.lua) or something might be possible.
Linking multiple scripts together might put excessive utilization on the engine while processing not only that 1 spell, but all the other spells from all the other players + quests and spawnscripts. I doubt it's much, but every little bit is a hit.

Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests