Page 1 of 2
Scripting Development
Posted: Mon Mar 24, 2008 12:22 pm
by LethalEncounter
When I get back from my vacation (probably next week) I will start working on the LUA/C++ interface. I also plan on converting the spell system to use lua scripts instead of the database as using scripts will be much easier to use and modify. Each spell will consist of a different lua script file which is executed when the spell is triggered. Combat, spells, and scripting will be completed before 0.6 is released. Once that is done people will be able to play the game with at least some functionality. This will be followed closely with loot, merchants, groups, banks and lastly tradeskills.
Posted: Mon Mar 24, 2008 3:07 pm
by alfa
Great news

Posted: Tue Mar 25, 2008 3:15 am
by Arremis
WOOT

Posted: Tue Mar 25, 2008 5:57 am
by ZexisStryfe
LE, you are my hero :sniff sniff:
Just a side note, where do AAs fit in on that schedule?
Posted: Tue Mar 25, 2008 2:35 pm
by LethalEncounter
dunno above AAs, I might implement them in between along with something else.
Posted: Sun Mar 30, 2008 3:56 pm
by LethalEncounter
OK, I have gotten Sprint to work correctly in LUA using an interface I wrote. I'm not really happy with the design at this point mainly from an inheritance standpoint. My code automatically looks in the Spells directory for any *.lua scripts and loads them. Here is the Sprint script:
Code: Select all
--Defines
spell_tier = 1
min_num_calls = 20
max_num_calls = 20
call_frequency = 3000
interruptable = false
speed_value = 40
power_req = .10
--main process function
function process1(Caster, Target)
power_left = GetPower(Caster)
total_power = GetMaxPower(Caster)
if (total_power * power_req) < power_left then
speed = GetSpeed(Caster)
if speed < speed_value then
SetSpeed(Caster, speed_value)
end
new_power = GetPower(Caster) - (total_power * power_req)
if new_power > 0 and HasMoved(Caster) == true then
SetPower(Caster, new_power)
elseif new_power <= 0 then
SetSpeed(Caster, 0)
end
else
SetSpeed(Caster, 0)
end
return
end
function remove1(Caster, Target)
SetSpeed(Caster, 0)
end
This works well. The problem comes into play when I want to have one spell inherit from another. This would be really useful so that we can just change a few values instead of copying all the code for spell upgrades. Like if there was an upgrade to Sprint, if it was properly setup I could just change the speed_value/power_req variables and call the same function for the new spell. I could change the global values to accomplish this, but I would rather have a better solution that that. Anyone have a clue how to do this in LUA? I just started playing with it yesterday so I am definitely not good at it

