From 4641b0b1455f46dacc8eb651e8f89d67830d8377 Mon Sep 17 00:00:00 2001 From: Zarkonnen Date: Mon, 8 Jul 2013 19:16:16 +0200 Subject: [PATCH 1/5] Initial medicine implementation. Needs more events. --- script/events.js | 45 +++ script/events/encounters.js | 65 ++-- script/events/setpieces.js | 713 ++++++++++++++++++++++++++++++++++-- script/room.js | 8 + script/world.js | 7 +- 5 files changed, 787 insertions(+), 51 deletions(-) diff --git a/script/events.js b/script/events.js index 6219a4c..c47ca4b 100644 --- a/script/events.js +++ b/script/events.js @@ -7,6 +7,7 @@ var Events = { _PANEL_FADE: 200, _FIGHT_SPEED: 100, _EAT_COOLDOWN: 5, + _MEDS_COOLDOWN: 7, STUN_DURATION: 4000, init: function(options) { @@ -103,6 +104,7 @@ var Events = { Events.createAttackButton('fists').prependTo(btns); } + Events.createUseMedsButton().prependTo(btns); Events.createEatMeatButton().prependTo(btns); // Set up the enemy attack timer @@ -129,6 +131,26 @@ var Events = { return btn; }, + createUseMedsButton: function(cooldown) { + if (cooldown == null) { + cooldown = Events._MEDS_COOLDOWN; + } + + var btn = new Button.Button({ + id: 'meds', + text: 'use meds', + cooldown: cooldown, + click: Events.useMeds, + cost: { 'medicine': 1 } + }); + + if(Path.outfit['medicine'] == 0) { + Button.setDisabled(btn, true); + } + + return btn; + }, + createAttackButton: function(weaponName) { var weapon = World.Weapons[weaponName]; var cd = weapon.cooldown; @@ -192,6 +214,28 @@ var Events = { } }, + useMeds: function() { + if(Path.outfit['medicine'] > 0) { + Path.outfit['medicine']--; + World.updateSupplies(); + if(Path.outfit['medicine'] == 0) { + Button.setDisabled($('#meds'), true); + } + + var hp = World.health; + hp += World.medsHeal(); + hp = hp > World.getMaxHealth() ? World.getMaxHealth() : hp; + World.setHp(hp); + + if(Events.activeEvent()) { + var w = $('#wanderer'); + w.data('hp', hp); + Events.updateFighterDiv(w); + Events.drawFloatText('+' + World.medsHeal(), '#wanderer .hp'); + } + } + }, + useWeapon: function(btn) { if(Events.activeEvent()) { var weaponName = btn.attr('id').substring(7).replace('-', ' '); @@ -426,6 +470,7 @@ var Events = { }).appendTo(btns); Events.createEatMeatButton(0).appendTo(btns); + Events.createUseMedsButton(0).appendTo(btns); } } catch(e) { // It is possible to die and win if the timing is perfect. Just let it fail. diff --git a/script/events/encounters.js b/script/events/encounters.js index 891f48d..5286948 100644 --- a/script/events/encounters.js +++ b/script/events/encounters.js @@ -169,11 +169,16 @@ Events.Encounters = [ max: 10, chance: 0.8 }, - 'iron': { - min: 1, - max: 5, - chance: 0.5 - } + 'iron': { + min: 1, + max: 5, + chance: 0.5 + }, + 'medicine': { + min: 1, + max: 2, + chance: 0.1 + } }, notification: 'a scavenger draws close, hoping for an easy score' } @@ -271,16 +276,21 @@ Events.Encounters = [ max: 10, chance: 0.8 }, - 'bullets': { - min: 1, - max: 5, - chance: 0.5 - }, - 'rifle': { - min: 1, - max: 1, - chance: 0.2 - } + 'bullets': { + min: 1, + max: 5, + chance: 0.5 + }, + 'rifle': { + min: 1, + max: 1, + chance: 0.2 + }, + 'medicine': { + min: 1, + max: 2, + chance: 0.1 + } }, notification: 'a soldier opens fire from across the desert' } @@ -307,16 +317,21 @@ Events.Encounters = [ max: 10, chance: 0.8 }, - 'bullets': { - min: 1, - max: 5, - chance: 0.5 - }, - 'rifle': { - min: 1, - max: 1, - chance: 0.2 - } + 'bullets': { + min: 1, + max: 5, + chance: 0.5 + }, + 'rifle': { + min: 1, + max: 1, + chance: 0.2 + }, + 'medicine': { + min: 1, + max: 2, + chance: 0.1 + } }, notification: 'a shot rings out, from somewhere in the long grass' } diff --git a/script/events/setpieces.js b/script/events/setpieces.js index af55075..5759b02 100644 --- a/script/events/setpieces.js +++ b/script/events/setpieces.js @@ -210,6 +210,11 @@ Events.Setpieces = { min: 1, max: 3, chance: 0.5 + }, + 'medicine': { + min: 1, + max: 2, + chance: 0.1 } }, buttons: { @@ -444,6 +449,11 @@ Events.Setpieces = { min: 1, max: 3, chance: 0.3 + }, + 'medicine': { + min: 1, + max: 4, + chance: 0.15 } }, onLoad: function() { @@ -470,7 +480,12 @@ Events.Setpieces = { min: 1, max: 3, chance: 0.5 - } + }, + 'medicine': { + min: 1, + max: 3, + chance: 0.3 + } }, onLoad: function() { World.clearDungeon(); @@ -496,7 +511,7 @@ Events.Setpieces = { buttons: { 'enter': { text: 'explore', - nextScene: {0.5: 'a1', 1: 'a2'} + nextScene: {0.3: 'a1', 0.7: 'a3', 1: 'a2'} }, 'leave': { text: 'leave', @@ -522,6 +537,7 @@ Events.Setpieces = { } } }, + 'a2': { combat: true, enemy: 'thug', @@ -559,6 +575,23 @@ Events.Setpieces = { } } }, + 'a3': { + text: [ + "a squat building up ahead.", + 'a green cross barely visible behind grimy windows.' + ], + buttons: { + 'enter': { + text: 'enter', + nextScene: {0.5: 'b5', 1: 'c7'}, + cost: {torch: 1} + }, + 'leave': { + text: 'leave town', + nextScene: 'end' + } + } + }, 'b1': { text: [ 'a small cache of supplies is tucked inside a rusting locker.' @@ -578,7 +611,12 @@ Events.Setpieces = { min: 1, max: 5, chance: 0.3 - } + }, + 'medicine': { + min: 1, + max: 3, + chance: 0.05 + } }, buttons: { 'continue': { @@ -610,11 +648,11 @@ Events.Setpieces = { max: 10, chance: 0.8 }, - 'cured meat': { - min: 1, - max: 5, - chance: 0.5 - } + 'cured meat': { + min: 1, + max: 5, + chance: 0.5 + } }, notification: 'a scavenger waits just inside the door.', buttons: { @@ -680,6 +718,11 @@ Events.Setpieces = { min: 1, max: 5, chance: 0.3 + }, + 'medicine': { + min: 1, + max: 3, + chance: 0.1 } }, buttons: { @@ -693,6 +736,43 @@ Events.Setpieces = { } } }, + 'b2': { + combat: true, + enemy: 'madman', + char: 'M', + damage: 6, + hit: 0.3, + attackDelay: 1, + health: 10, + loot: { + 'cloth': { + min: 2, + max: 4, + chance: 0.3 + }, + 'cured meat': { + min: 1, + max: 5, + chance: 0.9 + }, + 'medicine': { + min: 1, + max: 2, + chance: 0.4 + } + }, + notification: 'a madman attacks, screeching.', + buttons: { + 'continue': { + text: 'continue', + nextScene: {0.3: 'c7', 1: 'c8'} + }, + 'leave': { + text: 'leave town', + nextScene: 'end' + } + } + }, 'c1': { combat: true, enemy: 'thug', @@ -850,6 +930,37 @@ 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', @@ -906,11 +1017,11 @@ Events.Setpieces = { max: 10, chance: 0.8 }, - 'steel sword': { - min: 1, - max: 1, - chance: 0.5 - } + 'steel sword': { + min: 1, + max: 1, + chance: 0.5 + } }, notification: "a man stands over a dead wanderer. notices he's not alone.", buttons: { @@ -952,6 +1063,11 @@ Events.Setpieces = { min: 1, max: 5, chance: 0.5 + }, + 'medicine': { + min: 1, + max: 2, + chance: 0.3 } }, buttons: { @@ -1049,6 +1165,11 @@ Events.Setpieces = { min: 1, max: 5, chance: 0.5 + }, + 'medicine': { + min: 1, + max: 2, + chance: 0.1 } }, buttons: { @@ -1129,6 +1250,22 @@ Events.Setpieces = { } } }, + 'a4': { + text: [ + 'the shell of an abandoned hospital looms ahead.' + ], + buttons: { + 'enter' { + text: 'enter', + cost: { 'torch': 1 }, + nextScene: {0.5: 'b7', 1: 'b8'} + } + 'leave': { + text: 'leave city', + nextScene: 'end' + } + } + }, 'b1': { text: [ 'the old tower seems mostly intact.', @@ -1274,16 +1411,21 @@ Events.Setpieces = { max: 5, chance: 0.8 }, - 'cloth': { - min: 1, - max: 5, - chance: 0.5 - }, - 'leather': { - min: 1, - max: 1, - chance: 0.2 - } + 'cloth': { + min: 1, + max: 5, + chance: 0.5 + }, + 'leather': { + min: 1, + max: 1, + chance: 0.2 + }, + 'medicine': { + min: 1, + max: 3, + chance: 0.05 + } }, buttons: { 'continue': { @@ -1311,6 +1453,59 @@ Events.Setpieces = { nextScene: 'end' } } + }, + 'b7': { + text: [ + 'empty corridors.', + 'the place has been swept clean by scavengers.' + ], + buttons: { + 'continue': { + text: 'continue', + nextScene: {0.3: 'c12', 0.7: 'c10', 1: 'c11'} + }, + 'leave': { + text: 'leave city', + nextScene: 'end' + } + } + }, + 'b8': { + notification: 'an old man bursts through a door, wielding a scalpel.', + combat: true, + enemy: 'old man', + char: 'M', + damage: 3, + hit: 0.5, + attackDelay: 2, + health: 10, + loot: { + 'cured meat': { + min: 1, + max: 3, + chance: 0.5 + }, + 'cloth': { + min: 1, + max: 5, + chance: 0.8 + }, + 'medicine': { + min: 1, + max: 2, + chance: 0.5 + } + }, + buttons: { + 'continue': { + text: 'continue', + nextScene: {0.3: 'c13', 0.7: 'c11', 1: 'end15'} + }, + 'leave': { + text: 'leave city', + nextScene: 'end' + } + } }, 'c1': { notification: 'a thug is waiting on the other side of the wall.', @@ -1501,6 +1696,11 @@ Events.Setpieces = { min: 1, max: 1, chance: 0.01 + }, + 'medicine': { + min: 1, + max: 4, + chance: 0.5 } }, buttons: { @@ -1539,6 +1739,123 @@ Events.Setpieces = { } }, + 'c10': { + text: [ + 'someone has locked and barricaded the door to this operating theatre.' + ], + buttons: { + 'enter': { + text: 'continue', + nextScene: {0.2: 'end12', 0.6: 'd10', 1: 'd11'} + }, + 'leave': { + text: 'leave city', + nextScene: 'end' + } + } + }, + + 'c11': { + notification: 'a tribe of elderly squatters is camped out in this ward.', + combat: true, + enemy: 'squatters', + plural: true, + char: 'SSS', + damage: 2, + hit: 0.7, + attackDelay: 0.5, + health: 40, + loot: { + 'cured meat': { + min: 1, + max: 3, + chance: 0.5 + }, + 'cloth': { + min: 3, + max: 8, + chance: 0.8 + }, + 'medicine': { + min: 1, + max: 3, + chance: 0.3 + } + }, + buttons: { + 'continue': { + text: 'continue', + nextScene: 'end10' + }, + 'leave': { + text: 'leave city', + nextScene: 'end' + } + } + }, + + 'c12': { + notification: 'a pack of lizards rounds the corner.', + combat: true, + enemy: 'lizards', + plural: true, + char: 'LLL', + damage: 4, + hit: 0.7, + attackDelay: 0.7, + health: 30, + loot: { + 'meat': { + min: 3, + max: 8, + chance: 1 + }, + 'teeth': { + min: 2, + max: 4, + chance: 1 + }, + 'scales': { + min: 3, + max: 5, + chance: 1 + } + }, + buttons: { + 'continue': { + text: 'continue', + nextScene: 'end10' + }, + 'leave': { + text: 'leave city', + nextScene: 'end' + } + } + }, + + 'c13': { + text: [ + 'strips of meat are hung up to dry in this ward.' + ], + loot: { + 'cured meat': { + min: 3, + max: 10, + chance: 1 + } + }, + buttons: { + 'continue': { + text: 'continue', + nextScene: { 0.5: 'end10', 1: 'end11' } + }, + 'leave': { + text: 'leave city', + nextScene: 'end' + } + } + }, + 'd1': { notification: 'a large bird nests at the top of the stairs.', combat: true, @@ -1850,6 +2167,70 @@ Events.Setpieces = { } } }, + + 'd10': { + notification: 'as you prise open the door, a deformed figure awakes and attacks.', + combat: true, + enemy: 'deformed', + char: 'D', + damage: 8, + hit: 0.6, + attackDelay: 2, + health: 40, + loot: { + 'cloth': { + min: 1, + max: 5, + chance: 0.8 + }, + 'teeth': { + min: 2, + max: 2, + chance: 1 + }, + 'steel': { + min: 1, + max: 3, + chance: 0.6 + }, + 'scales': { + min: 2, + max: 3, + chance: 0.1 + } + }, + buttons: { + 'continue': { + text: 'continue', + nextScene: 'end14' + } + } + }, + + 'd11': { + notification: 'as soon as the door is open a little bit, hundreds of tentacles erupt.', + combat: true, + enemy: 'tentacles', + plural: true, + char: 'TTT', + damage: 2, + hit: 0.6, + attackDelay: 0.5, + health: 60, + loot: { + 'meat': { + min: 10, + max: 20, + chance: 1 + } + }, + buttons: { + 'continue': { + text: 'continue', + nextScene: 'end13' + } + } + }, 'end1': { text: [ @@ -2020,6 +2401,11 @@ Events.Setpieces = { min: 1, max: 5, chance: 0.8 + }, + 'medicine': { + min: 1, + max: 4, + chance: 0.1 } }, buttons: { @@ -2173,7 +2559,262 @@ Events.Setpieces = { nextScene: 'end' } } - } + }, + + 'end10': { + text: [ + 'the stench of rot and death fills the operating theatres.', + "a few items are scattered on the ground.", + 'there is nothing else here.' + ], + onLoad: function() { + World.clearDungeon(); + State.cityCleared = true; + }, + loot: { + 'energy cell': { + min: 1, + max: 1, + chance: 0.3 + }, + 'medicine': { + min: 1, + max: 5, + chance: 0.3 + }, + 'teeth': { + min: 3, + max: 8, + chance: 1 + }, + 'scales': { + min: 4, + max: 7, + chance: 0.9 + } + }, + buttons: { + 'leave': { + text: 'leave city', + nextScene: 'end' + } + } + }, + + 'end11': { + text: [ + 'at the end of a hallway you find a pristine medicine cabinet.', + "the rest of the hospital is empty." + ], + onLoad: function() { + World.clearDungeon(); + State.cityCleared = true; + }, + loot: { + 'energy cell': { + min: 1, + max: 1, + chance: 0.2 + }, + 'medicine': { + min: 3, + max: 10, + chance: 1 + }, + 'teeth': { + min: 1, + max: 2, + chance: 0.2 + } + }, + buttons: { + 'leave': { + text: 'leave city', + nextScene: 'end' + } + } + }, + + 'end12': { + text: [ + 'someone had been stockpiling loot here.' + ], + onLoad: function() { + World.clearDungeon(); + State.cityCleared = true; + }, + loot: { + 'energy cell': { + min: 1, + max: 3, + chance: 0.2 + }, + 'medicine': { + min: 3, + max: 10, + chance: 0.5 + }, + 'bullets': { + min: 2, + max: 8, + chance: 1 + }, + 'torch': { + min: 1, + max: 3, + chance: 0.5 + }, + 'grenade': { + min: 1, + max: 1, + chance: 0.5 + }, + 'alien alloy': { + min: 1, + max: 2, + chance: 0.8 + } + }, + buttons: { + 'leave': { + text: 'leave city', + nextScene: 'end' + } + } + }, + + 'end13': { + text: [ + 'the tentacular horror is defeated.', + 'you wade into the operating theatre.', + 'the remains of its victims are everywhere.' + ], + onLoad: function() { + World.clearDungeon(); + State.cityCleared = true; + }, + loot: { + 'steel sword': { + min: 1, + max: 3, + chance: 0.5 + }, + 'rifle': { + min: 1, + max: 2, + chance: 0.3 + }, + 'teeth': { + min: 2, + max: 8, + chance: 1 + }, + 'cloth': { + min: 3, + max: 6, + chance: 0.5 + }, + 'alien alloy': { + min: 1, + max: 1, + chance: 0.1 + } + }, + buttons: { + 'leave': { + text: 'leave city', + nextScene: 'end' + } + } + }, + + 'end14': { + text: [ + 'the warped man lies dead.', + 'you examine the operating theatre.', + 'a lot of curious equipment.' + ], + onLoad: function() { + World.clearDungeon(); + State.cityCleared = true; + }, + loot: { + 'energy cell': { + min: 2, + max: 5, + chance: 0.8 + }, + 'medicine': { + min: 3, + max: 12, + chance: 1 + }, + 'cloth': { + min: 1, + max: 3, + chance: 0.5 + }, + 'steel': { + min: 2, + max: 3, + chance: 0.3 + }, + 'alien alloy': { + min: 1, + max: 1, + chance: 0.3 + } + }, + buttons: { + 'leave': { + text: 'leave city', + nextScene: 'end' + } + } + }, + + 'end15': { + text: [ + 'the old man had a small cache of interesting items.' + ], + onLoad: function() { + World.clearDungeon(); + State.cityCleared = true; + }, + loot: { + 'alien alloy': { + min: 1, + max: 1, + chance: 0.8 + }, + 'medicine': { + min: 1, + max: 4, + chance: 1 + }, + 'cured meat': { + min: 3, + max: 7, + chance: 1 + }, + 'bolas': { + min: 1, + max: 3, + chance: 0.5 + }, + 'fur': { + min: 1, + max: 5, + chance: 0.8 + } + }, + buttons: { + 'leave': { + text: 'leave city', + nextScene: 'end' + } + } + }, } }, "house": { /* Abandoned House */ @@ -2188,7 +2829,7 @@ Events.Setpieces = { buttons: { 'enter': { text: 'go inside', - nextScene: { 0.5: 'supplies', 1: 'occupied' } + nextScene: { 0.25: 'medicine', 0.5: 'supplies', 1: 'occupied' } }, 'leave': { text: 'leave', @@ -2230,6 +2871,28 @@ Events.Setpieces = { } } }, + 'supplies': { + text: [ + 'the house has been ransacked.' + 'but there is a cache of medicine under the floorboards.', + ], + onLoad: function() { + World.markVisited(World.curPos[0], World.curPos[1]); + }, + loot: { + 'medicine': { + min: 2, + max: 5, + chance: 1 + } + }, + buttons: { + 'leave': { + text: 'leave', + nextScene: 'end' + } + } + }, 'occupied': { combat: true, enemy: 'squatter', diff --git a/script/room.js b/script/room.js index 6b2e27f..d77c1a8 100644 --- a/script/room.js +++ b/script/room.js @@ -349,6 +349,14 @@ var Room = { } } }, + 'medicine': { + type: 'good', + cost: function() { + return { + 'scales': 50, 'teeth': 30 + } + } + }, 'bullets': { type: 'good', cost: function() { diff --git a/script/world.js b/script/world.js index 46f1a5b..9c74d80 100644 --- a/script/world.js +++ b/script/world.js @@ -31,7 +31,8 @@ var World = { FIGHT_CHANCE: 0.20, BASE_HEALTH: 10, BASE_HIT_CHANCE: 0.8, - MEAT_HEAL: 10, + MEAT_HEAL: 8, + MEDS_HEAL: 20, FIGHT_DELAY: 3, // At least three moves between fights NORTH: [ 0, -1], SOUTH: [ 0, 1], @@ -447,6 +448,10 @@ var World = { return World.MEAT_HEAL * (Engine.hasPerk('gastronome') ? 2 : 1); }, + medsHeal: function() { + return World.MEDS_HEAL; + }, + checkFight: function() { World.fightMove = typeof World.fightMove == 'number' ? World.fightMove : 0; World.fightMove++; From 4334f36e572b71617faa2291a45f0d1199befee4 Mon Sep 17 00:00:00 2001 From: Zarkonnen Date: Mon, 8 Jul 2013 21:39:28 +0200 Subject: [PATCH 2/5] Bugfixes. --- script/events.js | 10 +++++++--- script/events/setpieces.js | 12 ++++++------ 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/script/events.js b/script/events.js index c47ca4b..ca84240 100644 --- a/script/events.js +++ b/script/events.js @@ -104,7 +104,9 @@ var Events = { Events.createAttackButton('fists').prependTo(btns); } - Events.createUseMedsButton().prependTo(btns); + if((Path.outfit['medicine'] || 0) != 0) { + Events.createUseMedsButton().prependTo(btns); + } Events.createEatMeatButton().prependTo(btns); // Set up the enemy attack timer @@ -144,7 +146,7 @@ var Events = { cost: { 'medicine': 1 } }); - if(Path.outfit['medicine'] == 0) { + if((Path.outfit['medicine'] || 0) == 0) { Button.setDisabled(btn, true); } @@ -470,7 +472,9 @@ var Events = { }).appendTo(btns); Events.createEatMeatButton(0).appendTo(btns); - Events.createUseMedsButton(0).appendTo(btns); + if((Path.outfit['medicine'] || 0) != 0) { + Events.createUseMedsButton(0).appendTo(btns); + } } } catch(e) { // It is possible to die and win if the timing is perfect. Just let it fail. diff --git a/script/events/setpieces.js b/script/events/setpieces.js index 5759b02..cd675bd 100644 --- a/script/events/setpieces.js +++ b/script/events/setpieces.js @@ -736,7 +736,7 @@ Events.Setpieces = { } } }, - 'b2': { + 'b5': { combat: true, enemy: 'madman', char: 'M', @@ -1255,11 +1255,11 @@ Events.Setpieces = { 'the shell of an abandoned hospital looms ahead.' ], buttons: { - 'enter' { + 'enter': { text: 'enter', cost: { 'torch': 1 }, nextScene: {0.5: 'b7', 1: 'b8'} - } + }, 'leave': { text: 'leave city', nextScene: 'end' @@ -2871,10 +2871,10 @@ Events.Setpieces = { } } }, - 'supplies': { + 'medicine': { text: [ - 'the house has been ransacked.' - 'but there is a cache of medicine under the floorboards.', + 'the house has been ransacked.', + 'but there is a cache of medicine under the floorboards.' ], onLoad: function() { World.markVisited(World.curPos[0], World.curPos[1]); From bb953de92b8725856533ed8fa2ba2eaf8000d30b Mon Sep 17 00:00:00 2001 From: Zarkonnen Date: Wed, 10 Jul 2013 12:53:28 +0200 Subject: [PATCH 3/5] 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'; }, From d4034fe244cda205488522d825b1589cbfc9216e Mon Sep 17 00:00:00 2001 From: Zarkonnen Date: Wed, 10 Jul 2013 15:10:43 +0200 Subject: [PATCH 4/5] Fixed hospital never occurring in city. --- script/events/setpieces.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/script/events/setpieces.js b/script/events/setpieces.js index 0e42f51..a4b676c 100644 --- a/script/events/setpieces.js +++ b/script/events/setpieces.js @@ -1199,7 +1199,7 @@ Events.Setpieces = { buttons: { 'enter': { text: 'explore', - nextScene: {0.4: 'a1', 0.8: 'a2', 1: 'a3'} + nextScene: {0.2: 'a1', 0.5: 'a2', 0.8: 'a3', 1: 'a4'} }, 'leave': { text: 'leave', From 3515cbf75f1ef50e526b947b86fc6110054c2bc0 Mon Sep 17 00:00:00 2001 From: Zarkonnen Date: Wed, 10 Jul 2013 20:50:42 +0200 Subject: [PATCH 5/5] Removed mentions of "you". --- script/events/room.js | 19 +++++++++++-------- script/events/setpieces.js | 12 +++++------- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/script/events/room.js b/script/events/room.js index d88ca44..246ff06 100644 --- a/script/events/room.js +++ b/script/events/room.js @@ -215,7 +215,7 @@ Events.Room = [ scales: { reward: { scales: 20 }, text: [ - 'the beggar thanks you.', + 'the beggar expresses his thanks.', 'leaves a pile of small scales behind.' ], buttons: { @@ -228,7 +228,7 @@ Events.Room = [ teeth: { reward: { teeth: 20 }, text: [ - 'the beggar thanks you.', + 'the beggar expresses his thanks.', 'leaves a pile of small teeth behind.' ], buttons: { @@ -241,7 +241,7 @@ Events.Room = [ cloth: { reward: { cloth: 20 }, text: [ - 'the beggar thanks you.', + 'the beggar expresses his thanks.', 'leaves some scraps of cloth behind.' ], buttons: { @@ -513,7 +513,7 @@ Events.Room = [ 'start': { text: [ "a man hobbles up, coughing.", - "he begs you for medicine." + "he begs for medicine." ], notification: 'a sick man hobbles up', buttons: { @@ -531,7 +531,8 @@ Events.Room = [ }, 'alloy': { text: [ - "the man thanks you and gives you a reward.", + "the man is thankful.", + 'he leaves a reward.', 'some weird metal he picked up on his travels.' ], onLoad: function() { @@ -546,7 +547,8 @@ Events.Room = [ }, 'cells': { text: [ - "the man thanks you and gives you a reward.", + "the man is thankful.", + 'he leaves a reward.', 'some weird glowing boxes he picked up on his travels.' ], onLoad: function() { @@ -561,7 +563,8 @@ Events.Room = [ }, 'scales': { text: [ - "the man thanks you and gives you a reward.", + "the man is thankful.", + 'he leaves a reward.', 'all he has are some scales.' ], onLoad: function() { @@ -576,7 +579,7 @@ Events.Room = [ }, 'nothing': { text: [ - "the man thanks you and hobbles off." + "the man expresses his thanks and hobbles off." ], buttons: { 'bye': { diff --git a/script/events/setpieces.js b/script/events/setpieces.js index a4b676c..79681a4 100644 --- a/script/events/setpieces.js +++ b/script/events/setpieces.js @@ -1150,7 +1150,7 @@ Events.Setpieces = { }, 'end5': { text: [ - 'you search the clinic and find some medicine abandoned in the drawers.' + 'some medicine abandoned in the drawers.' ], onLoad: function() { World.clearDungeon(); @@ -2174,7 +2174,7 @@ Events.Setpieces = { }, 'd10': { - notification: 'as you prise open the door, a deformed figure awakes and attacks.', + notification: 'behind the door, a deformed figure awakes and attacks.', combat: true, enemy: 'deformed', char: 'D', @@ -2608,7 +2608,7 @@ Events.Setpieces = { 'end11': { text: [ - 'at the end of a hallway you find a pristine medicine cabinet.', + 'a pristine medicine cabinet at the end of a hallway.', "the rest of the hospital is empty." ], onLoad: function() { @@ -2691,8 +2691,7 @@ Events.Setpieces = { 'end13': { text: [ 'the tentacular horror is defeated.', - 'you wade into the operating theatre.', - 'the remains of its victims are everywhere.' + 'inside, the remains of its victims are everywhere.' ], onLoad: function() { World.clearDungeon(); @@ -2736,8 +2735,7 @@ Events.Setpieces = { 'end14': { text: [ 'the warped man lies dead.', - 'you examine the operating theatre.', - 'a lot of curious equipment.' + 'the operating theatre has a lot of curious equipment.' ], onLoad: function() { World.clearDungeon();