generic genius #155

Parent #106Owner #361Flags read, fertileSource hellcore/hellcore.db

Aliases: generic genius

19 verbs · 138 properties · 0 children

Verbs

VerbSpecFlagsDefinerLines
clear_queuethis none thisrxd#15516
cancel_current_actionthis none thisrxd#15517
process_queuethis none thisrx#15575
plan_actionthis none thisrxd#1558
_do_planthis none thisrxd#1555
suggest_next_actionthis none thisrxd#15512
heartbeatthis none thisrxd#15516
plan_loopthis none thisrxd#1551
diethis none thisrxd#1554
p_walktothis none thisrxd#15565
hear_say_tothis none thisrxd#1552
tell_planthis none thisrxd#1552
change_planthis none thisrxd#15519
btellthis none thisrxd#1553
_wanderthis none thisrxd#1554
p_defendthis none thisrxd#15538
next_planthis none thisrxd#1552
page_sendthis none thisrxd#1555
p_resthomethis none thisrxd#1553

Properties

PropertyDefinerFlagsOwnerValue
plan_action#155rc#361{}
plan_task#155rc#3610
last_converse_time#155rc#3610
plan_msg#155rc#361""
pwait#155rc#3610
brainlisteners#155rc#361{}
plan#155rc#361""
wristpad#155rc#361#-1
wields_weapons#106rc#361<clear>
public_wander_only#106rc#361<clear>
bravery#106rc#361<clear>
enemies#106rw#361{}
lastrooms#106r#361<clear>
wander_chance#106rc#361<clear>
last_greet_time#106r#361<clear>
conversation#106rc#361{"doing,plan|NULL|tell_plan"}
_conversation#106r#361{{{"doing", "plan"}, "NULL", "tell_plan"}}
dunno_msg#106rc#361<clear>
spawns_with#106rc#361<clear>
accepted_gifts#106rc#361<clear>
greet_msg#106rc#361<clear>
wander_speed#106rc#361<clear>
reacting_to#106rc#361<clear>
lastaction#106rw#361<clear>
comment_chance#106rc#361<clear>
respawn_time#106rc#361<clear>
death_time#106rc#3611237677663
nemeses#106rc#361<clear>
nemesis_lifetime#106rc#361<clear>
junk_on_death#106rc#361<clear>
say_fight_msg#106rc#361<clear>
wander_last_try#106rc#361<clear>
destination#106rc#361<clear>
last_wander_time#106rc#361<clear>
last_comment_time#106rc#361<clear>
max_contents#106rc#361<clear>
beg_health#106rc#361<clear>
beg_chance#106rc#361<clear>
beg_msg#106rc#361<clear>
reload_guns#106rc#361<clear>
clothing#106rwc#361<clear>
wardrobe#106rc#361<clear>
stay_home#106rc#361<clear>
respawn_clothing#106rc#361<clear>
walk_last_try#106rc#361<clear>
ignore_next_say#106rc#361<clear>
did_damage#106rc#361<clear>
walk_speed#106rc#361<clear>
here_for_something#106rc#361<clear>
hands#107rc#361<clear>
wielding#107rc#361<clear>
health#107rc#3610
unarmed_weapon#107rc#361<clear>
size#107rc#361<clear>
posture#107rc#361<clear>
gender#107rc#361<clear>
respawn#107rc#361<clear>
corpse#107rc#361<clear>
has_proper_name#107rc#361<clear>
die_msg#107rc#361<clear>
body_parts#107rc#361<clear>
wearing#107rc#361<clear>
armor#107rc#361<clear>
last_swing_message#107rc#361<clear>
health_max#107rc#361<clear>
fighting#107rc#361{}
last_dodge_time#107rc#361<clear>
following#107rc#361<clear>
icon#107rc#361<clear>
say_msg#107rc#361<clear>
say_to_msg#107rc#361<clear>
afterlife#107rc#361<clear>
get_msg#107rc#361<clear>
drop_msg#107rc#361<clear>
blood#107rc#361<clear>
squeals#107rc#361<clear>
prc#107rc#361<clear>
ppc#107rc#361<clear>
poc#107rc#361<clear>
psc#107rc#361<clear>
pr#107rc#361<clear>
pp#107rc#361<clear>
po#107rc#361<clear>
ps#107rc#361<clear>
pq#107rc#361<clear>
pqc#107rc#361<clear>
brief#107rc#361<clear>
knockout#107rc#361<clear>
knockout_msg#107rc#361<clear>
body#107rc#361<clear>
wake_msg#107rc#361<clear>
owake_msg#107rc#361<clear>
oknockout_msg#107rc#361<clear>
friends#107rc#361<clear>
home#107rc#361<clear>
respawn_msg#107rc#361<clear>
move_action#107rc#361<clear>
heart#107rc#361-1
last_heartbeat#107rc#361<clear>
dead#107rc#3611237677663
_tohit_next#107rc#361<clear>
last_words_msg#107rc#361<clear>
attacked#107rc#361<clear>
opens_doors#107rc#3611
movable_by_explosion#107rc#361<clear>
obscured#107rc#361<clear>
obscured_desc_msg#107rc#361<clear>
cooldowns#107rc#361<clear>
combat_rounds#107rc#361<clear>
encumbrance#107rc#361<clear>
respawn_handler#107rc#361<clear>
distant_form_msg#107rc#361<clear>
block_msg#107rc#361<clear>
attack_on_block#107rc#361<clear>
last_stunned#107rc#361<clear>
nude_descs#107rc#361<clear>
skills#107rc#361<clear>
explode_msg#107rc#361<clear>
death_listeners#107rc#361<clear>
queue#92r#361{}
preemptible#92r#361<clear>
executing#92r#361<clear>
process_queue#92r#361<clear>
help_msg#92rc#361<clear>
last_action#92r#361<clear>
article#92rc#361<clear>
last_last_action#92rc#361<clear>
action_count#92rc#361<clear>
aliases#1rc#361{"generic genius"}
description#1rc#361<clear>
object_size#1r#29{18152, 1298433871}
hidden_verbs#1rc#361<clear>
phelp_msg#1rc#361<clear>
weight#1rc#361<clear>
owner_verbs#1rc#361<clear>
plural_name#1rc#361<clear>
client_image#1rc#361<clear>
listening#1rc#361<clear>

