Previous (1) | Screenplay Reference | Next (3) |
Whilst not essential, let’s learn the basics about creating a new NPC to have a chat with. Maybe it’s the smuggler who’s going to give you the code to get into that new dungeon that you’re developing (eventually, soon, whenever).
The first thing we’ll need is a LUA file describing the NPC.
In your /bin/scripts/mobiles/custom_content folder, create a myscreenplay folder for your purposes. Naming it the same as your screenplay folder makes it easier to tie in all the resources for your screenplay later. Trust me, it’s worth doing.
Within this folder, create a new file, called whatever you want really, the name of the NPC or the role of the NPC – let’s call this one my_npc.lua.
myscreenplay_my_npc = Creature:new { -- instantiate the creature
objectName = "@mob/creature_names:commoner", -- give it a base name
customName = "My NPC", -- override the name with one of your choice
socialGroup = "townsperson", -- set the factions
pvpFaction = "neutral",
faction = "neutral",
level = 9, -- set the levels and stats for the creature
chanceHit = 0.27,
damageMin = 80,
damageMax = 90,
baseXp = 356,
baseHAM = 675,
baseHAMmax = 825,
armor = 0,
resists = {0,0,0,0,0,0,0,-1,-1},
meatType = "",
meatAmount = 0,
hideType = "",
hideAmount = 0,
boneType = "",
boneAmount = 0,
milk = 0,
tamingChance = 0,
ferocity = 0,
pvpBitmask = NONE,
creatureBitmask = NONE,
optionsBitmask = AIENABLED + CONVERSABLE,
diet = HERBIVORE,
-- set the appearance model of the NPC
-- multiple options can be set and it will choose randomly on each spawn
templates ={"object/mobile/dressed_rebel_master_sergeant_sullustan_male_01.iff"},
-- the loot groups to apply to the NPC - you can delete if this NPC can't be killed or looted
lootGroups = {
{
groups = {
{group = "junk", chance = 3000000}
}
}
},
-- the weapon groups that this NPC can use if it gets into combat
weapons = {},
-- this is the conversation template to use that we'll define in the next step
-- leave empty if this NPC can't be conversed with
conversationTemplate = "myscreenplay_my_npc",
-- the types of attacks that this NPC can use in combat
attacks = {},
}
-- add the template so that we can reference it from the screenplay
CreatureTemplates:addCreatureTemplate(myscreenplay_my_npc, "myscreenplay_my_npc")
Having the NPC defined is all well and good, but we need to actually spawn him within the screenplay, so edit the screenplay file you made previously bin/scripts/screenplays/custom_content/myscreenplay/myscreenplay.lua
and add the following 2 lines to the myscreenplay:start() function
-- function that is executed when the screenplay starts
function myscreenplay:start()
print("My Screenplay has started " .. self.scriptName)
local npc1 = spawnMobile("naboo", "myscreenplay_my_npc", 300, -4920, 6.0, 4100, 40 0)
self:setMoodString(npc1, "bored")
end
This will spawn your npc near the fountain outside Theed starport on Naboo, facing the starport
local npc1 = spawnMobile(“planet“, “npc_reference“, respawn_in_seconds_if_killed, x, y, z, rotation, cellid)
it then uses the returned reference npc1 to set the NPC’s mood to bored
check out Tyclo's amazing NPC database
Previous (1) | Screenplay Reference | Next (3) |