Page 1 of 3
NPC's and custom voice/sound?
Posted: Sat Nov 22, 2014 7:18 am
by Slade
Hey! I had an idea about npc's and found this :
viewtopic.php?f=14&t=5144
https://www.youtube.com/watch?v=o2BZoFmKlVk
So.. is this working on new editor? And are there any way to add my custom sound effects/voices for those npc's or enemies?
Thanks for answers already.
Re: NPC's and custom voice/sound?
Posted: Sat Nov 22, 2014 11:39 am
by mahric
There's a basic version running that enabled you to tell NPCs to walk somewhere, but the interaction part isn't done yet.
I'll look into it, but I don't dare to promise to meet a deadline

Re: NPC's and custom voice/sound?
Posted: Sat Nov 22, 2014 12:08 pm
by Doridion
Hey mahric, for NPC, i'm thinking for two simples solution :
- Clickable + offset + size + onClick(NPC)
- Control panel ( OnDrawGui ) - Button "Communicate" - Hook onComm(NPC) -> brain = "NPC"
Re: NPC's and custom voice/sound?
Posted: Sat Nov 22, 2014 12:28 pm
by mahric
Trying your "clickable" suggestion as we speak

Re: NPC's and custom voice/sound?
Posted: Sat Nov 22, 2014 12:37 pm
by Doridion
Already "tried" with my clickable doors, and see result ( It was a test to learn clicklable class and funtions utility )

Re: NPC's and custom voice/sound?
Posted: Sat Nov 22, 2014 5:46 pm
by mahric
I've uploaded a version for LoG2 that includes almost ALL (40+) of the basic monsters. (
video here or
download demo and source here)
With a few lines of scripting it's easy to interact with them, give them something or command them to move.
Code: Select all
mdNPC.source:registerNPC("myNPC") -- registers the npc at the framework
mdNPC.source:setRoute("myNPC", "f") -- moves the npc one square forward (use 'f' for forward, 'l' for turn left, 'r' for turn right and 'w' to wait a tiny bit)
You can register functions that are called if the player clicks on the npc or gives something to the npc.
Warning: these functions are only called if the npc is not moving.
Code: Select all
mdNPC.source:setOnInteract("myNPC", myScriptEntity.script.myFunction) -- Means: Call the 'myFunction' in the script 'myScript' if the npc 'myNPC' is clicked on while the player has NO item on the cursor
mdNPC.source:setOnGive("myNPC", myScriptEntity.script.myFunction) -- Means: call the 'myFunctoin' in the script 'myScript' if the npc 'myNPC' is clicked while the player HAS an item on the cursor
For more info, check the source in the example from the link above.
Edit: It is not possible to add custom voices or sounds to the npcs
Re: NPC's and custom voice/sound?
Posted: Sun Nov 23, 2014 1:54 am
by Doridion
You made it again mahric

Sticked in the superthread ^^
mahric wrote:Edit: It is not possible to add custom voices or sounds to the npcs
Are you sure ? If you define another NPC with attached script on hooks AND adding sounds/voices, i think it'll be possible. More else, remember that in LoG2, sounds injections are really easier, so adding a custom sound ( declared before of course ) for this or that action is pretty easy, no ?
Re: NPC's and custom voice/sound?
Posted: Sun Nov 23, 2014 11:56 am
by mahric
Doridion wrote:Are you sure ? If you define another NPC with attached script on hooks AND adding sounds/voices, i think it'll be possible. More else, remember that in LoG2, sounds injections are really easier, so adding a custom sound ( declared before of course ) for this or that action is pretty easy, no ?
I didn't mean that it was impossible at all, just that I didn't built in any specific support for that. The way you describe should be very doable indeed.
Re: NPC's and custom voice/sound?
Posted: Sat Nov 29, 2014 1:27 am
by cromcrom
I will give it a try, but it looks really amazing, thank you so much for sharing.
Re: NPC's and custom voice/sound?
Posted: Sat Nov 29, 2014 4:51 am
by Eleven Warrior
This script is totally awesome imam using it right now to the max so much potential. Man thxs for this
