EQEmulator Forums

EQEmulator Forums (https://www.eqemulator.org/forums/index.php)
-   Quests::Q&A (https://www.eqemulator.org/forums/forumdisplay.php?f=599)
-   -   Time Based Spell Bonuses (https://www.eqemulator.org/forums/showthread.php?t=39011)

zerjz3 11-14-2014 01:23 PM

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{
  if ($zonetime > 599 || $zonetime < 1900) {
  quest::selfcast(11);
  }
  }

What am I doing wrong here?

rencro 11-14-2014 03:30 PM

[quote]
Code:

sub EVENT_ENTERZONE{
  if ($zonetime > 599 || $zonetime < 1900) {
  quest::selfcast(11);
  }
  }

Your if statement will always be true regardless of the time.

zerjz3 11-14-2014 04:31 PM

Why is that? How can I correct it?

lerxst2112 11-14-2014 04:35 PM

To be more specific, you need to use logical and (&&) here instead of or.

rencro 11-14-2014 05:23 PM

Something like:

Code:

if ($zonetime > 599 && $zonetime < 1900) {
        $client->Message(12, "The time is right");
        quest::selfcast(11);
    }
    else {
        $client->Message(13, "Be very afraid of the dark");
    }


zerjz3 11-14-2014 07:13 PM

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.

rencro 11-14-2014 09:03 PM

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)

zerjz3 11-14-2014 09:20 PM

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 {
        if (!defined $qglobals{$zonesn}) {
                quest::gmsay("$name has discovered the zone $zoneln.", 335, 1, 0, 0);
                quest::setglobal($zonesn, 1, 7, "F");
        }
        quest::settimer("Zoned", 5);
}

sub EVENT_TIMER {
        if ($timer eq "Zoned") {
                quest::stoptimer("Zoned");
                if ($zonesn=~/Nexus/i && !defined $qglobals{"NexusBind"}) {
                        quest::selfcast(35);
                        quest::setglobal("NexusBind", 1, 5, "F");
                }
                if ($zonetime > 599 && $zonetime < 1900) {
                        $client->Message(12, "The time is right");
                        quest::selfcast(992);
                } else {
                        $client->Message(13, "Be very afraid of the dark");
                }
        }
}


rencro 11-14-2014 10:21 PM

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.

zerjz3 11-15-2014 12:20 PM

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!

zerjz3 11-15-2014 12:46 PM

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 {
        quest::setlanguage(0, 100);
        quest::setskill(40, 200);
        if ($zonetime > 599 && $zonetime < 1900) {
        $client->Message(12, "The sun's rays beam down.");
        quest::selfcast(992);
    } else {
        $client->Message(13, "It's very dark outside.");
                if($client->FindBuff(992));
                $client->BuffFadeBySpellID(992);
    }
}

sub EVENT_DISCOVER_ITEM {
        quest::gmsay("$name has discovered the item " . quest::varlink($itemid) . ".", 335, 1, 0, 0);
}
 
sub EVENT_COMBINE_SUCCESS {
        if (!defined $qglobals{$recipe_name}) {
                quest::gmsay("$name has discovered the recipe for '$recipe_name'.", 335, 1, 0, 0);
                quest::setglobal($recipe_name, 1, 7, "F");
        }
}

sub EVENT_ENTERZONE {
        if (!defined $qglobals{$zonesn}) {
                quest::gmsay("$name has discovered the zone $zoneln.", 335, 1, 0, 0);
                quest::setglobal($zonesn, 1, 7, "F");
        }
        quest::settimer("Zoned", 5);
}

sub EVENT_TIMER {
        if ($timer eq "Zoned") {
                quest::stoptimer("Zoned");
                if ($zonesn=~/Nexus/i && !defined $qglobals{"NexusBind"}) {
                        quest::selfcast(35);
                        quest::setglobal("NexusBind", 1, 5, "F");
                }
                if ($zonetime > 599 && $zonetime < 1900) {
                        $client->Message(12, "The sun's rays beam down");
                        quest::selfcast(992);
                } else {
                        $client->Message(13, "It's very dark outside.");
                                        if($client->FindBuff(992));
                $client->BuffFadeBySpellID(992);
                }
        }
}


Attempt 2

Code:

sub EVENT_CONNECT {
        quest::setlanguage(0, 100);
        quest::setskill(40, 200);
        if ($zonetime > 599 && $zonetime < 1900) {
        $client->Message(12, "The sun's rays beam down.");
        quest::selfcast(992);
    } elsif ($zonetime < 599 && $zonetime > 1900) {
        $client->Message(13, "It's very dark outside.");
                if($client->FindBuff(992));
                $client->BuffFadeBySpellID(992);
    }
}


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 {
        if ($timer eq "Zoned") {
                quest::stoptimer("Zoned");
                if ($zonesn=~/Nexus/i && !defined $qglobals{"NexusBind"}) {
                        quest::selfcast(35);
                        quest::setglobal("NexusBind", 1, 5, "F");
                }
                if ($zonetime > 599 && $zonetime < 1900) { #between 6am and 7pm
                        $client->Message(12, "The sun's rays beam down");
                        quest::selfcast(992);
                        }
        if ($zonetime < 599 && $zonetime > 1900) { #between 7pm and 6am
                        $client->Message(13, "It's very dark outside.");
                }
        }
}


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

zerjz3 11-15-2014 01:51 PM

Code:

sub EVENT_CONNECT {
        quest::setlanguage(0, 100);
        quest::setskill(40, 200);
        if ($zonetime > 599 && $zonetime < 1900) {
        $client->Message(12, "The sun's rays beam down.");
        quest::selfcast(992);
    }
elsif ($zonetime < 599 && $zonetime > 1900) { #night
        $client->Message(13, "It's very dark outside.");
    }
}

sub EVENT_DISCOVER_ITEM {
        quest::gmsay("$name has discovered the item " . quest::varlink($itemid) . ".", 335, 1, 0, 0);
}
 
sub EVENT_COMBINE_SUCCESS {
        if (!defined $qglobals{$recipe_name}) {
                quest::gmsay("$name has discovered the recipe for '$recipe_name'.", 335, 1, 0, 0);
                quest::setglobal($recipe_name, 1, 7, "F");
        }
}

sub EVENT_ENTERZONE {
        if (!defined $qglobals{$zonesn}) {
                quest::gmsay("$name has discovered the zone $zoneln.", 335, 1, 0, 0);
                quest::setglobal($zonesn, 1, 7, "F");
        }
        quest::settimer("Zoned", 5);
}

sub EVENT_TIMER {
        if ($timer eq "Zoned") {
                quest::stoptimer("Zoned");
                if ($zonesn=~/Nexus/i && !defined $qglobals{"NexusBind"}) {
                        quest::selfcast(35);
                        quest::setglobal("NexusBind", 1, 5, "F");
                }
                if ($zonetime > 599 && $zonetime < 1900) { #day
                        $client->Message(12, "The sun's rays beam down.");
                        quest::selfcast(992);
                }
elsif ($zonetime < 599 && $zonetime > 1900) { #night
                        $client->Message(13, "It's very dark outside.");
                }
        }
}


rencro 11-15-2014 01:58 PM

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 {
        quest::setlanguage(0, 100);
        quest::setskill(40, 200);
        if ($zonetime > 599 && $zonetime < 1900) {
        $client->Message(12, "The sun's rays beam down.");
        quest::selfcast(992);
    } else {
        $client->Message(13, "It's very dark outside.");
                if($client->FindBuff(992));
                $client->BuffFadeBySpellID(992);
    }
}

Need the { } brackets to process this if statement

Code:

sub EVENT_CONNECT {
        quest::setlanguage(0, 100);
        quest::setskill(40, 200);
        if ($zonetime > 599 && $zonetime < 1900) {
        $client->Message(12, "The sun's rays beam down.");
        quest::selfcast(992);
    } else {
        $client->Message(13, "It's very dark outside.");
                if($client->FindBuff(992)){
                    $client->Message(13, "Its dark and you have the daytime buff, so nighty night buff");
                    $client->BuffFadeBySpellID(992);
                } else {
                    $client->Message(13, "Its night, but you dont have the daytime buff");
                }

    }
}

Something like that, didnt actually test this in player.pl but on arias, but should be ok as long as I got all the brackets right/ Also you can ignore the messages or remove them I just use them for troubleshooting

zerjz3 11-15-2014 02:24 PM

Thank you! Got it working now, and now I understand WHY and HOW it works, most importantly!

rencro 11-15-2014 02:34 PM

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.


All times are GMT -4. The time now is 01:01 PM.

Powered by vBulletin®, Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.