Go Back   EQEmulator Home > EQEmulator Forums > Quests > Quests::Custom

Quests::Custom Custom Quests here

Reply
 
Thread Tools Display Modes
  #1  
Old 08-02-2024, 10:34 PM
ccyre3
Fire Beetle
 
Join Date: Nov 2022
Posts: 20
Default Script Check

This script works as its supposed to, but i get line 7 errors about setnexthpevent. Yes, I'm new, and yes, i used gpt to help me haha. anyway, any ideas why the error?

Code:
sub EVENT_SPAWN {
    # Variables to set hp and get flag to set hp
    my $hp_key = $npc->GetNPCTypeID() . "-60-hp";
    
    # Check if the 60% key exists; if it doesn't, set it to 60% hp event
    if (quest::get_data($hp_key) == 1) {
        quest::setnexthpevent(30);
        # Adjust HP if spawned with reduced health
        my $new_hp = $npc->GetMaxHP() * 0.60;
        $npc->SetHP($new_hp);
    } else {
        quest::setnexthpevent(60);
    }
}

sub EVENT_HP {
    # First HP check at 60%
    if ($hpevent == 60) {
        my $hp_key = $npc->GetNPCTypeID() . "-60-hp";
        quest::set_data($hp_key, 1);

        # Get current HP percentage
        my $current_hp = $npc->GetHP();
        my $max_hp = $npc->GetMaxHP();
        my $hp_percentage = $current_hp / $max_hp;

        # Depop current NPC and spawn at new location with the same HP percentage
        quest::depop();
        my $x = 239.61;
        my $y = -9.02;
        my $z = -5.50;
        my $h = 492.75;
        my $boss_id = 1228;
        my $new_npc = quest::spawn2($boss_id, 0, 0, $x, $y, $z, $h);
        my $new_npc_entity = $entity_list->GetNPCByID($new_npc);
        if ($new_npc_entity) {
            my $new_hp = $new_npc_entity->GetMaxHP() * $hp_percentage;
            $new_npc_entity->SetHP($new_hp);
            $new_npc_entity->SetNextHPEvent(30); # Ensure the new NPC continues the HP event
        }
    }
    # Second HP check at 30%
    elsif ($hpevent == 30) {
        # Make the NPC immune to all attacks for 10 seconds
        $npc->SetInvul(1);  # Make NPC invulnerable

        # Schedule an event to remove invulnerability after 10 seconds
        quest::settimer("remove_invul", 10);
    }
}

sub EVENT_TIMER {
    if ($timer eq "remove_invul") {
        quest::stoptimer("remove_invul");
        $npc->SetInvul(0);  # Remove invulnerability
    }
}

sub EVENT_DEATH_COMPLETE {
    # Deletes the key on death
    my $hp_key = $npc->GetNPCTypeID() . "-60-hp";
    quest::delete_data($hp_key);
    quest::signalwith(77027, 2, 2); # Notify NPC with ID 77027 with a 2-second delay when NPC 1228 dies
    
    # Shout message on death
    quest::shout("In the end... yyyXXxxxyronnnn iwwwiiiilll rrooDeSStttrrooYyYy YuooYouuu");
}

Last edited by joligario; 08-03-2024 at 07:44 AM.. Reason: Help you with formatting
Reply With Quote
  #2  
Old 08-03-2024, 04:46 AM
joligario's Avatar
joligario
Developer
 
Join Date: Mar 2003
Posts: 1,497
Default

Not seeing any issues with that call, but you should check that the key exists before checking its value

Last edited by joligario; 08-03-2024 at 07:45 AM.. Reason: clarity
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

   

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


 

Everquest is a registered trademark of Daybreak Game Company LLC.
EQEmulator is not associated or affiliated in any way with Daybreak Game Company LLC.
Except where otherwise noted, this site is licensed under a Creative Commons License.
       
Powered by vBulletin®, Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3