tsdobbi Posted July 9, 2020 Share Posted July 9, 2020 Overview: when the player is in range (lets say 400) of an NPC with X perk I want to trigger a sound. I created a castable detect life essentially that does this. (valid targets are only npcs with the perk) (i.e. when I cast it, it plays the sound when the specific NPC's are within the radius by putting the sound in the "on hit" of the magic effect). I tried essentially making the magic effect a "constant effect" instead of fire and forget and attached it to a constant effect ability that is added to the player. But it doesn't do anything, I assume because nothing is actually "casted". I am guessing maybe I can attach a script to the constant magic effect to achieve this. Link to comment Share on other sites More sharing options...
tsdobbi Posted July 11, 2020 Author Share Posted July 11, 2020 Overview: when the player is in range (lets say 400) of an NPC with X perk I want to trigger a sound. I created a castable detect life essentially that does this. (valid targets are only npcs with the perk) (i.e. when I cast it, it plays the sound when the specific NPC's are within the radius by putting the sound in the "on hit" of the magic effect). I tried essentially making the magic effect a "constant effect" instead of fire and forget and attached it to a constant effect ability that is added to the player. But it doesn't do anything, I assume because nothing is actually "casted". I am guessing maybe I can attach a script to the constant magic effect to achieve this. I just ended up attaching a script to the NPC that does it and it worked. Link to comment Share on other sites More sharing options...
cumbrianlad Posted July 11, 2020 Share Posted July 11, 2020 I saw this but scripting is my weakest link, so I didn't reply, hoping someone else would! How did you script it? Did you just add a script to cast the spell every so many seconds/minutes? Tbh, the one worry I had about the idea was that it could permanently tie the game engine up, casting 'detect life' style spells. I don't know how to do this, off the top of my head, but I thought it would be good if this was a spell/ability that the player could turn on or off. If the player gets sick of the 'audio NPC detect', which they could (I would!), they could disable it. Link to comment Share on other sites More sharing options...
tsdobbi Posted July 12, 2020 Author Share Posted July 12, 2020 (edited) I saw this but scripting is my weakest link, so I didn't reply, hoping someone else would! How did you script it? Did you just add a script to cast the spell every so many seconds/minutes? Tbh, the one worry I had about the idea was that it could permanently tie the game engine up, casting 'detect life' style spells. I don't know how to do this, off the top of my head, but I thought it would be good if this was a spell/ability that the player could turn on or off. If the player gets sick of the 'audio NPC detect', which they could (I would!), they could disable it. I created a script and attached it to the NPC . With the onInit its basically checking if the player (when the player has a specific perk) is in X range of the npc roughly every second. If the conditions are met the sound plays on the player. (and once the sound plays it wont repeat while the player is still in range, if the player leaves the range and comes back it will play again). Scriptname ImmortalBuzz extends Actor import game import debug import utility import sound event OnInit() RegisterForUpdate(1) gotoState("waiting") endEvent STATE waiting Event OnUpdate() if (Game.GetPlayer().GetDistance(Self) < TriggerDistance) if(Game.GetPlayer().HasPerk(HDRImmortal)) if(playSound == true) PlaySoundEffect(Game.GetPlayer()) playSound = false endif endif Else playSound = true endif if(Self.IsDead()) UnregisterForUpdate() GotoState("done") ; Switch to a state that doesn't use OnUpdate() EndIf EndEvent endSTATE STATE done endSTATE function PlaySoundEffect(Actor target) HDRImmortalBuzz.play(target) EndFunction float Property TriggerDistance = 900.0 Auto Sound property HDRImmortalBuzz auto Perk Property HDRImmortal Auto bool Property playSound = true Auto Edited July 12, 2020 by tsdobbi Link to comment Share on other sites More sharing options...
Recommended Posts