! _Shade_ ! Special source-code edition ! Copyright 2000-2002 Andrew Plotkin ! http://www.eblong.com/zarf/if.html ! This source code is provided for personal, educational use only. ! See README file for details. Constant MAXIMPS 12; Array goalimps --> MAXIMPS; Global impcount = 0; Global goalcount = 0; Object goalhandler with initial [; StartDaemon(self); ], imp [; "[BUG] no imp"; ], daemon [ ix jx kx; #ifdef DEBUG; if (debug_flag & 4 ~= 0) { for (ix=0 : ixix, ": imp^"; } } ! not entirely accurate; if an imp calls Goaled(Obj), the object's ! imp will be run that turn also. #endif; for (ix=0 : ixix; if (jx.imp == NULL) kx = -1; else kx = jx.imp(); if (kx == -1) { for (kx=ix : kxkx = goalimps-->(kx+1); } impcount--; ix--; } } ]; [ Goaled obj; if (~~(obj provides prereqs)) { print "[BUG] Goaled(", (name) obj, "): no prereqs^"; rfalse; } if (obj has goal_complete) return; goalcount++; give obj goal_complete; if (obj provides imp) { goalimps-->impcount = obj; impcount++; } ]; [ GoalOpen obj addr num ix jx; if (~~(obj provides prereqs)) { print "[BUG] GoalOpen(", (name) obj, "): no prereqs^"; rfalse; } if (obj has goal_complete) rfalse; addr = obj.&prereqs; num = (obj.#prereqs) / WORDSIZE; for (ix=0 : ixix; if (jx == true) continue; switch (metaclass(jx)) { Object: if (jx hasnt goal_complete) rfalse; Routine: if (jx() == false) rfalse; default: print_ret "[BUG] GoalOpen(", (name) obj, "): strange value ", jx; } } rtrue; ]; [ GoalClosed obj; return (obj has goal_complete); ]; [ GoalEverOpen obj; if (obj has goal_complete) rtrue; return GoalOpen(obj); ]; [ KillImp obj; if (~~(obj provides imp)) { print_ret "[BUG] KillImp(", (name) obj, "): no imp"; } obj.imp = NULL; ]; #ifdef ZDEBUG; [ GoalsScope obj; if (scope_stage == 1) rfalse; if (scope_stage == 2) { objectloop (obj provides prereqs) { PlaceInScope(obj); } rtrue; } "That's no goal."; ]; [ GoalListSub obj isopen isclosed any; ! 0: open and closed. 1: all. 2: only open. 3: only closed. objectloop (obj provides prereqs) { isopen = GoalOpen(obj); isclosed = GoalClosed(obj); any = false; if (isopen && noun == 0 or 1 or 2) { any = true; print (name) obj, ": open^"; } if (isclosed && noun == 0 or 1 or 3) { any = true; print (name) obj, ": closed^"; } if (noun == 1 && (~~any)) { print (name) obj, ": not yet^"; } } ]; [ ZapOpenGoalSub addr num ix; print "Opening: ", (the) noun, "^"; addr = noun.&prereqs; num = (noun.#prereqs) / WORDSIZE; for (ix=0 : ixix = true; } ]; [ ZapCloseGoalSub; print "Closing: ", (the) noun, "^"; Goaled(noun); ]; #endif; ! --- individual goal utilities Object firstgoal with name 'firstgoal', prereqs true, number 0, imp [; self.number++; switch (self.number) { 2: print "^Come to think of it, as with a hangover, dehydration is probably the problem. Your mouth is dry wool.^"; 7: print "^You're still feeling thirsty.^"; 15: print "^You run your tongue over dry teeth.^"; 16: self.number = 3; } ]; Global background_counter = 0; [ BackgroundInfo obj str; if (obj.background_flag) rtrue; obj.background_flag = true; background_counter++; print "^("; if (str) print (string) str, " "; switch (background_counter) { 1: print "It is, of course, the Death Valley Om -- half arts festival, half cult, a week in the deep desert where people show off, have sex, take drugs, and maintain a twenty-four-hour constant ", (emph) "OM.", " Sand, heat, and thousands of throats. A space outside the world; with no dues except that you join in the chant, as much as is in you to chant."; 2: print "Nothing is off-limits at the Om. ~Law ends at sea level.~ In one place in the country, for one week, a community is formed from pure will. No enforcement; only desire, and the knowledge of what the desert can do. And the Om. Every religion chants, you remember reading that."; 3: print "The experience is supposed to be transformative. And, frankly, you're in need of transformation. Another month of this and you'll indistinguishable from this apartment -- beige, featureless, and up for cheap rent. At the Death Valley Om, they say, you may be sunburnt and thirsty and exhausted, but you're alive. Nothing sounds better. You're planning to try the solo Zen night hiking."; default: print "[BUG] background info"; } ")"; ]; Object tickets "plane tickets" with name 'plane' 'airplane' 'ticket' 'tickets', description [; print "Your round-trip tickets to California."; if (~~self.seenonce) { self.seenonce = true; print " You stare at them for a moment -- lost in the idea of the desert."; } new_line; rtrue; ], seenonce false, after [; Take: if (self hasnt general) { give self general; "Taken. Something scrapes underfoot as you bend to pick the tickets up."; } ], prereqs water, imp [; StartMotorNoise(); BumpSand(livingsand); return -1; ], has rescuable pluralname; ! general means taken Global ticket_counter = 0; [ CheckTicket obj; if (obj.ticket_search >= 2) { if (obj.ticket_search == 3) "No matter how often you look, the plane tickets aren't there."; obj.ticket_search = 3; "The plane tickets still aren't there."; } obj.ticket_search = 2; ticket_counter++; if (ticket_counter < 3) { "Nope. The tickets aren't there."; } Goaled(tickets); move tickets to Apartment; print_ret "Nope. The tickets aren't -- ", (emph) "Aha.", " They are, after all. The tickets slide to the floor and lie there, smirking at you."; ]; [ StartMotorNoise; move motornoise to Apartment; StartDaemon(motornoise); ]; [ StopMotorNoise; StopDaemon(motornoise); remove motornoise; ]; Object motornoise "sounds" with name 'sound' 'sounds' 'helicopter' 'copter', before [; Listen: "You can hear a helicopter somewhere up in the night."; Examine: <>; Find: "Somewhere outside and above."; default: "You can only hear the helicopter."; ], number 0, daemon [; self.number++; switch (self.number) { 3: print "^The sound of a helicopter comes faintly through the closed window.^"; 5: print "^The helicopter is getting closer.^"; 7: print "^The sound of the helicopter is fading now.^"; 10: print "^You can barely hear the helicopter any more.^"; 11: StopMotorNoise(); } ], has scenery pluralname;