Q immortailty mod randomizes mods now
This commit is contained in:
@@ -5,7 +5,6 @@
|
|||||||
add a key that player picks up and needs to set on the exit door to open it
|
add a key that player picks up and needs to set on the exit door to open it
|
||||||
|
|
||||||
add Boss levels
|
add Boss levels
|
||||||
|
|
||||||
|
|
||||||
add modular difficulty settings
|
add modular difficulty settings
|
||||||
take reduced dmg
|
take reduced dmg
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ const level = {
|
|||||||
// b.giveGuns("all", 1000)
|
// b.giveGuns("all", 1000)
|
||||||
// b.giveGuns(9) // set a starting gun for testing
|
// b.giveGuns(9) // set a starting gun for testing
|
||||||
// mech.fieldUpgrades[2].effect(); //give a field power up for testing
|
// mech.fieldUpgrades[2].effect(); //give a field power up for testing
|
||||||
// b.giveMod(8)
|
// b.giveMod(7)
|
||||||
|
|
||||||
this.intro(); //starting level
|
this.intro(); //starting level
|
||||||
// this.testingMap();
|
// this.testingMap();
|
||||||
|
|||||||
65
js/player.js
65
js/player.js
@@ -359,12 +359,34 @@ const mech = {
|
|||||||
alive: true,
|
alive: true,
|
||||||
death() {
|
death() {
|
||||||
if (b.modIsImmortal) { //if player has the immortality buff, spawn on the same level with randomized stats
|
if (b.modIsImmortal) { //if player has the immortality buff, spawn on the same level with randomized stats
|
||||||
//remove mods
|
|
||||||
b.setModDefaults();
|
|
||||||
game.updateModHUD();
|
|
||||||
spawn.setSpawnList(); //new mob types
|
spawn.setSpawnList(); //new mob types
|
||||||
game.clearNow = true; //triggers a map reset
|
game.clearNow = true; //triggers a map reset
|
||||||
|
|
||||||
|
//count mods
|
||||||
|
let totalMods = -2; //lose the immortality mod and one more, so -2
|
||||||
|
for (let i = 0; i < b.mods.length; i++) {
|
||||||
|
if (b.mods[i].have) totalMods++
|
||||||
|
}
|
||||||
|
|
||||||
|
function randomizeMods() {
|
||||||
|
b.setModDefaults(); //remove all mods
|
||||||
|
for (let i = 0; i < totalMods; i++) {
|
||||||
|
//find what mods I don't have
|
||||||
|
let options = [];
|
||||||
|
for (let i = 0; i < b.mods.length; i++) {
|
||||||
|
if (!b.mods[i].have) options.push(i);
|
||||||
|
}
|
||||||
|
//add a new mods
|
||||||
|
if (options.length > 0) {
|
||||||
|
const choose = Math.floor(Math.random() * options.length)
|
||||||
|
let newMod = options[choose]
|
||||||
|
b.giveMod(newMod)
|
||||||
|
options.splice(choose, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
game.updateModHUD();
|
||||||
|
}
|
||||||
|
|
||||||
function randomizeField() {
|
function randomizeField() {
|
||||||
if (game.levelsCleared > 5 && Math.random() < 0.9) {
|
if (game.levelsCleared > 5 && Math.random() < 0.9) {
|
||||||
mech.fieldUpgrades[Math.floor(Math.random() * (mech.fieldUpgrades.length))].effect();
|
mech.fieldUpgrades[Math.floor(Math.random() * (mech.fieldUpgrades.length))].effect();
|
||||||
@@ -396,7 +418,7 @@ const mech = {
|
|||||||
//randomize ammo
|
//randomize ammo
|
||||||
for (let i = 0, len = b.inventory.length; i < len; i++) {
|
for (let i = 0, len = b.inventory.length; i < len; i++) {
|
||||||
if (b.guns[b.inventory[i]].ammo !== Infinity) {
|
if (b.guns[b.inventory[i]].ammo !== Infinity) {
|
||||||
b.guns[b.inventory[i]].ammo = Math.max(0, Math.floor(5 * b.guns[b.inventory[i]].ammo * (Math.random() - 0.25)))
|
b.guns[b.inventory[i]].ammo = Math.max(0, Math.floor(6 * b.guns[b.inventory[i]].ammo * (Math.random() - 0.3)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
game.makeGunHUD(); //update gun HUD
|
game.makeGunHUD(); //update gun HUD
|
||||||
@@ -406,16 +428,17 @@ const mech = {
|
|||||||
ctx.fillStyle = "rgba(255,255,255,0)";
|
ctx.fillStyle = "rgba(255,255,255,0)";
|
||||||
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
||||||
}
|
}
|
||||||
|
randomizeMods()
|
||||||
randomizeGuns()
|
randomizeGuns()
|
||||||
randomizeField()
|
randomizeField()
|
||||||
randomizeHealth()
|
randomizeHealth()
|
||||||
for (let i = 0; i < 7; i++) {
|
for (let i = 0; i < 6; i++) {
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
|
randomizeMods()
|
||||||
randomizeGuns()
|
randomizeGuns()
|
||||||
randomizeField()
|
randomizeField()
|
||||||
randomizeHealth()
|
randomizeHealth()
|
||||||
game.makeTextLog(`probability amplitude will synchronize in ${7-i} seconds`, 1000);
|
game.makeTextLog(`probability amplitude will synchronize in ${6-i} seconds`, 1000);
|
||||||
game.wipe = function () { //set wipe to have trails
|
game.wipe = function () { //set wipe to have trails
|
||||||
ctx.fillStyle = `rgba(255,255,255,${(i+1)*(i+1)*0.003})`;
|
ctx.fillStyle = `rgba(255,255,255,${(i+1)*(i+1)*0.003})`;
|
||||||
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
||||||
@@ -718,11 +741,16 @@ const mech = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
drawField() {
|
drawField() {
|
||||||
//draw field
|
if (mech.holdingTarget) {
|
||||||
|
ctx.fillStyle = "rgba(110,170,200," + (mech.fieldMeter * (0.05 + 0.05 * Math.random())) + ")";
|
||||||
|
ctx.strokeStyle = "rgba(110, 200, 235, " + (0.3 + 0.08 * Math.random()) + ")" //"#9bd" //"rgba(110, 200, 235, " + (0.5 + 0.1 * Math.random()) + ")"
|
||||||
|
} else {
|
||||||
|
ctx.fillStyle = "rgba(110,170,200," + (0.02 + mech.fieldMeter * (0.15 + 0.15 * Math.random())) + ")";
|
||||||
|
ctx.strokeStyle = "rgba(110, 200, 235, " + (0.6 + 0.2 * Math.random()) + ")" //"#9bd" //"rgba(110, 200, 235, " + (0.5 + 0.1 * Math.random()) + ")"
|
||||||
|
}
|
||||||
const range = this.grabRange - 20;
|
const range = this.grabRange - 20;
|
||||||
ctx.beginPath();
|
ctx.beginPath();
|
||||||
ctx.arc(mech.pos.x, mech.pos.y, range, mech.angle - Math.PI * mech.fieldArc, mech.angle + Math.PI * mech.fieldArc, false);
|
ctx.arc(mech.pos.x, mech.pos.y, range, mech.angle - Math.PI * mech.fieldArc, mech.angle + Math.PI * mech.fieldArc, false);
|
||||||
ctx.strokeStyle = "#9bd" //"rgba(110, 200, 235, " + (0.5 + 0.1 * Math.random()) + ")"
|
|
||||||
ctx.lineWidth = 2;
|
ctx.lineWidth = 2;
|
||||||
ctx.lineCap = "butt"
|
ctx.lineCap = "butt"
|
||||||
ctx.stroke();
|
ctx.stroke();
|
||||||
@@ -736,14 +764,8 @@ const mech = {
|
|||||||
cp1x = mech.pos.x + 0.6 * range * Math.cos(a)
|
cp1x = mech.pos.x + 0.6 * range * Math.cos(a)
|
||||||
cp1y = mech.pos.y + 0.6 * range * Math.sin(a)
|
cp1y = mech.pos.y + 0.6 * range * Math.sin(a)
|
||||||
ctx.quadraticCurveTo(cp1x, cp1y, mech.pos.x + 1 * range * Math.cos(mech.angle - Math.PI * mech.fieldArc), mech.pos.y + 1 * range * Math.sin(mech.angle - Math.PI * mech.fieldArc))
|
ctx.quadraticCurveTo(cp1x, cp1y, mech.pos.x + 1 * range * Math.cos(mech.angle - Math.PI * mech.fieldArc), mech.pos.y + 1 * range * Math.sin(mech.angle - Math.PI * mech.fieldArc))
|
||||||
// ctx.lineTo(mech.pos.x + eye * Math.cos(mech.angle), mech.pos.y + eye * Math.sin(mech.angle));
|
|
||||||
|
|
||||||
if (mech.holdingTarget) {
|
|
||||||
ctx.fillStyle = "rgba(110,170,200," + (mech.fieldMeter * (0.05 + 0.05 * Math.random())) + ")";
|
|
||||||
} else {
|
|
||||||
ctx.fillStyle = "rgba(110,170,200," + (0.02 + mech.fieldMeter * (0.15 + 0.15 * Math.random())) + ")";
|
|
||||||
}
|
|
||||||
ctx.fill();
|
ctx.fill();
|
||||||
|
// ctx.lineTo(mech.pos.x + eye * Math.cos(mech.angle), mech.pos.y + eye * Math.sin(mech.angle));
|
||||||
|
|
||||||
//draw random lines in field for cool effect
|
//draw random lines in field for cool effect
|
||||||
let offAngle = mech.angle + 1.7 * Math.PI * mech.fieldArc * (Math.random() - 0.5);
|
let offAngle = mech.angle + 1.7 * Math.PI * mech.fieldArc * (Math.random() - 0.5);
|
||||||
@@ -755,8 +777,7 @@ const mech = {
|
|||||||
ctx.lineWidth = 1;
|
ctx.lineWidth = 1;
|
||||||
ctx.stroke();
|
ctx.stroke();
|
||||||
},
|
},
|
||||||
grabPowerUp() {
|
grabPowerUp() { //look for power ups to grab with field
|
||||||
//look for power ups to grab
|
|
||||||
if (mech.fieldCDcycle < mech.cycle) {
|
if (mech.fieldCDcycle < mech.cycle) {
|
||||||
const grabPowerUpRange2 = (this.grabRange + 220) * (this.grabRange + 220)
|
const grabPowerUpRange2 = (this.grabRange + 220) * (this.grabRange + 220)
|
||||||
for (let i = 0, len = powerUp.length; i < len; ++i) {
|
for (let i = 0, len = powerUp.length; i < len; ++i) {
|
||||||
@@ -785,8 +806,7 @@ const mech = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
pushMobs() {
|
pushMobs() { // push all mobs in range and in direction looking
|
||||||
// push all mobs in range
|
|
||||||
for (let i = 0, len = mob.length; i < len; ++i) {
|
for (let i = 0, len = mob.length; i < len; ++i) {
|
||||||
if (this.lookingAt(mob[i]) && Matter.Vector.magnitude(Matter.Vector.sub(mob[i].position, this.pos)) < this.grabRange && Matter.Query.ray(map, mob[i].position, this.pos).length === 0) {
|
if (this.lookingAt(mob[i]) && Matter.Vector.magnitude(Matter.Vector.sub(mob[i].position, this.pos)) < this.grabRange && Matter.Query.ray(map, mob[i].position, this.pos).length === 0) {
|
||||||
const fieldBlockCost = Math.max(0.02, mob[i].mass * 0.012) //0.012
|
const fieldBlockCost = Math.max(0.02, mob[i].mass * 0.012) //0.012
|
||||||
@@ -811,8 +831,7 @@ const mech = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
pushMobs360(range = this.grabRange * 0.75) {
|
pushMobs360(range = this.grabRange * 0.75) { // push all mobs in range in any direction
|
||||||
// push all mobs in range
|
|
||||||
for (let i = 0, len = mob.length; i < len; ++i) {
|
for (let i = 0, len = mob.length; i < len; ++i) {
|
||||||
if (Matter.Vector.magnitude(Matter.Vector.sub(mob[i].position, this.pos)) < range && Matter.Query.ray(map, mob[i].position, this.pos).length === 0) {
|
if (Matter.Vector.magnitude(Matter.Vector.sub(mob[i].position, this.pos)) < range && Matter.Query.ray(map, mob[i].position, this.pos).length === 0) {
|
||||||
const fieldBlockCost = Math.max(0.02, mob[i].mass * 0.012)
|
const fieldBlockCost = Math.max(0.02, mob[i].mass * 0.012)
|
||||||
@@ -928,7 +947,7 @@ const mech = {
|
|||||||
},
|
},
|
||||||
hold() {},
|
hold() {},
|
||||||
fieldText() {
|
fieldText() {
|
||||||
game.makeTextLog(`<strong style='font-size:30px;'>${mech.fieldUpgrades[mech.fieldMode].name}</strong><br><span class='faded'>(right click or space bar)</span><br><br>${mech.fieldUpgrades[mech.fieldMode].description}`, 1000);
|
game.makeTextLog(`<div class="circle field "></div> <strong style='font-size:30px;'>${mech.fieldUpgrades[mech.fieldMode].name}</strong><br><span class='faded'>(right click or space bar)</span><br><br>${mech.fieldUpgrades[mech.fieldMode].description}`, 1000);
|
||||||
document.getElementById("field").innerHTML = mech.fieldUpgrades[mech.fieldMode].name //add field
|
document.getElementById("field").innerHTML = mech.fieldUpgrades[mech.fieldMode].name //add field
|
||||||
},
|
},
|
||||||
fieldUpgrades: [{
|
fieldUpgrades: [{
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ const powerUps = {
|
|||||||
let heal = (this.size / 40) ** 2
|
let heal = (this.size / 40) ** 2
|
||||||
heal = Math.min(1 - mech.health, heal)
|
heal = Math.min(1 - mech.health, heal)
|
||||||
mech.addHealth(heal);
|
mech.addHealth(heal);
|
||||||
if (!game.lastLogTime && heal > 0) game.makeTextLog("<span style='font-size:220;'> <span class='color-h'>heal</span> " + (heal * 100).toFixed(0) + "%</span>", 300)
|
if (!game.lastLogTime && heal > 0) game.makeTextLog("<span style='font-size:115%;'> <strong class='color-h' style = 'letter-spacing: 2px;'>heal</strong> " + (heal * 100).toFixed(0) + "%</span>", 300)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
ammo: {
|
ammo: {
|
||||||
@@ -41,13 +41,13 @@ const powerUps = {
|
|||||||
}
|
}
|
||||||
if (target.ammo === Infinity) {
|
if (target.ammo === Infinity) {
|
||||||
mech.fieldMeter = 1;
|
mech.fieldMeter = 1;
|
||||||
if (!game.lastLogTime) game.makeTextLog("<span style='font-size:200;'><span class='color-f'>+energy</span></span>", 300);
|
if (!game.lastLogTime) game.makeTextLog("<span style='font-size:115%;'><span class='color-f'>+energy</span></span>", 300);
|
||||||
} else {
|
} else {
|
||||||
//ammo given scales as mobs take more hits to kill
|
//ammo given scales as mobs take more hits to kill
|
||||||
const ammo = Math.ceil((target.ammoPack * (0.6 + 0.04 * Math.random())) / b.dmgScale);
|
const ammo = Math.ceil((target.ammoPack * (0.6 + 0.04 * Math.random())) / b.dmgScale);
|
||||||
target.ammo += ammo;
|
target.ammo += ammo;
|
||||||
game.updateGunHUD();
|
game.updateGunHUD();
|
||||||
if (!game.lastLogTime) game.makeTextLog("<span style='font-size:200;'>+" + ammo + " ammo for " + target.name + "</span>", 300);
|
if (!game.lastLogTime) game.makeTextLog("<span style='font-size:110%;'>+" + ammo + " ammo for " + target.name + "</span>", 300);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -91,16 +91,16 @@ const powerUps = {
|
|||||||
}
|
}
|
||||||
//give a random mod from the mods I don't have
|
//give a random mod from the mods I don't have
|
||||||
if (options.length > 0) {
|
if (options.length > 0) {
|
||||||
|
if (options.length === 1) powerUps.haveAllMods = true
|
||||||
let newMod = options[Math.floor(Math.random() * options.length)]
|
let newMod = options[Math.floor(Math.random() * options.length)]
|
||||||
b.giveMod(newMod)
|
b.giveMod(newMod)
|
||||||
game.makeTextLog(`<strong style='font-size:30px;'>${b.mods[newMod].name}</strong><br><br> ${b.mods[newMod].description}`, 1000);
|
game.makeTextLog(`<div class="circle mod"></div> <strong style='font-size:30px;'>${b.mods[newMod].name}</strong><br><br> ${b.mods[newMod].description}`, 1000);
|
||||||
if (options.length < 2) powerUps.haveAllMods = true
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
gun: {
|
gun: {
|
||||||
name: "gun",
|
name: "gun",
|
||||||
color: "#37a",
|
color: "#26a",
|
||||||
size() {
|
size() {
|
||||||
return 35;
|
return 35;
|
||||||
},
|
},
|
||||||
@@ -118,7 +118,7 @@ const powerUps = {
|
|||||||
if (options.length > 0) {
|
if (options.length > 0) {
|
||||||
let newGun = options[Math.floor(Math.random() * options.length)];
|
let newGun = options[Math.floor(Math.random() * options.length)];
|
||||||
if (b.activeGun === null) b.activeGun = newGun //if no active gun switch to new gun
|
if (b.activeGun === null) b.activeGun = newGun //if no active gun switch to new gun
|
||||||
game.makeTextLog(`<strong style='font-size:30px;'>${b.guns[newGun].name}</strong><br><span class='faded'>(left click)</span><br><br>${b.guns[newGun].description}`, 900);
|
game.makeTextLog(`<div class="circle gun "></div> <strong style='font-size:30px;'>${b.guns[newGun].name}</strong><br><span class='faded'>(left click)</span><br><br>${b.guns[newGun].description}`, 900);
|
||||||
b.guns[newGun].have = true;
|
b.guns[newGun].have = true;
|
||||||
b.inventory.push(newGun);
|
b.inventory.push(newGun);
|
||||||
b.guns[newGun].ammo += b.guns[newGun].ammoPack * 2;
|
b.guns[newGun].ammo += b.guns[newGun].ammoPack * 2;
|
||||||
@@ -129,7 +129,7 @@ const powerUps = {
|
|||||||
const ammo = Math.ceil(b.guns[ammoTarget].ammoPack * 2);
|
const ammo = Math.ceil(b.guns[ammoTarget].ammoPack * 2);
|
||||||
b.guns[ammoTarget].ammo += ammo;
|
b.guns[ammoTarget].ammo += ammo;
|
||||||
game.updateGunHUD();
|
game.updateGunHUD();
|
||||||
game.makeTextLog("<span style='font-size:200;'>+" + ammo + " ammo for " + b.guns[ammoTarget].name + "</span>", 300);
|
game.makeTextLog("<span style='font-size:110%;'>+" + ammo + " ammo for " + b.guns[ammoTarget].name + "</span>", 300);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -146,7 +146,7 @@ const powerUps = {
|
|||||||
powerUps.spawn(x, y, "gun");
|
powerUps.spawn(x, y, "gun");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (Math.random() < 0.008 && !powerUps.haveAllMods) {
|
if (Math.random() < 0.007 && !powerUps.haveAllMods) {
|
||||||
powerUps.spawn(x, y, "mod");
|
powerUps.spawn(x, y, "mod");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -160,11 +160,11 @@ const powerUps = {
|
|||||||
powerUps.spawn(x, y, "field")
|
powerUps.spawn(x, y, "field")
|
||||||
} else if (Math.random() < 0.35 && !powerUps.haveAllMods) {
|
} else if (Math.random() < 0.35 && !powerUps.haveAllMods) {
|
||||||
powerUps.spawn(x, y, "mod")
|
powerUps.spawn(x, y, "mod")
|
||||||
} else if (Math.random() < 0.27) {
|
} else if (Math.random() < 0.25) {
|
||||||
powerUps.spawn(x, y, "field");
|
powerUps.spawn(x, y, "field");
|
||||||
} else if (Math.random() < 0.04 * (7 - b.inventory.length)) { //a new gun has a low chance for each not acquired gun to drop
|
} else if (Math.random() < 0.05 * (7 - b.inventory.length)) { //a new gun has a low chance for each not acquired gun to drop
|
||||||
powerUps.spawn(x, y, "gun")
|
powerUps.spawn(x, y, "gun")
|
||||||
} else if (mech.health < 0.5) {
|
} else if (mech.health < 0.6) {
|
||||||
powerUps.spawn(x, y, "heal");
|
powerUps.spawn(x, y, "heal");
|
||||||
} else {
|
} else {
|
||||||
powerUps.spawn(x, y, "ammo");
|
powerUps.spawn(x, y, "ammo");
|
||||||
|
|||||||
30
style.css
30
style.css
@@ -196,12 +196,16 @@ summary {
|
|||||||
user-select: none;
|
user-select: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
em {
|
||||||
|
opacity: 0.7;
|
||||||
|
}
|
||||||
|
|
||||||
.color-f {
|
.color-f {
|
||||||
color: #0bf;
|
color: #0bf;
|
||||||
}
|
}
|
||||||
|
|
||||||
.color-b {
|
.color-b {
|
||||||
color: #023;
|
color: #024;
|
||||||
}
|
}
|
||||||
|
|
||||||
.color-d {
|
.color-d {
|
||||||
@@ -227,6 +231,27 @@ summary {
|
|||||||
font-size: 90%;
|
font-size: 90%;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.circle {
|
||||||
|
width: 25px;
|
||||||
|
height: 25px;
|
||||||
|
border-radius: 50%;
|
||||||
|
display: inline-block;
|
||||||
|
}
|
||||||
|
|
||||||
|
.field {
|
||||||
|
background: #0bf;
|
||||||
|
}
|
||||||
|
|
||||||
|
.mod {
|
||||||
|
background: #96e;
|
||||||
|
}
|
||||||
|
|
||||||
|
.gun {
|
||||||
|
background: #149;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
.box {
|
.box {
|
||||||
padding: 3px 8px 3px 8px;
|
padding: 3px 8px 3px 8px;
|
||||||
border: 2px solid #444;
|
border: 2px solid #444;
|
||||||
@@ -234,9 +259,6 @@ summary {
|
|||||||
background-color: rgba(255, 255, 255, 0.5);
|
background-color: rgba(255, 255, 255, 0.5);
|
||||||
}
|
}
|
||||||
|
|
||||||
em {
|
|
||||||
opacity: 0.7;
|
|
||||||
}
|
|
||||||
|
|
||||||
.wrapper {
|
.wrapper {
|
||||||
display: grid;
|
display: grid;
|
||||||
|
|||||||
Reference in New Issue
Block a user