Unit characters;type TNPC = class(TObject) ... function CreateMyContext: TContext;end;Unit context;type TContext = class(TObject)about: TNPC...end;type TDialogueContext = class(TObject) CurrentContext: TContext; Speaker,Listener: TNPC; ...end;
Unit genericNPCtype TGenericNPCUnit charactertype TNPC = class(TGenericNPC)Unit context...speaker,listener: TGenericNPC...Contex.add((speaker as TNPC).createMyContext);
Unit genericContexttype TContextUnit characteruses TContexttype TNPC = class(TGenericNPC)Unit context...Contex.add(speaker.createMyContext);
unit characterstype TNPC...unit contexttype TContexttype TNPC = helper... function getMyContext: TContextend;...
Unit characterstype TNPC... id: integer ...end;type TNPC_list... function findbyId(id: integer): TNPC;end;unit contexttype TContext...npc_id: integer;...type TDialogueContext listener,speaker: integer;...
function CreateMyContext: TContext;
function CreateFromNPC(NPC: TNPC): TContext;
Example:- Hi, Andry! Haven't seen you for ages! (context: %npc1 and %npc2 are friends, %npc1 didn't meet %npc2 for some time, %npc2 request name, generic: greeting (suggest next slot: greeting-response)- Hi, Jay! Nice to meet you! (context: %npc2 and %npc1 are friends, accept suggested slot: greeting-response (don't break the dialogue by some "I hate you. Get lost from my sight!" with suggest next slot: end-dialogue), %npc2 is "glad" (or pretending to be glad), suggest next slot: random-chat).- You know, I've saw Reann yesterday. (select random-chat dialogue slot: gossip. Use memory (%fact1) about %npc3. Suggest next dialogue slot (self): continue) She was wearing a really nice red shoes. (listener didn't interrupt the dialogue (was ok with next dialogue slot), disposition to %npc3 check, use memory (%fact2 related to %fact1), check values of %npc1 (he likes red color), select next slot: react-gossip)- Red? I never heard her of liking red color! (accept react-gossip slot, check %fact2 with %npc2.memory(about %npc3) and it contradicts result = context:"surprise", suggest next slot react-surprise).- I tell ya. (accept react-surprise slot, suggest next slot: random-chat or goodbye)
Example:TPhrase.text := 'Hi, (request listener:name, nominative)!'; //if speaker and listener are friends "request listener:name" script might return nickname insteadTPhrase.context.DEMAND.add(dialogueslot_generic_greeting); //this will do for greeting_hello and greeting_response dialogue slotsTPhrase.context.DEMAND.add(disposition_above_average); //the speaker must return disposition>0.5 towards listenerTPhrase.context.DEMAND.add(informal_chat,importance=0.9); //This phrase will have to suffer 90% penalty to be used in formal situation, but still possible