Ancestry

Ancestors (nearest first): #106 generic NPC#154 generic living creature#107 generic creature#92 generic actor#1 root

Children: none

Call graph

calls n155_1 #155:cancel_current_action n92_1 #92:fork_process_queue n155_1->n92_1 n155_2 #155:process_queue n155_5 #155:suggest_next_action n155_2->n155_5 n20_48 #20:print n155_2->n20_48 n107_25 #107:debug_tell n155_2->n107_25 n20_59 #20:name_and_number n155_2->n20_59 n18_43 #18:gil_float_to_int n155_2->n18_43 n106_3 #106:_fight n155_5->n106_3 n155_4 #155:_do_plan n155_5->n155_4 n155_14 #155:_wander n155_5->n155_14 n155_3 #155:plan_action n155_13 #155:btell n155_3->n155_13 n92_8 #92:jumpstart n155_3->n92_8 n155_13->n20_59 n155_14->n155_13 n106_2 #106:_wander n155_14->n106_2 n155_6 #155:heartbeat n155_6->n155_13 n106_15 #106:heartbeat n155_6->n106_15 n155_16 #155:next_plan n155_6->n155_16 n155_12 #155:change_plan n155_6->n155_12 n155_12->n155_13 n20_47 #20:from_value n155_12->n20_47 n103_24 #103:report_error n155_12->n103_24 n155_8 #155:die n106_5 #106:die n155_8->n106_5 n155_9 #155:p_walkto n155_9->n155_3 n155_9->n155_13 n107_34 #107:say n155_9->n107_34 n155_10 #155:hear_say_to n106_10 #106:hear_say_to n155_10->n106_10 n155_11 #155:tell_plan n155_11->n107_34 n155_15 #155:p_defend n155_15->n155_13 n155_15->n155_9 n155_15->n107_34 n106_7 #106:start_fighting n155_15->n106_7 n155_18 #155:p_resthome n155_18->n155_3 n155_18->n155_9

