: say ( s -- ) me @ swap notify ; : usage ( s -- ) "+--------------------------------------------------------+" say "Usage: " trigger @ name strcat " " strcat "" trigger @ "_noarg" getpropstr if "[" swap strcat "]" strcat then strcat "| " swap strcat dup strlen " " swap strcut swap pop strcat "|" strcat say "+-----------------------------+--------------------------+" say "| _[-{name|sex}]: | msg sent to doer |" say "| _v[-{name|sex}]: | msg sent to victim |" say "| _o[-{name|sex}]: | msg sent to all others |" say "+--------+---+----------------+--------------------------+" say "| | substitute the name of the specific action |" say "| {name} | substitute specific name for custom reply |" say "| {sex} | substitute specific gender for custom reply |" say "| [....] | any item within [] is an optional parameter |" say "+--------+-------------------------------+---------------+" say "| _a[-{name|sex}]:<[act1]..[actX]> | reply actions |" say "+------------------+---------------------+---------------+" say "| <[act1]..[actX]> | substitute a sequence of actions to |" say "| | be executed, each to be enclosed in |" say "| | brackets with no spaces in between |" say "+------------------+-------------------------------------+" say "| Above are used when player is the victim of an action. |" say "+--------------------------------------------------------+" say ; : pointer ( -- d ) dup "_atmosptr" getpropstr dup not if pop exit then swap pop dup "#" 1 strncmp not if 1 strcut swap pop then atoi dbref ; : not_found ( -- ) trigger @ name "> Name not found." strcat say ; : not_local ( -- ) trigger @ name "> Player not present." strcat say ; : format ( s -- s ) trigger @ name "%t" subst over name "%v" subst me @ name "%d" subst ; : get_reply ( s s -- s ) dup trigger @ name strcat "-" strcat me @ name strcat 4 pick pointer swap getpropstr dup if " " swap strcat swap pop strcat me @ swap pronoun_sub exit then pop dup trigger @ name strcat "-" strcat me @ "sex" getpropstr strcat 4 pick pointer swap getpropstr dup if " " swap strcat swap pop strcat me @ swap pronoun_sub exit then pop dup trigger @ name strcat 4 pick pointer swap getpropstr dup if " " swap strcat swap pop strcat me @ swap pronoun_sub exit then pop dup "default" strcat trigger @ swap getpropstr dup if " " swap strcat swap pop strcat over swap pronoun_sub over name "%v" subst me @ name "%d" subst exit then pop pop ; : do_noarg ( -- ) trigger @ "_noarg" getpropstr me @ swap pronoun_sub trigger @ name "%t" subst say trigger @ "_onoarg" getpropstr me @ name "%d" subst me @ swap pronoun_sub trigger @ name "%t" subst loc @ me @ rot notify_except ; : parse_forced_reply ( d s -- ) dup "[" 1 strncmp not if 1 strcut swap pop dup strlen 1 - strcut pop "][" explode else 1 strcut swap explode then begin dup while over dup dup "@" 1 strncmp not swap 1 strcut swap pop dup " " instr if dup " " instr 1 - strcut pop then number? and if dup " " instr if dup " " instr 1 - strcut 1 strcut swap pop swap atoi dbref call else "" swap atoi dbref call then swap pop 1 - else pop swap over 2 + pick name "%v" subst me @ name "%d" subst me @ swap pronoun_sub over 2 + pick swap force 1 - then loop ; : forced_reply ( -- ) dup pointer "_a" trigger @ name strcat "-" strcat me @ name strcat getpropstr dup if parse_forced_reply exit then pop dup pointer "_a" trigger @ name strcat "-" strcat me @ "sex" getpropstr strcat getpropstr dup if parse_forced_reply exit then pop dup pointer "_a" trigger @ name strcat getpropstr dup if parse_forced_reply exit then ; : gag_action ( d -- ) dup pointer "_gag" trigger @ name strcat "-" strcat me @ name strcat getpropstr dup if parse_forced_reply exit then pop dup pointer "_gag" trigger @ name strcat "-" strcat me @ "sex" getpropstr strcat getpropstr dup if parse_forced_reply exit then pop dup pointer "_gag" trigger @ name strcat getpropstr dup if parse_forced_reply exit then pop me @ trigger @ name "> You can't do that!" strcat notify ; : main ( s -- ) dup 2 strcut pop "-h" stringcmp not if usage exit then dup not trigger @ "_noarg" getpropstr not and if usage exit then dup not if trigger @ "_noarg" getpropstr if pop do_noarg exit else pop not_found exit then then dup match dup dup dup #-1 dbcmp not rot #-2 dbcmp not rot #-3 dbcmp not and and if swap pop else pop .pmatch+ then dup #-1 dbcmp trigger @ "_noarg" getpropstr not and if pop not_found exit then dup location me @ location dbcmp not if pop not_local exit then dup pointer "_gag" trigger @ name strcat getpropstr over pointer "_gag" trigger @ name strcat "-" strcat me @ "sex" getpropstr strcat getpropstr 3 pick pointer "_gag" trigger @ name strcat "-" strcat me @ name strcat getpropstr 4 pick pointer "_gagall" getpropstr or or or if gag_action pop exit then trigger @ "_format" getpropstr dup not if pop "You %t %v!" then format over swap pronoun_sub "_" get_reply say trigger @ "_vformat" getpropstr dup not if pop "%d %ts you!" then format me @ swap pronoun_sub "_v" get_reply over swap notify trigger @ "_oformat" getpropstr dup not if pop "%d %ts %v!" then format me @ swap pronoun_sub "_o" get_reply me @ 3 pick rot loc @ -4 rotate .notify_except2 forced_reply trigger @ "_endrun" getpropstr dup if atoi dbref dup call pop else pop then pop ;