Skip to content

Barrel Bomb -

I have the following script on the OnHeartbeat of my barrel object. When the object is already in the area the script counts down and it blows up just fine. However when an NPC places it down, it doesn't count down or explode but it does Destroy itself. What am I missing so the NPC can place it down and it will work correctly?
void explode()
{
        object oTarget;
        oTarget = OBJECT_SELF;
        ActionCastSpellAtObject(SPELL_FIREBALL, oTarget, METAMAGIC_ANY, TRUE, 9, PROJECTILE_PATH_TYPE_DEFAULT, TRUE);
        ActionSpeakString( "*Ka-B0oM!!*", TALKVOLUME_TALK);
        DestroyObject(oTarget, 0.5);
       
}



void main()
{
    int DoOnce = GetLocalInt(OBJECT_SELF, "DoOnce");

    if(DoOnce == 1)
    {
        return;
    }

     if(DoOnce != 1)
     {
        SetLocalInt(OBJECT_SELF, "DoOnce", 1);
        DelayCommand(3.1f, ActionSpeakString( "3", TALKVOLUME_TALK));
        DelayCommand(4.2f, ActionSpeakString( "2", TALKVOLUME_TALK));
        DelayCommand(5.2f, ActionSpeakString( "1", TALKVOLUME_TALK));
        DelayCommand(5.4f, explode());
     }
}


Comments

  • ForSeriousForSerious Member Posts: 471
    Try changing it to a function that gets called on the object you create when the NPC places the bomb.

    If that doesn't work, share your code of how the NCP places it.

    Bonus: Here's some ticking sounds—if you want.
        DelayCommand(3.1f, PlaySound("gui_trapsetoff"));
        DelayCommand(4.2f, PlaySound("gui_trapsetoff"));
        DelayCommand(5.2f, PlaySound("gui_trapsetoff"));
    
  • TerrorbleTerrorble Member Posts: 183
    I was wondering if you are close enough to it to see the chat messages and/or the explosion VFX. What happens if the TALKVOLUME is set to SHOUT?
  • BuddywarriorBuddywarrior Member Posts: 62
    Here is the script I'm using. It's OnPerception. The NPC places the Barrel just fine, but again the barrel onheartbeat script only trigger the DestroyObject, (including after having main as DelayCommand(2.0f,begin()); added to the barrel script as suggested.)
    void place_bomb()
    {
    
        object oTarget;
        object oSpawn;
        location lTarget;
        oTarget = OBJECT_SELF;
    
        lTarget = GetLocation(oTarget);
    
        oSpawn = CreateObject(OBJECT_TYPE_PLACEABLE, "barrelbomb", lTarget);
    
        oTarget = oSpawn;
    
    }
    
    
    
    
    void main()
    {
    
    
    
    object oPC = GetLastPerceived();
    
    if (!GetIsPC(oPC)) return;
    
    if (!GetLastPerceptionSeen()) return;
    
    float duration = 3.0f;
    duration = duration + IntToFloat(d3());
    
    say_this();
    
    
    
    ActionMoveToObject(oPC);
    DelayCommand( duration + 0.5, ClearAllActions());
    DelayCommand( duration + 0.5, ActionPlayAnimation( ANIMATION_LOOPING_GET_LOW, 2.0f));
    DelayCommand( duration + 1.0, ClearAllActions());
    DelayCommand( duration + 1.5, place_bomb());
    DelayCommand( duration + 2.0, ActionMoveAwayFromObject(oPC));
    DelayCommand( duration + 9.0, ActionAttack(oPC));
    
    
    
    
    }
    
  • ForSeriousForSerious Member Posts: 471
    All you have to do is delete the heartbeat script from the OnHeartBeat slot and call it in your on perception script:
    void place_bomb()
    {
        object oTarget;
        object oSpawn;
        location lTarget;
        oTarget = OBJECT_SELF;
        lTarget = GetLocation(oTarget);
        oSpawn = CreateObject(OBJECT_TYPE_PLACEABLE, "barrelbomb", lTarget);
        ExecuteScript("heartbomb", oSpawn); // This is how to call the script you had in the OnHeartBeat slot on the bomb.
        //oTarget = oSpawn; <-- This line does nothing.
    }
    
    void main()
    {
        object oPC = GetLastPerceived();
        if(!GetIsPC(oPC))
        {
            return;
        }
        if(!GetLastPerceptionSeen())
        {
            return;
        }
        float duration = 3.0f;
        duration = duration + IntToFloat(d3());
        //say_this(); <-- I don't have this function...
        ActionMoveToObject(oPC);
        DelayCommand(duration + 0.5, ClearAllActions());
        DelayCommand(duration + 0.5, ActionPlayAnimation(ANIMATION_LOOPING_GET_LOW, 2.0f));
        DelayCommand(duration + 1.0, ClearAllActions());
        DelayCommand(duration + 1.5, place_bomb());
        DelayCommand(duration + 2.0, ActionMoveAwayFromObject(oPC));
        DelayCommand(duration + 9.0, ActionAttack(oPC));
    }
    
    As you can see I named the script 'heartbomb'. Just change that to what you have and it will work. At least it did for me. The NPC walked everywhere, but maybe you know how to change that.
  • BuddywarriorBuddywarrior Member Posts: 62
    I'll try it, thank you for the ExecuteScript("heartbomb", oSpawn); idea.
Sign In or Register to comment.