Author Topic: Exploding Barrels System  (Read 369 times)

Legacy_JerrodAmolyan

  • Full Member
  • ***
  • Posts: 175
  • Karma: +0/-0
Exploding Barrels System
« on: August 12, 2013, 07:53:11 pm »


                So I am trying to make working barrels that you can blow up if you use fire or a gun (I use blackpowder guns in my module) 

So far I was happy with the one I had made at first, but then I noticed it just won't damage anything with the normal fireball spells, so I try to make a new system... unsuccessfully.

Any help is appreciated (again, lol... I've lots of time and problems.)
               
               

               
            

Legacy_JerrodAmolyan

  • Full Member
  • ***
  • Posts: 175
  • Karma: +0/-0
Exploding Barrels System
« Reply #1 on: August 12, 2013, 07:56:09 pm »


               void ExplodeAtLocation(location lTarget, int nDamage, int nSaveDC = 30, float fRadius = 7.)
{
 int nDamageAfterSave = GetReflexAdjustedDamage(nDamage, oObject, nSaveDC);
 object oObject = GetFirstObjectInShape(SHAPE_SPHERE, fRadius, lTarget, FALSE, OBJECT_TYPE_CREATURE | OBJECT_TYPE_PLACEABLE | OBJECT_TYPE_DOOR);
 oObject = GetNextObjectInShape(SHAPE_SPHERE, fRadius, lTarget, FALSE, OBJECT_TYPE_CREATURE | OBJECT_TYPE_PLACEABLE | OBJECT_TYPE_DOOR);
 ApplyEffectToObject( DURATION_TYPE_INSTANT, EffectDamage(nDamageAfterSave, DAMAGE_TYPE_FIRE), oObject);

}
//
void main()
{
 location lSource = GetLocation(OBJECT_SELF);
 object oPC = GetLastHostileActor;
 object oWeapon = GetItemInSlot(INVENTORY_SLOT_RIGHTHAND,oPC);

if ((GetDamageDealtByType(DAMAGE_TYPE_FIRE)))
{
 DelayCommand(0.1, ExplodeAtLocation(lSource, d20(6)));
 PlaySound("zep_explosion");

}

else if ((GetStringLeft(GetResRef(oWeapon), 4)== "gun_"))
{
 DelayCommand(0.1, ExplodeAtLocation(lSource, d20(6)));
 PlaySound("zep_explosion");
}
else SendMessageToPC(oPC, "You must use fire or a gun");
return;
}
               
               

               
            

Legacy_JerrodAmolyan

  • Full Member
  • ***
  • Posts: 175
  • Karma: +0/-0
Exploding Barrels System
« Reply #2 on: August 12, 2013, 07:56:54 pm »


               That's all I've come up with, and surprisingly it doesn't work... I've tried doing ifs and whiles and dos... but I have no real idea how they work so... well. Help me '<img'>
               
               

               
            

Legacy_The Amethyst Dragon

  • Hero Member
  • *****
  • Posts: 2981
  • Karma: +0/-0
Exploding Barrels System
« Reply #3 on: August 12, 2013, 08:55:02 pm »


               This may help...


void ExplodeAtLocation(location lTarget, int nDamage)
{
int nDamageAfterSave;
// get the first object in the area of effect
object oObject = GetFirstObjectInShape(SHAPE_SPHERE, 7.0, lTarget, FALSE, OBJECT_TYPE_CREATURE | OBJECT_TYPE_PLACEABLE | OBJECT_TYPE_DOOR);
while (oObject != OBJECT_INVALID)  // if oObject is not invalid, try to damage it!
   {
   // Each target object makes it's own Reflex save against the original damage (nDamage)
   nDamageAfterSave = GetReflexAdjustedDamage(nDamage, oObject, 30, SAVING_THROW_TYPE_FIRE);
   if (nDamageAfterSave > 0)    // if target object should suffer any damage, apply it and a fire VFX
      {
      ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectDamage(nDamageAfterSave, DAMAGE_TYPE_FIRE), oObject);
      ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_IMP_FLAME_M), oObject);
      }
   // get the next object in the area of effect
   oObject = GetNextObjectInShape(SHAPE_SPHERE, 7.0, lTarget, FALSE, OBJECT_TYPE_CREATURE | OBJECT_TYPE_PLACEABLE | OBJECT_TYPE_DOOR);
   }
}

//  On Damaged script for exploding barrel object

