Author Topic: Sound playing problems.  (Read 385 times)

Legacy_JerrodAmolyan

  • Full Member
  • ***
  • Posts: 175
  • Karma: +0/-0
Sound playing problems.
« on: August 11, 2013, 11:11:30 am »


                Okay, this time I'm having a problem with making a sound play when you damage something. 
This system I made is pretty nice if you like to explode the dung out of monsters, I just have this flavor sound not playing irritate me, even though it's not important in the sense of functionality... (The system works just fine otherwise.)

So this placeable item "Barrel of Gunpowder". You guessed it, I'm having it explode if shot with a gun, which works fine with the spell fireball instantly cast at itself OnDamaged event. But I seem to get the spell sound override the sound I gave it, even though I set that sound play first in code and the spell cast with 0.1 sec delay. 

Anyone got expertise on sounds etc. so they could tell me how to disable the fireball sound on this script, or atleast make this sound play ("zep_explosion")

Here's the script: 

void main()
{   
    effect eVFX;
    object oSelf = OBJECT_SELF;


    // Get the creature who triggered this event.
    object oPC = GetLastHostileActor();
    object oWeapon = GetItemInSlot(INVENTORY_SLOT_RIGHTHAND,oPC);

    // Abort if the PC does not have the item A gun equipped.
    if ((GetStringLeft(GetResRef(oWeapon), 4)== "gun_"))
       {
          PlaySound("zep_explosion");

         //Cast Fireball.
         DelayCommand(0.1, ActionCastSpellAtObject(SPELL_FIREBALL, oSelf, METAMAGIC_ANY, TRUE, 0, PROJECTILE_PATH_TYPE_DEFAULT, TRUE));

    // Apply some visual effects.
    eVFX = EffectVisualEffect(VFX_FNF_SCREEN_SHAKE);
    ApplyEffectToObject(DURATION_TYPE_INSTANT, eVFX, oSelf);
    eVFX = EffectVisualEffect(620);
    ApplyEffectToObject(DURATION_TYPE_INSTANT, eVFX, oSelf);
    // Destroy an object
    eVFX = EffectVisualEffect(VFX_IMP_DUST_EXPLOSION);
    ApplyEffectToObject(DURATION_TYPE_INSTANT, eVFX, oSelf);
    DestroyObject(oSelf, 3.0);

    }
    else SendMessageToPC(oPC, "You should shoot it with a gun.");
    return;
}
               
               

               


                     Modifié par JerrodAmolyan, 11 août 2013 - 10:44 .
                     
                  


            

Legacy_JerrodAmolyan

  • Full Member
  • ***
  • Posts: 175
  • Karma: +0/-0
Sound playing problems.
« Reply #1 on: August 11, 2013, 11:22:01 am »


               EDIT: No, the problem is the sound playing too near the object. Can it be set so it can be heard through out the entire area ? Shooting at a barrel of explosion from 1 metre distance would just be a bit dumb. '<img'>

Or  better yet, make it play with a wider range so you could hear it like a sound object with a cut off distance 40 or so
               
               

               


                     Modifié par JerrodAmolyan, 11 août 2013 - 11:10 .
                     
                  


            

Legacy_FunkySwerve

  • Hero Member
  • *****
  • Posts: 2325
  • Karma: +0/-0
Sound playing problems.
« Reply #2 on: August 11, 2013, 07:03:00 pm »


               I don't tinker much with sounds, being more visually fixated, but I think you have two basic options - either make a custom sound with a wider radius, or play the standard sound on each pc nearby.

I'd also recommend making your own code for the explosion, rather than relying on a fireball spell, though that's more of a personal preference. Here's our exploding black powder barrell code. It's somewhat complicated because it checks the number of barrels a pc has placed (we made them convertable between inventory item and placeable), and only opens certain passages if they use enough barrels placed close enough together. Still, the basic ideas may be helpful if you decide to code your own.


#include "hg_inc"

