Discuss all aspects related to modding Zandronum here.
-
HexaDoken
- Forum Regular
- Posts: 352
- Joined: Wed Jul 04, 2012 8:27 am
- Location: Void. Russian Void.
#1
Post
by HexaDoken » Sat Jul 25, 2015 4:09 pm
Is it possible to make an inventory item that goes to player's inventory upon pickup loop a sound when it's on the map?
I've tried
Code: Select all
Actor WeaponSurge : CustomInventory
{
Inventory.PickupMessage "item"
Inventory.PickupSound "weapons/surgetake"
Inventory.Amount 1
Inventory.MaxAmount 5
Scale 0.5
States
{
Spawn:
TNT1 A 0
TNT1 A 0 A_PlaySound("weapons/surgeloop", 5, 1.0, 1, ATTN_STATIC)
PPOS ABCDEF 3
Loop
Pickup:
TNT1 A 0 A_StopSound(5)
TNT1 A 0 A_JumpIfInventory("WeaponSurge", 5, 2)
TNT1 A 0 A_SetBlend("FF 00 00", 0.25, 25)
TNT1 A 0
Stop
Use:
TNT1 A 0
Fail
}
}
this but the effect it has is making the looping sound continue playing infinitely when I pick the thing up.
Any ideas?
Last edited by
HexaDoken on Sat Jul 25, 2015 4:12 pm, edited 1 time in total.
-
Ænima
- Addicted to Zandronum
- Posts: 3583
- Joined: Tue Jun 05, 2012 6:12 pm
#2
Post
by Ænima » Sun Jul 26, 2015 1:14 am
I think the problem is that the sound source changes once you pick up the item so doing StopSound on channel 5 is probably doing moot since the actor that called the sound loop has been removed from the map.
That's my theory.
-
Ivan
- Addicted to Zandronum
- Posts: 2229
- Joined: Mon Jun 04, 2012 5:38 pm
- Location: Omnipresent
#3
Post
by Ivan » Sun Jul 26, 2015 1:22 am
Ænima wrote:
I think the problem is that the sound source changes once you pick up the item so doing StopSound on channel 5 is probably doing moot since the actor that called the sound loop has been removed from the map.
That's my theory.
When you pick the item up, the activator is the player. Try running the A_StopSound in the player instead.
-
HexaDoken
- Forum Regular
- Posts: 352
- Joined: Wed Jul 04, 2012 8:27 am
- Location: Void. Russian Void.
#4
Post
by HexaDoken » Sun Jul 26, 2015 1:27 pm
It's pretty much what happens, yes. If the item can go to the player's inventory, then the Pickup state will be activated from the player's side rather than item's side, and the sound will be stopped on player's channel rather than item's channel.
Unfortunately, merely knowing why is this happening does not really give me any idea how to make this not happen.
Ivan wrote:
When you pick the item up, the activator is the player. Try running the A_StopSound in the player instead.
And that... will help me how exactly? You basically say that this does not work because A_StopSound is run in the player... so to fix it, we should run A_StopSound in the player.
Sense much?
oh wait nonononononono i can't read
The sound source does not change per se - the sound still originates from the exact same position you picked the item up from, walk away from it far enough and you won't hear it. The thing is, since the item goes to the player's inventory, the Pickup state run on the player... which means it can't stop the sound of... some dummy ghost item thing? that is being left behind.
Somehow.
Last edited by
HexaDoken on Sun Jul 26, 2015 1:34 pm, edited 1 time in total.
-
Ivan
- Addicted to Zandronum
- Posts: 2229
- Joined: Mon Jun 04, 2012 5:38 pm
- Location: Omnipresent
#5
Post
by Ivan » Sun Jul 26, 2015 3:21 pm
That's more likely to be happening, yes. So, make the item "spawn" sound emitters. Since the item will vanish, the sound emitters will also vanish. Problem solved.
-
HexaDoken
- Forum Regular
- Posts: 352
- Joined: Wed Jul 04, 2012 8:27 am
- Location: Void. Russian Void.
#6
Post
by HexaDoken » Sun Jul 26, 2015 5:22 pm
The problem is that the looping sound in question is about 3,9 seconds long.
The delay before the sound would finally stop would be... noticeable.
I SUPPOSE I could split it up in around six parts or so and play them at proper times(and also make the thing skip frames every so often so as to sync animation cycle with sound cycle), but then that'd be making what is already a very complicated code(which is obviously not included in the code snippet above) even MORE complicated.
I mean, it can be done if needs to, but I'll be crying tears throughout the whole thing.
-
Ænima
- Addicted to Zandronum
- Posts: 3583
- Joined: Tue Jun 05, 2012 6:12 pm
#7
Post
by Ænima » Sun Jul 26, 2015 5:30 pm
I think you could still use a sound loop, if you can use a master/child relationship on the item and its "sound emitter" actor. Then just put a_stopsound in the death state of the emitter so when you use a_killchildren in the item's pickup state it ends the emitter's sound.
-
HexaDoken
- Forum Regular
- Posts: 352
- Joined: Wed Jul 04, 2012 8:27 am
- Location: Void. Russian Void.
#8
Post
by HexaDoken » Sun Jul 26, 2015 5:32 pm
> implying the master/child relationship actually works when invoked from player's side
Yeah this will probably not work.
Though hold on, I can go try real quick-
-OH WAIT MASTER/CHILD RELATIONSHIP DOESN'T WORK WITH ITEMS.
Yeah.
EDIT: one really weird idea I'm starting to gear towards is to make the item not add itself to the player's inventory... which will allow it to stop the looping sound properly since the Pickup state is still called from the item, not the player.
INSTEAD, the item will run a script that will find the nearest player and give him the goddamn item.
Talk about gross hacks, huh.
Last edited by
HexaDoken on Sun Jul 26, 2015 5:36 pm, edited 1 time in total.
-
Lollipop
- Zandrone
- Posts: 1124
- Joined: Tue Jul 24, 2012 10:34 am
- Location: Denmark
#9
Post
by Lollipop » Sun Jul 26, 2015 6:56 pm
try adding the +ISMONSTER flag to the pickup for science. Might work, might not, but it is worth a shot. (I mean in regards of master/child relation)
Combinebobnt wrote:i can see the forum league is taking off much better than the ctf ones
GalactusToday at 1:07 PM
are you getting uncomfortable jap
feeling something happen down there
-
Ænima
- Addicted to Zandronum
- Posts: 3583
- Joined: Tue Jun 05, 2012 6:12 pm
#10
Post
by Ænima » Sun Jul 26, 2015 11:38 pm
Look at RGA2's weapon pickup code. IIRC there are "fail" pickup states resulting in inventory being given to the player while allowing the item actor to remain in the map. Might be able to do something with that.
-
HexaDoken
- Forum Regular
- Posts: 352
- Joined: Wed Jul 04, 2012 8:27 am
- Location: Void. Russian Void.
#11
Post
by HexaDoken » Mon Jul 27, 2015 1:57 pm
Lollipop wrote:
try adding the +ISMONSTER flag to the pickup for science. Might work, might not, but it is worth a shot. (I mean in regards of master/child relation)
No effect.
Ænima wrote:
Look at RGA2's weapon pickup code. IIRC there are "fail" pickup states resulting in inventory being given to the player while allowing the item actor to remain in the map. Might be able to do something with that.
It just uses A_GiveInventory to give the item to the player despite the fact that the on-map actor itself fails it's pickup state and thus remains on the map. Nice, but ultimately doesn't fix the initial problem of the state shifting focus.
-
Ænima
- Addicted to Zandronum
- Posts: 3583
- Joined: Tue Jun 05, 2012 6:12 pm
#12
Post
by Ænima » Mon Jul 27, 2015 4:54 pm
HexaDoken wrote:
Ænima wrote:
Look at RGA2's weapon pickup code. IIRC there are "fail" pickup states resulting in inventory being given to the player while allowing the item actor to remain in the map. Might be able to do something with that.
It just uses A_GiveInventory to give the item to the player despite the fact that the on-map actor itself fails it's pickup state and thus remains on the map. Nice, but ultimately doesn't fix the initial problem of the state shifting focus.
What I meant is that you can exploit this to be able to call StopSound even after the player receives what he needs, then remove the actor manually in DECORATE or make it end with a "Stop". To the player, it will just seem like a normal pickup.
Last edited by
Ænima on Mon Jul 27, 2015 4:57 pm, edited 1 time in total.
-
HexaDoken
- Forum Regular
- Posts: 352
- Joined: Wed Jul 04, 2012 8:27 am
- Location: Void. Russian Void.
#13
Post
by HexaDoken » Mon Jul 27, 2015 5:27 pm
Wait.
I didn't understand at first but yes, this actually works!
Here's the code I went with:
Code: Select all
Actor WeaponSurge : Inventory {Inventory.MaxAmount 5}
Actor WeaponSurgePickup : CustomInventory
{
Inventory.PickupMessage "item"
Inventory.PickupSound "weapons/surgetake"
Inventory.Amount 1
Scale 0.5
States
{
Spawn:
TNT1 A 0
TNT1 A 0 A_PlaySound("weapons/surgeloop", 5, 1.0, 1, ATTN_STATIC)
PPOS ABCDEF 3
Loop
Pickup:
TNT1 A 0 A_JumpIfInventory("WeaponSurge", 5, 4)
TNT1 A 0 A_SetBlend("FF 00 00", 0.25, 25)
TNT1 A 0 A_StopSound(5)
TNT1 A 0 A_GiveInventory("WeaponSurge", 1)
TNT1 A 0
Stop
}
}
Works like a charm.
Thank you very much for help, folks!
Last edited by
HexaDoken on Mon Jul 27, 2015 5:28 pm, edited 1 time in total.
-
Ænima
- Addicted to Zandronum
- Posts: 3583
- Joined: Tue Jun 05, 2012 6:12 pm
#14
Post
by Ænima » Mon Jul 27, 2015 5:58 pm
You're welcome. :p