Barrel Bomb -
Buddywarrior
Member Posts: 62
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());
}
}
0
Comments
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"));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)); }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.