Generic Action #93

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

Aliases: Generic Action, action

8 verbs · 19 properties · 11 children

Verbs

VerbSpecFlagsDefinerLines
_startthis none thisrxd#938
_finishthis none thisrxd#938
doing_msgthis none thisrxd#9316
durationthis none thisrxd#931
_abortthis none thisrxd#936
_forbiddenthis none thisrxd#933
unstoppablethis none thisrxd#931
is_being_done_bythis none thisrxd#936

Properties

PropertyDefinerFlagsOwnerValue
help_msg#93rc#361
list of 33{"Actions are objects that represent something a player can do in the game. Almost everything that happens in the game is tied to an action: shooting a gun, standing up, picking something up, etc. The most important characteristic of actions is that they all take time to perform. When a player tries to do something when he is already performing some other action, the actions get added to the player's action queue. This queue keeps track of all the things the player has told the command parser that she wants to do. When one action is finished, the system pulls the next action off the queue and begins executing it. When the queue is empty and the last action has finished, the player returns to an idle state.", "So, to make actions actually happen, they need to be placed on the player's action queue. Placing an action on the queue might result in the action happening immediately (if the player isn't doing anything) or they might have to wait for other events in the queue to finish before it can begin.", "Since actions have a duration, there are two phases to every action: a start phase and a finish phase. When an action begins, it calls its :_start verb which can contain any hooks necessary to do things like print messages to the player or the room, or in general make preparations for whatever is about to happen. Once the event's duration has passed, it calls its :_finish verb, which can also be used to print messages, and do any other cleanup necessary now that the action has completed.", "Since the action's :_start and :_finish verbs are being called back long after the player's initial request, we need to keep track of the context for the requested actions so that we can reconstruct what is really going on when it is time for the action to start and finish. This is done via the callback arguments parameter that's sent to $actor:queue_action. Depending on how complicated the action is, you might need to stuff all sorts of data in this list. Most commonly you will need to include the object that the player is using to perform the action, and possibly a target for the action. So, if the player was shooting a gun at someone, you would need to keep send both the gun object, which is what is being used to perform the action, and the person the player is shooting at, the target of the shooting action. In your code, it might look like this:", "", "\"shoot any with this\";", "target = dobj;", "device = this;", "player:queue_action($actions.shoot, {device, target}, 1, (verb + \" \" + argstr));", "", "From here, it is up to $actions.shoot:_start and $actions.shoot:_finish to actually carry out the shooting action. Those verbs might look something like this:", "", "\"$actions.shoot:_start(OBJ device, {OBJ target})\";", "player.location:announce(player:title() + \" aims his \" + device:title() + \" at \" + target:title() + \".\");", "\"return the action's duration (5 seconds) and any extra info for :_finish\";", "return {5.0, 0};", "", "\"$actions.shoot:_finish(OBJ device, {OBJ target})\";", "player:tell(\"You shoot your \" + device:title() + \" at \" + target:title() + \".\");", "player.location:announce(player:title() + \" shoots his \" + device:title() + \" at \" + target:title() + \".\");", "\"more code which actually handles whether player hit, etc\";", "\"return E_NONE so we don't :_continue\";", "return E_NONE;", "", "Action Permissions", "When you queue an action, there is a chance that the action won't be allowed by some other object in the room. This negotiation is handled by the event system.", "", "Action Continuation", "Your :_finish method can optionally indicate to the action system that we want this action to continue. If we return an action list from _finish...", "", " return {this, {target}};", "", "..the actor's next action will be to call :_continue() instead of :_start(), on the action given (generally, this)."}
duration#93rc#3610.0
preemptible#93rc#3610
unstoppable#93rc#3610
dodge_mod#93rc#3610
doing_msg#93rc#361"%ting"
doing_to_msg#93rc#361"%ting %il"
oabort_msg#93rc#361""
can_parry#93rc#3611
aliases#1rc#361{"Generic Action", "action"}
description#1rc#361<clear>
object_size#1r#29{8251, 1298433815}
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): #1 root

Children: #162 social, #164 fight, #180 sysmon, #182 sit, #184 get, #222 attack, #224 stand, #270 drop, #350 eat, #359 move, #364 arrive

Call graph

calls n93_0 #93:_start n20_59 #20:name_and_number n93_0->n20_59 n93_3 #93:duration n93_0->n93_3 n93_1 #93:_finish n93_1->n20_59 n93_2 #93:doing_msg n93_2->n20_59 n20_34 #20:pronoun_sub n93_2->n20_34 n103_24 #103:report_error n93_2->n103_24 n93_4 #93:_abort n93_4->n20_34

Source

_start

Spec this none thisFlags rxdOwner #361Definer #93

Referenced by

none

Source

1who = args[1];
2if (length(args[2]) > 0)
3dobj = args[2][1];
4who:announce_action_text(who.name, " starts ", this.name, "ing ", $su:nn(dobj), ".");
5else
6who:announce_action_text(who.name, " starts ", this.name, "ing.");
7endif
8return {this:duration(), 0};

_finish

Spec this none thisFlags rxdOwner #361Definer #93

Referenced by

none

Source

1who = args[1];
2start_result = args[3];
3if (args[2])
4dobj = args[2][1];
5who:announce_action_text(who.name, " finishes ", this.name, "ing ", $su:nn(dobj), ".");
6else
7who:announce_action_text(who.name, " finishes ", this.name, "ing.");
8endif

doing_msg

Spec this none thisFlags rxdOwner #361Definer #93

Referenced by

none

Source

1{who, actionargs} = args;
2if (actionargs)
3if (length(actionargs) > 3)
4actionargs = actionargs[1..3];
5endif
6try
7return $su:ps(this.doing_to_msg, who, this, @actionargs);
8except e (ANY)
9if (e[1] != E_NONE)
10extra_info = tostr($su:nn(who), " doing ", $su:nn(this), " args: ", toliteral(actionargs));
11$rpg:report_error(e, extra_info);
12endif
13endtry
14else
15return $su:ps(this.doing_msg, who, this);
16endif

duration

Spec this none thisFlags rxdOwner #361Definer #93

Referenced by

Source

1return this.duration;

_abort

Spec this none thisFlags rxdOwner #361Definer #93

Referenced by

none

Source

1who = args[1];
2who:tell($ansi.cyan, "[ Stopped ", this.name, ". ]", $ansi.reset);
3if (m = this.oabort_msg)
4who:aat($su:ps(m, who));
5endif
6return;

_forbidden

Spec this none thisFlags rxdOwner #361Definer #93

Referenced by

none

Source

1":_forbidden(OBJ source, @action-spec)";
2"We tried to execute, but were forbidden by the room.";
3"Do any necessary clean-up.";

unstoppable

Spec this none thisFlags rxdOwner #361Definer #93

Referenced by

none

Source

1return this.(verb);

is_being_done_by

Spec this none thisFlags rxdOwner #361Definer #93

Referenced by

none

Source

1who = args[1];
2if (who.executing)
3if (who.executing[1] == this)
4return 1;
5endif
6endif