浏览代码

Healing over time happens on the creature side. Added priority for attacks

tags/v0.2.8
Fen Dweller 7 年前
父节点
当前提交
2bddf4bb26
共有 3 个文件被更改,包括 44 次插入14 次删除
  1. +24
    -12
      combat.js
  2. +8
    -2
      feast.js
  3. +12
    -0
      vore.js

+ 24
- 12
combat.js 查看文件

@@ -25,7 +25,8 @@ function punchAttack(attacker) {
return "The " + attacker.description() + " punches you for " + attack(attacker, defender, attacker.str) + " damage";
}, requirements: [
function(attacker, defender) { return isNormal(attacker) && isNormal(defender); }
]
],
priority: 1,
};
}

@@ -40,7 +41,8 @@ function flankAttack(attacker) {
return "The " + attacker.description() + " runs past you, then turns and hits you for " + attack(attacker, defender, attacker.str) + " damage";
}, requirements: [
function(attacker, defender) { return isNormal(attacker) && isNormal(defender); }
]
],
priority: 1,
};
}

@@ -68,7 +70,8 @@ function grapple(attacker) {
},
requirements: [
function(attacker, defender) { return isNormal(attacker) && isNormal(defender); }
]
],
priority: 1,
};
}

@@ -100,7 +103,8 @@ function grappleDevour(attacker) {
function(attacker, defender) { return isNormal(attacker) && isGrappled(defender); }
], conditions: [
function(prefs, player=false) { return player || prefs.player.prey; }
]
],
priority: 1,
};
}

@@ -122,7 +126,8 @@ function grappleAnalVore(attacker) {
function(attacker, defender) { return isNormal(attacker) && isGrappled(defender); }
], conditions: [
function(prefs, player=false) { return player || prefs.player.prey; }
]
],
priority: 1,
};
}

@@ -135,7 +140,8 @@ function grappleRelease(attacker) {
return "You throw the " + defender.description() + " back, dealing " + attack(attacker, defender, attacker.str*1.5) + " damage";
}, requirements: [
function(attacker, defender) { return isNormal(attacker) && isGrappled(defender); }
]
],
priority: 1,
};
}

@@ -163,7 +169,8 @@ function grappledStruggle(attacker) {
},
requirements: [
function(attacker, defender) { return isGrappled(attacker) && isNormal(defender); }
]
],
priority: 1,
};
}

@@ -176,7 +183,8 @@ function pass(attacker) {
},
attackPlayer: function(defender) {
return "The " + attacker.description() + " does nothing.";
}
},
priority: 0,
};
}

@@ -193,7 +201,8 @@ function devourPlayer(attacker) {
attackPlayer: function(defender) {
changeMode("eaten");
return "The voracious " + attacker.description() + " pins you down and devours you in seconds.";
}
},
priority: 1,
};
}

@@ -207,7 +216,8 @@ function leer(attacker) {
},
requirements: [
function(attacker, defender) { return attacker.leering != true && attacker.grappled != true; }
]
],
priority: 1,
};
}

@@ -217,7 +227,8 @@ function poke(attacker) {
desc: "Poke a nerd",
attackPlayer: function(defender) {
return "The " + attacker.description() + " pokes you on the snout for " + attack(attacker, defender, 1e12) + " damage";
}
},
priority: 1,
};
}

@@ -226,6 +237,7 @@ function digestPlayerStomach(predator,damage=20) {
digest: function(player) {
attack(predator, player, damage);
return "The " + predator.description() + "'s stomach grinds over your body, swiftly digesting you.";
}
},
priority: 1,
};
}

+ 8
- 2
feast.js 查看文件

@@ -26,6 +26,11 @@ function filterValid(options, attacker, defender) {
return filtered.filter(option => option.requirements == undefined || option.requirements.reduce((result, test) => result && test(attacker, defender), true));
}

function filterPriority(options) {
let max = options.reduce((max, option) => option.priority > max ? option.priority : max, -1000);
return options.filter(option => option.priority == max);
}

function round(number, digits) {
return Math.round(number * Math.pow(10,digits)) / Math.pow(10,digits);
}
@@ -171,7 +176,8 @@ function updateDisplay() {

function advanceTime(amount) {
time = (time + amount) % 86400;
player.health = Math.min(amount * player.maxHealth / 86400 * 12 + player.health, player.maxHealth);
player.restoreHealth(amount);
player.restoreStamina(amount);
update(player.stomach.digest(amount));
update(player.butt.digest(amount));
}
@@ -335,7 +341,7 @@ function attackClicked(index) {
update(["The " + currentFoe.description() + " falls to the ground!"]);
startDialog(new FallenFoe(currentFoe));
} else if (mode == "combat") {
let attack = pick(filterValid(currentFoe.attacks, currentFoe, player));
let attack = pick(filterPriority(filterValid(currentFoe.attacks, currentFoe, player)));

if (attack == null) {
attack = currentFoe.backupAttack;


+ 12
- 0
vore.js 查看文件

@@ -24,6 +24,18 @@ function Creature(name = "Creature", str=10, dex=10, con=10) {
this.health = this.maxHealth;
Object.defineProperty(this, "maxStamina", {get: function() { return this.dex * 5 + this.con * 10 }});
this.stamina = this.maxStamina;

// fraction of max health per second
this.healthRate = 1 / 86400 * 12;
this.staminaRate = 1 / 86400 * 48;

this.restoreHealth = function(time) {
this.health = Math.min(this.maxHealth, this.health + this.maxHealth * time * this.healthRate);
};

this.restoreStamina = function(time) {
this.stamina = Math.min(this.maxStamina, this.stamina + this.maxStamina * time * this.staminaRate);
};
}

function Player(name = "Player") {


正在加载...
取消
保存