• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

OTClient sounds

alessandroLino

New Member
Joined
May 30, 2013
Messages
1
Reaction score
0
Has anyone had consistent success with playing sounds? I'm testing out the client and have been able to play sounds in response to some events like a creature talking, but i'm only able to play one kind of sound, as in one file, if i change the file name to play another one it will simply remain silent. I feel like the issue is on the files rather than on the code.

Code:
local musicB = "music/erreur"
local musicChannel = g_sounds.getChannel(2)
local intsounds = 100
function init() 
	g_sounds.preload(musicB)

	connect (g_game, { onGameStart = startup, onGameEnd = close, onTalk = checkTalk })	
	connect (Creature, { onDeath = checkDeath })
end
function terminate()
	disconnect (g_game, { onGameStart = startup })
end
function startup()
	musicChannel:stop(3)
        musicChannel:enqueue(musicB, 0)
end
function close()
	musicChannel:stop(3)
end
function playSound(name)
	file = "sounds/" .. name
	g_sounds.preload(file)
	channel = g_sounds.getChannel(intsounds)
	channel:stop(intsounds)
	channel:play(file, 0)
	intsounds = intsounds+1 -- quick hack to get multiple sounds playing at once
end
function checkDeath(creature)
	if creature:getName() == "Goblin" then
		playSound("die_goblin2")
		modules.game_textmessage.displayMessage(MessageModes.Blue, 'The goblin dies an horrible death.')
	end
end
function checkTalk(name, level, mode, text, channelId, pos)
	if text == "Hahahaha!" and name == "Goblin" then
		playSound("laugh_goblin")
		modules.game_textmessage.displayMessage(MessageModes.Blue, 'The goblin laughs at you.') -- debug
	end
end

Is there any specific setup to do on the files, besides being ogg? Also the onDeath event seems to fire twice for no reason
 
Hiho I worked in sounds for like 5 mins XD I just wanted to make sound for when characters engage battles, I was thinking in adding more but I disliked the system and found it kinda unorganized and undocumented so I was lazy to read too much code and quited from that idea, also the difference between sound and music was not clear, so my general answer and opinion is that they didn't take too much time on sounds yet, so instead of trying to work with what they have now, try to make they change it or wait until it is in their plans because I don't think is completed at all, is more like the minimum you need to say that you have sound in the client, so I consider big efforts in sound managment now with what the client has is a waste of time :D
 
Yeah, some basic tutorial on using sound engine would be appreciated.
I just found to put sound in areas, but I did not think of putting sound into actions, like when using a rune it makes a sound, I think I need to use opcodes, but there's no way I can use them, there must be another way
 
I tried to align sound effects to magiceffects and missiles but it crashed otc. We need someone to explain the procedure of playing a sound, like do you have to create channel first, buffer the sound before playing, etc.
 
I tried to align sound effects to magiceffects and missiles but it crashed otc. We need someone to explain the procedure of playing a sound, like do you have to create channel first, buffer the sound before playing, etc.
here it explains, but I did not understand

Did you use what in yours?
 
I tried to use functions that are already in OTC to play a sound when missile is drawn in mapview.cpp (OTC source).
 
It's not really a script. Inside mapview.cpp I added:
C++:
SoundChannel* missileChannel;
And under line missile->draw(transformPositionTo2D(missile->getPosition(), cameraPosition), scaleFactor, drawFlags & Otc::DrawAnimations, m_lightView.get());
C++:
                    missileChannel->enable();
                    missileChannel->play("sounds/test.ogg", 0);
So for now I tried to play one test sound when any kind of missile is drawn but it crashes.
 
Back
Top