|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Quests::Q&A This is the quest support section |
11-14-2014, 01:23 PM
|
Banned
|
|
Join Date: Aug 2010
Location: Sanctuary
Posts: 269
|
|
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?
|
11-14-2014, 03:30 PM
|
Hill Giant
|
|
Join Date: Sep 2008
Location: So. California
Posts: 219
|
|
[quote]
Code:
sub EVENT_ENTERZONE{
if ($zonetime > 599 || $zonetime < 1900) {
quest::selfcast(11);
}
}
Your if statement will always be true regardless of the time.
|
11-14-2014, 04:31 PM
|
Banned
|
|
Join Date: Aug 2010
Location: Sanctuary
Posts: 269
|
|
Why is that? How can I correct it?
|
11-14-2014, 04:35 PM
|
Demi-God
|
|
Join Date: Aug 2010
Posts: 1,743
|
|
To be more specific, you need to use logical and (&&) here instead of or.
|
11-14-2014, 05:23 PM
|
Hill Giant
|
|
Join Date: Sep 2008
Location: So. California
Posts: 219
|
|
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");
}
|
11-14-2014, 07:13 PM
|
Banned
|
|
Join Date: Aug 2010
Location: Sanctuary
Posts: 269
|
|
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.
|
11-14-2014, 09:03 PM
|
Hill Giant
|
|
Join Date: Sep 2008
Location: So. California
Posts: 219
|
|
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)
|
11-14-2014, 09:20 PM
|
Banned
|
|
Join Date: Aug 2010
Location: Sanctuary
Posts: 269
|
|
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");
}
}
}
|
11-14-2014, 10:21 PM
|
Hill Giant
|
|
Join Date: Sep 2008
Location: So. California
Posts: 219
|
|
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.
|
11-15-2014, 12:20 PM
|
Banned
|
|
Join Date: Aug 2010
Location: Sanctuary
Posts: 269
|
|
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!
|
|
|
|
11-15-2014, 12:46 PM
|
Banned
|
|
Join Date: Aug 2010
Location: Sanctuary
Posts: 269
|
|
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
|
|
|
|
|
|
|
11-15-2014, 01:58 PM
|
Hill Giant
|
|
Join Date: Sep 2008
Location: So. California
Posts: 219
|
|
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
Last edited by rencro; 11-15-2014 at 02:01 PM..
Reason: Ugg my formatiing is ugg but ugg too lazy to make it look good
|
|
|
|
|
|
|
11-15-2014, 01:51 PM
|
Banned
|
|
Join Date: Aug 2010
Location: Sanctuary
Posts: 269
|
|
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.");
}
}
}
|
|
|
|
11-15-2014, 02:24 PM
|
Banned
|
|
Join Date: Aug 2010
Location: Sanctuary
Posts: 269
|
|
Thank you! Got it working now, and now I understand WHY and HOW it works, most importantly!
|
11-15-2014, 02:34 PM
|
Hill Giant
|
|
Join Date: Sep 2008
Location: So. California
Posts: 219
|
|
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.
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -4. The time now is 12:29 AM.
|
|
|
|
|
|
|
|
|
|
|
|
|