func (a *BlowFlag) Do(obj gameObjectsBase.Activer) { if obj.ReadyAttack() { p := obj.GetAttackPoint() if p != nil && !a.field.OutOfRange(int(p.X), int(p.Y)) { for _, actor := range a.field.GetActors(int(p.X), int(p.Y)) { r := actor.GetRectangle() if r.In(p) { obj.SetTarget(actor) break } } // obj.ClearAttackPoint() } if target, exists := obj.GetTarget(); exists || p != nil { msg := obj.Attack() obj.ZeroCooldown() if msg != nil { notifier.GameNotifier.NotifyAboutAttack(obj, target, msg) } } // if target, exists := obj.GetTarget(); exists && target.GetID() != obj.GetID() { // msg := obj.Attack() // obj.ZeroCooldown() // if msg != nil { // notifier.GameNotifier.NotifyAboutAttack(obj, target, msg) // } // } } else { obj.IncCooldownCounter() } }
func (h *HateFlag) Do(obj gameObjectsBase.Activer) { if _, exists := obj.GetTarget(); exists { return } center := obj.GetCenter() lt, rb := h.field.GetSquareArea(center.X, center.Y, obj.GetRadiusVision()) for i := int(lt.Y); i < int(rb.Y); i++ { for j := int(lt.X); j < int(rb.X); j++ { for _, m := range h.field.GetActors(j, i) { if m.GetKind().GetRace() == h.hated && obj.GetID() != m.GetID() { obj.SetTarget(m) return } } } } }