I'm trying to make a Gnome engineer, when on perception of the player, he places an Exploding Barrel on the ground, that wil detonate in 10 seconds.
How can i make the barrel explode w/o using triggers? Can I do it from the heartbeat?
Count down exploding barrel?
Débuté par
Buddywarrior
, juin 07 2013 03:50
#1
Posté 07 juin 2013 - 03:50
#2
Posté 07 juin 2013 - 04:59
// Countdown to a fiery explosion. Run via ExecuteScript() on the barrel when it is
// placed/spawned. - The Amethyst Dragon
void TenNineBoom(object oBarrel)
{
if (GetCurrentHitPoints(oBarrel) < 1) { return; } // Don't run if barrel is destroyed before time runs out
location lBarrel = GetLocation(oBarrel);
int nDamage;
effect eVis = EffectVisualEffect(VFX_IMP_FLAME_M);
int nDC = 14; // save DC
ApplyEffectAtLocation(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_FNF_FIREBALL), lBarrel);
object oTarget = GetFirstObjectInShape(SHAPE_SPHERE, RADIUS_SIZE_HUGE, lBarrel, TRUE);
while (oTarget != OBJECT_INVALID)
{
nDamage = d6(10); // generic big boom damage
int nDamage = GetReflexAdjustedDamage(nDamage, oTarget, nDC, SAVING_THROW_TYPE_FIRE, oBarrel);
if (nDamage > 0)
{
ApplyEffectToObject(DURATION_TYPE_INSTANT, eVis, oTarget);
ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectDamage(nDamage, DAMAGE_TYPE_FIRE), oTarget);
}
oTarget = GetNextObjectInShape(SHAPE_SPHERE, RADIUS_SIZE_HUGE, lBarrel, TRUE);
}
}
void main()
{
DelayCommand(10.0, TenNineBoom(OBJECT_SELF));
}
Modifié par The Amethyst Dragon, 07 juin 2013 - 08:03 .
#3
Posté 07 juin 2013 - 10:33
You could grab my script package called fun doors (111kb download) that has a door with a visible count down before exploding. Actually there are other things in there that you might find useful as well. Just grab whatever scripts you need. I included a table in the package so that people could do that. So have a play with the demo module. Just remember to give credit to whoever's script you go with when you release your work
.
TR
TR
#4
Posté 07 juin 2013 - 11:47
if (GetCurrentHitPoints(oBarrel) > 0) { return; } // Don't run if barrel is destroyed before time runs out
Last time I checked that barrel would be alive... .e.g. if has 1 hp or more means it is alive, then stop the script... So this should technically stop it from exploding while it is alive, correct?
Last time I checked that barrel would be alive... .e.g. if has 1 hp or more means it is alive, then stop the script... So this should technically stop it from exploding while it is alive, correct?
Modifié par _Guile, 07 juin 2013 - 11:49 .
#5
Posté 07 juin 2013 - 08:02
D'oh!_Guile wrote...
if (GetCurrentHitPoints(oBarrel) > 0) { return; } // Don't run if barrel is destroyed before time runs out
Last time I checked that barrel would be alive... .e.g. if has 1 hp or more means it is alive, then stop the script... So this should technically stop it from exploding while it is alive, correct?
Thanks for catching that. I'll fix it in the script.
#6
Posté 07 juin 2013 - 08:03
When the item is placed on the map before hand the heartbeat script triggers. But when the NPC places it down, it doesn't seam to trigger. Any ideas why? I've tripplechecked the resref. Item is usable, no inventory.
He is the primary part of the create object script I'm using.
oSpawn = CreateObject(OBJECT_TYPE_PLACEABLE, "engineeredexplo", lTarget);
He is the primary part of the create object script I'm using.
oSpawn = CreateObject(OBJECT_TYPE_PLACEABLE, "engineeredexplo", lTarget);
#7
Posté 07 juin 2013 - 09:06
Does the blueprint of the item have the script in the proper slot?
#8
Posté 07 juin 2013 - 09:21
yes. That was the first thing I thought about. The NPC creates the item just fine, but the script doen't look to run. But if I place the same object into the area, it works just fine. I've compiled the module several time. I also changed to a diff object and the same problem.
#9
Posté 07 juin 2013 - 09:44
Can you screenshot the script script on the object and paste every script relevant? Meaning the script to spawn the object and the script in the heartbeat, if those are the only two involved?
#10
Posté 07 juin 2013 - 09:53
What the gnome puts down. OnPerceived script
exploding barrel script is the script The Amethyst Dragon posted above. Place directly into the heartbeat of the object.
void main()
{
object oPC = GetLastPerceived();
object oTarget;
object oSpawn;
location lTarget;
oTarget = oPC;
if (!GetIsPC(oPC)) return;
if (!GetLastPerceptionSeen()) return;
ClearAllActions();
ActionMoveToObject(oPC);
ActionWait(5.0f);
ActionPlayAnimation(ANIMATION_LOOPING_GET_LOW, 1.0f, 4.0f);
lTarget = GetLocation(OBJECT_SELF);
oSpawn = CreateObject(OBJECT_TYPE_PLACEABLE, "engineeredexplo", lTarget);
ClearAllActions();
ActionMoveAwayFromObject(oPC);
}
exploding barrel script is the script The Amethyst Dragon posted above. Place directly into the heartbeat of the object.
#11
Posté 07 juin 2013 - 11:44
The script I posted before wasn't meant for a heartbeat script, it was meant to go in the script that spawns the barrel.
Here's a revised script to replace your onPerception one. It should cause the calling NPC to try to run to the PC, 5 seconds later stop and do an animation, dropping the barrel a few seconds later. 10 seconds after it's spawned, then it explodes. It's set to run once, but your can change that number if your NPC is meant to drop more than one barrel...in which case you'll need a way to keep him from running off to plant another while in the process of planting the first if he perceives another PC during that time.
Here's a revised script to replace your onPerception one. It should cause the calling NPC to try to run to the PC, 5 seconds later stop and do an animation, dropping the barrel a few seconds later. 10 seconds after it's spawned, then it explodes. It's set to run once, but your can change that number if your NPC is meant to drop more than one barrel...in which case you'll need a way to keep him from running off to plant another while in the process of planting the first if he perceives another PC during that time.
// Use for gnome's onPerception to place 1 exploding barrel.
// - The Amethyst Dragon
void DropTheBoomer(location lTarget, object oDropper)
{
// This function lets the spawning of the barrel be delayed.
object oSpawn = CreateObject(OBJECT_TYPE_PLACEABLE, "engineeredexplo", lTarget);
SetLocalObject(oDropper, "theboom", oSpawn);
}
void TenNineBoom(object oDropper)
{
object oBarrel = GetLocalObject(oDropper, "theboom");
DeleteLocalObject(oDropper, "theboom");
if (GetCurrentHitPoints(oBarrel) < 1) { return; } // Don't run if barrel is destroyed before time runs out
location lBarrel = GetLocation(oBarrel);
int nDamage;
effect eVis = EffectVisualEffect(VFX_IMP_FLAME_M);
int nDC = 14; // save DC
ApplyEffectAtLocation(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_FNF_FIREBALL), lBarrel);
object oTarget = GetFirstObjectInShape(SHAPE_SPHERE, RADIUS_SIZE_HUGE, lBarrel, TRUE);
while (oTarget != OBJECT_INVALID)
{
nDamage = d6(10); // generic big boom damage
nDamage = GetReflexAdjustedDamage(nDamage, oTarget, nDC, SAVING_THROW_TYPE_FIRE, oBarrel);
if (nDamage > 0)
{
ApplyEffectToObject(DURATION_TYPE_INSTANT, eVis, oTarget);
ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectDamage(nDamage, DAMAGE_TYPE_FIRE), oTarget);
}
oTarget = GetNextObjectInShape(SHAPE_SPHERE, RADIUS_SIZE_HUGE, lBarrel, TRUE);
}
}
void main()
{
object oPC = GetLastPerceived();
if (!GetIsPC(oPC)) return;
if (!GetLastPerceptionSeen()) return;
if (GetLocalInt(OBJECT_SELF, "droppedtheboom") != 1)
{
ClearAllActions();
ActionMoveToObject(oPC, TRUE);
DelayCommand(5.0, ActionPlayAnimation(ANIMATION_LOOPING_GET_LOW, 1.0f, 4.0f));
location lTarget = GetLocation(OBJECT_SELF); // get location to drop barrel
DelayCommand(9.0, DropTheBoomer(lTarget, OBJECT_SELF)); // drop it like it's hot!
DelayCommand(9.0, SetLocalInt(OBJECT_SELF, "droppedtheboom", 1)); // set to only drop 1 barrel
DelayCommand(9.1, ClearAllActions());
DelayCommand(9.2, ActionMoveAwayFromObject(oPC, TRUE, 20.0)); // run away! run away!
DelayCommand(19.0, TenNineBoom(OBJECT_SELF)); // start the timer
}
}
#12
Posté 07 juin 2013 - 11:52
Thanks Amethyst Dragon. No doubt the greatest game community (and most likely oldest). I'm very thankful.





Retour en haut







