Adjust random logic
This commit is contained in:
parent
8f7c30dca0
commit
f83ddcd81d
|
@ -129,7 +129,7 @@ export class AnimalEntity extends Entity {
|
||||||
this.sprite.setCtor(`${this.sprite.spriteKey}.${this.sprite.animationKey}.${this.sprite.setKey}.${cardinal}.${this.sprite.frameIndex}`)
|
this.sprite.setCtor(`${this.sprite.spriteKey}.${this.sprite.animationKey}.${this.sprite.setKey}.${cardinal}.${this.sprite.frameIndex}`)
|
||||||
}
|
}
|
||||||
if (this.stepSoundElapsed >= 200) {
|
if (this.stepSoundElapsed >= 200) {
|
||||||
let v = 1+Math.round(Math.random()*3)
|
let v = 1 + Math.floor(Math.random() * 3)
|
||||||
playSound('action/footstep-tiny-v'+v, 0.5)
|
playSound('action/footstep-tiny-v'+v, 0.5)
|
||||||
this.stepSoundElapsed = 0
|
this.stepSoundElapsed = 0
|
||||||
}
|
}
|
||||||
|
@ -165,7 +165,7 @@ export class AnimalEntity extends Entity {
|
||||||
while (this.thinkTimer >= 100) {
|
while (this.thinkTimer >= 100) {
|
||||||
if (!this.isMonster) {
|
if (!this.isMonster) {
|
||||||
if (this.seenTarget) {
|
if (this.seenTarget) {
|
||||||
let r = Math.atan2(this.y-this.seenTarget.y, this.x-this.seenTarget.x)
|
let r = Math.atan2(this.y-(this.seenTarget.y+10), this.x-this.seenTarget.x) // FIXME: 10 ain't right son
|
||||||
let a = r * (180 / Math.PI)
|
let a = r * (180 / Math.PI)
|
||||||
if (a < 0) {
|
if (a < 0) {
|
||||||
a += 360
|
a += 360
|
||||||
|
@ -176,6 +176,9 @@ export class AnimalEntity extends Entity {
|
||||||
}
|
}
|
||||||
this.desiredActions = adjustAction([], this.getCardinal(a), 0.85)
|
this.desiredActions = adjustAction([], this.getCardinal(a), 0.85)
|
||||||
this.desiredActions = adjustAction(this.desiredActions, this.getCardinal(Math.random()*360), Math.random())
|
this.desiredActions = adjustAction(this.desiredActions, this.getCardinal(Math.random()*360), Math.random())
|
||||||
|
if (Math.random() > 1 - this.mode.erratic) {
|
||||||
|
this.desiredActions = adjustAction(this.desiredActions, this.getCardinal(Math.random()*360), 1)
|
||||||
|
}
|
||||||
this.yell(1)
|
this.yell(1)
|
||||||
} else if (this.smelledTarget) {
|
} else if (this.smelledTarget) {
|
||||||
let r = Math.atan2(this.y-this.smelledTarget.y, this.x-this.smelledTarget.x)
|
let r = Math.atan2(this.y-this.smelledTarget.y, this.x-this.smelledTarget.x)
|
||||||
|
@ -251,7 +254,7 @@ export class AnimalEntity extends Entity {
|
||||||
if (this.lastYellElapsed > this.nextYell) {
|
if (this.lastYellElapsed > this.nextYell) {
|
||||||
this.nextYell = 500 + Math.random()*3000
|
this.nextYell = 500 + Math.random()*3000
|
||||||
this.lastYellElapsed = 0
|
this.lastYellElapsed = 0
|
||||||
let v = 1+Math.round(Math.random()*2)
|
let v = 1 + Math.floor(Math.random() * 2)
|
||||||
if (this.isMonster) {
|
if (this.isMonster) {
|
||||||
playSound(`monsters/evil-${this.def.name}-v${v}`, volume)
|
playSound(`monsters/evil-${this.def.name}-v${v}`, volume)
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user