User Tools

Site Tools


sd:rogueima_plan

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
sd:rogueima_plan [2026/09/08 15:55] – external edit 127.0.0.1sd:rogueima_plan [2026/09/09 03:27] (current) – external edit 127.0.0.1
Line 1269: Line 1269:
 village is a place; it is not yet inhabited. village is a place; it is not yet inhabited.
  
-==== Step 28. A level script ====+==== Step 28. A level script, and people who answer questions - DONE ====
  
-Brynn is 84x30 of map text followed by directives:+A level'map text is now followed by directives:
  
-  "DENIZEN Farmer_Jim 19 17 The_apples_look_lovely_this_year. The_farmin'_life_for_me! ..." +  DENIZEN Farmer_Jim 19 17 
-  "SHOPKEEPER RANDOM 53 9" +  CHAT  The_apples_look_lovely_this_year. 
-  "NOMONSTERS"+  REPLY job   I_work_the_orchard._Apples,_mostly._It's_a_living
 +  REPLY name  I'm_Jim._Farmer_Jim,_on_account_of_the_farm.
  
-Underscores for spacesbecause the parser splits on them. ''LevelFactory'' +''DENIZEN''its inline chats and ''NOMONSTERS'' are NetWhack's, read the way 
-has comment saying all of this //"needs to be put into some kind of script +''DungeonMaker'' reads them -- split on spaces, ''_'' standing in for a space 
-and attached to the level file, and not written here"// — and it is rightOur +inside a token -- so **Brynn's own four denizens parse as written**. ''CHAT'' 
-''level_table'' already holds a source pointerthis is the format it points +and ''REPLY'' are ours. 
-at.+ 
 +=== Why directive and not punctuation === 
 + 
 +''job:I'm_a_farmer'' reads well and would work. Split on the **first** colon 
 +and the answer can contain as many more as it likes, so no escape is needed 
 +for the colon at all -- a keyword is one word and cannot contain one. 
 + 
 +Two things argued against it: 
 + 
 +  * The format already has **exactly one escape**, ''_'' for space. A 
 +    backslash rule would be a second one to learn, and every directive added 
 +    later would inherit both. 
 +  * Inferring the //kind// of speech from a punctuation mark cannot tell a 
 +    keyword from a random line that happens to contain a colon. 
 + 
 +A directive says which it is instead of leaving it to be guessed, and the next 
 +thing we want -- ''GIVE'', ''QUEST'', ''SHOP'' -- is another word rather than 
 +another mark. 
 + 
 +=== Talking: Ultima IV's three cases === 
 + 
 +NetWhack has only the middle one. An NPC there holds a list of lines and says 
 +one at random; there is no interactive speech in it anywhere. The other two 
 +are Rogueima's. 
 + 
 +^ case ^ what happens ^ 
 +| nothing to say | //"They do not seem to want to talk."//
 +| random speech | Farmer Jim says, "The apples look lovely this year." | 
 +| keyword replies | a page of its own, and you type words at it | 
 + 
 +  Farmer Jim -- and you are talking to them. 
 + 
 +    I work the orchard. Apples, mostly. It's a living. 
 + 
 +    Ask about a subject -- try NAME, or JOB. BYE to stop. 
 +    Say: 
 + 
 +An unknown word gets //"They shrug, and say nothing about that."//; ''BYE'' or 
 +an empty line ends it. Matching folds case, so ''JOB'' and ''job'' are the 
 +same question. 
 + 
 +''npc_mode'' makes the three-way choice **value rather than a shape of 
 +code**, so it can be checked without reading a screen. Replies win over chats: 
 +somebody who will hold a conversation should not be reduced to muttering one 
 +line at you. 
 + 
 +=== Nothing copies text === 
 + 
 +The script stays in the program image and an NPC holds **pointers into it**. 
 +''print_script'' turns the underscores back into spaces on the way out, rather 
 +than rewriting the source the way ''replace('_',' ')'' does -- so a level can 
 +be built twice without its script having been consumed. A keyword ends at the 
 +space that follows it in the script, since it has no terminator of its own. 
 + 
 +=== Verification === 
 + 
 +  denizens created          4        chat lines             21 
 +  keyword replies          20        "JOB" finds an answer   yes 
 +  "wombat" does not       yes        modes: 2, then 1, then 0 
 + 
 +The three modes are read off one denizen stripped in stages: with both, it 
 +converseswith its replies taken away it falls back to random; with its chats 
 +gone too it has nothing to say. 
 + 
 +=== An ordering bug === 
 + 
 +''init_objects'' and ''npc_init'' ran **after** ''load_all_levels'', so the 
 +script put four denizens into the node array and ''init_objects'' immediately 
 +emptied it again -- ''npc_count'' read 0 and the village was deserted. 
 +Everything a level writes into has to exist before the level is built.
  
 ==== Step 29. Branches, and stairs that know where they go ==== ==== Step 29. Branches, and stairs that know where they go ====
sd/rogueima_plan.1788882930.txt.gz · Last modified: by 127.0.0.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki