Generic Action #93
Aliases: Generic Action, action
8 verbs · 19 properties · 11 children
Verbs
| Verb | Spec | Flags | Definer | Lines |
|---|---|---|---|---|
_start | this none this | rxd | #93 | 8 |
_finish | this none this | rxd | #93 | 8 |
doing_msg | this none this | rxd | #93 | 16 |
duration | this none this | rxd | #93 | 1 |
_abort | this none this | rxd | #93 | 6 |
_forbidden | this none this | rxd | #93 | 3 |
unstoppable | this none this | rxd | #93 | 1 |
is_being_done_by | this none this | rxd | #93 | 6 |
Properties
| Property | Definer | Flags | Owner | Value |
|---|---|---|---|---|
help_msg | #93 | rc | #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 | #93 | rc | #361 | 0.0 |
preemptible | #93 | rc | #361 | 0 |
unstoppable | #93 | rc | #361 | 0 |
dodge_mod | #93 | rc | #361 | 0 |
doing_msg | #93 | rc | #361 | "%ting" |
doing_to_msg | #93 | rc | #361 | "%ting %il" |
oabort_msg | #93 | rc | #361 | "" |
can_parry | #93 | rc | #361 | 1 |
aliases | #1 | rc | #361 | {"Generic Action", "action"} |
description | #1 | rc | #361 | <clear> |
object_size | #1 | r | #29 | {8251, 1298433815} |
hidden_verbs | #1 | rc | #361 | <clear> |
phelp_msg | #1 | rc | #361 | <clear> |
weight | #1 | rc | #361 | <clear> |
owner_verbs | #1 | rc | #361 | <clear> |
plural_name | #1 | rc | #361 | <clear> |
client_image | #1 | rc | #361 | <clear> |
listening | #1 | rc | #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
Source
_start
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
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
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
Referenced by
- #93:_start line 8:
this:duration - #182:_start line 6:
this:duration - #184:_start line 84:
this:duration - #224:_start line 1:
this:duration - #270:_start line 82:
this:duration
Source
1return this.duration;
_abort
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
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
Referenced by
none
Source
1return this.(verb);
is_being_done_by
Referenced by
none
Source
1who = args[1]; 2if (who.executing) 3if (who.executing[1] == this) 4return 1; 5endif 6endif