EQEmulator Forums

EQEmulator Forums (https://www.eqemulator.org/forums/index.php)
-   Quests::Q&A (https://www.eqemulator.org/forums/forumdisplay.php?f=599)
-   -   Custom Boss (test) (https://www.eqemulator.org/forums/showthread.php?t=32115)

Reynin89 09-15-2010 09:56 AM

Custom Boss (test)
 
Ive been messing with timers and I was just wondering if anyone knew why in the world this boss will NOT cast this spell, has equal brackets, ID is correct, syntax looks fine.. so wth?
Code:

sub EVENT_COMBAT {
 if ($combat_state == 1) {
quest::settimer(test,3); }

 if ($combat_state == 0) {
quest::stoptimer(test); }


sub EVENT_TIMER
{
if($timername == test)
{
quest::castspell($userid,92);

}
}}


Thanks in advance. Lol im sure its a nub mistake >_<

Akkadius 09-15-2010 10:07 AM

Quote:

Originally Posted by Reynin89 (Post 192152)
Ive been messing with timers and I was just wondering if anyone knew why in the world this boss will NOT cast this spell, has equal brackets, ID is correct, syntax looks fine.. so wth?
Code:

sub EVENT_COMBAT {
 if ($combat_state == 1) {
quest::settimer(test,3); }

 if ($combat_state == 0) {
quest::stoptimer(test); }
}

sub EVENT_TIMER
{
if($timername == test)
{
quest::castspell($userid,92);
quest::stoptimer("test");
}
}}


Thanks in advance. Lol im sure its a nub mistake >_<

Red is an extra bracket, Dark Orange is a missing bracket, and Blue needs to be 'eq' for an equal operator for strings, not integers. Test will work but you also want to quote your strings so it would be "test" in your script. You will also want to stop timer in your script or else it will loop.

Reynin89 09-15-2010 10:09 AM

Ahhh great thank you Akkadian!

Reynin89 09-15-2010 10:15 AM

Hm.. Well right now I have

Code:

sub EVENT_COMBAT {
 if ($combat_state == 1) {
quest::settimer(test,3); }

 if ($combat_state == 0) {
quest::stoptimer("test"); }
}


sub EVENT_TIMER
{
if($timername "eq" test)
{
quest::castspell($userid,92);

}
}

and it still wont work. I tried adding quest::stoptimer("test"); into the sub EVENT_TIMER like u said, and it still didnt work. I figured because I already had 1 in the combat event? the
Code:

if ($combat_state == 0) {
quest::stoptimer("test"); }

I need to stay there so that way it will stop casting if aggro drops right?

Akkadius 09-15-2010 10:16 AM

Quote:

Originally Posted by Reynin89 (Post 192154)
Ahhh great thank you Akkadian!

Also forgot about your $timer object, it needs to be $timer. See an example script below.

Code:

sub EVENT_SPAWN{
        my $npc_name = $npc->GetCleanName();
        quest::gmsay("$npc_name has spawned in [$zoneln]");
        quest::shout("I have slain many Iksar and any tribe that defies our goals, you mortals know nothing about what is the truth!");
        $npc->CameraEffect(2000, 5);
        quest::settimer("repeatsay",600);
        quest::doanim(44);
}

sub EVENT_TIMER{
        if ($timer eq "repeatsay"){
        quest::shout("I have slain many Iksar and any tribe that defies our goals, you mortals know nothing about what is the truth!");
        $npc->CameraEffect(2000, 5);
        quest::stoptimer("repeatsay");
        quest::settimer("repeatsay",600);
        quest::doanim(44);
        }
}

sub EVENT_COMBAT
{
        my $npc_name = $npc->GetCleanName();
        if($combat_state == 1)
                {
                $NextActivate = 90;
                $StartNPCID = 2328802;
                quest::gmsay("$npc_name has been engaged");
                $x = $npc->GetX();
                $y = $npc->GetY();
                $z = $npc->GetZ();
                $h = $npc->GetHeading();
                quest::setnexthpevent(90);
                quest::shout("You dare challenge our existence? The Sethos will never have patience for you...");
                $npc->CameraEffect(2000, 7);
                quest::stoptimer("repeatsay");
                }
        if($combat_state == 0)
                {
                quest::say("You mortals are so pathetic.");
                $npc->CameraEffect(2000, 7);
                quest::settimer("repeatsay", 600);
                plugin::MobHealPercentage(100);
                }
}

sub EVENT_HP
{
if ($hpevent == $NextActivate)
        {
        $NextActivate -= 10;
        $StartNPCID += 1;
        quest::setnexthpevent($NextActivate);
        quest::signalwith($StartNPCID, 10, 10);
        quest::shout("How about fighting some old friends of yours maybe?");
        $npc->CameraEffect(2000, 3);
        }
}

sub EVENT_SLAY{
        quest::say("Hmm another $race at my feet, weak mortal...");
}

sub EVENT_DEATH{
        my $npc_name = $npc->GetCleanName();
        quest::gmsay("$npc_name has been slain in [$zoneid] : [$zoneln]");
}


Reynin89 09-15-2010 10:22 AM

Ohhh.. Great thanks so much! Working perfect now :)

joligario 09-15-2010 10:26 AM

You probably need to learn about strings:

Code:

sub EVENT_COMBAT {
  if ($combat_state == 1) {
    quest::settimer("test",3);
  }
  if ($combat_state == 0) {
    quest::stoptimer("test");
  }
}

sub EVENT_TIMER {
  if($timer eq "test") {
    quest::castspell($userid,92);
  }
}

FYI: From http://www.eqemulator.net/wiki/wikka...=QuestTutorial

quest::castspell(id,spellid) - Casts "spell" on entity with "id". This is buggy, if it does not work try $npc->CastSpell(id,spellid);

Reynin89 09-15-2010 10:27 AM

Bah! I didnt know, its casting it when not even aggro'd if ur near the mob. It will just cast the spell, why is that the case when i have
Quote:

if ($combat_state == 0) {
quest::stoptimer("test"); }
that should make it so if the mob isnt in combat it wont cast it i thought?

Akkadius 09-15-2010 10:28 AM

Quote:

Originally Posted by Reynin89 (Post 192159)
Bah! I didnt know, its casting it when not even aggro'd if ur near the mob. It will just cast the spell, why is that the case when i have
that should make it so if the mob isnt in combat it wont cast it i thought?

Yes, that is correct.

Reynin89 09-15-2010 10:29 AM

oh great guide Joligario ty.

Reynin89 09-15-2010 10:30 AM

But thats why im confused Akkadian, I have that in. But ill attack the mob, itll cast. Ill #repop and as soon as it gets back it starts casting on me again..

Akkadius 09-15-2010 10:34 AM

Quote:

Originally Posted by Akkadius (Post 192153)
Red is an extra bracket, Dark Orange is a missing bracket, and Blue needs to be 'eq' for an equal operator for strings, not integers. Test will work but you also want to quote your strings so it would be "test" in your script. You will also want to stop timer in your script or else it will loop.

Refer to this post.

joligario 09-15-2010 10:37 AM

Akkadius: FYI - In your code sample, you don't need to stop and start your repeatsay timer in your timer block above. Just redundant as the timer cycles.

Reynin89 09-15-2010 10:45 AM

Im reading it Akkadius, but im unsure. I am somewhat new and starting to learn scripting.. I mean, im reading that, but im still unsure as to why the mob is casting out of combat when i have that code in there?

Reynin89 09-15-2010 10:47 AM

I tried changing the integer like u said so now its
Quote:

if ($combat_state eq 0) {
quest::stoptimer("test"); }
}
but its still just casting on me when I go near him.

Akkadius 09-15-2010 11:21 AM

Quote:

Originally Posted by Reynin89 (Post 192167)
I tried changing the integer like u said so now its but its still just casting on me when I go near him.

Code:

sub EVENT_COMBAT {
  if ($combat_state == 1) {
    quest::settimer("test",3);
  }
  if ($combat_state == 0) {
    quest::stoptimer("test");
  }
}

sub EVENT_TIMER {
  if($timer eq "test") {
    quest::castspell($userid,92);
    quest::stoptimer("test");
  }
}


Akkadius 09-15-2010 11:25 AM

Quote:

Originally Posted by joligario (Post 192164)
Akkadius: FYI - In your code sample, you don't need to stop and start your repeatsay timer in your timer block above. Just redundant as the timer cycles.

Yep, I'm aware that it cycles, it's just habitual as it I use the same formatting in many other scripts that require a stop, sometimes templates are copy/pasted too and find/replaced. I appreciate you pointing it out. 8 D

joligario 09-15-2010 11:39 AM

What do you want him to do? According to the code you have given, he is acting as intended. If you aggro the NPC, his combat state changes to 1. If you are standing near him when he repops, he will isntantly aggro you. If you want to test it, you should try turning on your GM flag (#gm on) so that he won't aggro you until you attack him.

Reynin89 09-15-2010 04:30 PM

Well hes non kos, and he shouldnt be casting the spell on a random player that just runs by. Hes an indifferent mob.

Reynin89 09-15-2010 04:45 PM

Yea when I add in that extra stoptimer, the mob will only cast the spell once, instead of on the timer.
Quote:

sub EVENT_COMBAT {
if ($combat_state == 1) {
quest::settimer("test",3); }

if ($combat_state eq 0) {
quest::stoptimer("test"); }
}


sub EVENT_TIMER
{
if($timer eq "test")
{
quest::castspell(92,$targetid);
quest::stoptimer("test");

}
}

Caryatis 09-15-2010 08:09 PM

I find it hilarious that you have been given a ton of examples of proper formatting and you still don't use a tab or space for anything. You will go far...

Secrets 09-15-2010 08:58 PM

Quote:

Originally Posted by Caryatis (Post 192185)
I find it hilarious that you have been given a ton of examples of proper formatting and you still don't use a tab or space for anything. You will go far...

I find it hilarious that you are a critic, yet the subject that you are mentioning was not brought up in this thread, therefore he is supposed to assume that he needs to do that (which he doesn't, but it certainly helps.)

Reynin89 09-15-2010 09:28 PM

Im sorry... Im very new to this, I cant find any of my old timer scripts to look off of. Ive read the examples I just still cant figure it out. Im still studying it. I just dont understand. Ive read tutorials on the site and the GeorgeS Tools lexicon page. Im trying. But I just cant get the darn thing to loop, but stop when the mob isnt in combat.

And as far as your
Quote:

You will go far...
Caryatis, I enjoy scripting and learning new things, and ill keep studying and practicing it and I will go far. Not everyone can start off a pro.

Caryatis 09-15-2010 10:00 PM

Not to derail your thread anymore but its all part of the package. Nobody had to tell me to format things a certain way, I looked at examples and thought "damn that does make it alot easier to read and see errors." So when somebody is coming here asking about problems(and if you read the whole thread, he initially had syntax errors as well) and doesnt decide to make his code both more readable for him and for his audience, I do find it hilarious.

Either way our style is totally different Secrets but I can guarantee this guy will use more legible formatting from now on, so I count it as a victory :)


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

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