#--- #Fighting fantasy library #--- #Release 1 #--- constant skill 1 ;The current skill of a creature. constant stamina 3 ;The current stamina of a creature. constant istamina 4 ;The initial stamina of a creature. constant luck 5 ;The current luck of a creature. constant iluck 6 ;The initial luck of a creature. constant attackstrength 7 ;The attack strength of a creature in combat. constant damage 8 ;The effectiveness in combat. constant dice1 9 ;Four dice, mainly used by the random number generator. constant dice2 10 constant dice3 11 constant dice4 12 constant iskill 13 ;The initial skill of a creature. #Combat bonuses constant DoubleBonus 1 ;The player has two equal dice constant FirstHitBonus 2 ;The player manages to hit his/her opponent for the first time attribute CantChoose ;A location tagged with this attribute will have no numbered menu to choose a direction from. integer InCombat false ;When combat begins, this variable should be changed to true. integer VictoryPage 0 ;After a successful test, the player will be moved to this location. integer FailedPage 0 ;After a failed test, the player will be moved to this location. integer turncount 0 ;A variable to keep track of the turns in combat. integer turnslimit 0 ;A variable to limit the player's turns in combat integer_array CombatBonus 2 0 ;The array of combat bonuses (up to two items) integer MAX_OPTION integer_array OPTIONS 10 0 integer OPTION_COUNT 0 integer temp 0 integer MONSTERS 10 0 integer MONSTER_COUNT integer FIRST_FIGHTING_OPTION integer multipleTests false #The text which is printed when the player types 'eq' string before_eq "Looking into your backpack you see:" grammar $integer >number grammar blankjacl >blankjacl grammar eq >display_eq grammar stats >PrintStats integer status_window 3 integer INDEX string status_text "null" {+update_status_window style reverse padstring status_text " " status_width write status_text cursor 0 1 write status_text cursor 0 2 write status_text execute "+print_right 1 : arg[0] < -1 write "modifier points " else write "modifier point " endif write "to the result, it equals " temp ". Comparing this to your current luck (" player(luck) ") " endif if temp <= player(luck) write "you are lucky.^" execute +DecreaseLuck<1 move player to VictoryPage set VictoryPage = 0 set FailedPage = 0 look return else write "you are unlucky.^" execute +DecreaseLuck<1 set VictoryPage = 0 move player to FailedPage set FailedPage = 0 look return endif } {+TestYourSkill write "Testing your skill:^" set player(dice1) = +rnd<6 set player(dice2) = +rnd<6 set temp = player(dice1) + player(dice2) if arg[0] = 0 write "You roll a " player(dice1) " and a " player(dice2) ", which " write "equals " temp ". Comparing this to your current skill (" player(skill) ") " else set temp + arg[0] write "You roll a " player(dice1) " and a " player(dice2) ". " if arg[0] < 0 write "Subtracting " else write "Adding " endif write arg[0] " " if arg[0] > 1 : arg[0] < -1 write "modifier points " else write "modifier point " endif write "to the result, it equals " temp ". " write "Comparing this to your current skill (" player(skill) ") " endif if temp <= player(skill) write "you are skillful.^" move player to VictoryPage set VictoryPage = 0 set FailedPage = 0 look return else write "you are unskillful.^" move player to FailedPage set VictoryPage = 0 set FailedPage = 0 look return endif } {+TestYourStamina write "Testing your stamina:^" set player(dice1) = +rnd<6 set player(dice2) = +rnd<6 set player(dice3) = +rnd<6 set player(dice4) = +rnd<6 set temp = player(dice1) + player(dice2) + player(dice3) + player(dice4) if arg[0] = 0 write "You roll a " player(dice1) ", a " player(dice2) ", a " write player(dice3) " and a " player(dice4) ", which " write "equals " temp ". Comparing this to your current stamina (" player(stamina) ") " else set temp + arg[0] write "You roll a " player(dice1) ", a " player(dice2) ", a " write player(dice3) " and a " player(dice4) ". " if arg[0] < 0 write "Subtracting " else write "Adding " endif write arg[0] " " if arg[0] > 1 : arg[0] < -1 write "modifier points " else write "modifier point " endif write "to the result, it equals " temp ". " write "Comparing this to your current stamina (" player(stamina) ") " endif if temp <= player(stamina) write "you are strong.^" move player to VictoryPage set VictoryPage = 0 set FailedPage = 0 look return else write "you are weak.^" move player to FailedPage set VictoryPage = 0 set FailedPage = 0 look return endif } {+DecreaseLuck if player(luck) > 1 set player(luck) - arg[0] write "You lose " arg[0] " luck.^" if player(luck) < 1 set player(luck) = 1 endif write "Your luck is now " player(luck) .^ endif } {+IncreaseLuck if player(luck) < player(iluck) set player(luck) + arg[0] write "You gain " arg[0] " luck.^" if player(luck) > player(iluck) set player(luck) = player(iluck) endif write "Your luck is now " player(luck) .^ endif } {+DecreaseStamina set player(stamina) - arg[0] if player(stamina) < 1 execute +game_over else write "You lose " arg[0] " stamina.^" write "Your stamina is now " player(stamina) .^ endif } {+IncreaseStamina if player(stamina) < player(istamina) set player(stamina) + arg[0] write "You gain " arg[0] " stamina.^" if player(stamina) > player(istamina) set player(stamina) = player(istamina) endif write "Your stamina is now " player(stamina) .^ endif } {+DecreaseSkill if player(skill) > 1 set player(skill) - arg[0] write "You lose " arg[0] " skill.^" if player(skill) < 1 set player(skill) = 1 endif write "Your skill is now " player(skill) .^ endif } {+IncreaseSkill if player(skill) < player(iskill) set player(skill) + arg[0] write "You gain " arg[0] " skill.^" if player(skill) > player(iskill) set player(skill) = player(iskill) endif write "Your skill is now " player(skill) .^ endif } {+blankjacl write "Invalid command^" } {+number if $integer < 1 : $integer > OPTION_COUNT if OPTION_COUNT = 1 write "The only available choice is 1.^" return true else write "Please choose a number between 1 and " OPTION_COUNT .^ return true endif endif ifall here = combat : $integer => FIRST_FIGHTING_OPTION # THE OPTIONS TO DO WITH FIGHTING ARE HANDLED DIFFERENTLY TO NORMAL OPTION execute "+combat_action 0 move player to VictoryPage look set VictoryPage = 0 return endif else execute here.OPTIONS[$integer] endif } {+clear_options set OPTION_COUNT = 0; set FIRST_FIGHTING_OPTION = 0; } {+add_option if OPTION_COUNT = 10 # NO MORE ROOM return false endif set OPTION_COUNT + 1 write OPTION_COUNT ". " string_arg[1] ^ set OPTIONS[OPTION_COUNT] = arg[0] return true } {+add_fighting_option if OPTION_COUNT = 10 # NO MORE ROOM return false endif set OPTION_COUNT + 1 write OPTION_COUNT ". Fight " current_monster{the} ^ set OPTIONS[OPTION_COUNT] = arg[0] if FIRST_FIGHTING_OPTION = 0 # NOTE THE INDEX OF THE FIRST FIGHTING OPTION BECAUSE THEY ARE HANDLED # DIFFERENTLY set FIRST_FIGHTING_OPTION = OPTION_COUNT endif return true } {+footer if here hasnt CantChoose execute here.choices endif } location combat : Combat short name "Combat" integer current_monster integer MONSTER_COUNT {look write "Your stamina: " player(stamina) ^ write "Your skill: " player(skill) ^ # LOOP THROUGH ALL THE OBJECTS IN THE GAME loop current_monster ifall current_monster(parent) = combat : current_monster != player # IF IT IS IN THIS LOCATION AND NOT THE PLAYER, IT MUST BE A MONSTER write current_monster{The} "'s stamina: " current_monster(stamina) ^ write current_monster{The} "'s skill: " current_monster(skill) ^ endif endloop } {choices execute "+clear_options" # ADD COMBAT-ONLY ANY NORMAL OPTIONS HERE #execute "+add_option<1 0 set turncount + 1 if turncount >= turnslimit loop if noun3(parent) = combat move noun3 to limbo endif endloop move player to FailedPage set VictoryPage = 0 set FailedPage = 0 look endif endif } {+bonuses if CombatBonus[0] = DoubleBonus : CombatBonus[1] = DoubleBonus if player(dice1) = player(dice2) # IN THIS CASE YOU HAVE ONLY KILLED YOUR OPPONENT write "You kill " opponent{the} ".^" move opponent to limbo # REBUILD THE LIST AS THERE IS NOW ONE LESS MONSTER execute "+build_monster_list opponent(attackstrength) # Caught the first hit of the player execute "+attack_compare arg[0](attackstrength) write "You hit " arg[0]{the} "!^" set arg[0](stamina) - player(damage) if arg[0](stamina) < 1 write "You kill " arg[0]{the} ".^" move arg[0] to limbo # REBUILD THE LIST TO SEE HOW MANY ARE LEFT execute "+build_monster_list 1 write ", " else if ItemCounter = 1 write " and " else write .^ endif endif } {+PrintStats write "Your stats are:^" write "Skill: " player(skill) " out of " player(iskill) ".^" write "Stamina: " player(stamina) " out of " player(istamina) ".^" write "Luck: " player(luck) " out of " player(iluck) ".^" } {+game_over write "---[Your adventure ends here.]---^" endgame } {+title style subheader write here{the} ^ style normal } {+look_around ensure here hasnt VISITED execute "+display_location" set time = false } {+display_location if here has DARKNESS execute "+dark_description" return endif call "+title" if display_mode = true ensure here hasnt VISITED endif execute "here.look" ensure here has KNOWN ensure here has VISITED ensure here has MAPPED execute "+object_descriptions" } {+object_descriptions loop ifall noun3(parent) = here : noun3(mass) < scenery : noun3 hasnt LOCATION write ^ noun3{long} endif endloop }