We need a tutorial on how to set up and NPC for scripts

General support forum. If you require assistance and your problem doesnt fall in any of the other categories, this is the forum for you!

Moderator: Team Members

Forum rules
READ THE FORUM STICKY THREADS BEFORE ASKING FOR HELP!
Most information can be found there, and if not, the posts will help you determine the information required to get assistance from the development team.
Incomplete Help Requests will be locked or deleted.
Post Reply
User avatar
Astal
Posts: 96
Joined: Tue Dec 09, 2008 1:35 pm

We need a tutorial on how to set up and NPC for scripts

Post by Astal » Sun Sep 27, 2009 5:37 pm

Ive been searching around and nothing says how to tie a script to a certain NPC, ive been trying to get an NPC to talk when I hail it forever now. If anyone could help me out id appreciate it.
I DIE FREE!!

User avatar
Scatman
Retired
Posts: 1688
Joined: Wed Apr 16, 2008 5:44 am
EQ2Emu Server: Scatman's Word
Characters: Scatman
Location: New Jersey

Re: We need a tutorial on how to set up and NPC for scripts

Post by Scatman » Sun Sep 27, 2009 5:56 pm

Go to your spawn_scripts table. If you want a certain spawn to have a spawn script, enter a new row and fill in their spawn id into the spawn_id column. Next, enter in the location of your lua scripted you created into the lua_script column (C:\eq2emu\SpawnScripts\blahblah). Here's an example spawn script. I wasn't sure exactly what you needed help with since you didn't explain what your problem was in depth:

Code: Select all

function spawn(NPC)
	SetPlayerProximityFunction(NPC, 20, "InRange", "LeavingRange")
end

function InRange(NPC, Spawn)
	Say(NPC, "Hey, you've come within 20 meters of me!", Spawn)
end

function LeavingRange(NPC, Spawn)
	Say(NPC, "You're now outside my 20 meter radius of checking for spawns.", Spawn)
end

function respawn(NPC)
	spawn(NPC)
end

function hailed(NPC, Spawn)
	FaceTarget(NPC, Spawn)
	conversation = CreateConversation()
	
	AddConversationOption(conversation, "Just great thanks, and yourself?", "GreatThanks")
	AddConversationOption(conversation, "Grande.")
	StartConversation(conversation, NPC, Spawn, "Hey there " .. GetName(Spawn) .. ", how are ya doin' today?")
end

function hailed_busy(NPC, Spawn)
	Say(NPC, "You've hailed me while I'm busy like fighting.", Spawn)
end

function targeted(NPC, Spawn)
	Say(NPC, "You've targeted me.", Spawn)
end

function attacked(NPC, Spawn)
	Say(NPC, "You've attacked me.", Spawn)
end

function healthchanged(NPC, Spawn)
	Say(NPC, "My health has changed.", Spawn)
end

function aggro(NPC, Spawn)
	Say(NPC, "This is called when you first attack me.", Spawn)
end

function killed(NPC, Spawn)
	Say(NPC, "I've killed you!", Spawn)
end

function death(NPC, Spawn)
	Say(NPC, "You've killed me :(", Spawn)
end

function casted_on(NPC, Spawn, SpellName)
	Say(NPC, "You casted " .. SpellName .. " on me!", Spawn)
end

-----------------------------------------------------------------------------
--			functions to handle the extended conversations from hailed
-----------------------------------------------------------------------------

function GreatThanks(NPC, Spawn)
	FaceTarget(NPC, Spawn)
	conversation = CreateConversation()
	
	AddConversationOption(conversation, "Good to hear..")
	StartConversation(conversation, NPC, Spawn, "Wonderful!")
end

User avatar
Astal
Posts: 96
Joined: Tue Dec 09, 2008 1:35 pm

Re: We need a tutorial on how to set up and NPC for scripts

Post by Astal » Sun Sep 27, 2009 6:27 pm

thanks scat, thats exactly what i needed
I DIE FREE!!

User avatar
Astal
Posts: 96
Joined: Tue Dec 09, 2008 1:35 pm

Re: We need a tutorial on how to set up and NPC for scripts

Post by Astal » Sun Sep 27, 2009 7:01 pm

Did i Do this right?

F:\Eq 2 Emu\Config Files\SpawnScripts\Greeter.lua is in the lua script box then i have 1 for all the other boxes, because it is the only spawn on my server and its all set to one lol. Im still not getting anything. I have the NPC set up so it can be hailed also.

I guess u gotta restart the server each time you change a script or somthin, its workin now
I DIE FREE!!

bolly
Retired
Posts: 389
Joined: Mon Sep 21, 2009 3:03 pm
Location: Leeds, UK