void main()
{
location lSource = GetLocation(OBJECT_SELF);
object oPC = GetLastHostileActor();
object oWeapon = GetItemInSlot(INVENTORY_SLOT_RIGHTHAND,oPC);

if (GetDamageDealtByType(DAMAGE_TYPE_FIRE) > 0)
   {
   DelayCommand(0.1, ExplodeAtLocation(lSource, d20(6)));
   PlaySound("zep_explosion");
   }
else if (GetStringLeft(GetResRef(oWeapon), 4) == "gun_")
   {
   DelayCommand(0.1, ExplodeAtLocation(lSource, d20(6)));
   PlaySound("zep_explosion");
   }
else
   {
   SendMessageToPC(oPC, "You must use fire or a gun");
   }
}

               
               

               


                     Modifié par The Amethyst Dragon, 12 août 2013 - 08:02 .
                     
                  


            

Legacy_The Amethyst Dragon

  • Hero Member
  • *****
  • Posts: 2981
  • Karma: +0/-0
Exploding Barrels System
« Reply #4 on: August 12, 2013, 09:09:50 pm »


               The script above made some basic changes to yours.

I put the save DC and explosion radius right into the ExplodeAtLocation() function, since it's just for this script right now and doesn't need to be changed.

I added a proper while loop to the explosion so it cycles through the objects in the area of effect.  The reflex save is now done by each object in the area of effect, rather than being done at the start and adjusting damage for every creature after the first.

I added a few comments to the code so you can see what some of the parts of it are supposed to be doing.

You might want to consider changing the delay in exploding from 0.1 seconds to something a little longer, perhaps to 1.0 or even 2.0 seconds, just for effect.

If you have this as the on damaged script for your barrels, it should work.  And if you line several of these up within 7 meters of the last one, you could get a chain of explosions as the first sets off the second, and that sets off the third, and onward...

':devil:'
               
               

               


                     Modifié par The Amethyst Dragon, 12 août 2013 - 08:15 .
                     
                  


            

Legacy_JerrodAmolyan

  • Full Member
  • ***
  • Posts: 175
  • Karma: +0/-0
Exploding Barrels System
« Reply #5 on: August 12, 2013, 09:18:24 pm »


               Thanks. '<img'> Now I need to try and understand how I will go about adding that damage. As far as I can see it's already supposed to be there... right ? O_o or am I just blind
               
               

               
            

Legacy_JerrodAmolyan

  • Full Member
  • ***
  • Posts: 175
  • Karma: +0/-0
Exploding Barrels System
« Reply #6 on: August 12, 2013, 09:22:10 pm »


               = Tested and it doesn't do a thing, just plays the explosion sound '<img'> Am I being dumb here ? lol
               
               

               
            

Legacy_Fester Pot

  • Hero Member
  • *****
  • Posts: 1698
  • Karma: +0/-0
Exploding Barrels System
« Reply #7 on: August 12, 2013, 09:29:52 pm »


               Is the static box unchecked for all your barrels?

FP!
               
               

               
            

Legacy_JerrodAmolyan

  • Full Member
  • ***
  • Posts: 175
  • Karma: +0/-0
Exploding Barrels System
« Reply #8 on: August 12, 2013, 09:31:37 pm »


               Yeah, their point is to be useable and portable. I can lug them around and set them back beside myself and now I'm trying to blow them up. I'm just curious though...

ExplodeAtLocation(lSource, d20(6)));

Isn't that the damage dealing thingie ? If so, then the lSource is missing ?

Seriously, talk the grunting orc language to me, I'm not even novice at this yet x)
               
               

               


                     Modifié par JerrodAmolyan, 12 août 2013 - 08:32 .
                     
                  


            

Legacy_JerrodAmolyan

  • Full Member
  • ***
  • Posts: 175
  • Karma: +0/-0
Exploding Barrels System
« Reply #9 on: August 12, 2013, 09:49:58 pm »


               Okay, got the damage and effects applied myself. NOW... I'd like to make it a bit less... well predictable. I had to assign it 100 damage, since it doesn't seem to recognize any d100 or 10d20 or anything with dice. Or if it would, I don't know the correct type '<img'> And the visual doesn't apply to the adjacent barrels, only the one I shoot at '<img'>

Also, I'd like to make it blow up the PC (if he gets in the radius and miraculously even evades the fire) if he carries those barrels ("jer_explosives") and make those barrels then be taken from the inventory '<img'> How can I do that ?
               
               

               


                     Modifié par JerrodAmolyan, 12 août 2013 - 08:50 .
                     
                  


            

Legacy_JerrodAmolyan

  • Full Member
  • ***
  • Posts: 175
  • Karma: +0/-0
Exploding Barrels System
« Reply #10 on: August 14, 2013, 01:51:56 pm »


               I've still been unable to work this out. Seems I can't blow up the adjacent barrels, instead the damage just either destroys them, or if I give them lots of hit points, does nothing to them.