void DoBoom(location lLoc, int nNumBarr) {

    float fRad = 5.0 * nNumBarr;
    if (fRad > 25.0)
        fRad = 25.0;
    object oBoom = GetFirstObjectInShape(SHAPE_SPHERE, fRad, lLoc, FALSE, OBJECT_TYPE_CREATURE | OBJECT_TYPE_PLACEABLE | OBJECT_TYPE_DOOR);
    int nFir = d100(3*nNumBarr);
    int nBlud = d100(3*nNumBarr);
    effect eDam = EffectDamage(nFir, DAMAGE_TYPE_FIRE);
    effect eDam2 = EffectDamage(nFir, DAMAGE_TYPE_BLUDGEONING);
    effect eExpl = EffectVisualEffect(VFX_FNF_FIREBALL);
    effect eImp = EffectVisualEffect(VFX_IMP_FLAME_M);
    effect eDead = ExtraordinaryEffect(EffectDeath());

    string sTag = GetTag(GetArea(OBJECT_SELF));
    int nMine = (sTag == "uro_ancientgemmi");
    if (sTag == "hiv_breach") {
        object oDoor = GetNearestObjectByTag("hiv_breach_to_wax");
        DeleteLocalString(oDoor, "KeyTag");
    }

    int nType;
    object oWay, oClear;

    ApplyEffectAtLocation(0, eExpl, lLoc);

    while (GetIsObjectValid(oBoom)) {
        if (nMine) {
            if (nNumBarr > 2) {
                if (GetTag(oBoom) == "boomtarget") {
                    SetPlotFlag(oBoom, FALSE);

                    object oDoor = GetNearestObjectByTag("invisiblebarrier", OBJECT_SELF);
                    if (!GetIsObjectValid(oDoor)) {
                        oDoor = GetNearestObject(OBJECT_TYPE_DOOR, OBJECT_SELF);
                        SetLocalInt(oDoor, "Open", 1);
                    }
                } else if (GetIsPC(oBoom) || GetIsPC(GetMaster(oBoom)))
                    ApplyEffectToObject(0, eDead, oBoom);
            }


            if (nNumBarr < 3 || (!GetIsPC(oBoom) && !GetIsPC(GetMaster(oBoom)))) {
                ApplyEffectToObject(0, eDam, oBoom);
                ApplyEffectToObject(0, eDam2, oBoom);
                ApplyEffectToObject(0, eImp, oBoom);
            }
        } else {
            nType = GetObjectType(oBoom);
            if (nType == OBJECT_TYPE_DOOR &&
                GetLocalInt(oBoom, "BarrelCount") <= nNumBarr) {

                if (GetLocalString(oBoom, "KeyTag") == "uro_barrel_explode")
                    DeleteLocalString(oBoom, "KeyTag");

                if (sTag == "uro_losttemple") {
                    oWay = GetWaypointByTag("dul_entry_from_uro");
                    oClear = GetNearestObjectByTag("dul_upper_to_uro", oWay);
                    DeleteLocalString(oClear, "KeyTag");
                }
                if (GetLocalInt(oBoom, "Uro_Barrel")) {
                    SetPlotFlag(oBoom, FALSE);
                    DestroyObject(oBoom);
                }

            } else if (nType == OBJECT_TYPE_PLACEABLE &&
                GetLocalInt(oBoom, "Uro_Barrel")) {

                SetPlotFlag(oBoom, FALSE);
                DestroyObject(oBoom);

            } else if (GetIsTarget(oBoom)) {

                ApplyEffectToObject(0, eDam, oBoom);
                ApplyEffectToObject(0, eDam2, oBoom);
                ApplyEffectToObject(0, eImp, oBoom);
            }
        }

        oBoom = GetNextObjectInShape(SHAPE_SPHERE, fRad, lLoc, FALSE, OBJECT_TYPE_CREATURE | OBJECT_TYPE_PLACEABLE | OBJECT_TYPE_DOOR);
    }
}

int GetBarrelCount() {
    location lLoc = GetLocation(OBJECT_SELF);
    int nReturn;
    object oBoom =
        GetFirstObjectInShape(SHAPE_SPHERE, RADIUS_SIZE_MEDIUM, lLoc, FALSE, OBJECT_TYPE_CREATURE | OBJECT_TYPE_PLACEABLE);

    while (GetIsObjectValid(oBoom)) {
        if (GetTag(oBoom) == "blackpowderbarre")
            nReturn++;
        oBoom = GetNextObjectInShape(SHAPE_SPHERE, RADIUS_SIZE_MEDIUM, lLoc, FALSE, OBJECT_TYPE_CREATURE | OBJECT_TYPE_PLACEABLE);
    }

    return nReturn;
}

void main() {
    int nBarrCount = GetBarrelCount();
    object oPC = GetLastDamager();
    object oBarrel = OBJECT_SELF;
    location lLoc = GetLocation(oBarrel);
    if (!GetLocalInt(oBarrel, "Triggered")) {
        SetLocalInt(oBarrel, "Triggered", 1);
        DelayCommand(0.1, AssignCommand(oPC, DoBoom(lLoc, nBarrCount)));
    }
}



Funky
               
               

               
            

Legacy_JerrodAmolyan

  • Full Member
  • ***
  • Posts: 175
  • Karma: +0/-0
Sound playing problems.
« Reply #3 on: August 11, 2013, 08:58:43 pm »


               Ah, this looks more complicated. My barrels are indeed also portable. But it's just a simple system. how mine works is You get an item (Misc, looks like a barrel-bomb with a fuse) called Barrel of Gunpowder. When you "use" the item's special power (self only) it will spawn a barrel placeable with the above code (Except for more devastating approach, I made it blast 5 fireballs ((Overkill, lol)) today. Instead of 1)

