Chats

From LSWiki

(Difference between revisions)
Jump to: navigation, search
Revision as of 10:16, 20 January 2007 (edit)
Msb (Talk | contribs)

← Previous diff
Revision as of 10:20, 20 January 2007 (edit)
Msb (Talk | contribs)
(Closures in Chats)
Next diff →
Line 13: Line 13:
==Closures in Chats== ==Closures in Chats==
-There are any number of reasons to use [[closures]] in chats. The simplest case is that you want a correct message of the [[autonomon]] in question interacting with an object. For example, the fishermen in Hanoma perform various actions directed at their fishing rods.+There are any number of reasons to use [[closures]] in chats. The simplest case is that you want a correct message of the [[autonomon]] in question interacting with an object. For example, the fishermen in Hanoma perform various actions directed at their fishing rods. So I map this fish_command function to an [[add_action]] and have them call it in their chat cycle:
<pre>status fish_command() { <pre>status fish_command() {
Line 25: Line 25:
return True; return True;
} }
- int i = random(10);+ int i = random(4);
switch(i) { switch(i) {
case 0 : message(({ 0, ({ "check", 0 }), "the line on", ({ 'r', 0, rod }) })); break; case 0 : message(({ 0, ({ "check", 0 }), "the line on", ({ 'r', 0, rod }) })); break;
Line 36: Line 36:
}</pre> }</pre>
-More complex cases can include varying the response depending on conditions.+You can also see that you can something like the above to handle more complex cases, in this case where they are. If they are on a dock in Hanoma, they will attempt to fish, otherwise they will maintain their rod in one of four ways.
- +
-Example...+

Revision as of 10:20, 20 January 2007

Chat Variables

Here are some escape characters you can use in chats and combat chats.

  • %e, enemy
  • %f, friend
  • %s, source (on chat responses)
  • %p, person, prefers players but will choose an NPC if one isn't around
  • %s, source, i.e. the thing that initiates a response for responses
  • %b, bystander, like someone not involved in combat
  • %h, someone hiding, i.e. someone attacking you other than the person you're attacking

Closures in Chats

There are any number of reasons to use closures in chats. The simplest case is that you want a correct message of the autonomon in question interacting with an object. For example, the fishermen in Hanoma perform various actions directed at their fishing rods. So I map this fish_command function to an add_action and have them call it in their chat cycle:

status fish_command() {
    if(query_attacker() || query_incapacitated())
        return True;
    object rod = locate_name("fishing rod");
    unless(rod)
        return True;
    if(environment(this_object())->query_realm("Hanoma_Dock")) {
        message(({ 0, "expertly", ({ "cast", 0 }), "a line from", ({ 'r', 0, rod }), "off the dock and into the bay" }));
        return True;
    }
    int i = random(4);
    switch(i) {
        case 0  : message(({ 0, ({ "check", 0 }), "the line on", ({ 'r', 0, rod }) })); break;
        case 1  : message(({ 0, "carefully", ({ "examine", 0 }), ({ 'r', 0, rod }) })); break;
        case 2  : message(({ 0, ({ "adjust", 0 }), "the taughtness of the line on", ({ 'r', 0, rod }) })); break;
        case 3  : message(({ 0, ({ "tighten", 0 }), "the knot holding the hook on", ({ 'r', 0, rod }) })); break;
        default : 0; break;
    };
    return True;
}

You can also see that you can something like the above to handle more complex cases, in this case where they are. If they are on a dock in Hanoma, they will attempt to fish, otherwise they will maintain their rod in one of four ways.

Personal tools