Page 1 of 1

Lua function ideas

Posted: Sun Oct 07, 2012 5:59 pm
by Jabantiz
First let me stress this is just ideas I have, some I have been toying with for months, some may be easy to do while others not so much, either way I have no Intent to drop everything to work on these, just want to get them out there to see what others think about it.

First off I was thinking about 2 more calls to a zonescript for time change, mainly thinking something like

Code: Select all

function Dusk()
   -- do something when we transition to night time
end

function Dawn()
   -- do something when we transition to day time
end
The times at wich these function are called can be controlled by the rules system so it can be tweaked per server to fit their needs.

Another somewhat simple idea is a temporary variables stored per spawn. These will not be saved and will be reset upon death/zone/restart. These could be used for simple events, or for complicated quests within the zone without actually giving the player a quest. The main use I see is in the healthchanged() function in lua scripts to make an event only happen once (the first time a mob gets to 50% or less hp do an event once and never again). An example of the idea would be something like the following

Code: Select all

-- Set a temp variable named test to true for Spawn
SetTempVariable(Spawn, "test", "true")

-- get the temp variable test from Spawn
var = GetTempVariable(Spawn, "test")
if var ~= nil then
   if var == "true" then
      -- do something if temp var is set to true
   end
end
Finally (for now at least) I was thinking of the possibility to override the hardcoded AI and have a function in the spawnscript do all the AI work, if this function is not found then use the default hardcoded stuff. While it would be simple to switch to the function instead of the hardcoded one, a lot of other lua functions would be needed to allow this to do all the AI stuff. I like the idea of this but want opinons on it and if it is worth it.

Again I want to stress I have no intent to go and work on these right away, this is mainly going to be a brain storming thread for me to see if others will find interest in these function, and feel free to post your own ideas.

Re: Lua function ideas

Posted: Mon Oct 08, 2012 3:59 am
by alfa
Good catch Jab, it aleready exist on live for some quest, mob appaire only night. Also some mobs move when night come (ex Gnoll in Antonica)

Re: Lua function ideas

Posted: Mon Oct 08, 2012 8:09 am
by John Adams
Jabantiz wrote:First off I was thinking about 2 more calls to a zonescript for time change, mainly thinking something like

Code: Select all

function Dusk()
   -- do something when we transition to night time
end

function Dawn()
   -- do something when we transition to day time
end
The times at wich these function are called can be controlled by the rules system so it can be tweaked per server to fit their needs.
On my task list (if you look at ProjMan) are "conditional spawns". Like the day/night shift stuff in the Forest Ruins and other EQ2 zones, similar to how EQEmu does their conditionals. I did not want to implement this as a LUA controlled option, because (in my opinion) it's harder to maintain if everything is in a text file on a remote server somewhere, and not in the database.

I'd prefer this system remain DB-driven from the spawns tables. That said, having an OVERRIDE option in LUA would be a great option - specifically for events that occur based of some other scripting. The reason I am chiming in on Dusk/Dawn is because that is pretty specific to what I am already designing.

Generalize it, and that sounds awesome.


As far as the other points, we definitely should discuss the pros and cons of offloading everything into LUA. My only hesitation at all is manageability, as mentioned above. I'd hate to be trying to troubleshoot why a spawn is acting funky by having to open a dozen LUA files when everything SHOULD be in the database (spawn AI params as well as RuleSets).

fwiw, I fought tooth and nail with Lethal against putting everything in LUA. So, it's nothing personal ;)

Re: Lua function ideas

Posted: Mon Oct 08, 2012 12:05 pm
by Jabantiz
For the dusk/dawn I wasn't thinking about spawns (completely forgot about them to be honest) what came to mind when I first thought of this was loping planes, at night you get a message and a debuff is applied to all the players in the zone, at dawn you got another message and the debuff is removed. Something like that I think would be better in a lua script I think. However I agree that conditonal spawns should be handled in the DB.

My idea for ai is because of the wide range of behavior ai has in eq. In some cases you want to ignore the aggro list or jump around in it, other times you want the npc to just focus on one npc/player the entire fight, there are other times where the mob needs to disenage and walk to a location without actually breaking combat, and some times you don't want the mob to melee at all. I just think it would be easier to have custom scripts for these instances instead of trying to get every thing hard coded cause that can quickly become a mess. It would also allow for users to come up with a wide variety of stuff we may not even think about now without the need to recompile the server to test.

But as you say the lua files can become cluttered with this and we need to look at all the pros and cons first. We could even seperate it and make it is own script and add ai scripts to mobs in the db so each spawn could be assigned a spawn script and ai script, this is just ideas off the top of my head though and I should clerify that when I say AI I mean the combat logic, nothing else.

Re: Lua function ideas

Posted: Mon Oct 08, 2012 5:06 pm
by Jabantiz
dusk/dawn functions were easy to implement to see what we can do with them, can easily be removed if they aren't useful. Again I do not think this should be used for conditional spawns, I agree with John that day/night spawns should be handled by the DB.

The functions are as follows

Code: Select all

function dusk(Zone)
  -- do something when changing to night
end

function dawn(Zone)
  -- do something when changing to day
