!===========================================================================! ! This is an EXTREMELY UNOFFICIAL pre-beta release of GNPCmess.h, the ! ! default English -> NPC message conversion library for use with GNPC.h, ! ! GLYPH's NPC library. ! ! ! ! DO NOT use this version in your own game, because the official release ! ! *will* be different, and almost definitely incompatible with this one! ! ! This is only being released for L.P. Smith's FEAMTOIF mini-comp. ! ! ! ! Feel free to peruse the code and e-mail me any suggestions / requests, ! ! but if you're going to use it in a game, do yourself a favor and wait ! ! for the official release! ! ! ! ! - GLYPH ! !===========================================================================! Constant er = '*//'; Constant query = '?q?'; Global bestmesslen; Array NPCparse -> 65; [ NPCmess o i; NPCmess_s = 0; NPCmess_a = 0; NPCmess_b = 0; NPCmess_c = 0; bestmesslen = 0; for (i = 1 : i <= (parse->1)+1 : i++) NPCparse->i = 0; objectloop(o ofclass messclass && ~~parent(o)) NPCmessloop(o,0,1,verb_wordnum); if (bestmesslen > 0) rtrue; rfalse; ]; [ NPCmessloop o clen r ws m c d n t i w s l wh j; l = 0; n = 0; wh = 0; c = 0; d = 1; m = o.&mustnot; t = (o.#mustnot)/2; i = 0; while (i < t && d == 1) { wn = ws; s = m-->i; w = NextWordStopped(); while (NPCparse->wn == 1) w = NextWordStopped(); while (w ~= -1) { if (w == s) { d = 0; break; } w = NextWordStopped(); while (NPCparse->wn ~= 0) w = NextWordStopped(); } i++; } if (d == 0) return; m = o.&must; t = (o.#must)/2; ! clear flags of siblings, nieces and nephews for (i = 1 : i <= (parse->1)+1 : i++) if (NPCparse->i >= r) NPCparse->i = 0; i = 0; #ifdef DEBUG; if (parser_trace >= 1) { print "^";spaces(r); } #endif; wn = ws; while (i < t) { ! test for query (extra case) if ((m-->i) == query && i < t) { j = o.mess_query(); if (~~j) { d = 0; break; } i++; l = l + j; } if (i >= t) continue; wn = ws; s = m-->i; #ifdef DEBUG; if (parser_trace >= 1) print (address)s," "; #endif; c = 0; w = NextWordStopped(); while (NPCparse->wn == 1) w = NextWordStopped(); while (w ~= -1) { if (w == s) { c = 1; break; } w = NextWordStopped(); while (NPCparse->wn ~= 0) w = NextWordStopped(); } i++; if (c == 0) { if (i < t) { if ((m-->i) == er) i++; ! skip to the next synonym else { d = 0; break; } ! a MUST word is missing, so screw it! } else { d = 0; break; } ! a MUST word is missing, so screw it! } if (c == 1) ! MATCH -> skip remaining synonyms & test for query { ! clear word from sentence NPCparse->wn = r; wh = wn; l++; while ((m-->i) == er && i < t-1) i = i + 2; ! test for query if ((m-->i) == query && i < t) { j = o.mess_query(); if (~~j) { d = 0; break; } i++; l = l + j; } } } if (d == 0) return; ! All MUST words were found #ifdef DEBUG; if (parser_trace >= 1) print " (",l,"/",l+clen,")"; #endif; ! Call children, if any: if (child(o)) objectloop(i in o) { if (i.crop) NPCmessloop(i,l+clen,r+1,wh); else NPCmessloop(i,l+clen,r+1,ws); } if (l+clen >= bestmesslen) { bestmesslen = l+clen; NPCmess_s = 0; NPCmess_a = 0; NPCmess_b = 0; NPCmess_c = 0; o.mess_match(); } ]; [ SayInsteadSub; style bold; print "To talk to someone, try ~someone, something~^"; style roman; rtrue; ]; [ AskInsteadSub; style bold; print "To ask someone a question, try ~someone, question~^"; print "Remember to NOT use a question mark.^"; style roman; rtrue; ]; Extend "answer" replace * ConTopic -> SayInstead; Extend "tell" replace * ConTopic -> SayInstead; Extend "ask" replace * ConTopic -> AskInstead; Class messPronoun; messPronoun NPCit with name 'it' 'that' 'they' 'them' 'those' 'this' 'these', DoPronoun [o; if (actor.NPCitobj) return actor.NPCitobj; objectloop(o ~= actor && o ~= player) if (ObjectSees(actor,o)) return o; return 0; ]; messPronoun NPChim with name 'he' 'him' 'himself', DoPronoun [o; if (actor.NPChimobj) return actor.NPChimobj; objectloop(o hasnt female && o ~= actor && o has animate && o ~= player) if (ObjectSees(actor,o)) return o; return 0; ]; messPronoun NPCher with name 'she' 'her' 'herself', DoPronoun [o; if (actor.NPCherobj) return actor.NPCherobj; objectloop(o has female && o ~= actor && o has animate && o ~= player) if (ObjectSees(actor,o)) return o; return 0; ]; messPronoun NPCthat with name 'that' 'they' 'them' 'those' 'this' 'these', DoPronoun [o; if (actor.NPCthatobj) return actor.NPCthatobj; objectloop(o ~= actor && o ~= player) if (ObjectSees(actor,o)) return o; return 0; ]; messPronoun NPCyou with name 'you' 'ya' 'yourself', DoPronoun [; return actor; ]; messPronoun NPCme with name 'me' 'myself' 'I//', DoPronoun [; return player; ]; Class messclass with must, mustnot, mess_match [;], mess_q, crop 0, mess_query [o; o = objquery(); ! do pronouns if (o ofclass messPronoun) o = o.DoPronoun(); self.mess_q = o; if (o) return match_length; ]; [ objquery t b i o n; t = wn; while (NextWordStopped() == 'a//' or 'an' or 'the') t = wn; objectloop(o) { wn = t; match_bonus = 0; match_length = 0; n = TryGivenObject(o); n = n + match_bonus; if (n > b) { b = n; i = o; } } match_length = b; return i; ]; ! NPCmessages ! ----------- ! o,s,a,b,c -> generic form: o is ALWAYS the object sending the message ! ! o,actor,action,noun,second -> o asks actor to do action,noun,second ! o,action,noun,second,? -> o just did action,noun,second ! ! o,s,##NotUnderStood,?,? -> player's command not understood ! ! o,s,0,0,0 -> null message code ! ! o,s,<0,b,c -> reserved: ! -1,b,? -> o does not understand b ! -2,b,? -> o greets b ! -3,b,? -> o confirms / agrees with / understands b ! -4,b,? -> o says no to b ! -5,b,? -> o thanks b ! -6,b,c -> o asks b who/what c is/was ! -7,b,c -> o asks b what c did ! -8,b,c -> o asks b what c does ! -9,b,c -> o asks b about c (generic) ! -10,b,c -> o asks b to find c ! -11,b,c -> o asks b what c is doing here ! -12,b,? -> o asks b to shut up ! -13,b,c -> o asks b how c is doing / feeling / going ! -14,b,? -> o says goodbye to b ! -15,b,? -> o laughs at b ! -16,b,? -> o says doh to b ! -17,b,? -> o is iffy with b ! -18,b,? -> o confirms / asks b for confirmation ! -19,b,c -> o asks b why c did that ! -20,b,? -> o asks b for help ! -21,b,? -> o asks b what o should ask b ! -22,b,? -> o is amazed at b ! -23,b,c -> o asks b where c is ! -24,b,c -> o asks b where b got c ! -25,b,? -> o asks b what b's name is ! -26,b,c -> o asks b if b wants c ! -27,b,c -> o asks b what c has ! -28,b,c -> o asks b if b is c ! ! o,s,>0,b,c -> user messages ! ! the WHATs messclass with must 'what' er 'what^s', mess_match [; NPCmess_a = -1; NPCmess_b = actor; ]; messclass -> with must 'does' er 'do' er 'have' query 'got' er 'have', mess_match [; NPCmess_a = -27; NPCmess_b = actor; NPCmess_c = self.mess_q; ]; messclass -> with must 'did' query 'do', mess_match [; NPCmess_a = -7; NPCmess_b = actor; NPCmess_c = self.mess_q; ]; messclass -> with must 'does' er 'do' query 'do', mess_match [; NPCmess_a = -8; NPCmess_b = actor; NPCmess_c = self.mess_q; ]; messclass -> with must 'was' er 'is' er 'are' er 'am', mess_match [; NPCmess_a = -1; NPCmess_b = actor; ]; messclass -> -> with must query 'for' er 'about', mess_match [; NPCmess_a = -9; NPCmess_b = actor; NPCmess_c = self.mess_q; ]; messclass -> -> with must 'your' 'name', mess_match [; NPCmess_a = -25; NPCmess_b = actor; ]; messclass -> with must 'about' er 'concerning' query, mess_match [; NPCmess_a = -9; NPCmess_b = actor; NPCmess_c = self.mess_q; ]; messclass -> with must 'now', mess_match [; NPCmess_a = -20; NPCmess_b = actor; ]; messclass -> with must 'I//' 'ask' 'you', mess_match [; NPCmess_a = -21; NPCmess_b = actor; ]; ! the WHO/WHATs messclass with must 'who' er 'who^s' er 'what' er 'what^s', mess_match [; NPCmess_a = -1; NPCmess_b = actor; ]; messclass -> with must 'was' er 'is' er 'are' er 'am' query, mess_match [; NPCmess_a = -6; NPCmess_b = actor; NPCmess_c = self.mess_q; ]; messclass -> with must 'I//' er 'is' 'speaking' er 'talking', mess_match [; NPCmess_a = -25; NPCmess_b = actor; ]; messclass -> with must 'speaking' er 'talking', mess_match [; NPCmess_a = -25; NPCmess_b = actor; ]; ! the WHEREs messclass with must 'where' er 'where^s', mess_match [; NPCmess_a = -1; NPCmess_b = actor; ]; messclass -> with must 'is' er 'are' er 'am' query, mess_match [; NPCmess_a = -23; NPCmess_b = actor; NPCmess_c = self.mess_q; ]; ! the WHERE/HOWs messclass with must 'where' er 'where^s' er 'how' er 'how^s', mess_match [; NPCmess_a = -1; NPCmess_b = actor; ]; messclass -> with must 'you' 'get' er 'find' er 'on' er 'upon' query, mess_match [; NPCmess_a = -24; NPCmess_b = actor; NPCmess_c = self.mess_q; ]; ! the WHYs messclass with must 'why' er 'why^s', mess_match [; NPCmess_a = -1; NPCmess_b = actor; ]; messclass -> with must 'did' er 'does' er 'do' query 'do', mess_match [; NPCmess_a = -19; NPCmess_b = actor; NPCmess_c = self.mess_q; ]; ! the HOWs messclass with must 'how' er 'how^s', mess_match [; NPCmess_a = -1; NPCmess_b = actor; ]; messclass -> with must 'is' er 'are' er 'am' query, mess_match [; NPCmess_a = -13; NPCmess_b = actor; NPCmess_c = self.mess_q; ]; ! the WHY/HOWs messclass with must 'how' er 'how^s' er 'why' er 'why^s', mess_match [; NPCmess_a = -1; NPCmess_b = actor; ]; ! the WHAT/WHY/HOWs messclass with must 'what' er 'what^s' er 'how' er 'how^s' er 'why' er 'why^s', mess_match [; NPCmess_a = -1; NPCmess_b = actor; ]; messclass -> with must 'is' er 'are' er 'am' query 'doing' er 'here' er 'to', mess_match [; NPCmess_a = -11; NPCmess_b = actor; NPCmess_c = self.mess_q; ]; ! the WHAT/HOWs messclass with must 'what' er 'what^s' er 'how' er 'how^s', mess_match [; NPCmess_a = -1; NPCmess_b = actor; ]; messclass -> with must 'shakin' er 'shaking' er 'hangin' er 'hanging' er 'going' er 'doing' er 'up' er 'wrong' er 'matter' er 'happenin' er 'happening', mess_match [; NPCmess_a = -13; NPCmess_b = actor; NPCmess_c = actor; ]; messclass -> -> with must 'with' query, mess_match [; NPCmess_a = -13; NPCmess_b = actor; NPCmess_c = self.mess_q; ]; messclass -> with must query, mess_match [; NPCmess_a = -13; NPCmess_b = actor; NPCmess_c = self.mess_q; ]; ! the MAY/CAN/COULDs messclass with must 'can' er 'may' er 'could', mess_match [; NPCmess_a = -1; NPCmess_b = actor; ]; messclass -> with must 'I//' 'have' er 'get' er 'borrow' query, mess_match [; NPCmess_s = actor; NPCmess_a = ##give; NPCmess_b = self.mess_q; NPCmess_c = player; ]; ! the rest messclass with must 'is' er 'are' 'this' er 'you' query, mustnot 'who' 'what' 'when' 'where' 'why' 'how', mess_match [; NPCmess_a = -28; NPCmess_b = actor; NPCmess_c = self.mess_q; ]; messclass with must 'you' 'are' query, mustnot 'who' 'what' 'when' 'where' 'why' 'how', mess_match [; NPCmess_a = -28; NPCmess_b = actor; NPCmess_c = self.mess_q; ]; messclass with must 'you^re' query, mess_match [; NPCmess_a = -28; NPCmess_b = actor; NPCmess_c = self.mess_q; ]; messclass with must 'huh' er 'what', mess_match [; NPCmess_a = -1; NPCmess_b = actor; ]; messclass with must 'hi' er 'hello' er 'greetings' er 'yo' er 'hiya' er 'hey' er 'heyho' er 'hullo' er 'haloo' er 'halloo' er 'howdy' er 'mornin' er 'evenin' er 'heya', mess_match [; NPCmess_a = -2; NPCmess_b = actor; ]; messclass with must 'good' 'day' er 'morning' er 'afternoon' er 'evening', mess_match [; NPCmess_a = -2; NPCmess_b = actor; ]; messclass with must 'yes' er 'yup' er 'yeah' er 'right' er 'affirmative' er 'sure' er 'y//' er 'yay' er 'right' er 'oh' er 'ah' er 'indeed' er 'agreed', mess_match [; NPCmess_a = -3; NPCmess_b = actor; ]; messclass with must 'yep' er 'riight' er 'riiight' er 'mmm' er 'mmhmm', mess_match [; NPCmess_a = -3; NPCmess_b = actor; ]; messclass with must 'I' 'see', mess_match [; NPCmess_a = -3; NPCmess_b = actor; ]; messclass with must 'no' er 'nope' er 'nah' er 'wrong' er 'negative' er 'never' er 'n//' er 'nay' er 'not', mess_match [; NPCmess_a = -4; NPCmess_b = actor; ]; messclass with must 'thanks' er 'thank', mess_match [; NPCmess_a = -5; NPCmess_b = actor; ]; messclass with must 'find' er 'locate' query, mess_match [; NPCmess_a = -10; NPCmess_b = actor; NPCmess_c = self.mess_q; ]; messclass with must 'look' er 'search' 'for' query, mess_match [; NPCmess_a = -10; NPCmess_b = actor; NPCmess_c = self.mess_q; ]; messclass with must 'shut' 'up' er 'mouth' er 'trap' er 'hole' er 'face', mess_match [; NPCmess_a = -12; NPCmess_b = actor; ]; messclass with must 'quiet', mess_match [; NPCmess_a = -12; NPCmess_b = actor; ]; messclass with must 'goodbye' er 'bye' er 'adios' er 'cheers' er 'ciao', mess_match [; NPCmess_a = -14; NPCmess_b = actor; ]; messclass with must 'see' er 'catch' 'ya' er 'yah' er 'you' er 'y^all', mess_match [; NPCmess_a = -14; NPCmess_b = actor; ]; messclass with must 'I//' er 'I^ve' er 'I^m' 'taking' er 'should' er 'shall' er 'must' er 'got' er 'gotta' 'go' er 'off' er 'leave', mess_match [; NPCmess_a = -14; NPCmess_b = actor; ]; messclass with must 'haha' er 'ha' er 'tee' er 'hee' er 'teehee', mess_match [; NPCmess_a = -15; NPCmess_b = actor; ]; messclass with must 'doh' er 'd^oh' er 'nuts' er 'crap' er 'dang' er 'damn', mess_match [; NPCmess_a = -16; NPCmess_b = actor; ]; messclass with must 'er' er 'erm' er 'eagh' er 'eeagh' er 'ahem' er 'yuck' er 'sheesh' er 'oof' er 'hm' er 'hmm' er 'hrm', mess_match [; NPCmess_a = -17; NPCmess_b = actor; ]; messclass with must 'really' er 'sure' er 'okay' er 'would', mess_match [; NPCmess_a = -18; NPCmess_b = actor; ]; messclass with must 'help', mess_match [; NPCmess_a = -20; NPCmess_b = actor; ]; messclass with must 'wow' er 'woo' er 'ooh' er 'cool' er 'amazing' er 'awesome', mess_match [; NPCmess_a = -22; NPCmess_b = actor; ]; messclass with must 'want' er 'fancy' er 'need' er 'like' query, mess_match [; NPCmess_a = -26; NPCmess_b = actor; NPCmess_c = self.mess_q; ]; messclass -> with must 'I//', mess_match [; NPCmess_s = actor; NPCmess_a = ##give; NPCmess_b = self.mess_q; NPCmess_c = player; ]; messclass with must 'hankerin' er 'care' 'for' query, mess_match [; NPCmess_a = -26; NPCmess_b = actor; NPCmess_c = self.mess_q; ]; messclass -> with must 'I//', mess_match [; NPCmess_s = actor; NPCmess_a = ##give; NPCmess_b = self.mess_q; NPCmess_c = player; ]; messclass with must 'get' er 'give' er 'hand' 'me' query, mess_match [; NPCmess_s = actor; NPCmess_a = ##give; NPCmess_b = self.mess_q; NPCmess_c = player; ]; messclass with must 'I//' er 'I^ll' 'have' query, mess_match [; NPCmess_s = actor; NPCmess_a = ##give; NPCmess_b = self.mess_q; NPCmess_c = player; ]; messclass with must query, mess_match [; NPCmess_s = actor; NPCmess_a = ##give; NPCmess_b = self.mess_q; NPCmess_c = player; ];