thief script complete

Error message

Deprecated function: implode(): Passing glue string after array is deprecated. Swap the parameters in drupal_get_feeds() (line 394 of /var/www/pied-piper.ermarian.net/includes/common.inc).
AuthorTopic: thief script complete
Apprentice
Member # 5294
Profile Homepage #0
Just in case people were wondering, I completed the thief creature script with some help from here. Since the prior question contained an unworking script, I've included the completed, fixed one here. Nothing like being in fight with someone and have your sword swipped :) .
// thief.txt v1.0
// M. G. Slack - 2005
// (slack at attglobal . net)
// - based off of basicnpc
// A very simple, naive text. Creature attacks anything it hates nearby.
// Once it has won, it returns to its home.
// In addition, will occasionally, based on level, will attempt to steal a
// random object from the character fighting. If successful, will then
// teleport away or stay if cell 6 is set.
// POTENTIAL TODO - add counter to loop when determining where to teleport
// to, so endless loop not generated, user controllable?
// Memory Cells:
// Cell 0 - How creature moves.
// 0 - If 0, wander randomly.
// 1 - Stands still until a target appears.
// 2 - Completely immobile, even if target appears.
// Cell 1,2 - Stuff done flag. If both 0, nothing. Otherwise when this
// is killed, set to 1. (Example: If cell 1 is 3 and cell 2 is 5, when
// creature is killed, sets SDF(3,5) to 1.)
// Cell 3 - Dialogue node to start with if talked to. if left at 0, this
// character doesn't talk.
// Cell 4,5 - Coordinates of chest/spot to place stolen items at. If both
// left at zero, thief keeps item. Note, if not set, thief will not
// steal equipped items.
// Cell 6 - If set to 1 (non-zero), thief won't teleport away. Logically
// does not make sense to set 4,5 and 6 - how can the thief put items in
// a cache if he doesn't go anywhere?

begincreaturescript;

variables;

short i, itm, slt, st, x, y, fl, tr, target;

body;

beginstate INIT_STATE;
if (get_memory_cell(0) == 2)
set_mobility(ME, 0);
break;

beginstate DEAD_STATE;
// Set the appropriate stuff done flag for this character being dead
if ((get_memory_cell(1) != 0) || (get_memory_cell(2) != 0))
set_flag(get_memory_cell(1), get_memory_cell(2), 1);
break;

beginstate START_STATE;
// if I have a target for some reason, go attack it
if (target_ok()) {
if (dist_to_char(get_target()) <= 16)
set_state(3);
else set_target(ME, -1);
}

// Look for a target, attack it if visible
if (select_target(ME, 8, 0)) {
do_attack();
set_state(3);
}

// Have I been hit? Strike back!
if (who_hit_me() >= 0) {
set_target(ME, who_hit_me());
do_attack();
set_state(3);
}

// Otherwise, just peacefully move around. Go back to start, if I'm too far
// from where I started.
if ((my_dist_from_start() >= 6) || ((my_dist_from_start() > 0) && (get_memory_cell(0) > 0))) {
if (get_ran(1, 1, 100) < 40)
return_to_start(ME, 1);
}
else if (get_memory_cell(0) == 0) {
fidget(ME, 25);
}

// if we're in combat and the above didn't give me anything to do, just
// stop now. Otherwise, game will keep running script, and that eats up CPU time.
if (am_i_doing_action() == FALSE)
end_combat_turn();
break;

beginstate 3; // attacking
if (target_ok() == FALSE) {
set_state(START_STATE);
}
// try to steal?
if (get_ran(1, 0, 100) <= get_level(my_number())) {
set_state_continue(10);
}
else {
do_attack();
}
break;

beginstate TALKING_STATE;
if (get_memory_cell(3) == 0) {
print_str("Talking: It doesn't respond.");
end();
}
begin_talk_mode(get_memory_cell(3));
break;

beginstate 10;
// steal something?
// print_str("Start of steal.");
i = get_target();
// print_big_str("Target = ", i, "");
if ((get_memory_cell(4) == 0) && (get_memory_cell(5) == 0)) {
st = 13;
}
else {
st = 0;
}
slt = get_ran(1, st, 39);
// print_big_str("Slot = ", slt, "");
itm = item_type_in_slot(i, slt);
if (itm > 0) {
// steal it and go...
// print_big_str("Good item = ", itm, "");
if (st > 0) {
// char_take_item(i, itm);
destroy_char_item(i, slt);
char_give_item(my_number(), itm);
}
else {
take_item_char_item(i, slt, get_memory_cell(4), get_memory_cell(5));
}
if (get_memory_cell(6) == 0) {
// print_str("Getting ready to leave.");
set_state_continue(11);
}
else {
end_combat_turn();
set_state(3);
}
}
else {
do_attack();
set_state(3);
}
break;

beginstate 11;
// teleport away (get random location (not blocked) and go)
print_str_color("The thief takes an item and slips away.", 4);
i = current_town_size();
if (i == 0)
st = 63;
else if (i == 1)
st = 47;
else
st = 31;
i = 0;
while (i == 0) {
x = get_ran(1, 0, st);
y = get_ran(1, 0, st);
// check x and y
fl = get_floor(x, y);
tr = get_terrain(x, y);
if ((((fl >= 0) && (fl <= 22)) || ((fl >= 37) && (fl <= 56)) ||
((fl >= 72) && (fl <= 78)) || ((fl >= 81) && (fl <= 91)) ||
((fl >= 95) && (fl <= 123))) &&
((tr == 0) || ((tr >= 2) && (tr <= 121)) || ((tr >= 137) && (tr <= 146)) ||
((tr >= 155) && (tr <= 165))) &&
(is_blocked(x, y) == FALSE)) {
i = 1;
}
// slip to location
if (i == 1) {
relocate_character(my_number(), x, y);
}
}
// print_big_str("New x = ", x, "");
// print_big_str("New y = ", y, "");
end_combat_turn();
set_target(ME, -1);
set_char_alert(my_number(), 0);
set_state(START_STATE);
break;
Let me know if you find something that doesn't work.

Mike
Posts: 30 | Registered: Wednesday, December 15 2004 08:00
Infiltrator
Member # 5567
Profile Homepage #1
Whoa!! Now that is useful.

EDIT: I am certainly going to use that in my scen.
I have a secret guild in it.

[ Friday, April 22, 2005 00:08: Message edited by: JadeWolf ]

--------------------
How many shapers are there?
Why is Drypeak controlled by Zakary?
Why is Barzahl a Guardian?
How does the Geneforge work?
What's as small as nothing?
Why am I asking stupid questions?
--------------------------------
Shaper teacher : "DON'T TOUCH THAT!"
BOOM!!
apprentice :*little voice* "Sorry..."
---------------------------
CSM RIFQ
Neopets Do join, it's fun. Do you know what is the answer to the greatest question ever? It's here.
Posts: 576 | Registered: Wednesday, March 2 2005 08:00
Infiltrator
Member # 5566
Profile #2
quote:
Originally written by JadeWolf:

Whoa!! Now that is useful.

EDIT: I am certainly going to use that in my scen.
I have a secret guild in it.

me to great script by the way :D
Posts: 507 | Registered: Tuesday, March 1 2005 08:00