end
I tested this by modifying GetSpawn() to take a zone/spawn paramet first (not part of the commit was just a quick way for me to test) and have a spawn shout a message and everything works great, when you transition from day to night or night to day the functions get called (including if you use /settime). Code is on Dev SVN.

Re: Lua function ideas

Posted: Tue Oct 09, 2012 3:26 pm
by John Adams
Jabantiz wrote:For the dusk/dawn I wasn't thinking about spawns (completely forgot about them to be honest) what came to mind when I first thought of this was loping planes, at night you get a message and a debuff is applied to all the players in the zone, at dawn you got another message and the debuff is removed.
Ahh, that makes sense then. I had no idea EQ2 had that effect. That is definitely what LE had in mind with ZoneScripts so yeah. Go for it. I am not sure it should be labeled "dusk/dawn" tho, because as you said, they could be set to any time of day. Maybe a name that is more generic? Enable(), Disable(), or something along those lines?

I think Scat and I once talked about how we could implement disabling Casting in a zone, or an area of a zone, or not allowing mounts to be summoned, etc. Lots of interesting stuff could come from that option. Good idea, Jabz.

Jabantiz wrote:My idea for ai is because of the wide range of behavior ai has in eq. In some cases you want to ignore the aggro list or jump around in it, other times you want the npc to just focus on one npc/player the entire fight, there are other times where the mob needs to disenage and walk to a location without actually breaking combat, and some times you don't want the mob to melee at all. I just think it would be easier to have custom scripts for these instances instead of trying to get every thing hard coded cause that can quickly become a mess. It would also allow for users to come up with a wide variety of stuff we may not even think about now without the need to recompile the server to test.
I think I get what you're suggesting here. Allow nearly total configuration of our Combat AI via script. It makes sense, but I would definitely prefer there be some "default behavior" coded into C++, which could be overridden by custom LUAs. Reason being, you don't want to force admins to write scripts for every type of generic encounter... unless I am still missing something?

Jabantiz wrote:We could even seperate it and make it is own script and add ai scripts to mobs in the db so each spawn could be assigned a spawn script and ai script, this is just ideas off the top of my head though and I should clerify that when I say AI I mean the combat logic, nothing else.
I actually like this idea a lot. Currently, I think our spawn_scripts table is 1:1, but it could be made to stack multiple scripts in a single spawn, group or location. The alternate is to just INCLUDE a custom/AI script into an individual spawn's spawnscript.

I was not yet sure that *every* spawn in EQ2 had a spawnscript, but it's probably likely, eh? Or at least some native, default behavior (like FaceTarget()).

Re: Lua function ideas

Posted: Tue Oct 09, 2012 3:32 pm
by Jabantiz
John Adams wrote: I think I get what you're suggesting here. Allow nearly total configuration of our Combat AI via script. It makes sense, but I would definitely prefer there be some "default behavior" coded into C++, which could be overridden by custom LUAs. Reason being, you don't want to force admins to write scripts for every type of generic encounter... unless I am still missing something?
That is exactly what I had in mind. If no AI script is found it will default to the AI in the server code, wich in the end the vast majority of mobs will use.

As for Dusk/Dawn I can rename them, I designed them to be the transition from day to night and night to day, not sure the code will be happy if some one puts in odd hours for them though, didn't think about that.

If you want any other functions to be called from the zone script let me know, as of right now the zonescript doesn't have many functions to call (Init_zone_script, player_entry, enter_location, leave_location).

Re: Lua function ideas

Posted: Thu Oct 11, 2012 5:19 am
by alfa
Dusk and Dawn can be used for Loping Plains (you got a zone wide debuff at night and zone wide buff at day or maybe it night buff and day debuff, don't remember)

Re: Lua function ideas

Posted: Thu Oct 11, 2012 12:04 pm
by John Adams
Jabantiz wrote:when I first thought of this was loping planes, at night you get a message and a debuff is applied to all the players in the zone, at dawn you got another message and the debuff is removed.
alfa, I will blame it on your Google translator ;)
alfa wrote:Dusk and Dawn can be used for Loping Plains (you got a zone wide debuff at night and zone wide buff at day or maybe it night buff and day debuff
My point about the function 'name' stands. It can be any time of day, or should be, thus "Dusk" and "Dawn" does not apply if it's 12:00 noon when the event happens.

Re: Lua function ideas

Posted: Thu Oct 11, 2012 2:24 pm
by Jabantiz
I am open to renaming them, just give me a name. I would like to point out that right now it is coded to rely on both and the time set for dawn needs to come before dusk.

Re: Lua function ideas

Posted: Thu Oct 11, 2012 2:48 pm
by John Adams
EventStart()
EventEnd()

BeginEvent()
EndEvent()

ClockStart()
ClockEnd()

TimerStart()
TimerEnd()

EffectStart()
EffectEnd()

EnableZoneWideSpecialCondition()
DisableZoneWideSpecialCondition()


Shall i keep coming up with them? :mrgreen: Since it is uncertain exactly what a zone may be starting or stopping, that is why I wish it to be generic, but sensible.

PS: I do not care if they stay dusk/dawn for now. Just keep it in mind to change somewhere down the road, or if the system grows some.