Add spells, weapon abilities, and durable corpse resurrection
This commit is contained in:
@@ -11,6 +11,8 @@ import (
|
||||
)
|
||||
|
||||
type Projectile struct {
|
||||
Credit *CombatCredit `json:"credit,omitempty"`
|
||||
MovingAura bool `json:"movingAura"`
|
||||
Target string `json:"target"`
|
||||
ID string `json:"id"`
|
||||
Source string `json:"source"`
|
||||
@@ -101,6 +103,9 @@ func (w *World) terrainHit(a, b p.Vec3) (p.Vec3, bool) {
|
||||
return b, false
|
||||
}
|
||||
func (w *World) attack(c *Character, target string) error {
|
||||
if c.PendingCast != nil {
|
||||
return errors.New("finish or cancel the current cast")
|
||||
}
|
||||
if !w.AllowsXP() {
|
||||
return errors.New("combat is unavailable here")
|
||||
}
|
||||
@@ -147,7 +152,7 @@ func (w *World) attack(c *Character, target string) error {
|
||||
c.AttackReadyAt = w.Age() + a.Cooldown
|
||||
c.View.Stamina -= a.Stamina
|
||||
w.dirty = true
|
||||
shot := Projectile{ID: w.combatID("projectile"), Source: c.View.Entity.ID, Player: true, Target: target, Position: from, Destination: to, Attack: a, Power: power}
|
||||
shot := Projectile{Credit: &CombatCredit{Weapon: w.weaponType(c)}, ID: w.combatID("projectile"), Source: c.View.Entity.ID, Player: true, Target: target, Position: from, Destination: to, Attack: a, Power: power}
|
||||
if a.Delivery == "projectile" {
|
||||
w.Projectiles[shot.ID] = &shot
|
||||
w.projectileVisual(shot, "launch", "")
|
||||
@@ -218,6 +223,9 @@ func (w *World) combatHit(shot Projectile, target string) {
|
||||
return
|
||||
}
|
||||
if healing && shot.Player {
|
||||
if shot.Power > 0 && c.View.Entity.HP < c.View.Entity.MaxHP {
|
||||
w.awardCombatCredit(shot)
|
||||
}
|
||||
c.View.Entity.HP = math.Min(c.View.Entity.MaxHP, c.View.Entity.HP+shot.Power)
|
||||
} else if !healing && !shot.Player {
|
||||
w.damageCharacter(c, shot.Power)
|
||||
@@ -235,6 +243,9 @@ func (w *World) combatHit(shot Projectile, target string) {
|
||||
if healing && !shot.Player {
|
||||
w.BossHP = math.Min(w.Balance.BossHp, w.BossHP+shot.Power)
|
||||
} else if !healing && shot.Player {
|
||||
if shot.Power > 0 {
|
||||
w.awardCombatCredit(shot)
|
||||
}
|
||||
w.damageBoss(w.Characters[shot.Source], shot.Power)
|
||||
}
|
||||
w.dirty = true
|
||||
@@ -251,6 +262,9 @@ func (w *World) combatHit(shot Projectile, target string) {
|
||||
if m.Definition != nil {
|
||||
defence = m.Definition.Defence
|
||||
}
|
||||
if shot.Power > defence {
|
||||
w.awardCombatCredit(shot)
|
||||
}
|
||||
m.Entity.HP = math.Max(0, m.Entity.HP-math.Max(0, shot.Power-defence))
|
||||
m.Target = shot.Source
|
||||
if m.Entity.HP == 0 {
|
||||
@@ -341,6 +355,11 @@ func (w *World) updateCombat(dt float64) {
|
||||
w.dirty = true
|
||||
continue
|
||||
}
|
||||
if area.MovingAura {
|
||||
if c := w.Characters[area.Source]; c != nil {
|
||||
area.Position = body(c.View.Entity.Position)
|
||||
}
|
||||
}
|
||||
if w.Age() >= area.NextAt {
|
||||
w.areaPulse(area.Projectile)
|
||||
area.NextAt = w.Age() + area.Attack.Interval
|
||||
|
||||
Reference in New Issue
Block a user