Author Topic: Playing a sound on a moving PC  (Read 316 times)

Legacy_GIANTSWORD

  • Full Member
  • ***
  • Posts: 175
  • Karma: +0/-0
Playing a sound on a moving PC
« on: December 17, 2014, 06:12:47 pm »


               

I am trying to get a sound to play on a PC and have it move with them as they move.  


 


After I got it to work it only plays on the location of where it was activated.  I've tried playing it on the area (doesn't work) and the location obviously just plays the sound on the location.  


 


Any thoughts?


 


 


//::///////////////////////////////////////////////

//:: Shapechange

//:: NW_S0_ShapeChg.nss

//:: Copyright © 2001 Bioware Corp.

//:://////////////////////////////////////////////

//:://////////////////////////////////////////////

//:: Created By: Preston Watamaniuk

//:: Created On: Jan 22, 2002

//:://////////////////////////////////////////////

 

#include "x2_inc_spellhook"

 

void main()

{

 

/*

  Spellcast Hook Code

  Added 2003-06-23 by GeorgZ

  If you want to make changes to all spells,

  check x2_inc_spellhook.nss to find out more

 

*/

 

    if (!X2PreSpellCastCode())

    {

    // If code within the PreSpellCastHook (i.e. UMD) reports FALSE, do not run this spell

        return;

    }

 

// End of Spell Cast Hook

 

 

    //Declare major variables

    int nSpell = GetSpellId();

    object oTarget = GetSpellTargetObject();

    object oPC = OBJECT_SELF;

    effect eVis = EffectVisualEffect(VFX_FNF_SUMMON_MONSTER_3);

    effect ePoly;

    int nPoly;

    int nMetaMagic = GetMetaMagicFeat();

    int nDuration = GetCasterLevel(OBJECT_SELF);

    //Enter Metamagic conditions

    if (nMetaMagic == METAMAGIC_EXTEND)

    {

        nDuration = nDuration *2; //Duration is +100%

    }

 

    //Determine Polymorph subradial type

    if(nSpell == 392)

    {

        nPoly = POLYMORPH_TYPE_RED_DRAGON;

    }

    else if (nSpell == 393)

    {

        nPoly = POLYMORPH_TYPE_FIRE_GIANT;

    }

    else if (nSpell == 394)

    {

        nPoly = POLYMORPH_TYPE_BALOR;

    }

    else if (nSpell == 395)

    {

        nPoly = POLYMORPH_TYPE_DEATH_SLAAD;

    }

    else if (nSpell == 396)

    {

        nPoly = POLYMORPH_TYPE_IRON_GOLEM;

    }

 

    ePoly = EffectPolymorph(nPoly);

    //Fire cast spell at event for the specified target

    SignalEvent(oTarget, EventSpellCastAt(OBJECT_SELF, SPELL_SHAPECHANGE, FALSE));

 

    //Apply the VFX impact and effects

    ApplyEffectAtLocation(DURATION_TYPE_INSTANT, eVis, GetLocation(oTarget));

    DelayCommand(0.4, AssignCommand(oTarget, ClearAllActions())); // prevents an exploit

    DelayCommand(0.5, ApplyEffectToObject(DURATION_TYPE_TEMPORARY, ePoly, oTarget, TurnsToSeconds(nDuration)));

    DelayCommand(0.6, AssignCommand(oPC,PlaySound("me_amidemon")));

    MusicBackgroundStop(GetArea(oTarget));

    DelayCommand(75.0, MusicBackgroundPlay(GetArea(oTarget)));

}


               
               

               
            

Legacy_henesua

  • Hero Member
  • *****
  • Posts: 6519
  • Karma: +0/-0
Playing a sound on a moving PC
« Reply #1 on: December 17, 2014, 07:41:41 pm »


               

I don't believe this is "easily" possible. The problem is that an object has to have a cleared action queue to play a sound as far as i know.


 


What I mean is that I don't think you can merely use PlaySound.


 


 


One way to try this would be to adjust the creature sound list, and create a new one which has a droning sound that you want.  Create a new appearance (invisible model) in appearances.2da which has the creature sound that you created. Create a blueprint using this appearance. Spawn the creature and set to follow PC.


 


I don't know if this will work. But its the best that I think you can do. Unless maybe this can be done with a persistent vfx which has a sound and follows the PC. Haven't tried that either.



               
               

               
            

Legacy_GIANTSWORD

  • Full Member
  • ***
  • Posts: 175
  • Karma: +0/-0
Playing a sound on a moving PC
« Reply #2 on: December 17, 2014, 08:02:41 pm »


               

Nice suggestions!  I really like the invisible creature following the PC around, that gives me some good ideas for quest/area flavor.


 


I ended up settling with the PlaySound just working on the location and shortening the sound played from 1 minute to about 15 seconds.