From bb953de92b8725856533ed8fa2ba2eaf8000d30b Mon Sep 17 00:00:00 2001 From: Zarkonnen Date: Wed, 10 Jul 2013 12:53:28 +0200 Subject: [PATCH] Finished first version of medicine feature. --- css/main.css | 1 + script/events.js | 4 +- script/events/encounters.js | 40 +++++++++++++ script/events/outside.js | 114 ++++++++++++++++++++++++++++++++++++ script/events/room.js | 86 ++++++++++++++++++++++++++- script/events/setpieces.js | 75 +++++++++++++----------- script/path.js | 3 +- script/world.js | 2 +- 8 files changed, 285 insertions(+), 40 deletions(-) diff --git a/css/main.css b/css/main.css index 7e21aa7..56a5bc1 100644 --- a/css/main.css +++ b/css/main.css @@ -438,6 +438,7 @@ body.noMask #description { #buttons > .button { margin: 0 5px 5px; + margin-right: 15px; } /* Combat! */ diff --git a/script/events.js b/script/events.js index ca84240..ba12210 100644 --- a/script/events.js +++ b/script/events.js @@ -104,10 +104,10 @@ var Events = { Events.createAttackButton('fists').prependTo(btns); } + Events.createEatMeatButton().appendTo(btns); if((Path.outfit['medicine'] || 0) != 0) { - Events.createUseMedsButton().prependTo(btns); + Events.createUseMedsButton().appendTo(btns); } - Events.createEatMeatButton().prependTo(btns); // Set up the enemy attack timer Events._enemyAttackTimer = setTimeout(Events.enemyAttack, scene.attackDelay * 1000); diff --git a/script/events/encounters.js b/script/events/encounters.js index 5286948..bcaf26c 100644 --- a/script/events/encounters.js +++ b/script/events/encounters.js @@ -109,6 +109,46 @@ Events.Encounters = [ } }, /* Tier 2*/ + { /* Shivering Man */ + title: 'A Shivering Man', + isAvailable: function() { + return World.getDistance() > 10 && World.getDistance() <= 20 && World.getTerrain() == World.TILE.BARRENS; + }, + scenes: { + 'start': { + combat: true, + enemy: 'shivering man', + char: 'S', + damage: 5, + hit: 0.5, + attackDelay: 1, + health: 20, + loot: { + 'cloth': { + min: 1, + max: 1, + chance: 0.2 + }, + 'teeth': { + min: 1, + max: 2, + chance: 0.8 + }, + 'leather': { + min: 1, + max: 1, + chance: 0.2 + }, + 'medicine': { + min: 1, + max: 3, + chance: 0.7 + } + }, + notification: 'a shivering man approaches and attacks with surprising strength' + } + } + }, { /* Man-eater */ title: 'A Man-Eater', isAvailable: function() { diff --git a/script/events/outside.js b/script/events/outside.js index c6a1db0..aa1b7c7 100644 --- a/script/events/outside.js +++ b/script/events/outside.js @@ -63,6 +63,120 @@ Events.Outside = [ } }, + { /* Sickness */ + title: 'Sickness', + isAvailable: function() { + return Engine.activeModule == Outside && Outside.getPopulation() > 10 && Outside.getPopulation() < 50; + }, + scenes: { + 'start': { + text: [ + 'a sickness is spreading through the village.', + 'medicine is needed immediately.' + ], + buttons: { + 'heal': { + text: '1 medicine', + cost: { 'medicine' : 1 }, + nextScene: {1: 'healed'} + }, + 'ignore': { + text: 'ignore it', + nextScene: {1: 'death'} + } + } + }, + 'healed': { + text: [ + 'the sickness is cured in time.' + ], + buttons: { + 'end': { + text: 'go home', + nextScene: 'end' + } + } + }, + 'death': { + text: [ + 'the sickness spreads through the village.', + 'the days are spent with burials.', + 'the nights are rent with screams.' + ], + onLoad: function() { + var numKilled = Math.floor(Math.random() * 20) + 1; + Outside.killVillagers(numKilled); + }, + buttons: { + 'end': { + text: 'go home', + nextScene: 'end' + } + } + } + } + }, + + { /* Plague */ + title: 'Plague', + isAvailable: function() { + return Engine.activeModule == Outside && Outside.getPopulation() > 50; + }, + scenes: { + 'start': { + text: [ + 'a terrible plague is fast spreading through the village.', + 'medicine is needed immediately.' + ], + buttons: { + 'heal': { + text: '5 medicine', + cost: { 'medicine' : 5 }, + nextScene: {1: 'healed'} + }, + 'ignore': { + text: 'do nothing', + nextScene: {1: 'death'} + } + } + }, + 'healed': { + text: [ + 'the plague is kept from spreading.', + 'only a few die.', + 'the rest bury them.' + ], + onLoad: function() { + var numKilled = Math.floor(Math.random() * 5) + 2; + Outside.killVillagers(numKilled); + }, + buttons: { + 'end': { + text: 'go home', + nextScene: 'end' + } + } + }, + 'death': { + text: [ + 'the plague rips through the village.', + 'the nights are rent with screams.', + 'the only hope is a quick death.' + ], + onLoad: function() { + var numKilled = Math.floor(Math.random() * 80) + 10; + Outside.killVillagers(numKilled); + }, + buttons: { + 'end': { + text: 'go home', + nextScene: 'end' + } + } + } + } + }, + { /* Beast attack */ title: 'A Beast Attack', isAvailable: function() { diff --git a/script/events/room.js b/script/events/room.js index aebe941..d88ca44 100644 --- a/script/events/room.js +++ b/script/events/room.js @@ -502,5 +502,89 @@ Events.Room = [ } } } + }, + + { /* The Sick Man */ + title: 'The Sick Man', + isAvailable: function() { + return Engine.activeModule == Room && typeof State.world == 'object'; + }, + scenes: { + 'start': { + text: [ + "a man hobbles up, coughing.", + "he begs you for medicine." + ], + notification: 'a sick man hobbles up', + buttons: { + 'help': { + text: 'give 1 medicine', + cost: { 'medicine': 1 }, + notification: 'the man swallows the medicine eagerly', + nextScene: { 0.1: 'alloy', 0.3: 'cells', 0.5: 'scales', 1.0: 'nothing' } + }, + 'ignore': { + text: 'tell him to leave', + nextScene: 'end' + } + } + }, + 'alloy': { + text: [ + "the man thanks you and gives you a reward.", + 'some weird metal he picked up on his travels.' + ], + onLoad: function() { + Engine.addStore('alien alloy', 1); + }, + buttons: { + 'bye': { + text: 'say goodbye', + nextScene: 'end' + } + } + }, + 'cells': { + text: [ + "the man thanks you and gives you a reward.", + 'some weird glowing boxes he picked up on his travels.' + ], + onLoad: function() { + Engine.addStore('energy cell', 3); + }, + buttons: { + 'bye': { + text: 'say goodbye', + nextScene: 'end' + } + } + }, + 'scales': { + text: [ + "the man thanks you and gives you a reward.", + 'all he has are some scales.' + ], + onLoad: function() { + Engine.addStore('scales', 5); + }, + buttons: { + 'bye': { + text: 'say goodbye', + nextScene: 'end' + } + } + }, + 'nothing': { + text: [ + "the man thanks you and hobbles off." + ], + buttons: { + 'bye': { + text: 'say goodbye', + nextScene: 'end' + } + } + } + } } -] \ No newline at end of file +]; \ No newline at end of file diff --git a/script/events/setpieces.js b/script/events/setpieces.js index cd675bd..0e42f51 100644 --- a/script/events/setpieces.js +++ b/script/events/setpieces.js @@ -583,7 +583,7 @@ Events.Setpieces = { buttons: { 'enter': { text: 'enter', - nextScene: {0.5: 'b5', 1: 'c7'}, + nextScene: {0.5: 'b5', 1: 'end5'}, cost: {torch: 1} }, 'leave': { @@ -765,7 +765,7 @@ Events.Setpieces = { buttons: { 'continue': { text: 'continue', - nextScene: {0.3: 'c7', 1: 'c8'} + nextScene: {0.3: 'end5', 1: 'end6'} }, 'leave': { text: 'leave town', @@ -930,37 +930,6 @@ Events.Setpieces = { } } }, - 'c7': { - text: [ - 'you search the clinic and find some medicine abandoned in the drawers.' - ], - loot: { - 'medicine': { - min: 2, - max: 5, - chance: 1 - } - }, - buttons: { - 'leave': { - text: 'leave town', - nextScene: 'end' - } - } - }, - 'c8': { - text: [ - 'the clinic has been ransacked.', - 'only dust and stains remain.' - ], - loot: {}, - buttons: { - 'leave': { - text: 'leave town', - nextScene: 'end' - } - } - }, 'd1': { combat: true, enemy: 'scavenger', @@ -1178,6 +1147,42 @@ Events.Setpieces = { nextScene: 'end' } } + }, + 'end5': { + text: [ + 'you search the clinic and find some medicine abandoned in the drawers.' + ], + onLoad: function() { + World.clearDungeon(); + }, + loot: { + 'medicine': { + min: 2, + max: 5, + chance: 1 + } + }, + buttons: { + 'leave': { + text: 'leave town', + nextScene: 'end' + } + } + }, + 'end6': { + text: [ + 'the clinic has been ransacked.', + 'only dust and stains remain.' + ], + onLoad: function() { + World.clearDungeon(); + }, + buttons: { + 'leave': { + text: 'leave town', + nextScene: 'end' + } + } } } }, @@ -2202,7 +2207,7 @@ Events.Setpieces = { buttons: { 'continue': { text: 'continue', - nextScene: 'end14' + nextScene: {1: 'end14'} } } }, @@ -2227,7 +2232,7 @@ Events.Setpieces = { buttons: { 'continue': { text: 'continue', - nextScene: 'end13' + nextScene: {1: 'end13'} } } }, diff --git a/script/path.js b/script/path.js index 41c9369..85cb52d 100644 --- a/script/path.js +++ b/script/path.js @@ -156,7 +156,8 @@ var Path = { 'laser rifle': {type: 'weapon' }, 'energy cell': {type: 'tool' }, 'bayonet': {type: 'weapon' }, - 'charm': {type: 'tool'} + 'charm': {type: 'tool'}, + 'medicine': {type: 'tool'} }, Room.Craftables); for(var k in carryable) { diff --git a/script/world.js b/script/world.js index 9c74d80..8793b00 100644 --- a/script/world.js +++ b/script/world.js @@ -815,7 +815,7 @@ var World = { }, leaveItAtHome: function(thing) { - return thing != 'cured meat' && thing != 'bullets' && thing != 'energy cell' && thing != 'charm' + return thing != 'cured meat' && thing != 'bullets' && thing != 'energy cell' && thing != 'charm' && thing != 'medicine' && typeof World.Weapons[thing] == 'undefined' && typeof Room.Craftables[thing] == 'undefined'; },