Re: We need a tutorial on how to set up and NPC for scripts

Post by bolly » Sun Sep 27, 2009 7:14 pm

nope you can do a /reload spawnscripts and then follow it by /reload spawns :-)

User avatar
Scatman
Retired
Posts: 1688
Joined: Wed Apr 16, 2008 5:44 am
EQ2Emu Server: Scatman's Word
Characters: Scatman
Location: New Jersey

Re: We need a tutorial on how to set up and NPC for scripts

Post by Scatman » Sun Sep 27, 2009 7:20 pm

Just a /reload spawnscripts will work if you are changing content of the script.

User avatar
Astal
Posts: 96
Joined: Tue Dec 09, 2008 1:35 pm

Re: We need a tutorial on how to set up and NPC for scripts

Post by Astal » Sun Sep 27, 2009 7:45 pm

ok, hey you know how to make item at all? Checked the wiki, but it is severely lacking in info lol.
I DIE FREE!!

bolly
Retired
Posts: 389
Joined: Mon Sep 21, 2009 3:03 pm
Location: Leeds, UK

Re: We need a tutorial on how to set up and NPC for scripts

Post by bolly » Sun Sep 27, 2009 7:51 pm

http://www.eq2emulator.net/wiki/index.p ... ns:Content

Put together a little page on the wiki to get new peeps started

User avatar
Astal
Posts: 96
Joined: Tue Dec 09, 2008 1:35 pm

Re: We need a tutorial on how to set up and NPC for scripts

Post by Astal » Sun Sep 27, 2009 7:53 pm

bolly wrote:http://www.eq2emulator.net/wiki/index.p ... ns:Content

Put together a little page on the wiki to get new peeps started
yeah, i wish i knew more about items id add to the wiki on em. I got a lot of learning to do.
I DIE FREE!!

bolly
Retired
Posts: 389
Joined: Mon Sep 21, 2009 3:03 pm
Location: Leeds, UK

Re: We need a tutorial on how to set up and NPC for scripts

Post by bolly » Sun Sep 27, 2009 8:01 pm

Astal wrote:ok, hey you know how to make item at all? Checked the wiki, but it is severely lacking in info lol.
Yeah i had the same problem so I looked at the databases, searched around the forums and then started filling in the wiki to help others, help me!! check out the items table and it's children ie item_appearance and what not. Fill in as appropriate - trial and error then update the wiki

Also worth checking out the source code whenever you get stuck (good ol' grep/findinfiles)

Here's a sample item (backpack):

Code: Select all

insert into items (name, item_type,icon,weight,description,sell_price,lua_script) values ('Basic Backpack','Bag', 10,5,'A 4 slot bag with 5 perc reduction',10,'');
then find the ID for the one you just inserted

Code: Select all

select id,name from items where name like '%Basic Backpack%';
We'll say it was ID 1 for this example

Then insert it's bag details into the item_defails_bag table

Code: Select all

insert into item_details_bag (item_id,num_slots,weight_reduction) values (1,4,5); 
Now reload your items in game /reload items

Search for it with /item

There's lots of other tables for different types of items, look at item_details_weapon etc :-)
Last edited by bolly on Sun Sep 27, 2009 8:03 pm, edited 1 time in total.

User avatar
Astal
Posts: 96
Joined: Tue Dec 09, 2008 1:35 pm

Re: We need a tutorial on how to set up and NPC for scripts

Post by Astal » Sun Sep 27, 2009 8:02 pm

will do, im gonna load up the release pack along side and check out the items on there and see what I can learn, i will be sure to fill out the wiki when i learn things.
I DIE FREE!!

bolly
Retired
Posts: 389
Joined: Mon Sep 21, 2009 3:03 pm
Location: Leeds, UK

Re: We need a tutorial on how to set up and NPC for scripts

Post by bolly » Sun Sep 27, 2009 8:09 pm

awesome, that pack is pretty sweet - check out the spawnscripts and quests folder but note the version i downloaded was a different database schema to the current version on svn

good luck bro!

User avatar
Astal
Posts: 96
Joined: Tue Dec 09, 2008 1:35 pm

Re: We need a tutorial on how to set up and NPC for scripts

Post by Astal » Sun Sep 27, 2009 8:20 pm

bolly wrote:awesome, that pack is pretty sweet - check out the spawnscripts and quests folder but note the version i downloaded was a different database schema to the current version on svn

good luck bro!
yeah i noticed that too so you cant directly import it, you would have to type it all out manually.

I noticed a guy was working on an item editor, hopefully he will include item icons and possibly a model viewer in it, that would be awesome
I DIE FREE!!

Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests