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!
Grimfan
Posts: 369
Joined: Wed Jan 02, 2013 7:48 am

Re: NPC's and custom voice/sound?

Post by Grimfan »

Nicely done Mahric. :D
User avatar
Mysterious
Posts: 226
Joined: Wed Nov 06, 2013 8:31 am

Re: NPC's and custom voice/sound?

Post by Mysterious »

Hi mahric. The script you made is awesome and I was wondering how I could the Item given to the NPC be a certain item. Your script allows for any item. I would like to for example, if the player give the NPC a Staff then the se_ogre.script.WizardGone1() activates. I cant remember how to do that. I think it's like: if item==staff then etc... Could you help me on this please thxs :)

function onGive(self, monster, item) --Would like this to be a certain item only--
hudPrint("Thank you for that "..item:getUiName())
se_ogre.script.WizardGone1()
return true
User avatar
mahric
Posts: 192
Joined: Sun Nov 04, 2012 3:05 pm

Re: NPC's and custom voice/sound?

Post by mahric »

In the script you can check the name if the item that is given.
If it's not the item you want the NPC to accept, return false and the item will be kept on the cursor.

See the example below; it's what I use in the mod i'm working on now.
The name of the item the npc accepts is "md_sewer_package". You can replace it with anything you want to accept.

Code: Select all

function onGive(self, npc, item)
	if item.go.name == "md_sewer_package" then	
		-- do magic stuff here, the right item was given
		return true
	end
	hudPrint("I have no need for this item")
	return false
end
Did you visit the Wine Merchant's Basement? And heard about the Awakening of Taarnab?
bongobeat
Posts: 1076
Joined: Thu May 16, 2013 5:58 pm
Location: France

Re: NPC's and custom voice/sound?

Post by bongobeat »

if you want to add custom voice to your npc, here is a site that allow you to hear what you write, in most languages.

http://www.oddcast.com/home/demos/tts/tts_example.php
you can then record what you hear with your computer/micro the sound.
it's quite good, I have use this for my mod toorum manor, to simulate some super computer voice.
My asset pack: viewtopic.php?f=22&t=9320

Log1 mod : Toorum Manor: viewtopic.php?f=14&t=5505
User avatar
Eleven Warrior
Posts: 739
Joined: Thu Apr 18, 2013 2:32 pm
Location: Australia

Re: NPC's and custom voice/sound?

Post by Eleven Warrior »

Hi mahric. This script is awesome man I was wonder is there a way that if the party attacks the npc then the npc turns on the party and attacks them? I do hope this is possible because this script has so much potential. Thxs for any help :)
User avatar
Eleven Warrior
Posts: 739
Joined: Thu Apr 18, 2013 2:32 pm
Location: Australia

Re: NPC's and custom voice/sound?

Post by Eleven Warrior »

SORRY BUMP :)
User avatar
mahric
Posts: 192
Joined: Sun Nov 04, 2012 3:05 pm

Re: NPC's and custom voice/sound?

Post by mahric »

It's not possible at the moment, but I don't think it's too hard to add to the script, as long as you don't mind the monster will stay hostile once it is.

I don't have time to look at this right now, I hope I can get to it this weekend.
Did you visit the Wine Merchant's Basement? And heard about the Awakening of Taarnab?
User avatar
Eleven Warrior
Posts: 739
Joined: Thu Apr 18, 2013 2:32 pm
Location: Australia

Re: NPC's and custom voice/sound?

Post by Eleven Warrior »

Thxs for the reply Mahric. It will be awesome, because if the party attacks the NPC they may fail a Quest or he gets the Shits and say imam not help you now unless you say sorry lol :)
User avatar
Aisuu
Posts: 61
Joined: Fri Oct 31, 2014 2:07 pm

Re: NPC's and custom voice/sound?

Post by Aisuu »

It is possible and its very easy with a hook onDamage. Here is example if your using mahric npc scripts.

mdNPC.script:registerNPC("npc_neutral")
SpoilerShow

Code: Select all

npc_neutral.monster:addConnector("onDamage",self.go.id,"npcdamage")

function npcdamage(sender)
  spawn("regular_mob",npc_neutral.level,npc_neutral.x,npc_neutral.y,npc_neutral.facing,npc_neutral.elevation,nil)
	delayedCall(self.go.id,0.1,"killnpc")
end

function killnpc()
	npc_neutral:destroy()
end
User avatar
mahric
Posts: 192
Joined: Sun Nov 04, 2012 3:05 pm

Re: NPC's and custom voice/sound?

Post by mahric »

Thanks for the solution Aisuu, now I don't have to worry how to fit this into my schedule!
Did you visit the Wine Merchant's Basement? And heard about the Awakening of Taarnab?
Post Reply