Source

clear_queue

Spec this none thisFlags rxdOwner #361Definer #155

Referenced by

none

Source

1":clear_queue()";
2"Kill all queued actions.";
3for x in ({@this.queue, this.executing})
4if (length(x) > 5)
5if (task_valid(x[6]))
6kill_task(x[6]);
7endif
8endif
9endfor
10this.queue = {};
11if (task_valid(this.process_queue) && (task_id() != this.process_queue))
12kill_task(this.process_queue);
13endif
14if (this.executing)
15this.executing = {};
16endif

cancel_current_action

Spec this none thisFlags rxdOwner #361Definer #155

Referenced by

none

Source

1":cancel_current_action([INT dontabort])";
2"If we're currently executing an action, abort it and immediately start our next action.";
3if (this.executing)
4if (length(this.executing) > 5)
5"...Some AI thread was waiting for this action to finish.  KILL IT.";
6kill_task(this.executing[6]);
7endif
8if ((!args) || (!args[1]))
9this.executing[1]:_abort(this, @this.executing[2..$]);
10endif
11this.executing = {};
12if (task_valid(this.process_queue))
13old_pq = this.process_queue;
14this:fork_process_queue();
15kill_task(old_pq);
16endif
17endif

process_queue

Spec this none thisFlags rxOwner #361Definer #155

Referenced by

none

Source

