A Miner Mining
Create 3 mounds of dirt in your grove
Create a spawn point and attach a friendly NPC to it. I recommend using 122, who is a mining NPC already equippred with a shovel.
Use /iscript to add the following script, making you sure alter walk_locations and ACTOR_CDEFID to match the locations of your mounds and the Creature Def ID of your actor.
/*
* This script demonstrates adding some 'life' to an NPC. The
* NPC is instructed to walk to one of several spots (randomly
* chosen). They will then say a phrase in local chat (again
* chosen randomly), and finally performing an emote, and
* then going through the whole cycle again.
*
*/
// Change this for to the create definition ID you want to animate
const ACTOR_CDEFID = 122;
// Change this to use different animation
const ANIMATION = "Dig_Shovel";
// This determines the chance the actor will speak when they arrive (%age chance)
const SPEAK_CHANCE = 33;
/* The speed you want your actor to walk at. There are 3 pre-defined
* speed constants you can use :-
*
* CREATURE_WALK_SPEED
* CREATURE_JOG_SPEED
* CREATURE_RUN_SPEED
*
* Or you can use any integer number between 1 and 500.
*
* NOTE!!!! Speed doesn't currently work properly
*
*/
speed <- CREATURE_JOG_SPEED;
/*
* An 'array' of different things the actor might say.
*/
phrases <- [
"I just know it's buried here somewhere ..",
"One day I'll be able to pay others to do this for me",
"I really dig ... digging",
"Rock .. that's all I seem to find these days",
"I mine the mine, and what's mine is mine",
"I'm really digging a hole for myself here"
];
/*
* An array of locations the actor may move to. Each location
* is a 'Point' object, that contains the X and Z co-ordinates
*/
walk_locations <- [
Point(3028, 4110),
Point(3139, 4048),
Point(3026, 4006)
];
/*
* Move the actor to one of the pre-defined spots
*/
function moveSomewhere() {
/*
* Pick a random location from the list. 'randmodrnd' is used as it
* returns a number between 0 (inclusive) and 1 less than the number of possible
* locations
*/
local location = walk_locations[randmodrng(0, walk_locations.len())];
// As with most things, we need the CID of the creature to act on
local cids = inst.cids(ACTOR_CDEFID);
if(cids.len() == 0) {
// Just in case they haven't spawned (yet), we don't an error
inst.queue(moveSomewhere, 5000);
return;
}
/* Instruct the actor to walk to the chosen location. The
* last argument to 'orderWalk' is the function to call when
* the actor arrives
*/
inst.walkThen(cids[0], location, speed, 0, arrived);
}
/*
* Called when the actor arrives at his location
*/
function arrived() {
local cid = inst.cids(ACTOR_CDEFID)[0];
/* Determine if we want the actor to speak at all */
if(randmodrng(0, 100) <= SPEAK_CHANCE) {
/*
* Pick a random phrase to 'say'. As with the location, randmodrng is used. We also
* delay the speech by a second
*/
inst.queue(function() {
inst.creatureChat(cid, "s/", phrases[randmodrng(0, phrases.len())]);
}, 1000);
}
/* Make the character perform an emote. We will perform the emote 4 times, once
* every 2000ms (2 seconds).
*/
inst.emote(cid, ANIMATION);
inst.queue(function() { inst.emote(cid, ANIMATION); }, 2000);
inst.queue(function() { inst.emote(cid, ANIMATION); }, 4000);
inst.queue(function() { inst.emote(cid, ANIMATION); }, 6000);
inst.queue(function() { inst.emote(cid, ANIMATION); }, 8000);
/*
* At 10 seconds, we move the actor on
*/
inst.queue(moveSomewhere, 10000);
}
inst.queue(moveSomewhere, 1000);