and it destroys the "item" you used. You can talk to the barrel and "Pick it up" which creates the item in your inventory again. It's a simple but working approach. Your scripts look really complicated though, I don't understand a thing O.o... But I'm not really a scripter so. Anyway, will try this out too I think, My barrels also blow up in unison, because I made a modification to the script, that either you have a gun_ resref item or the damage dealt is Fire type. In theory it should work, since fireball certainly is fire...


For the record... how would one make a custom sound to accompany a placeable ?(like the blow up sound here)
               
               

               
            

Legacy_FunkySwerve

  • Hero Member
  • *****
  • Posts: 2325
  • Karma: +0/-0
Sound playing problems.
« Reply #4 on: August 11, 2013, 09:25:08 pm »


               We have scripts just like that, allowing players to swap between item and placeable - they're two separate scripts, likely very similar to yours.

I'm reasonably sure you can just make a custom sound with the ones provided in the palette, though I'm not sure there's a suitable explosion. Like I said, I haven't played with em much. We have only used standard sounds with PlaySound. You could also check out PlaySoundByStrRef, but we haven't used that one at all, so I have no idea if they're all just voice stuff. Anyway, you can always just make a custom explosion script and play the sound on each pc if nothing else is suitable.

Funky
               
               

               
            

Legacy_JerrodAmolyan

  • Full Member
  • ***
  • Posts: 175
  • Karma: +0/-0
Sound playing problems.
« Reply #5 on: August 11, 2013, 11:18:57 pm »


               Hmmm... I think I sort of understand this now... If I create a custom sound object and give it the area of effect I want... I actually just have made some. CEP comes with a cool explosion sound that accompanies the CEP custom Cannon placeables. Basicly I could just do PlaySound ("jer_explosion"); because I have a sound object with that tag that actually is what I want... does it work like that or does it have to be some sound from the actual sound palettes ? I hope I made any sense, it's late at night, lol.

Just noticed though, that even though I have many fireballs bombarded at the barrel's position, it doesn't work like I want it to. DC 15 reflex save = Pretty much everyone over lvl 6 can pass it like nothing at all... I'll take a look at that script tomorrow and see if I can create something that has a higher DC and alot higher Damage (Fireball visual is good though, I'd like to keep the visual and I'm sure it can be done too.)
               
               

               
            

Legacy_JerrodAmolyan

  • Full Member
  • ***
  • Posts: 175
  • Karma: +0/-0
Sound playing problems.
« Reply #6 on: August 11, 2013, 11:19:43 pm »


               (The CEP sound is "zep_explosion", check it out, it's cool for these objects.)
               
               

               
            

Legacy_FunkySwerve

  • Hero Member
  • *****
  • Posts: 2325
  • Karma: +0/-0
Sound playing problems.
« Reply #7 on: August 12, 2013, 01:17:09 am »


               

Basicly I could just do PlaySound ("jer_explosion"); because I have a sound object with that tag that actually is what I want... does it work like that or does it have to be some sound from the actual sound palettes ? I hope I made any sense, it's late at night, lol.


I think so, but like I said, I haven't actually tried with a custom sound. I don't see any reason why it shouldn't, though.

Funky
               
               

               
            

Legacy_JerrodAmolyan

  • Full Member
  • ***
  • Posts: 175
  • Karma: +0/-0
Sound playing problems.
« Reply #8 on: August 12, 2013, 03:46:22 pm »


               Something's not right... meh. The custom sound doesn't play... least of my problems, the fireball doesn't seem to affect ANYBODY or ANYTHING, it doesn't even damage the nearby barrels... no idea what's wrong O_o

All I want is a simple script where it does configurable amount of damage on 20feet radius (damage type fire, ofcourse) and damages like a fireball, everything that's nearby. I just want it to be like 100+ damage and DC 30 reflex save... I'm unable to do that, been trying all day.

Technically if it has

if ((GetDamageDealtByType(DAMAGE_TYPE_FIRE)))

As first line in the code... and it blows up causing fire damage, it would simply then also blow up everything nearby with the same script. Right ?
               
               

               


                     Modifié par JerrodAmolyan, 12 août 2013 - 02:52 .
                     
                  


            

Legacy_JerrodAmolyan

  • Full Member
  • ***
  • Posts: 175
  • Karma: +0/-0
Sound playing problems.
« Reply #9 on: August 12, 2013, 07:46:02 pm »


               The sound problem is solved, so I'll make a new post about what this is turning into:)
               
               

               


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


            

Legacy_JerrodAmolyan

  • Full Member
  • ***
  • Posts: 175
  • Karma: +0/-0
Sound playing problems.
« Reply #10 on: August 12, 2013, 07:46:43 pm »


               Thanks for help with the sound, what I got now will do for now.
               
               

               


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