| 06-17-2009, 07:17 PM | #1 |
I just tried importing some sounds into my game and I've ran into a big problem, they won't play. At first I thought it was because I imported them as mp3 files, so I tried wav. files, but it still didn't work. So after that I tried replacing internal sounds with my wav. files, but they still won't play! Does anybody have a solution to this problem? |
| 06-17-2009, 07:38 PM | #2 |
Is it only the first time they not play, or do you try to play them several times? |
| 06-17-2009, 07:49 PM | #3 |
I have tried to play the sound several times and still no sound. |
| 06-17-2009, 07:55 PM | #4 |
Code plx. |
| 06-17-2009, 08:07 PM | #5 |
Well here's the spell that I'm using that should play the sound. JASS:scope FireWeapon globals private constant integer SPELL_ID = 'A001' //======================================================================= // ONLY MODIFY THESE VALUES WITHIN THE GREEN LINES //Modifies the damage of the missile private constant real MISSILE_DAMAGE = 15. //Modifies the model of the missile private constant string MISSILE_SFX = "Abilities\\Weapons\\WardenMissile\\WardenMissile.mdl" //Modifies the sound of the missile firing private constant sound MISSILE_SOUND = gg_snd_Rifle_Fire //Modifies the speed of the missile private constant real MISSILE_SPEED = 1500.00 //Modifies the turning speed of the missile private constant real MISSILE_ANGLESPEED = 0.00 //Modifies the maximum distance traveled by the missile private constant real MISSILE_MAXDIST = 1800.00 //Modifies the actucal height from where the missile is fired private constant real MISSILE_HEIGHT = 120.00 //Modifies the collision radius of the missile private constant real MISSILE_COLLISION = 70.00 //======================================================================= private constant string BLOOD_SFX = "Abilities\\Spells\\Other\\Stampede\\StampedeMissileDeath.mdl" private trigger SPELL_TRIGGER private constant attacktype ATTACKTYPE = ATTACK_TYPE_CHAOS private constant damagetype DAMAGETYPE = DAMAGE_TYPE_FIRE endglobals private struct Missile_Data unit target unit u endstruct private function missile_hit takes nothing returns nothing local unit m=GetTriggerCollisionMissile() local Missile_Data T = Missile_Data( CollisionMissile_GetTag(m) ) //See how we are using CollisionMissile tags instead of CSData. local unit o = T.u local player po = GetOwningPlayer(o) local unit u = GetTriggerUnit() local integer l local integer s local real f local timer x if (u!=null) then if IsUnitEnemy(u,po)==true then call UnitDamageTarget(o,u,MISSILE_DAMAGE,true,false,ATTACKTYPE,DAMAGETYPE, null) call DestroyEffect(AddSpecialEffectTarget(BLOOD_SFX,u,"chest")) call CollisionMissile_Destroy(m) call T.destroy() endif else call T.destroy() //cleanup now that the collision missile has died... endif set u=null set m=null set o=null endfunction private function casting takes nothing returns nothing local Missile_Data T = Missile_Data.create() local unit u = GetTriggerUnit() local player pu = GetOwningPlayer(u) local unit m local location loc = GetSpellTargetLoc() local location loc2 = GetUnitLoc(u) local real x = GetUnitX(u) local real y = GetUnitY(u) local real angle = AngleBetweenPoints(loc2,loc) local real mana = GetUnitState(u,UNIT_STATE_MANA) call snd_rifle_fired.PlayAttachUnit(u) if mana >= 1 then set angle = angle + GetRandomReal(-1.,1.) set m = CollisionMissile_Create(MISSILE_SFX,x,y,angle,MISSILE_SPEED,0.00,MISSILE_MAXDIST,MISSILE_HEIGHT,true,MISSILE_COLLISION,function missile_hit) call CollisionMissile_SetTag(m,integer(T) ) set T.u = u call SetUnitState(u,UNIT_STATE_MANA,(mana-1)) else call CS_Error(pu,"No ammo, reload!") endif call RemoveLocation(loc) call RemoveLocation(loc2) set u = null set m = null set loc = null set loc2 = null endfunction //=========================================================================== public function InitTrig takes nothing returns nothing call OnAbilityEffect(SPELL_ID, SCOPE_PRIVATE+"casting") endfunction endscope snd_rifle_fired.PlayAttachedUnit() was provided to me by the Sound library Midiway created. JASS:library SpellSound //Created by Midiway globals private integer registered_sounds = 0 endglobals struct soundSX extends array private string name private integer duration private real min_pitch private real max_pitch private boolean rnd_pitch //// Playing method PlayNormal takes nothing returns nothing local sound s = CreateSound( .name, false, false, false, 127, 127, "SpellsEAX" ) if .rnd_pitch then call SetSoundPitch( s, GetRandomReal(.min_pitch, .max_pitch) ) endif call SetSoundDuration( s , .duration ) call SetSoundVolume( s, 127 ) call StartSound( s ) call KillSoundWhenDone( s ) endmethod method PlayAttachUnit takes unit attach returns nothing local sound s = CreateSound( .name, false, true, false, 127, 127, "SpellsEAX" ) if .rnd_pitch then call SetSoundPitch( s, GetRandomReal(.min_pitch, .max_pitch) ) endif call SetSoundDuration( s , .duration ) call SetSoundVolume( s, 127 ) call AttachSoundToUnit( s, attach ) call StartSound( s ) call KillSoundWhenDone( s ) endmethod //// Inicialization private method PreloadSound takes nothing returns nothing local sound s = CreateSound( .name, false, false, false, 127, 127, "" ) call TriggerSleepAction( 0.0 ) call SetSoundVolume( s, 0 ) call StartSound( s ) call KillSoundWhenDone( s ) endmethod method RandomPitch takes real min, real max returns nothing set .rnd_pitch = true set .min_pitch = min set .max_pitch = max endmethod static method NewSound takes string path, integer dur returns soundSX local soundSX snd = soundSX[registered_sounds] set snd.name = path set snd.duration = dur call snd.PreloadSound.execute() set registered_sounds = registered_sounds+1 return snd endmethod endstruct endlibrary The library works with all the internal sounds in the editor, but not with the ones I'm importing. |
| 06-17-2009, 08:35 PM | #6 |
call snd_rifle_fired.PlayAttachUnit(u) What are you trying to do...? That even compiles?!? |
| 06-17-2009, 09:34 PM | #7 |
I'm just trying to play the sound attached to the unit, I tried the simple ways such as... JASS:call AttachSoundToUnit(gg_snd_Rifle_Fired,u) call SetSoundVolume(gg_snd_Rifle_Fired,100) call StartSound(gg_snd_Rifle_Fired) But that did not work, so I turned to sound systems made by the community, so I tried Midiway's, but that didn't work either. And if it didn't compile, the thread would have been titled Sound System doesn't work lol. ![]() |