Also, I'm unable to assign a damage like 10d20 (or anything d anything) I can just assign a number which will be it, meh. Not that 100 damage isn't "enough", it's just so predictable and you can't get lucky and evade some of it by rolling well. if you fail the reflex, it's 100 damage. It gets boring '<img'>

Biggest problem is not getting the barrels explode if hit by another barrel, I think it might have something to do with PC being the one who triggers the event, but the barrel being the one who causes the damage... then again it's just a hunch. I really need help '<img'>
               
               

               
            

Legacy_FunkySwerve

  • Hero Member
  • *****
  • Posts: 2325
  • Karma: +0/-0
Exploding Barrels System
« Reply #11 on: August 14, 2013, 02:57:09 pm »


               You need to post your current code for us to help with it. '<img'>

Funky
               
               

               
            

Legacy_HipMaestro

  • Hero Member
  • *****
  • Posts: 2849
  • Karma: +0/-0
Exploding Barrels System
« Reply #12 on: August 14, 2013, 03:08:44 pm »


               Scripting dunce here... but try changing the radius of the GetFirstObjectInShape to a constant like RADIUS_SIZE_HUGE and retry. The effect may not be locating target(s) properly.  Have you tried different spacings of the barrels?  (The others may be lying just outside the edge of the radius.)  

*bumping until a pro shows*
               
               

               
            

Legacy_JerrodAmolyan

  • Full Member
  • ***
  • Posts: 175
  • Karma: +0/-0
Exploding Barrels System
« Reply #13 on: August 14, 2013, 09:36:26 pm »


               *Derps* Right the current code !

void ExplodeAtLocation(location lTarget, int nDamage)

{int nDamageAfterSave;
// get the first object in the area of effect
object oObject = GetFirstObjectInShape(SHAPE_SPHERE, 7.0, lTarget, FALSE, OBJECT_TYPE_CREATURE | OBJECT_TYPE_PLACEABLE | OBJECT_TYPE_DOOR);
while (oObject != OBJECT_INVALID)  // if oObject is not invalid, try to damage it! 
 {   // Each target object makes it's own Reflex save against the original damage (nDamage)   
nDamageAfterSave = GetReflexAdjustedDamage(nDamage, oObject, 30, SAVING_THROW_TYPE_FIRE);   
if (nDamageAfterSave > 0)  
 // if target object should suffer any damage, apply it and a fire VFX     
{      ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectDamage(100, nDamageAfterSave, DAMAGE_TYPE_FIRE), oObject);     
ActionCastSpellAtObject(SPELL_COMBUST, oObject, METAMAGIC_ANY, TRUE, 0,
PROJECTILE_PATH_TYPE_DEFAULT, TRUE);     
ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_IMP_FLAME_M), oObject);      ApplyEffectAtLocation(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_FNF_FIREBALL), lTarget);
      }
   // get the next object in the area of effect   oObject = GetNextObjectInShape(SHAPE_SPHERE, 7.0, lTarget, FALSE, OBJECT_TYPE_CREATURE | OBJECT_TYPE_PLACEABLE | OBJECT_TYPE_DOOR); 
 }
}
//  On Damaged script for exploding barrel object
void main()
{location lSource = GetLocation(OBJECT_SELF);
object oPC = GetLastHostileActor();
object oWeapon = GetItemInSlot(INVENTORY_SLOT_RIGHTHAND,oPC);

if (GetDamageDealtByType(DAMAGE_TYPE_FIRE) > 0) 
 {   DelayCommand(0.1, ExplodeAtLocation(lSource, d20(6))); 
 PlaySound("zep_explosion");   
}
else if (GetStringLeft(GetResRef(oWeapon), 4) == "gun_") 
 {   DelayCommand(0.1, ExplodeAtLocation(lSource, d20(6)));   
PlaySound("zep_explosion");   
}
else 
 {   
SendMessageToPC(oPC, "You must use fire or a gun");   
}
}
               
               

               


                     Modifié par JerrodAmolyan, 14 août 2013 - 08:40 .
                     
                  


            

Legacy_FunkySwerve

  • Hero Member
  • *****
  • Posts: 2325
  • Karma: +0/-0
Exploding Barrels System
« Reply #14 on: August 15, 2013, 01:41:42 am »


               There are numerous problems in your script. You have the parameters for EffectDamage wrong, and you commented out the line that continues to iterate the while loop. You also appear to be having it cast a Combust spell for no reason I can fathom. I'll post a cleaned-up version in a couple minutes.

Funky