[Source] Easy to use NPC script (interaction, walking)

Talk about creating Grimrock 1 levels and mods here. Warning: forum contains spoilers!
User avatar
mahric
Posts: 192
Joined: Sun Nov 04, 2012 3:05 pm

Re: Moving NPC's v0.3 (incl source)

Post by mahric »

A very nice update: NPC's are now clickable!

You can register two functions that you can use for interaction with the npc, once for clicking on the NPC and one when you give stuff to the npc.
This way you can start a dialog, or script what happens if the npc receives an item from the npc.

Sadly I don't have time to upload a new version yet. I just got it working and wanted to share it with you.
Tomorrow I'll clean up the code and upload the source of the new version.
Did you visit the Wine Merchant's Basement? And heard about the Awakening of Taarnab?
User avatar
Neikun
Posts: 2457
Joined: Thu Sep 13, 2012 1:06 pm
Location: New Brunswick, Canada
Contact:

Re: Moving NPC's v0.3 (incl source)

Post by Neikun »

That sounds awesome. I think clicking will feel most natural for starting a conversation
"I'm okay with being referred to as a goddess."
Community Model Request Thread
See what I'm working on right now: Neikun's Workshop
Lead Coordinator for Legends of the Northern Realms Project
  • Message me to join in!
User avatar
mahric
Posts: 192
Joined: Sun Nov 04, 2012 3:05 pm

Re: Moving NPC's (incl source)

Post by mahric »

The source has been uploaded, with an example that shows the use of all functions:
- Create NPCs by either placing them on a spot in the editor or through code
- Define a pre-defined route for the NPC to walk. Repeatable if you want to
- Define a function that gets called when the player clicks on an NPC
- Another function can be set to be called when clicks on an NPC while having an item on the cursor. It gives the item to the npc that way

Please take a look at the demo, the source and let me know if you think it's usefull. (link is on the first page of this topic)
If you find bugs or want things different, please post it here.
Did you visit the Wine Merchant's Basement? And heard about the Awakening of Taarnab?
valley609
Posts: 16
Joined: Thu May 09, 2013 4:32 pm

Re: [Source] Easy to use NPC script (interaction, walking)

Post by valley609 »

I was wondering something, I have this custom monster which is basicly a retextured ogre, would it be possible to make this work with it as long as I change the names and directories, or is it something even deeper that keeps the other monsters from being used with this.

Will I have to change the texture of the ogre itself if I want a custom textured ogre NPC, or can I make a custom one, identical with the ogre, just retextured?
User avatar
mahric
Posts: 192
Joined: Sun Nov 04, 2012 3:05 pm

Re: [Source] Easy to use NPC script (interaction, walking)

Post by mahric »

valley609 wrote:I was wondering something, I have this custom monster which is basicly a retextured ogre, would it be possible to make this work with it as long as I change the names and directories, or is it something even deeper that keeps the other monsters from being used with this.

Will I have to change the texture of the ogre itself if I want a custom textured ogre NPC, or can I make a custom one, identical with the ogre, just retextured?

If you have a retextured ogre, you should be able to get away by doing the following stuff:

0) Make sure you have your monster defined (I assum it's called myOgre in this example)
1) Open the md_npc\scripts\monsters.lua in a text editor
2) Find the definition of "md_npc_ogre"
3) Change the line: "baseObject = "ogre",
Into: "baseObject = "myOgre",
4) Save the file

After the modifications above the ogre should be replaced by your retextured ogre.
If you need any more help, feel free to post or msg me.
Did you visit the Wine Merchant's Basement? And heard about the Awakening of Taarnab?
valley609
Posts: 16
Joined: Thu May 09, 2013 4:32 pm

Re: [Source] Easy to use NPC script (interaction, walking)

Post by valley609 »

mahric wrote:
If you have a retextured ogre, you should be able to get away by doing the following stuff:

0) Make sure you have your monster defined (I assum it's called myOgre in this example)
1) Open the md_npc\scripts\monsters.lua in a text editor
2) Find the definition of "md_npc_ogre"
3) Change the line: "baseObject = "ogre",
Into: "baseObject = "myOgre",
4) Save the file
It works great, thank you so much.
Btw, your script is amazing.
User avatar
LordGarth
Posts: 500
Joined: Mon Jun 18, 2012 5:07 pm
Location: Colorado USA

Re: [Source] Easy to use NPC script (interaction, walking)

Post by LordGarth »

Could this be used as a shop for buying and selling?

LordGarth
Dungeon Master and DOOM will live forever.
User avatar
mahric
Posts: 192
Joined: Sun Nov 04, 2012 3:05 pm

Re: [Source] Easy to use NPC script (interaction, walking)

Post by mahric »

LordGarth wrote:Could this be used as a shop for buying and selling?

LordGarth
This script has nothing to do with buying and/or selling itself.

Theoretically it can be expanded to incorporate buying and/or selling, but it would have to be build from the ground up.
The only thing you can re-use is the start of the interaction (e.q. player clicks on the npc to start trading or gives an item to sell).

If you're looking for a quick solution I think there are other buy/sell scripts floating around somewhere.
Did you visit the Wine Merchant's Basement? And heard about the Awakening of Taarnab?
User avatar
LordGarth
Posts: 500
Joined: Mon Jun 18, 2012 5:07 pm
Location: Colorado USA

Re: [Source] Easy to use NPC script (interaction, walking)

Post by LordGarth »

I will have to check but I dont think they are compatible with skyscript framework.

LordGarth
Dungeon Master and DOOM will live forever.
bongobeat
Posts: 1076
Joined: Thu May 16, 2013 5:58 pm
Location: France

Re: [Source] Easy to use NPC script (interaction, walking)

Post by bongobeat »

woww

I'm not sure what you are all doing here peoples!
are you programming grimrock 2 or something? :D

nice job!
My asset pack: viewtopic.php?f=22&t=9320

Log1 mod : Toorum Manor: viewtopic.php?f=14&t=5505
Post Reply