System_file; ! This section defines actions and conditions. Both will be passed three ! arguments, the first of which is the actor. ! Actions do something to get closer to the current goal; ! if a value is returned then it is ignored. [ rapBegDown actor unused1 unused2; if (TestScope (player, actor)) print "^", (The) actor, " whines and struggles to get free.^"; ]; [ rapBegUp actor unused1 unused2; if (TestScope (player, actor)) print "^", (The) actor, " whines and begs pleadingly.^"; ]; [ rapGoTo actor room unused; if (TestScope (player, actor)) print "^", (the) actor, " heads off to ", (the) room, ".^"; unused = room; move actor to room; if (TestScope (player, actor)) print "^", (the) actor, " arrives from ", (the) unused, ".^"; ]; [ rapPickUp actor object unused; move object to actor; if (TestScope (player, actor)) print "^", (The) actor, " picks up ", (the) " object."; ]; [ rapPutDown actor object unused; move object to parent(actor); if (TestScope (player, actor)) print "^", (The) actor, " puts down ", (the) " object."; ]; [ rapPlayWith actor toy unused; if (TestScope (player, actor)) print "^", (The) actor, " plays with ", (the) toy, ".^"; ]; [ rapNullAction actor param1 param2 ; rtrue; ]; ! Conditions shouldn't do anything except return true or false. [ rapCarried actor object person; !print "^Is ", (the) object, " carried by ", (the) person, "? "; !if (object in person) print "Yes.^"; else print "No.^"; return object in person; ]; [ routinename x ; switch (x) { default: print ""; } ]; rapGoal rapPuppyFun "rapPuppyFun" with istrue [ actor unused1 unused2; rfalse; ], get_nbr_plans [ actor unused1 unused2 ; return 1; ], get_nbr_steps [ actor unused1 unused2 plan ; switch (plan) { 1: return 2; } ], get_plan [ actor unused1 unused2 plan step; switch (plan) { 1: switch (step) { 1: rap_set_step(RAP_BE,rapSamePlace, ball, 0); 2: rap_set_step(RAP_DO,rapPlayWith, ball, 0); } } ]; rapGoal rapInRoom "rapInRoom" with istrue [ actor room unused; return (actor in room); ], get_nbr_plans [ actor room unused ; return 0+ (room.#come_from/2); ], get_nbr_steps [ actor room unused plan ; switch (plan) { default: return 2; } ], get_plan [ actor room unused plan step; switch (plan) { default: plan = plan - 1; switch (step) { 1: rap_set_step(RAP_BE,rapInRoom, room.&come_from-->plan, 0); 2: rap_set_step(RAP_DO,rapGoTo, room, 0); } } ]; rapGoal rapSamePlace "rapSamePlace" with istrue [ actor object unused; return (actor in parent(object)); ], get_nbr_plans [ actor object unused ; return 3; ], get_nbr_steps [ actor object unused plan ; switch (plan) { 1: return 2; 2: return 3; 3: return 1; } ], get_plan [ actor object unused plan step; switch (plan) { 1: switch (step) { 1: rap_set_step(RAP_IF,rapCarried, actor, player); 2: rap_set_step(RAP_DO,rapBegDown, 0, 0); } 2: switch (step) { 1: rap_set_step(RAP_IF,rapCarried, object, player); 2: rap_set_step(RAP_BE,rapSamePlace, player, 0); 3: rap_set_step(RAP_DO,rapBegUp, 0, 0); } 3: switch (step) { 1: rap_set_step(RAP_BE,rapInRoom, parent(object), 0); } } ]; ! All done