Time Based Spell Bonuses
I'm trying to set up time and weather based buffs that are automatically cast on the player as the time and weather change.
I'm starting simple, just to get a feel for how this is scripted and how it works, but the method seems to be eluding me. Here's what I've got in the player.pl file in one zone currently, just to test it - when I have the script working, I'm gonna move it into global_player.pl I've currently got this set to (when it's working) cast on the player every time they zone, but what I *really* want is for the daytime buff to cast when it hits daytime, last until night, and then the nighttime buff is cast and overwrites the daytime buff. But I'm starting small, just to get a grip on this. Code:
sub EVENT_ENTERZONE{ |
[quote]
Code:
sub EVENT_ENTERZONE{ |
Why is that? How can I correct it?
|
To be more specific, you need to use logical and (&&) here instead of or.
|
Something like:
Code:
if ($zonetime > 599 && $zonetime < 1900) { |
Thanks for the help, that works perfectly for sub EVENT_CONNECT but I cannot seem to get it working for sub EVENT_ZONE or sub EVENT_ENTERZONE sadly.
|
I tested in tutorialb on player.pl in EVENT_ENTERZONE just fine, but my code is forked off of June 2014, though doubt that would make a difference ( i guess it could, but that would be bad if so)
Also, need to consider that you would need some kind of logic to turn the daytime buff off and replace with the nighttime version and vice versa, these would only run once (but as you said, start small) As for your final version may want to do it in the BuffProcees() function in zone/spell_effects.cpp although it could be done many ways I suppose in perl. Ill try to put something like this together in c++ this weekend if I get the time (on-call for work, so no promises) I already do custom buffing ala eq2 in the BuffProcess() function myself. As for your issues with EVENT_ENTERZONE, could you post your script for that? Curious why it works for me but not you (code differences notwithstanding) |
rencro, that would be FANTASTIC if you would take the time to code that for our server. I will indeed need some way to turn the daytime buff off and replace with the night buff, but hadn't gotten that far in my own thinking yet.
Code:
sub EVENT_ENTER_ZONE { |
You have an underscore between Enter and Zone, ie EVENT_ENTER_ZONE instead of EVENT_ENTERZONE more than likely from your testing going back and forth between settings.
|
That fixed it, rencro! Thank you!
Now just to figure out how to make the night spell overwrite the day spell, and vice versa. Looking into this now! |
This is my first attempt at trying to cancel the daytime buff if the player zones and it is nighttime. Seems to have broken the entire script. Continuing to try and solve this...
Code:
sub EVENT_CONNECT { Attempt 2 Code:
sub EVENT_CONNECT { Attempt 3... if someone could gently nudge me in the right direction (or crudely beat me over the head with it) that would be awesome.. Code:
sub EVENT_TIMER { I should note that in this last attempt I am simply trying to change the night time message to trigger in a different fashion so I can then insert the buff removal code once I see that it's checking a specific time and not just going by an else statement |
Code:
sub EVENT_CONNECT { |
You shoulnd't need to do another time compare because if its not daytime, then an else means its gotta be dark
On attempt two, there is an error with the if statement Code:
sub EVENT_CONNECT { Code:
sub EVENT_CONNECT { |
Thank you! Got it working now, and now I understand WHY and HOW it works, most importantly!
|
I'm testing this is both BuffProcess and in BuffTic by creating a new SE_TimeOfDayBuff, not sure which would be better but this could all be done from perl by I guess having a timer constantly running on player zonein that checks the status of the buff on said player and, if the time changes while they are still in zone, to fade one and apply the other. Just dont know how "expensive" that would be having all these timers running in perl. Maybe Kingly Krab or Akka can chime in and help you there, as they definitely have perl grasped far better than I.
But Im intrigued by this idea and will keep working on it in c++. The problem if you apply a c++ solution is you will have to maintain(merge) it any time you decide to upgrade the server source. |
I have done a few source code edits of my own, so that would need to be done (the merging) anyhow, when the time comes to upgrade the server source.
I was myself puzzling over how to implement a "live" time change switch, like you mentioned, instead of just triggering on zoning. Incidentally, I have managed to break this script again, by trying to reverse what we coded and cancel out the night time buff when it's day time. I will highlight the area I think caused the problem, and explain why I think it happened. Code:
sub EVENT_TIMER { I believe this happened because we've kept the night check as just an "else" statement and not actually coded in the times that it considers to be night, so when I added another "else" in there, it's getting confused about what's actually going on. This is why I thought we needed to actually designate the specific times of night, instead of just going by "else" --- does that make sense, and am I correct in thinking this is what caused the problem? |
Here is your script edited for Arias, I have used spellid 11 as the day buff. Putting this back into .pl will be almost identical.
Code:
if ($text=~/timebuff/i) { quest::selfcast(346); #cast night buff but we are still in the "else" day/night check, but are outside of the "if has daytime buff check, which is also part of the else daytime/nightime check" Sorry, i suck at explaining things. Also, in this case you will get a message that it is dark, then a message that the sun fades, so if you would want this switched then just move the its very dark outside messaage to after the check for daytime buff and vice versa. |
rencro, you got it! This one works exactly as I wanted it to! Would still love to get it working in a "live" manner, as in automatically firing when the right times hit, but I'm more than happy with its current implementation! Maybe Kingly will know how to get it to update itself automatically without needing to zone.
Edit: I'm thinking about this, and my guess is that timers would somehow be involved in making this update itself without the need to zone......... |
Actually you did it, this is your code, I just helped a bit with the formatting. This could get silly complicated depending how far you want to push this idea. For instance if its nightime and the class in Necro, do they get a boost buff, where as if its a paladin do they get maybe a slight debuff.
Also, if its daytime and it starts to rain, do the day buffs get halved, and do druids get a silly powerfull storm buff, also what happens when inside a dungeon, I assume you would negate the system altogether but the choice is yours. ect ect ect, lots of places to take this. I'll post the c++ code sometime soon, just want to play with different setting ect first. |
Awesome! That's my ultimate plan, to make this into a very complex and robust Time and Weather System. I just wanted to start small so I could get a handle on how this would be working in practice. Theories, I have many, but putting them into practice is where I sometimes have trouble :)
Next I am going to be looking into the DayNight npcs and DayNight.pl in quest globals to find a way to make this update itself automatically when the time of day changes. Once I have a more robust version of this, with weather effects and such, I will be posting it for others who are interested in doing something like this with their servers. |
Edit: Nevermind!
|
Here is what i have so far, I built this on my fork, and tested, but a diff from my fork would be useless so I imported into the latest source after doing a diff between my source and the latest (not too many changes, and nothing I think that would cause any issues) Note, I did not build or test this on the current live source even though it is diffed against it.
I cannot stress enough to create a branch of your source, patch this in, and build on a TEST ENVIRONMENT, not your production server, also that test environment should be using a COPY of your production database, not the actual production db itself (sorry if I seem overly anal, but I assisted a server op before with the same provisos, and to thoroughly test my changes, and he told me he would, but he went live with it 5 minutes later :???: and there were countless bugs as a result affecting the live players :facepalm Rant over diff current source Code:
diff --git a/common/spdat.cpp b/common/spdat.cpp All this does is check if any of these buffs are active, and if its active during the wrong time-frame to remove it and put the relevant version on. You still need to turn the relevant buff on via perl for this to do the checks on. I made this to where it is easily expandable, can add more spells in, do compares of day buffs during the day ect ect. Also, please anyone, feel free to tell me where this can be improved ect.. |
All times are GMT -4. The time now is 04:04 AM. |
Powered by vBulletin®, Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.