Exemplo n.º 1
0
func (bl *BlowList) ChooseBlowMethod(bt int) fightBase.Blower {
	dice.Shake()
	blow := bl.blows[dice.Throw(len(bl.blows), 1)-1]
	for (bt == fightBase.BT_MELEE && blow.IsRange()) || (bt == fightBase.BT_RANGE && !blow.IsRange()) {
		blow = bl.blows[dice.Throw(len(bl.blows), 1)-1]
	}
	return blow
}
Exemplo n.º 2
0
func (m *Mob) chooseDir() {
	newDir := m.Dir
	for newDir == m.Dir {
		newDir = directions[dice.Throw(4, 1)-1]
	}
	m.Dir = newDir
}
Exemplo n.º 3
0
func (m *Mob) GetHit(blow fightBase.Blower, attacker gameObjectsBase.Activer) consts.JsonType {
	res := m.ActiveObject.GetHit(blow, attacker)
	if t, isExist := m.GetTarget(); isExist {
		if t.GetType() != consts.PLAYER_TYPE {
			if attacker.GetType() == consts.PLAYER_TYPE {
				m.SetTarget(attacker)
			} else {
				dice.Shake()
				ary := [2]gameObjectsBase.Activer{t, attacker}
				m.SetTarget(ary[dice.Throw(2, 1)-1])
			}
		}
	} else {
		m.SetTarget(attacker)
	}
	return res
}
Exemplo n.º 4
0
func (m *Mob) goToTarget() {
	target := m.Target.GetCenter()
	dx := target.X - m.Center.X
	dy := target.Y - m.Center.Y
	eps := 0.2
	if dice.Throw(4, 1)%2 == 0 {
		if math.Abs(dx) > eps {
			m.chooseHorizontalDir(dx)
		} else {
			m.chooseVerticalDir(dy)
		}
	} else {
		if math.Abs(dy) > eps {
			m.chooseVerticalDir(dy)
		} else {
			m.chooseHorizontalDir(dx)
		}
	}
}
Exemplo n.º 5
0
func (dd *DmgDescription) GetDamage() int {
	dice.Shake()
	return dice.Throw(dd.edge_amount, dd.throws_amount)
}