NPC's and custom voice/sound?

Ask for help about creating mods and scripts for Grimrock 2 or share your tips, scripts, tools and assets with other modders here. Warning: forum contains spoilers!
User avatar
Slade
Posts: 45
Joined: Tue Oct 21, 2014 6:31 pm

NPC's and custom voice/sound?

Post 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.
User avatar
mahric
Posts: 192
Joined: Sun Nov 04, 2012 3:05 pm

Re: NPC's and custom voice/sound?

Post 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 :?
Did you visit the Wine Merchant's Basement? And heard about the Awakening of Taarnab?
User avatar
Doridion
Posts: 256
Joined: Tue Jun 10, 2014 9:23 pm

Re: NPC's and custom voice/sound?

Post 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"
User avatar
mahric
Posts: 192
Joined: Sun Nov 04, 2012 3:05 pm

Re: NPC's and custom voice/sound?

Post by mahric »

Trying your "clickable" suggestion as we speak :)
Did you visit the Wine Merchant's Basement? And heard about the Awakening of Taarnab?
User avatar
Doridion
Posts: 256
Joined: Tue Jun 10, 2014 9:23 pm

Re: NPC's and custom voice/sound?

Post by Doridion »

Already "tried" with my clickable doors, and see result ( It was a test to learn clicklable class and funtions utility ) ;)
User avatar
mahric
Posts: 192
Joined: Sun Nov 04, 2012 3:05 pm

Re: NPC's and custom voice/sound?

Post 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
Did you visit the Wine Merchant's Basement? And heard about the Awakening of Taarnab?
User avatar
Doridion
Posts: 256
Joined: Tue Jun 10, 2014 9:23 pm

Re: NPC's and custom voice/sound?

Post 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 ?
User avatar
mahric
Posts: 192
Joined: Sun Nov 04, 2012 3:05 pm

Re: NPC's and custom voice/sound?

Post 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.
Did you visit the Wine Merchant's Basement? And heard about the Awakening of Taarnab?
User avatar
cromcrom
Posts: 549
Joined: Tue Sep 11, 2012 7:16 am
Location: Chateauroux in a socialist s#!$*&% formerly known as "France"

Re: NPC's and custom voice/sound?

Post by cromcrom »

I will give it a try, but it looks really amazing, thank you so much for sharing.
A trip of a thousand leagues starts with a step.
User avatar
Eleven Warrior
Posts: 745
Joined: Thu Apr 18, 2013 2:32 pm
Location: Australia

Re: NPC's and custom voice/sound?

Post by Eleven Warrior »

This script is totally awesome imam using it right now to the max so much potential. Man thxs for this :)
Post Reply