This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
scriptlib:minerminig [2015/05/09 16:36] emerald |
scriptlib:minerminig [2015/05/16 15:52] emerald |
||
---|---|---|---|
Line 37: | Line 37: | ||
* | * | ||
*/ | */ | ||
- | speed <- 500; | + | speed <- CREATURE_JOG_SPEED; |
/* | /* | ||
Line 43: | Line 43: | ||
*/ | */ | ||
phrases <- [ | phrases <- [ | ||
- | "I just know it's buried here somewhere ..", | + | "I just know it's buried here somewhere ..", |
- | "One day I'll be able to pay others to do this for me", | + | "One day I'll be able to pay others to do this for me", |
- | "I really dig ... digging", | + | "I really dig ... digging", |
- | "Rock .. that's all I seem to find these days" | + | "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" | ||
]; | ]; | ||
Line 54: | Line 56: | ||
*/ | */ | ||
walk_locations <- [ | walk_locations <- [ | ||
- | Point(3028, 4110), | + | Point(3028, 4110), |
- | Point(3139, 4048), | + | Point(3139, 4048), |
- | Point(3026, 4006) | + | Point(3026, 4006) |
]; | ]; | ||
Line 63: | Line 65: | ||
*/ | */ | ||
function moveSomewhere() { | function moveSomewhere() { | ||
- | /* | + | /* |
- | * Pick a random location from the list. 'randmodrnd' is used as it | + | * 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 | + | * returns a number between 0 (inclusive) and 1 less than the number of possible |
- | * locations | + | * locations |
- | */ | + | */ |
- | local location = walk_locations[randmodrng(0, walk_locations.len())]; | + | local location = walk_locations[randmodrng(0, walk_locations.len())]; |
- | // As with most things, we need the CID of the creature to act on | + | // As with most things, we need the CID of the creature to act on |
- | local cid = inst.cids(ACTOR_CDEFID)[0]; | + | 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 | + | /* Instruct the actor to walk to the chosen location. The |
- | * last argument to 'orderWalk' is the function to call when | + | * last argument to 'orderWalk' is the function to call when |
- | * the actor arrives | + | * the actor arrives |
- | */ | + | */ |
- | inst.walkThen(cid, location, speed, 0, arrived); | + | inst.walkThen(cids[0], location, speed, 0, arrived); |
} | } | ||
Line 84: | Line 91: | ||
*/ | */ | ||
function arrived() { | 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 | ||
- | */ | ||
- | inst.creatureChat(cid, "s/", phrases[randmodrng(0, phrases.len())]); | ||
- | } | ||
- | /* Make the character perform an emote. We will perform the emote 4 times, once | + | local cid = inst.cids(ACTOR_CDEFID)[0]; |
- | * every 2000ms (2 seconds). | + | |
- | */ | + | /* Determine if we want the actor to speak at all */ |
- | local i = 0; | + | |
- | for(; i < 10000; i += 2000) { | + | if(randmodrng(0, 100) <= SPEAK_CHANCE) { |
- | core.queue(function() { | + | /* |
- | inst.emote(cid, ANIMATION); | + | * Pick a random phrase to 'say'. As with the location, randmodrng is used. We also |
- | }, i); | + | * delay the speech by a second |
- | } | + | */ |
- | + | inst.queue(function() { | |
- | /* | + | inst.creatureChat(cid, "s/", phrases[randmodrng(0, phrases.len())]); |
- | * At 10 seconds, we move the actor on | + | }, 1000); |
- | */ | + | } |
- | core.queue(moveSomewhere, i); | + | |
+ | /* 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); | ||
} | } | ||
- | core.queue(moveSomewhere, 1000); | + | inst.queue(moveSomewhere, 1000); |
</code> | </code> |