private void CombatRoutine() { // If enough time has passed since the last attack // Or the aggressor is dead if (WaitForTimer(5) || !Aggressor.IsAlive) { // Stop and forget ClearStatus(); Stop(); return; } // If already has a weapon if (Me.EquipmentSlots[0].Equipped != null && Me.EquipmentSlots[0].Equipped.TagList.HasTag(EntityTags.Weapon)) { // Move towards the aggressor GoTo(Aggressor.Position); // If close enough if (Me.DistanceTo(Aggressor) < 1.5f) { // Use the weapon Me.ActivateEquipment(); } return; } // If a weapon was found if (Focus != null) { // Give up if the weapon was picked up by something else if (Focus.IsChild) { Focus = null; return; } // Move towards the weapon GoTo(Focus.Position); // If in range, equip the weapon if (Focus.Interaction.RunInteraction(Me, Interactions.Equip)) { Focus = null; } return; } // If no weapon was found yet else { // Look for a nearby weapon Focus = Awareness.FindNearest(EntityTags.Weapon); } // If no weapon can be found, flee RunAwayFrom(Aggressor.Position); }