1"Copied from Gilmore (#98):process_queue by Satan (#2) Mon Jun  7 20:36:31 2004 PDT";
2"Copied from generic actor (#716):process_queue by Satan (#2) Mon Jun  7 15:47:39 2004 PDT";
3":process_queue()";
4"Keep running actions until we don't have any to run.";
5player = this;
6next_action_delay = 0;
7if ((!this.queue) && (this.health > 0))
8if (action = this:suggest_next_action())
9this.queue = {action[1]};
10next_action_delay = action[2];
11endif
12endif
13while (this.queue)
14this.preemptible = 0;
15if (this.location == #742)
16this.queue = {};
17endif
18if (this.queue)
19action = this.queue[1];
20this.preemptible = action[1].preemptible;
21this.queue = listdelete(this.queue, 1);
22this.last_action = action;
23debugtext = $su:print(action[2..$]);
24"...sanity check...";
25if (((!action[2]) || (typeof(action[2][1]) != OBJ)) || (!is_a(action[2][1], $garbage)))
26if (!this.location:check_forbid_action(this, @action))
27"...nobody in here cancelled us...";
28this.executing = {@action, @{$action, {}, 1, "", 0}[length(action) + 1..$]};
29this:debug_tell("action", "start  | ", $su:nn(action[1]), " ", debugtext);
30"...start the action...";
31if (result = action[1]:_start(this, action[2]))
32duration = result[1];
33pass_to_finish = result[2];
34else
35duration = 0.0;
36pass_to_finish = 0;
37endif
38durint = $math_utils:gil_float_to_int(duration);
39suspend(durint);
40"...finish the action...";
41this:debug_tell("action", "finish | ", $su:nn(action[1]), " ", debugtext);
42action[1]:_finish(this, action[2], pass_to_finish);
43this.executing = {};
44if (length(action) > 4)
45"...wake up the waiting AI thread...";
46resume(action[6], 1);
47endif
48else
49this:debug_tell("action", "forbid | ", $su:nn(action[1]), " ", debugtext);
50action[1]:_forbidden(this, @action[2..$]);
51if (length(action) > 4)
52resume(action[6], 0);
53endif
54endif
55endif
56endif
57this.preemptible = next_action_delay > 0;
58suspend(next_action_delay);
59this.preemptible = 0;
60if (!this.queue)
61"...no more queued actions, do we have an auto-action?...";
62if (result = this:suggest_next_action())
63action = result[1];
64if (((action[1] in $rpg.repeatable_actions) || is_player(this)) || (action != this.last_action))
65next_action_delay = result[2];
66"...add our auto-action to the queue...";
67this.queue = {action};
68endif
69endif
70else
71next_action_delay = 0;
72endif
73endwhile
74"...the queue's empty! go away now...";
75this.process_queue = 0;

plan_action

Spec this none thisFlags rxdOwner #361Definer #155

Referenced by

Source

1if (this.plan_action || ((this.executing && (length(this.executing) > 5)) && task_valid(this.executing[6])))
2this:btell("PLAN BURP");
3kill_task(task_id());
4else
5this.plan_action = {@args, @{$action, {}, 1, "", 0}[length(args) + 1..$], task_id()};
6this:jumpstart();
7return suspend($maxint);
8endif

_do_plan

Spec this none thisFlags rxdOwner #361Definer #155

Referenced by

Source

1if (this.plan_action)
2r = this.plan_action;
3this.plan_action = {};
4return r;
5endif

suggest_next_action

Spec this none thisFlags rxdOwner #361Definer #155

Referenced by

Source

1if (r = this:_fight())
2return {r, 0};
3elseif (r = this:_do_plan())
4this.pwait = 1;
5return {r, 0};
6elseif (this.pwait)
7return;
8else
9if (r = this:_wander())
10return {r, this.wander_speed};
11endif
12endif

heartbeat

Spec this none thisFlags rxdOwner #361Definer #155

Referenced by

none

Source

1pass(@args);
2if (!task_valid(this.plan_task))
3if (this.pwait)
4this:btell("hmm, that's STRANGE.  i thought i had something important to do, but it seems to have vanished.");
5this.pwait = 0;
6endif
7this.plan = "";
8this.plan_task = 0;
9if (p = this:next_plan())
10this:change_plan(@p);
11endif
12elseif ((!this.executing) && (!this.queue))
13pt = this.plan_task;
14this.plan_task = 0;
15resume(pt);
16endif

plan_loop

Spec this none thisFlags rxdOwner #361Definer #155

Referenced by

none

Source

1this.plan_msg = "thinking";

die

Spec this none thisFlags rxdOwner #361Definer #155

Referenced by

none

Source

1if (task_valid(this.plan_task))
2kill_task(this.plan_task);
3endif
4return pass(@args);

p_walkto

Spec this none thisFlags rxdOwner #361Definer #155

Referenced by

Source

1":p_walkto(OBJ dest, INT step delay[, STR reasoN, INT hurry])";
2"Walk to the destination.  If 'hurry', don't stop to chat.";
3{dest, delay, reason, ?hurry = 0} = args;
4this.pwait = 1;
5this.plan_msg = (("walking to " + dest.name) + " ") + reason;
6abort = 0;
7lastrooms = {};
8if (is_a(dest, $room))
9destwho = #-1;
10else
11destwho = dest;
12dest = destwho.location;
13endif
14while ((!abort) && (this.location != dest))
15if (valid(destwho) && (destwho.location == this.location))
16this:btell("oh, i ran into ", destwho.name, " on my way to ", dest.name, "!");
17return 1;
18endif
19if (hurry && ((time() - this.last_converse_time) < 5))
20this:say(("Sorry, I have to get going " + reason) + ".");
21this:btell("stupid talkers, wasting our precious time!");
22suspend(1);
23else
24wait_on_converse = 0;
25while ((time() - this.last_converse_time) < 30)
26wait_on_converse = 1;
27this.plan_msg = ("walking to " + dest.name) + ", but I stopped to chat.";
28this:btell("waiting to finish talking");
29suspend(5);
30endwhile
31if (wait_on_converse)
32this:say("Alright, I gotta get moving.");
33this.plan_msg = "walking to " + dest.name;
34endif
35endif
36if (this.location in lastrooms)
37this:btell("damn, i'm lost.");
38this:say("Damn.  I'm lost.");
39suspend(5);
40abort = 1;
41elseif (valid(hop = this.location:next_hop_to(dest)))
42lastrooms = setadd(lastrooms, this.location);
43oldloc = this.location;
44this:btell("heading ", hop.name, " to get to ", dest.name, " (", reason, ")");
45this:plan_action($actions.move, {hop}, 1, "");
46suspend(delay);
47while (this.executing || this.queue)
48suspend(delay);
49endwhile
50if (this.location == oldloc)
51this:say("Damn!  I'm stuck.");
52this:btell("i couldn't go ", hop.name, ", apparently.");
53abort = 1;
54endif
55else
56this:btell("damn.  i don't know how to get to ", dest.name, " from ", this.location.name, ".");
57return 0;
58endif
59endwhile
60if (!abort)
61this:btell("hey, i made it to ", this.location.name, "!");
62endif
63this.plan_msg = "";
64this.pwait = 0;
65return this.location == dest;

hear_say_to

Spec this none thisFlags rxdOwner #361Definer #155

Referenced by

none

Source

1this.last_converse_time = time();
2pass(@args);

tell_plan

Spec this none thisFlags rxdOwner #361Definer #155

Referenced by

none

Source

1who = args[1];
2this:say(("I'm " + this.plan_msg) + ".", who);

change_plan

Spec this none thisFlags rxdOwner #361Definer #155

Referenced by

Source

1if (task_valid(this.plan_task))
2this:btell(("I'm giving up my " + this.plan_msg) + " plan.");
3kill_task(this.plan_task);
4this.plan_task = 0;
5endif
6if (newplan = args[1])
7this:btell(((("New plan - " + newplan) + " (") + $su:from_value(args[2..$], 1, 5)) + ")");
8fork task_id (0)
9try
10this:(newplan)(@args[2..$]);
11this.plan_task = 0;
12this.plan = "";
13except e (ANY)
14$rpg:report_error(e);
15endtry
16endfork
17this.plan_task = task_id;
18this.plan = newplan;
19endif

btell

Spec this none thisFlags rxdOwner #361Definer #155

Referenced by

Source

1for x in (this.brainlisteners)
2x:tell($ansi.cyan, $ansi.bold_on, $su:nn(this), ": ", @args, $ansi.reset);
3endfor

_wander

Spec this none thisFlags rxdOwner #361Definer #155

Referenced by

Source

1if (r = pass(@args))
2this:btell("hmm, i think i'll wander ", r[4]);
3endif
4return r;

p_defend

Spec this none thisFlags rxdOwner #361Definer #155

Referenced by

none

Source

1who = args[1];
2this:btell("I've got to defend ", who.name, "!");
3this.pwait = 1;
4if (who.location != this.location)
5if (!this:p_walkto(who, 1, "to defend " + who.name, 1))
6this:btell("So much for defending ", who.name, ".");
7return this.pwait = 0;
8endif
9endif
10while ((foes = who.fighting) && (who.location == this.location))
11foe = foes[1];
12this:btell(foe.name, " is fighting ", who.name, ", and must therefore DIE.");
13this:start_fighting(foe);
14suspend(1);
15while ((foe.location == this.location) && (foe in who.fighting))
16if (!(foe in this.fighting))
17this:start_fighting(foe);
18endif
19suspend(5);
20endwhile
21if (who.location != this.location)
22this:btell("damn, ", who.name, " is gone!");
23this.pwait = 0;
24return 0;
25endif
26endwhile
27this.pwait = 0;
28if (who:is_in_afterlife())
29this:btell("shit! ", who.name, " died and we couldn't save ", who.po, ".");
30this:say("Why, God?  WHY?");
31return 0;
32else
33this:btell("we saved ", who.name, "!");
34this:say("You okay?", who);
35this.last_converse_time = 0;
36this.pwait = 0;
37return 1;
38endif

next_plan

Spec this none thisFlags rxdOwner #361Definer #155

Referenced by

Source

1"Return the next plan to be executed on a heartbeat, if we don't already have one.";
2return 0;

page_send

Spec this none thisFlags rxdOwner #361Definer #155

Referenced by

none

Source

1who = args[1];
2msg = args[2];
3fork (1)
4who:_receive(this, msg);
5endfork

p_resthome

Spec this none thisFlags rxdOwner #361Definer #155

Referenced by

none

Source

1if (this:p_walkto(this.home, 3, "to rest", 0))
2this:plan_action($actions.recline, {this.location}, 1, "");
3endif