Posted: Sun Mar 30, 2008 5:42 pm
by alfa
First good work for your script engine.
And can you just store some spell value in DB ?
I mean keep spell struct with LUA and increment some value like "speed_value" (for example) with a table in DB.
Posted: Mon Mar 31, 2008 3:00 pm
by LethalEncounter
Yah, the spells are definitely going to be a combination of DB work and LUA scripts. Andrew came up with an idea last night that I will be implementing tonight. Basically he suggested that we put the script name in the spells table along with any parameters for that script so that instead of 500-600 spells (most with tiers of 1-9) we can greatly reduce the number of LUA scripts needed. Most spells are pretty common in their effects. I am going to go through the spell tables and clean them up tonight as well.
Posted: Mon Mar 31, 2008 7:19 pm
by LethalEncounter
OK, I finished creating the system that Andrew thought about. I got rid of 3 spell tables in the process and it is far more flexible than it used to be! I created a new command called /reloadspells that will reload them so that you can update spells and use them immediately in game. Having the spell variables in the DB makes it easy to modify your spells, just update your db, reload your spells and it is done. The new Sprint.lua script:
Code: Select all
function process(Caster, Target, PowerCost, SpeedValue)
power_left = GetPower(Caster)
total_power = GetMaxPower(Caster)
if (total_power * PowerCost) < power_left then
speed = GetSpeed(Caster)
if speed < SpeedValue then
SetSpeed(Caster, SpeedValue)
end
new_power = GetPower(Caster) - (total_power * PowerCost)
if new_power > 0 and HasMoved(Caster) == true then
SetPower(Caster, new_power)
elseif new_power <= 0 then
SetSpeed(Caster, 0)
end
else
SetSpeed(Caster, 0)
end
return
end
function remove(Caster, Target)
SetSpeed(Caster, 0)
end
When creating spells, the first two parameters will allows be Caster and Target, the rest are values from your spell_data table. The process function is called when a spell is called (not necessarily when cast, as in this case process is called every 3 seconds as based on the spell requirement) and remove is called when the spell duration is completed or the spell is removed (player clickable removing not working yet). Notice that the global defines are no longer needed since we are passing in the data from the DB at run time.
Any other ideas that people want to suggest in regards to the new scripting engine?
Posted: Tue Apr 01, 2008 11:40 am
by alfa
Yes another idea but not related to spell, just for scripting mob AI, have you plain to add a basical functions like check target life, check mob in group life, do an action,...
It would be allow a big part of community to make some AI / Raid / Instance script easly.
Posted: Tue Apr 01, 2008 2:42 pm
by LethalEncounter
You mean like do something similar with mobs by storing a script name in the NPCs table and calling it when they are attacked? If so, that could definitely be doable. Or were you talking about something differently?
Posted: Tue Apr 01, 2008 4:05 pm
by John Adams
TessEQ2 is hooked to the 9102 update DB, got the table updates, and trying the Sprint button in my book. The client is saying "You cannot do that right now" and no sprinting. I do have the Spells folder under EQ2World.exe folder, with Sprint.lua inside.
I saw 1 LUA spell loaded at server startup as well.
Am I missing anything? Does the book button not work yet? Do I have to /cast or something?
Posted: Tue Apr 01, 2008 4:06 pm
by LethalEncounter
Drag it to your spell bar and try it there. It should work.
Posted: Tue Apr 01, 2008 4:07 pm
by John Adams
Damn that was fast, lol... I didn't even get to refresh the screen to see if you were browsing this forum

I did that. No love, sorry. That's where I was getting the response in chat.
Posted: Tue Apr 01, 2008 4:08 pm
by alfa
Yes, and also script some basic function for help people to make script.
Some example:
GetCurrentPower(Mob)
//Get the current power of mob or player
GetCurrentLife(Mob)
//Get the current life of mob or player
CastSpell(Spell_ID)
//The mob cast the spell
DoEmote(Emote_ID)
//The mob do an emote
CheckAgroOfTarget(Player)
// Allow server/script engine to get what mob of group is currently target by player
...
I think it would be greate for make some AI script like (still for example) the gnolls group in Antonica, I mean:
In group (of mob) there is a gnoll Shaman, a gnoll Caster, and a gnoll Warrior
----------------
Example of script
Script for Shaman // When the Warrior is under 50% Shaman try to heal him
Code: Select all
If GetCurrentLife(Warrior) < (Total_Life / 2) then
CastSpell(ID of an healling Spell)
End
Script for Warrior // When the player is targeting the healer the Warrior try to taunt him
Code: Select all
If CheckAgroOfTarget(Player) = "a gnoll Shaman" and GetCurrentLife(Shaman) < (Total_Life / 2) then
CastSpell(ID of a taunting Spell)
End
Script for Caster // When the Shaman total power is under 50% the Caster try to feed him
Code: Select all
If GetCurrentPower(Shaman) < (Total_Power / 2) then
CastSpell(ID of an feed mana Spell)
End
For sure the script in example are not working, and is incomplete (no mana check before try to cast a spell,...) but hope this can help you to understand what I mean when I talk about basic function
I think it would be a great thing to have some thing like that because it wouldn't be so hard to script some AI and the combat interaction would be better, for sure.