-
Member
Play sound when a rainbow goblin is near/on screen?
Hey fam,
I know it's possible to create sound notifications to play for pretty much any circumstance, however I am new-ish to C# and lack the necessary talent to write a code I'd very much be interested in. Basically, I'd just like a sound notification to play whenever a rainbow goblin is close enough to deem "near" the player (however that is interpreted by the HUD). I remember the later .xml versions of THUD had this feature and it would make my life dramatically easier while I farm for those cosmic wings.
Thanks for your attention and for whatever help you can give!
*Edit*
So far I've thrown together a little something that probably needs a lot of tweaking, borrowed from: [v7.6] [INTERNATIONAL] [Resu] ChannelingPlugin for the sound notification work am using the SNO for a rainbow goblin (at least I believe I am).
using System;
using System.Linq;
using System.Collections.Generic;
using System.Globalization;
using SharpDX;
using SharpDX.Direct2D1;
using Turbo.Plugins.Default;
namespace Turbo.Plugins.User
{
public class RainbowGobAlert : BasePlugin, IInGameTopPainter, IAfterCollectHandler , INewAreaHandler
{
public bool RainbowNotification { get; set; }
var highSound = Hud.Sound.LoadSoundPlayer("Resource-Full-By-Resu.wav");
if (405624.IsOnScreen)
{ ThreadPool.QueueUserWorkItem(state =>
{
highSound.PlaySync();
});
}
}
}
I don't think it will take too much time to get something like this to work but I'm sure I'm still a little while from getting to the point of this working as intended.
Last edited by wreck1; 01-20-2018 at 05:37 AM.
-
Contributor
It seems that GoblinPlugin (default plugin) has EnableSpeak that is by default false;
If you set EnableSpeak to true that should do the trick for you.
Code:
var goblins = Hud.Game.AliveMonsters.Where(x => x.SnoMonster.Priority == MonsterPriority.goblin);
foreach (var goblin in goblins)
{
if (EnableSpeak && (goblin.LastSpeak == null) && Hud.Sound.LastSpeak.TimerTest(5000))
{
Hud.Sound.Speak(goblin.SnoMonster.NameLocalized);
goblin.LastSpeak = Hud.Time.CreateAndStartWatch();
}
...
But the goblins make sounds far away so it is hard to get by them without hearing theirs sounds, right?
-
Member
Originally Posted by
JarJarD3
It seems that GoblinPlugin (default plugin) has EnableSpeak that is by default false;
If you set EnableSpeak to true that should do the trick for you.
Code:
var goblins = Hud.Game.AliveMonsters.Where(x => x.SnoMonster.Priority == MonsterPriority.goblin);
foreach (var goblin in goblins)
{
if (EnableSpeak && (goblin.LastSpeak == null) && Hud.Sound.LastSpeak.TimerTest(5000))
{
Hud.Sound.Speak(goblin.SnoMonster.NameLocalized);
goblin.LastSpeak = Hud.Time.CreateAndStartWatch();
}
...
But the goblins make sounds far away so it is hard to get by them without hearing theirs sounds, right?
I thought I replied to this earlier but I guess I forgot to submit it. I play the game without sound on (too much going on at once), so having THUD shout it out is extremely helpful. I want to thank you for bringing this to my attention. I've spent the last afternoon working on dialing this down to just RGobs. I took this plugin, through it into users, and trimmed it down to only RGobs and portals. However, I do not know how to isolate the loop function to yell out only rainbow goblins so it's still useless for my needs. Do you know what variables need to be placed in the:
(x => x.SnoMonster.Priority == MonsterPriority.goblin) in order to isolate it to rainbow goblins? I've tried replacing SnoMonster with the Sno of the rainbow goblin (405186) but it's not as easy as I thought it'd be.
Can anyone help me or touch up the code below to work for explicitly rainbow goblins?
RainbowGobAlert
I'm not sure if public DefaultGoblinDecorator needs to be defined if the loop is isolated to include just rainbow gobs, but currently it throws an exception because the loop calls for it.
Appreciate the help!
-
Contributor
Code:
public void PaintWorld(WorldLayer layer)
{
var portals = Hud.Game.Actors.Where(x => x.SnoActor.Sno == 410460);
foreach (var actor in portals)
{
PortalDecorator.Paint(layer, actor, actor.FloorCoordinate, null);
}
var goblins = Hud.Game.AliveMonsters.Where(x => x.SnoActor.Sno == 405186); // RainbowGoblin
foreach (var goblin in goblins)
{
if (EnableSpeak && (goblin.LastSpeak == null) && Hud.Sound.LastSpeak.TimerTest(5000))
{
Hud.Sound.Speak(goblin.SnoMonster.NameLocalized);
goblin.LastSpeak = Hud.Time.CreateAndStartWatch();
}
RainbowGoblinDecorator.Paint(layer, goblin, goblin.FloorCoordinate, goblin.SnoMonster.NameLocalized);
}
}
-
Post Thanks / Like - 2 Thanks
-
Member
Originally Posted by
JarJarD3
Code:
public void PaintWorld(WorldLayer layer)
{
var portals = Hud.Game.Actors.Where(x => x.SnoActor.Sno == 410460);
foreach (var actor in portals)
{
PortalDecorator.Paint(layer, actor, actor.FloorCoordinate, null);
}
var goblins = Hud.Game.AliveMonsters.Where(x => x.SnoActor.Sno == 405186); // RainbowGoblin
foreach (var goblin in goblins)
{
if (EnableSpeak && (goblin.LastSpeak == null) && Hud.Sound.LastSpeak.TimerTest(5000))
{
Hud.Sound.Speak(goblin.SnoMonster.NameLocalized);
goblin.LastSpeak = Hud.Time.CreateAndStartWatch();
}
RainbowGoblinDecorator.Paint(layer, goblin, goblin.FloorCoordinate, goblin.SnoMonster.NameLocalized);
}
}
You are a gentleman and a scholar. I salute you sir!
-
Active Member
Would you mind showing me the full detail source which makes it work in game?
I did it myself adding this and that from other sources but failed making a lot of exception errors.
-
Contributor
Originally Posted by
jaeheung09
Would you mind showing me the full detail source which makes it work in game?
I did it myself adding this and that from other sources but failed making a lot of exception errors.
Code:
using System.Linq;
using Turbo.Plugins.Default;
namespace Turbo.Plugins.JarJar
{
/// <summary>
/// Speaks given goblin's name when first time encountered (seen in minimap).
/// </summary>
/// <remarks>
/// This file must be copied into following folder: plugins\JarJar\RainbowGoblinSpeak.cs
/// </remarks>
public class RainbowGoblinSpeak : BasePlugin, IInGameWorldPainter
{
/// <summary>
/// See plugins\Default\Monsters\GoblinPlugin.cs for other goblin numbers.
/// </summary>
public uint GoblinNumber { get; set; }
public RainbowGoblinSpeak()
{
Enabled = true;
GoblinNumber = 405186;
}
public void PaintWorld(WorldLayer layer)
{
foreach (var goblin in Hud.Game.AliveMonsters.Where(x => x.SnoActor.Sno == GoblinNumber))
{
if (goblin.LastSpeak == null && Hud.Sound.LastSpeak.TimerTest(5000))
{
Hud.Sound.Speak(goblin.SnoMonster.NameEnglish);
goblin.LastSpeak = Hud.Time.CreateAndStartWatch();
break; // Can not speak more than one goblin within 5 sec.
}
}
}
}
}
I put it in "my" namespace folder "JarJar" instead of "User" because it is the way to do it
This has been running on my machine for two days but no luck with RainbowGoblin - so to say this has not been tested yet.
-
Active Member
Thanks for your kind reply.
Hope to have many chances to test this plugin sooner or later.