home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Special: Spiele Hits
/
Hits-CD.iso
/
aminet
/
spiele
/
ammud1_1.lha
/
AmigaMUD
/
Src
/
Basics
/
chat.m
< prev
next >
Wrap
Text File
|
1997-06-10
|
21KB
|
908 lines
/*
* Amiga MUD
*
* Copyright (c) 1997 by Chris Gray
*/
/*
* chat.m - add a simple chat mode.
*/
private tp_chat CreateTable()$
use tp_chat
define tp_chat ChatThing CreateThing(nil)$
define tp_chat p_chNoiseAdverbs CreateStringProp()$
define tp_chat p_chActionAdverbs CreateStringProp()$
ChatThing@p_chNoiseAdverbs := ""$
ChatThing@p_chActionAdverbs := ""$
define tp_chat p_pSaveAction CreateActionProp()$
define tp_chat p_pSavePrompt CreateStringProp()$
define tp_chat p_pChatting CreateBoolProp()$
define tp_chat p_pChatAliases CreateThingListProp()$
define tp_chat p_chKey CreateStringProp()$
define tp_chat p_chContents CreateStringProp()$
define tp_chat proc chatReset()void:
thing me;
me := Me();
ignore SetPrompt(me@p_pSavePrompt);
me -- p_pSavePrompt;
ignore SetCharacterInputAction(me@p_pSaveAction);
me -- p_pSaveAction;
me -- p_pChatting;
DelElement(me@p_pEnterActions, chatReset);
DelElement(me@p_pExitActions, chatReset);
corp;
define tp_chat proc chatHandler(string line)void:
thing me, alias;
list thing aliases;
int count;
string word, contents;
bool found;
me := Me();
if line = "." or line = "$" then
chatReset();
elif SubString(line, 0, 1) = "!" then
call(me@p_pSaveAction, void)(SubString(line, 1, Length(line) - 1));
else
aliases := me@p_pChatAliases;
SetTail(line);
word := GetWord();
if word == "alias" then
word := GetWord();
if word = "" then
if aliases = nil then
Print("You have no chat aliases.\n");
else
count := Count(aliases);
Print("Chat aliases:\n");
while count ~= 0 do
count := count - 1;
alias := aliases[count];
Print(" ");
Print(alias@p_chKey);
Print(" => ");
Print(alias@p_chContents);
Print("\n");
od;
fi;
else
Print("Chat alias '");
Print(word);
Print("' ");
found := false;
if aliases ~= nil then
count := Count(aliases);
while count ~= 0 and not found do
count := count - 1;
alias := aliases[count];
if alias@p_chKey == word then
found := true;
fi;
od;
fi;
contents := GetTail();
if contents = "" then
if found then
DelElement(aliases, alias);
Print("removed.\n");
else
Print("does not exist.\n");
fi;
else
if SubString(contents, 0, 1) = "\"" then
contents := SubString(contents, 1, Length(contents)-2);
fi;
if found then
alias@p_chContents := contents;
Print("updated.\n");
else
if aliases = nil then
aliases := CreateThingList();
me@p_pChatAliases := aliases;
fi;
alias := CreateThing(nil);
alias@p_chKey := word;
alias@p_chContents := contents;
AddTail(aliases, alias);
Print("added.\n");
fi;
fi;
fi;
else
alias := nil;
if aliases ~= nil then
count := Count(aliases);
while count ~= 0 and not found do
count := count - 1;
alias := aliases[count];
if alias@p_chKey == word then
found := true;
fi;
od;
fi;
if found then
DoSay(alias@p_chContents + " " + GetTail());
else
DoSay(line);
fi;
fi;
fi;
corp;
define tp_chat proc v_chat()bool:
thing me;
action oldAction;
string tail;
me := Me();
if me@p_pChatting then
Print("You are already in chat mode!\n");
false
else
tail := GetTail();
if tail = "" then
oldAction := SetCharacterInputAction(chatHandler);
if oldAction = nil then
OPrint(Capitalize(CharacterNameS(me)) + " is confused.\n");
false
else
me@p_pChatting := true;
me@p_pSaveAction := oldAction;
me@p_pSavePrompt := SetPrompt("chat> ");
AddHead(me@p_pEnterActions, chatReset);
AddHead(me@p_pExitActions, chatReset);
true
fi
else
chatHandler(tail);
true
fi
fi
corp;
VerbTail(G, "c", v_chat)$
Synonym(G, "c", "chat")$
define tp_chat proc v_whisper()bool:
string what, ch, agentName;
character who;
thing agent;
what := GetWord();
if what == "to" then
what := GetWord();
fi;
if what = "" then
Print("Specify who you want to whisper to.\n");
false
else
ch := SubString(what, Length(what) - 1, 1);
if ch = "," or ch = ":" then
what := SubString(what, 0, Length(what) - 1);
fi;
who := Character(what);
if who = nil then
who := Character(Capitalize(what));
fi;
if who = nil then
agent := FindAgent(what);
else
agent := CharacterThing(who);
fi;
if agent = nil then
Print("You can't whisper to " + what + ".\n");
false
elif agent = Me() then
Print("You can't whisper to yourself!\n");
false
else
what := GetTail();
agentName := CharacterNameS(agent);
if what = "" then
Print("Specify what you want to whisper to " +
agentName + ".\n");
false
else
if Me()@p_pEchoPose then
Print("You whisper to " + agentName + ": " +
what + "\n");
fi;
note - Magic value of 10 is probability of being overheard;
if Whisper("", what, agent, 10) then
true
else
Print(agentName + " is not here!\n");
false
fi
fi
fi
fi
corp;
VerbTail(G, "wh", v_whisper)$
Synonym(G, "wh", "whisper")$
define tp_chat proc v_pose()bool:
thing me;
string activity;
me := Me();
activity := GetTail();
if activity = "" then
Print("You must give the pose/emote you want to do.\n");
false
elif not CanSee(Here(), me) then
Print("It is dark - no-one could see you " + activity + "!\n");
false
elif me@p_pHidden then
Print("You are hidden - no-one could see you " + activity + "!\n");
false
else
if GlobalThing@p_FreePoses then
Pose("", activity);
if me@p_pEchoPose then
Print("You " + activity + ".\n");
fi;
else
Pose("", "=> " + activity);
if me@p_pEchoPose then
Print("You => " + activity + ".\n");
fi;
fi;
true
fi
corp;
VerbTail(G, "pose", v_pose)$
Synonym(G, "pose", "emote")$
Synonym(G, "pose", ":")$
define tp_chat proc v_emit()bool:
thing me, here;
string message;
me := Me();
message := GetTail();
if message = "" then
Print("You must give the emit you want to do.\n");
Print(" E.g. .It is very quiet here.\n");
false
else
here := Here();
if GlobalThing@p_FreePoses then
ABPrint(here, nil, nil, message + "\n");
else
ABPrint(here, nil, nil,
"[" + CharacterNameG(me) + "] " + message + "\n");
fi;
true
fi
corp;
VerbTail(G, "emit", v_emit)$
Synonym(G, "emit", ".")$
define tp_chat proc actionAdverb(string s)void:
ChatThing@p_chActionAdverbs := ChatThing@p_chActionAdverbs + s;
corp;
actionAdverb("aimlessly,aimless,aim.")$
actionAdverb("awkwardly,awkward,awk.")$
actionAdverb("briefly,brief.")$
actionAdverb("briskly,brisk.")$
actionAdverb("clumsily,clumsy,clu.")$
actionAdverb("crazily,crazy,cra.")$
actionAdverb("deeply,deep.")$
actionAdverb("enthusiastically,enthusiastic,enthuse,ent.")$
actionAdverb("exitedly,excited,exc,e.")$
actionAdverb("fervently,fervent,fer.")$
actionAdverb("firmly,firm.")$
actionAdverb("frentically,frentic,fren,fre.")$
actionAdverb("furiously,furious,fur.")$
actionAdverb("gayly,gay.")$
actionAdverb("gracefully,gracefull,gra.")$
actionAdverb("happily,happy,h.")$
actionAdverb("hesitantly,hesitant,hes.")$
actionAdverb("hurriedly,hurry,hur.")$
actionAdverb("impatiently,impatient,imp.")$
actionAdverb("majestically,majestic,maj.")$
actionAdverb("merrily,merry,mer.")$
actionAdverb("mischievously,mischievous,mis.")$
actionAdverb("mockingly,mocking,mock.")$
actionAdverb("mysteriously,mysterious,mys.")$
actionAdverb("nastily,nasty,nas.")$
actionAdverb("naughtily,naughty,nau.")$
actionAdverb("passionately,passionate,pas.")$
actionAdverb("patiently,patient,pat.")$
actionAdverb("playfully,playfull,pla.")$
actionAdverb("pointedly,pointed,poi.")$
actionAdverb("politely,polite,pol.")$
actionAdverb("quickly,quick,qui,q,f.")$
actionAdverb("rapidly,rapid,rap.")$
actionAdverb("sadly,sad.")$
actionAdverb("sharply,sharp,sha.")$
actionAdverb("slowly,slow,slo,s.")$
actionAdverb("smoothly,smooth,smo.")$
actionAdverb("solemnly,solemn,sol.")$
actionAdverb("suddenly,sudden,sud.")$
actionAdverb("suggestively,suggest,sug.")$
actionAdverb("swiftly,swift,swi.")$
actionAdver