We need a tutorial on how to set up and NPC for scripts
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.
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.
- Astal
- Posts: 96
- Joined: Tue Dec 09, 2008 1:35 pm
We need a tutorial on how to set up and NPC for scripts
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!!
- 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
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- 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
thanks scat, thats exactly what i needed
I DIE FREE!!
- 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
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
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
nope you can do a /reload spawnscripts and then follow it by /reload spawns 
- 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
Just a /reload spawnscripts will work if you are changing content of the script.
- 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
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
http://www.eq2emulator.net/wiki/index.p ... ns:Content
Put together a little page on the wiki to get new peeps started
Put together a little page on the wiki to get new peeps started
- 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
yeah, i wish i knew more about items id add to the wiki on em. I got a lot of learning to do.bolly wrote:http://www.eq2emulator.net/wiki/index.p ... ns:Content
Put together a little page on the wiki to get new peeps started
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
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 wikiAstal wrote:ok, hey you know how to make item at all? Checked the wiki, but it is severely lacking in info lol.
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,'');Code: Select all
select id,name from items where name like '%Basic Backpack%';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); 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.
- 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
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
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!
good luck bro!
- 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
yeah i noticed that too so you cant directly import it, you would have to type it all out manually.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!
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!!
Who is online
Users browsing this forum: No registered users and 0 guests