Scripting Development
Moderator: Team Members
-
LethalEncounter
- Team: Zombie
- Posts: 2717
- Joined: Wed Jul 25, 2007 10:10 pm
Scripting Development
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.
- alfa
- Team Member
- Posts: 550
- Joined: Fri Jul 27, 2007 6:24 pm
- Location: France
- Contact:
- ZexisStryfe
- Posts: 1026
- Joined: Thu Jul 26, 2007 6:39 am
- EQ2Emu Server: Sytherian Legends
- Location: Connecticut
- Contact:
-
LethalEncounter
- Team: Zombie
- Posts: 2717
- Joined: Wed Jul 25, 2007 10:10 pm
-
LethalEncounter
- Team: Zombie
- Posts: 2717
- Joined: Wed Jul 25, 2007 10:10 pm
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:
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 
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- alfa
- Team Member
- Posts: 550
- Joined: Fri Jul 27, 2007 6:24 pm
- Location: France
- Contact:
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.
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.
Fight with me... Or die, like the rest.
J.A. say: "I think Xinux tried to tell me this, but I ignore most things he suggests."
J.A. say: "I think Xinux tried to tell me this, but I ignore most things he suggests."
-
LethalEncounter
- Team: Zombie
- Posts: 2717
- Joined: Wed Jul 25, 2007 10:10 pm
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.
-
LethalEncounter
- Team: Zombie
- Posts: 2717
- Joined: Wed Jul 25, 2007 10:10 pm
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:
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?
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)
endAny other ideas that people want to suggest in regards to the new scripting engine?
- alfa
- Team Member
- Posts: 550
- Joined: Fri Jul 27, 2007 6:24 pm
- Location: France
- Contact:
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.
It would be allow a big part of community to make some AI / Raid / Instance script easly.
Fight with me... Or die, like the rest.
J.A. say: "I think Xinux tried to tell me this, but I ignore most things he suggests."
J.A. say: "I think Xinux tried to tell me this, but I ignore most things he suggests."
-
LethalEncounter
- Team: Zombie
- Posts: 2717
- Joined: Wed Jul 25, 2007 10:10 pm
- John Adams
- Retired
- Posts: 9684
- Joined: Thu Jul 26, 2007 6:27 am
- EQ2Emu Server: EQ2Emulator Test Center
- Characters: John
- Location: Arizona
- Contact:
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?
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?
-
LethalEncounter
- Team: Zombie
- Posts: 2717
- Joined: Wed Jul 25, 2007 10:10 pm
- John Adams
- Retired
- Posts: 9684
- Joined: Thu Jul 26, 2007 6:27 am
- EQ2Emu Server: EQ2Emulator Test Center
- Characters: John
- Location: Arizona
- Contact:
- alfa
- Team Member
- Posts: 550
- Joined: Fri Jul 27, 2007 6:24 pm
- Location: France
- Contact:
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
Script for Warrior // When the player is targeting the healer the Warrior try to taunt him
Script for Caster // When the Shaman total power is under 50% the Caster try to feed him
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.
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
Code: Select all
If CheckAgroOfTarget(Player) = "a gnoll Shaman" and GetCurrentLife(Shaman) < (Total_Life / 2) then
CastSpell(ID of a taunting Spell)
End
Code: Select all
If GetCurrentPower(Shaman) < (Total_Power / 2) then
CastSpell(ID of an feed mana Spell)
End
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.
Fight with me... Or die, like the rest.
J.A. say: "I think Xinux tried to tell me this, but I ignore most things he suggests."
J.A. say: "I think Xinux tried to tell me this, but I ignore most things he suggests."
Who is online
Users browsing this forum: No registered users and 0 guests


