game.title = "Bloodfields"; global { command: "quit" { exit(); } } situation <> { setup { global.enemyTypes = { 1: { 'name': 'Snail', 'action': 'bites', 'hp': 3, 'attack': 2 }, 2: { 'name': 'Wolf', 'action': 'bites', 'hp': 7, 'attack': 3 }, 3: { 'name': 'Snake', 'action': 'strikes at', 'hp': 3, 'attack': 3 } }; global.enemyMods = { 1: { 'name': 'Pathetic', 'hp': 0, 'attack': 0 }, 2: { 'name': 'Sickly', 'hp': 3, 'attack': 1 }, 3: { 'name': 'Wimpy', 'hp': 5, 'attack': 2 } }; player.hpMax = 10; player.hpCur = player.hpMax; player.xp = 0; player.attack = 3; global.bJustTravelled = false; goto( <> ); } } function status() { display('You have ' + player.hpCur + ' of ' + player.hpMax + ' hp.'); } function look() { if( exists(global.enemy) )then { display('''You are standing in a field of wheat. You see a ''' + global.enemy['name'] + ''' in front of you.'''); } else { display('''You are standing in a field of wheat.'''); } // status(); } function mkEnemy() { eid = random( 1, 3 ); global.enemy = global.enemyTypes[eid]; mod = 1; global.enemy['name'] = global.enemyMods[mod]['name'] + ' ' + global.enemy['name']; global.enemy['attack'] = global.enemy['attack'] + global.enemyMods[mod]['attack']; global.enemy['hp'] = global.enemy['hp'] + global.enemyMods[mod]['hp']; } function rollAttack( attack ) { return( random( attack-attack/3, attack+attack/3 ) ); } function playerAttack() { damage = rollAttack( player.attack ); global.enemy['hp'] = global.enemy['hp'] - damage; display('You strike the ' + global.enemy['name'] + ' for ' + damage + ' damage.'); if global.enemy['hp'] <= 0 then { display('You killed the ' + global.enemy['name'] + '!'); delete( global.enemy ); } } function enemyAttack() { damage = rollAttack( global.enemy['attack'] ); player.hpCur -= damage; display("The " + global.enemy['name'] + ' ' + global.enemy['action'] + ' you for ' + damage + ' damage.'); if player.hpCur <= 0 then { display('The ' + global.enemy['name'] + ' killed you!'); exit(); } } situation <> { enter { delete( global.enemy ); display('You wander aimlessly through the seemingly endless field of wheat.'); select = random(1,3); if select == 1 then { mkEnemy(); display('''There's a ''' + global.enemy['name'] + ''' here!'''); } global.bJustTravelled = true; goto( <> ); } } situation <> { command: "attack" { if exists(global.enemy) then { playerAttack(); goto( <> ); } else { display('''There's nothing here to attack...'''); } } command: "look" { look(); } command: "walk" { if not exists(global.enemy) then { goto( <> ); } else { display("You can't walk around with an enemy in front of you! You can try to flee if you'd like..."); } } setup { look(); } enter { if not global.bJustTravelled then { if exists( global.enemy ) then { enemyAttack(); } status(); // look(); } else { } global.bJustTravelled = false; } }