public static IProjectile FireProjectile(Entity creator, Rigidbody projectilePrefab, Transform fireTransform, Vector3 destination, float secondsToFlyHorizontalMeter) { // EARLY OUT! // if (creator == null || projectilePrefab == null || fireTransform == null) { return(null); } // Create an instance of the shell and store a reference to it's rigidbody. Rigidbody projectileRigidbody = Utils.Instantiate(projectilePrefab, fireTransform.position, fireTransform.rotation); projectileRigidbody.transform.SetParent(SL.Get <GameModel>().BoardRoot.transform, worldPositionStays: true); Vector3 velocity = CombatUtils.CalculateVelocityToHit( fireTransform.position, destination, secondsToFlyHorizontalMeter); projectileRigidbody.AddForce(velocity, ForceMode.VelocityChange); var projectile = projectileRigidbody.gameObject.GetInterface <IProjectile>(); if (projectile != null) { projectile.Init(creator); } else { Debug.LogWarning("Problem with the projectile setup."); } return(projectile); }
private void OnTriggerEnter(Collider other) { // EARLY OUT! // // If the trigger isn't on an impact layer, ignore it. if (_isCollided || !CombatUtils.IsProjectileCollider(other.gameObject.layer)) { return; } // EARLY OUT! // // If the collider is a friendly entity, early out. if (CombatUtils.IsEntity(other.gameObject.layer) && !CombatUtils.IsEnemy(_creator.Owner, other)) { return; } _isCollided = true; var card = SL.Get <Config>().GetCardByName(_entityToSpawn); if (card != null) { card.SpawnChargeSeconds = 0; var unit = Entity.SpawnFromDefinition(_creator.Owner, card, transform.position.ZeroY(), isFromPlayersHand: false); _creator.Owner.RotateForPlayer(unit.gameObject); } else { Debug.LogWarning("Can't find card: " + card.Name); } // Destroy the shell. Destroy(gameObject); }
public AmeisenObjectManager(AmeisenDataHolder ameisenDataHolder, AmeisenDBManager ameisenDBManager) { AmeisenDataHolder = ameisenDataHolder; AmeisenDBManager = ameisenDBManager; RefreshObjects(); AmeisenDataHolder.Partymembers = CombatUtils.GetPartymembers(Me, ActiveWoWObjects); }
public void HandleAttacking() { if (Me != null) { Me.Update(); } if (Target != null) { Target.Update(); } Unit unitToAttack = Target; // Get a target if (Me.TargetGuid == 0) { unitToAttack = CombatUtils.AssistParty(Me, AmeisenDataHolder.ActiveWoWObjects); } if (unitToAttack != null) { // Start autoattack if (!Me.InCombat) { CombatUtils.FaceTarget(Me, unitToAttack); CombatUtils.AttackTarget(); } DoAttackRoutine(); } }
public Entity[] GetEnemiesInRange(PlayerModel enemyPlayer, float radius) { // Collect all the colliders in a capsule of the given radius covering all units on the y axis. Vector3 bottom, top; CombatUtils.GetCapsulePointsFromPosition(transform.position, out bottom, out top); Collider[] colliders = Physics.OverlapCapsule(bottom, top, radius, CombatUtils.EntityMask); List <Entity> entities = new List <Entity>(); for (int i = 0; i < colliders.Length; i++) { Entity targetEntity = colliders[i].GetComponent <Entity> (); // If there is no entity script attached to the gameobject, go on to the next collider. if (targetEntity != null) { // If it's an enemy unit, do damage to it. if (targetEntity.Owner == enemyPlayer) { entities.Add(targetEntity); } } } return(entities.ToArray()); }
protected override void BasicCast() { hero.GainEnergy(energyGained); Enemy target = gameController.stage.getActiveEnemies()[0]; CombatUtils.DealDamage(caster, target, baseDamage); }
private void onInit() { // EARLY OUT! // if (_entity == null) { return; } var owner = _entity.Owner; if (owner != null && owner.HQ != null) { var fireTransform = owner.HQ.transform.Find("FireTransform"); if (fireTransform != null) { // Fire a projectile to this position. var projectile = CombatUtils.FireProjectile(_entity, _projectile, fireTransform, transform.position, _secondsToFlyHorizontalMeter); if (projectile != null) { // Change the clip to the firing clip and play it. _shootingAudio.clip = _fireClip; _shootingAudio.Play(); projectile.DestroyedEvent.AddListener(onProjectileDestroyed); } } } }
public override void ActionUpdate(float timekey) { timer += timekey; if (timer > spawnDelay && !projectileSpawned) { // apply damage Vector3 spawnPoint = character.transform.position + character.transform.TransformDirection(projectileSpawn); projectileInstance = GameObject.Instantiate(projectile); projectileInstance.transform.position = spawnPoint; projectileInstance.character = character; projectileInstance.velocity = velocity; projectileSpawned = true; } if (timer > spawnDelay + timeOfFlight) { projectileInstance.Destroy(); Destructible destructible = target.GetComponent <Destructible>(); if (destructible != null) { destructible.Damage(CombatUtils.GetDamageToDestructible(destructible, baseDamage * damageModifer)); } Done(); } }
void Update() { if (_entity.IsSpawned) { _agent.speed = _entity.MovementSpeed; CombatUtils.MoveToAggroTarget(_entity, _aggro.Target, this); } }
void FixedUpdate() { // If we aren't navigating but we have an aggro target, we should still rotate towards the target. // This is needed for targeting. Should it be part of it's own component? We'll see when we get // to static building defenses where this should go. if (_aggro.Target != null && !_isNavigating) { CombatUtils.RotateTowards(transform, _aggro.Target.transform); } }
/// <summary> /// Should this unit be affected by this spell? /// </summary> private bool isAffectedEntity(PlayerModel friendly, Entity target) { if (_isAffectingFriendlies) { return(!CombatUtils.IsEnemy(friendly, target)); } else { return(CombatUtils.IsEnemy(friendly, target)); } }
private void applyEffects() { if (effect != null) { GameObject instance = GameObject.Instantiate(effect); instance.transform.position = targetSelf ? character.position : target.position; } destructible.Damage(CombatUtils.GetDamageToDestructible(destructible, weapon.baseDamage * damageModifier)); target.AddBuffs(buffs); }
private Spell TryUseSpell(string spellname, Me me) { Spell spellToUse = Spells.Where(spell => spell.Name == spellname).FirstOrDefault(); if (spellToUse == null) { return null; } if (me.Mana < spellToUse.Costs) { return null; } if (CombatUtils.GetSpellCooldown(spellToUse.Name) < 0) { return spellToUse; } return null; }
public void HandleBuffs() { List <string> myAuras = CombatUtils.GetAuras(LuaUnit.player); if (!myAuras.Contains("demon armor")) { CombatUtils.CastSpellByName(Me, Target, "Demon Armor", true); } if (!myAuras.Contains("blood pact")) { CombatUtils.CastSpellByName(Me, Target, "Summon Imp", true); } }
public async Task Pull() { inBlock = false; //Log.Info("Rest Called==============="); if (profile.attackTarget) { //PULL Actor target = null; try { target = GameManager.LocalPlayer.CurrentTarget; if (target == null) { target = CombatUtils.ClosestEnemy(true); } if (CombatUtils.ValidateTarget(target)) { } else { return; } CombatUtils.TurnToActor(target); Log.Info("Init Combat to " + target.Name + " Dis:" + (target.Distance / 50)); if ((target.Distance / 50) < profile.gapCloseRange) { Log.Info("Try to PULL Close for range " + (target.Distance / 50)); foreach (SkillInfo skill in profile.skillList.Where(i => i.type.Equals(SkillType.PULL)).ToList()) { if (await CombatUtils.ValidateConditions(skill, target, inBlock)) { _nextSkill = skill; await FireNextSkill(); return; } } } } catch (Exception ex) { //Log.Error("NO TARGET FOUND (pull)= " + ex.Message); } } }
private void OnTriggerEnter(Collider other) { // EARLY OUT! // // If the trigger isn't on an impact layer, ignore it. if (!CombatUtils.IsProjectileCollider(other.gameObject.layer)) { return; } // EARLY OUT! // // If the collider is a friendly entity, early out. if (CombatUtils.IsEntity(other.gameObject.layer) && !CombatUtils.IsEnemy(_owner, other)) { return; } // Collect all the colliders in a sphere from the shell's current position to a radius of the explosion radius. Collider[] colliders = Physics.OverlapSphere(transform.position, _explosionRadius, CombatUtils.EntityMask); for (int i = 0; i < colliders.Length; i++) { Entity targetEntity = colliders[i].GetComponent <Entity> (); // If it's an enemy unit, do damage to it. if (CombatUtils.IsEnemy(_owner, targetEntity)) { targetEntity.TakeDamage(_areaDamage); } } if (_explosionParticlePrefab != null) { var explosion = Utils.Instantiate(_explosionParticlePrefab, transform.position, transform.rotation); // Play the particle system. explosion.Play(); // Once the particles have finished, destroy the gameobject they are on. Destroy(explosion.gameObject, explosion.main.duration); } if (_explosionAudio != null) { // Play the explosion sound effect. _explosionAudio.Play(); } // Destroy the shell. Destroy(gameObject); }
private void triggerEffect() { Vector3 bottom, top; CombatUtils.GetCapsulePointsFromPosition(transform.position, out bottom, out top); // Collect all the colliders in a sphere from the shell's current position to a radius of the explosion radius. Collider[] colliders = Physics.OverlapCapsule(bottom, top, _effectRadius, CombatUtils.EntityMask); _workingSet.Clear(); for (int i = 0; i < colliders.Length; i++) { Entity targetEntity = colliders[i].GetComponent <Entity> (); // If it's an enemy unit, do damage to it. if (isAffectedEntity(_entity.Owner, targetEntity)) { targetEntity.TakeDamage(_entity.AreaAttackDamage); if (!_affectedEntities.Contains(targetEntity)) { foreach (var effect in _effects) { _affectedEntities.Add(targetEntity); targetEntity.ApplyEffect(effect); } } _workingSet.Add(targetEntity); } } var oldList = _affectedEntities; _affectedEntities = new List <Entity>(); foreach (var entity in oldList) { if (!_workingSet.Contains(entity)) { foreach (var effect in _effects) { entity.RemoveEffect(effect); } } else if (entity != null) { _affectedEntities.Add(entity); } } }
private void stealLife(float damage) { Enemy target = gameController.stage.getActiveEnemies()[0]; float damageDealt = CombatUtils.DealDamage(hero, target, damage); if (target.health <= 0) { SetCooldown(0); } IEnumerator coroutine = HealAfterTime(delay, damageDealt, caster); gameController.StartCoroutine(coroutine); }
void Update() { CombatUtils.MoveToAggroTarget(_entity, _aggro.Target, this); if (_isNavigating) { Vector3 dir = (_destination - transform.position).normalized; Vector3 velocity = dir * _entity.MovementSpeed * Time.deltaTime; // Ignore Y position for flying units. velocity.y = 0f; transform.position += velocity; } }
private void DoAttackRoutine() { List <string> targetAuras = CombatUtils.GetAuras(LuaUnit.target); Me?.Update(); // Restore Mana if (Me.EnergyPercentage < 30 && Me.HealthPercentage > 50) { CombatUtils.CastSpellByName(Me, Target, "Life Tap", true); return; } Target?.Update(); // DoT's to apply if (!targetAuras.Contains("curse of agony")) { CombatUtils.CastSpellByName(Me, Target, "Curse of Agony", false); return; } if (!targetAuras.Contains("corruption")) { CombatUtils.CastSpellByName(Me, Target, "Corruption", false); return; } if (!targetAuras.Contains("unstable affliction")) { CombatUtils.CastSpellByName(Me, Target, "Unstable Affliction", false); return; } if (!targetAuras.Contains("haunt")) { CombatUtils.CastSpellByName(Me, Target, "Haunt", false); return; } Target?.Update(); // Active-Damage Spell if (Target?.HealthPercentage < 25) { CombatUtils.CastSpellByName(Me, Target, "Drain Soul", false); return; } else { CombatUtils.CastSpellByName(Me, Target, "Shadow Bolt", false); return; } }
async Task <bool> ExecuteSkill(SkillInfo skillInfo, Actor target) { if (sslist.Contains(skillInfo.skillName)) { return(await ExecuteSS(skillInfo.skillName)); } int castDuration = profile.minCastTime; //Log.Info("Cheking skill: " + skillName); var skill = GameManager.LocalPlayer.GetSkillByName(skillInfo.skillName); if (skill == null) { //Log.Info(skillName + " not available"); return(false); } if (await CombatUtils.BasicSkillCondition(skill, skillInfo, target)) { skill.Cast(); int fullCast = skill.CastDuration; //TODO check if we can anicancel lateron /* * if (skillInfo.channeledSkill) * { * fullCast = skill.Record.ExecDuration1 + skill.Record.ExecDuration2 + skill.Record.ExecDuration3 + skill.Record.ExecDuration4 + skill.Record.ExecDuration5; + + }*/ if (fullCast > castDuration) { castDuration = fullCast; } Log.Warn("+++Casting " + skillInfo.skillName + " with sleep: " + castDuration); await Coroutine.Sleep(castDuration); Log.Info("Done waiting " + castDuration); return(true); } return(false); }
async Task <bool> FireNextSkill() { if (_nextSkill == null) { return(false); } Actor target = GameManager.LocalPlayer.CurrentTarget; try { CombatUtils.TurnToActor(target); } catch (Exception ex) { Log.Info("Problem Turning to Target"); return(false); } if (await ExecuteSkill(_nextSkill, target)) { var skill = GameManager.LocalPlayer.GetSkillByName(_nextSkill.skillName); var castResult = skill.ActorCanCastResult(GameManager.LocalPlayer); var castResultSummon = SkillUseError.Unknown; if (GameManager.SummonedMinion != null && GameManager.SummonedMinion.IsValid) { castResultSummon = skill.ActorCanCastResult(GameManager.SummonedMinion); } Log.Info(_nextSkill.skillName + " CanCast result: " + castResult); if ((castResult <= SkillUseError.None) && (castResultSummon <= SkillUseError.None)) { Log.InfoFormat("Skill {0} didnt fire", _nextSkill.skillName); _nextSkill = null; return(true); } Log.InfoFormat("Skill {0} did fire", _nextSkill.skillName); _currentChain = _nextSkill; _nextSkill = null; return(false); } _nextSkill = null; _currentChain = null; chainPosition = 0; return(false); }
/// <summary> /// Attempt attacks when we detect a rigidbody collision. /// </summary> private void OnTriggerStay(Collider other) { // EARLY OUT! // // If on cooldown don't attack. if (!this.enabled || _cooldownSeconds > 0f) { return; } // EARLY OUT! // // If the trigger isn't an entity, ignore it. if (!CombatUtils.IsEntity(other.gameObject.layer)) { return; } // EARLY OUT! // // If the collider isn't an enemy, ignore it. var target = other.GetComponent <Entity>(); if (!CombatUtils.IsEnemy(_entity.Owner, target)) { return; } bool didAttack = false; // Only attack if the entity is a type that this unit attacks. if (_entity.AttacksGroundUnits || target.IsBuilding) { didAttack = attemptDirectAttack(target); didAttack |= attemptAreaAttack(target); } if (didAttack) { // Reset cooldown. _cooldownSeconds = _entity.AttackSpeed; // Play attack audio if we have any. if (_animator != null) { _animator.Attack(); } } }
public async Task Loot() { //Log.Info("Moving Around"); //await StrafeAround(); //Log.InfoFormat("Player HP {0} MAX HP {1} PCTHP {2}", GameManager.LocalPlayer.Health, GameManager.LocalPlayer.MaxHealth, GameManager.LocalPlayer.HealthPercent); //Log.Info("Heal Called==============="); if (GameManager.LocalPlayer.IsCasting) { await Coroutine.Sleep(100); return; } await CombatUtils.DoLoot(); }
public void ApplyEffect(Point target, Stat casterStats) { switch (AreaOfEffect) { case SpellAreaEffect.Target: Entity poorGuy = GameLoop.World.CurrentMap.GetEntityAt <Entity>(target); if (poorGuy == null) { return; } CombatUtils.DealDamage(Damage, poorGuy, SpellDamageType); if (poorGuy is Item) { // Custom logic here } if (poorGuy is Actor) { // Custom logic here } break; case SpellAreaEffect.Ball: break; case SpellAreaEffect.Shape: break; case SpellAreaEffect.Beam: break; case SpellAreaEffect.Level: break; case SpellAreaEffect.World: throw new NotImplementedException(); default: break; } }
private bool InCombatCheck() { if (Me != null) { if (Me.InCombat || (AmeisenDataHolder.IsAllowedToAssistParty && CombatUtils.GetPartymembersInCombat(Me, AmeisenDataHolder.Partymembers).Count > 0)) { StateMachine.PushAction(BotState.Combat); return(true); } else { StateMachine.PopAction(BotState.Combat); return(false); } } return(false); }
private Spell TryUseSpell(string spellname, Me me) { Spell spellToUse = Spells.Where(spell => spell.Name == spellname).FirstOrDefault(); if (spellToUse == null) { return(null); } if (me.Rage < spellToUse.Costs) { return(null); } if (CombatUtils.GetSpellCooldown(spellToUse.Name) < 0) { IsInMainCombo = false; return(spellToUse); } return(null); }
private void InCombatCheck() { if (Me != null) { if (Me.InCombat || (CombatUtils.PartymembersInCombat(Me, AmeisenDataHolder.ActiveWoWObjects).Count > 0 && AmeisenDataHolder.IsAllowedToAssistParty)) { if (StateMachine.GetCurrentState() != BotState.Idle) { StateMachine.PopAction(); } StateMachine.PushAction(BotState.Combat); } else if (StateMachine.GetCurrentState() == BotState.Combat) { StateMachine.PopAction(); } } }
// Question, will this be sufficient for flying enemies? Or do we want a box check? private Entity[] getAllEnemiesInRange(float radius) { Vector3 bottom, top; CombatUtils.GetCapsulePointsFromPosition(transform.position, out bottom, out top); Collider[] allColliders = Physics.OverlapCapsule(bottom, top, radius, CombatUtils.EntityMask); List <Entity> enemies = new List <Entity>(); foreach (var collider in allColliders) { var entity = collider.GetComponent <Entity>(); // If it's an enemy entity if (entity != null && entity.Owner != _entity.Owner) { enemies.Add(entity); } } return(enemies.ToArray()); }
private bool attemptAreaAttack(Entity target) { bool didAttack = true; // Trigger enter only applies to area attacks. if (target != null && _entity.AreaAttackDamage > 0) { Collider[] colliders = Physics.OverlapSphere(transform.position, _attackRadius, CombatUtils.EntityMask); for (int i = 0; i < colliders.Length; i++) { var areaTarget = colliders[i].GetComponent <Entity>(); if (CombatUtils.IsEnemy(_entity.Owner, areaTarget)) { attack(areaTarget, _entity.AreaAttackDamage); didAttack = true; } } } return(didAttack); }