//called from outside only by KinematicEnemy script public virtual void hit(IDamageable objectHit) { objectHit.takeDamage(weapon.Player.Stats.Damage); if(GlobalSettings.bloodSplash && ((Unit)objectHit).GetComponent<ZombieHole>() == null) spawnBloodSplashEffect (((Unit)objectHit).gameObject); deactivate (); }
// Update is called once per frame void Update () { timer += Time.deltaTime; if (shotTarget != null && !shotTarget.IsAlive()) { pointTarget = shotTarget.GetPosition(); shotTarget = null; } if (shotTarget != null) { transform.position = Vector3.Lerp(startPoint, shotTarget.GetPosition(), timer); } else { transform.position = Vector3.Lerp(startPoint, pointTarget, timer); } if (timer > 1f) { if (shotTarget != null) { shotTarget.DoDamage(ShotDamage); } Destroy(this.gameObject); } }
public void Update () { checkTimer += Time.deltaTime; if (currentTarget == null && checkTimer >= checkRate) { checkTimer -= checkRate; DoTargetCheck(); } if (currentTarget != null) { if (!currentTarget.IsAlive() || Vector3.Distance(currentTarget.GetPosition(), transform.position) > Range) { currentTarget = null; } } if (currentTarget != null) { TryShot(); } }
public override void OnHit(Mobile attacker, IDamageable defender, double damageBonus) { base.OnHit(attacker, defender, damageBonus); if(defender is Mobile) ((Mobile)defender).Stam -= Utility.Random(3, 3); // 3-5 points of stamina loss }
public WeaponTargetAction(Ship firer, int weaponIndex, IDamageable target) : base(ActionType.WEAPON_TARGET) { Firer = firer; WeaponIndex = weaponIndex; Target = target; }
public override bool AllowHarmful(Mobile from, IDamageable target) { if (from.Player) from.SendMessage("You may not do that in jail."); return (from.IsStaff()); }
public override TimeSpan OnSwing(Mobile attacker, IDamageable damageable) { // Make sure we've been standing still for .25/.5/1 second depending on Era if (Core.TickCount - attacker.LastMoveTime >= (Core.SE ? 250 : Core.AOS ? 500 : 1000) || (Core.AOS && WeaponAbility.GetCurrentAbility(attacker) is MovingShot)) { bool canSwing = true; if (Core.AOS) { canSwing = (!attacker.Paralyzed && !attacker.Frozen); if (canSwing) { Spell sp = attacker.Spell as Spell; canSwing = (sp == null || !sp.IsCasting || !sp.BlocksMovement); } } #region Dueling if (attacker is PlayerMobile) { PlayerMobile pm = (PlayerMobile)attacker; if (pm.DuelContext != null && !pm.DuelContext.CheckItemEquip(attacker, this)) { canSwing = false; } } #endregion if (canSwing && attacker.HarmfulCheck(damageable)) { attacker.DisruptiveAction(); attacker.Send(new Swing(0, attacker, damageable)); if (OnFired(attacker, damageable)) { if (CheckHit(attacker, damageable)) { OnHit(attacker, damageable); } else { OnMiss(attacker, damageable); } } } attacker.RevealingAction(); return GetDelay(attacker); } attacker.RevealingAction(); return TimeSpan.FromSeconds(0.25); }
public override void Attack( Unit targetUnit, IDamageable hittee ) { if( this.Chance(chanceBleeding) ) { targetUnit.buffs += BuffBook.Bleeding(targetUnit); } }
protected override void OnStart() { this.attacker = parent.GetComponent<IAttacker>(); myPlayer = parent.GetComponent<IDamageable>(); //TODO:ちゃんとインターフェイスに切り分ける mover = parent.GetComponent<PlayerMover>(); }
private void ApplyDamages(IDamageable damageable) { damageable.Damage(damages); ParticleSystem particles = GetComponentInChildren<ParticleSystem>(); if(particles != null){ particles.transform.SetParent(null); particles.enableEmission = false; particles.gameObject.AddComponent<AutoDestroy>().timer = 10f; } Explode(); }
public void Target(IDamageable m) { Mobile mob = m as Mobile; if (!this.Caster.CanSee(m)) { this.Caster.SendLocalizedMessage(500237); // Target can not be seen. } else if (this.CheckHSequence(m)) { SpellHelper.Turn(this.Caster, m); if(mob != null) SpellHelper.CheckReflect((int)this.Circle, this.Caster, ref mob); double damage = 0; if (Core.AOS) { damage = this.GetNewAosDamage(48, 1, 5, m); } else if (mob != null) { damage = Utility.Random(27, 22); if (this.CheckResisted(mob)) { damage *= 0.6; mob.SendLocalizedMessage(501783); // You feel yourself resisting magical energy. } damage *= this.GetDamageScalar(mob); } if (mob != null) { mob.FixedParticles(0x3709, 10, 30, 5052, EffectLayer.LeftFoot); mob.PlaySound(0x208); } else { Effects.SendLocationParticles(m, 0x3709, 10, 30, 5052); Effects.PlaySound(m.Location, m.Map, 0x208); } if (damage > 0) { SpellHelper.Damage(this, m, damage, 0, 100, 0, 0, 0); } } this.FinishSequence(); }
public InternalTimer(MagerySpell spell, Mobile attacker, IDamageable target) : base(TimeSpan.FromSeconds(Core.AOS ? 3.0 : 2.5)) { m_Spell = spell; m_Attacker = attacker; m_Target = target; if (this.m_Spell != null) this.m_Spell.StartDelayedDamageContext(attacker, this); this.Priority = TimerPriority.FiftyMS; }
public override void OnHit(Mobile attacker, IDamageable defender, double damageBonus) { base.OnHit(attacker, defender, damageBonus); if (!Core.AOS && defender is Mobile && this.Poison != null && this.PoisonCharges > 0) { --this.PoisonCharges; if (Utility.RandomDouble() >= 0.5) // 50% chance to poison ((Mobile)defender).ApplyPoison(attacker, this.Poison); } }
public void Add(IDamageable d, Timer t) { Timer oldTimer; if (m_Contexts.TryGetValue(d, out oldTimer)) { oldTimer.Stop(); m_Contexts.Remove(d); } m_Contexts.Add(d, t); }
void Attack() { if(!mobStats.IsDead()){ attackTimer = 0f; damageableTarget.ReceiveDamage(attackDamage); if (damageableTarget.IsDead()) { aggroTarget = null; damageableTarget = null; } } }
internal static void ApplyDamage(IDamageable first, IDamageable second) { KeyValuePair<Type, Type> pair = new KeyValuePair<Type, Type>(first.GetType(), second.GetType()); if (damages.ContainsKey(pair)) { KeyValuePair<int, int> damage = damages[pair]; bool firstKilled = first.ApplyDamage(damage.Key); bool secondKilled = second.ApplyDamage(damage.Value); if (firstKilled) MessageDispatcher.Post(new Kill(first)); if (secondKilled) MessageDispatcher.Post(new Kill(second)); } }
//called from outside only by KinematicEnemy script public override void hit(IDamageable objectHit) { enemiesInRange = Physics2D.OverlapCircleAll(transform.position, explosionRange); foreach(Collider2D e in enemiesInRange) { if (e.tag == "Enemy" && !e.isTrigger) { e.GetComponent<Enemy> ().takeDamage (weapon.Player.Stats.Damage); if(GlobalSettings.bloodSplash) spawnBloodSplashEffect (e.gameObject); } } explosion = BulletsPool.pool.getExplosion (); explosion.transform.position = transform.position; explosion.gameObject.SetActive (true); deactivate (); }
public void Target(IDamageable d) { Mobile m = d as Mobile; if (!this.Caster.CanSee(d)) { this.Caster.SendLocalizedMessage(500237); // Target can not be seen. } else if (this.CheckHSequence(d)) { Mobile source = this.Caster; SpellHelper.Turn(source, d); if(m != null) SpellHelper.CheckReflect((int)this.Circle, ref source, ref m); double damage = 0; if (Core.AOS) { damage = this.GetNewAosDamage(10, 1, 4, d); } else if (m != null) { damage = Utility.Random(4, 4); if (this.CheckResisted(m)) { damage *= 0.75; m.SendLocalizedMessage(501783); // You feel yourself resisting magical energy. } damage *= this.GetDamageScalar(m); } if (damage > 0) { source.MovingParticles(d, 0x36E4, 5, 0, false, false, 3006, 0, 0); source.PlaySound(0x1E5); SpellHelper.Damage(this, d, damage, 0, 100, 0, 0, 0); } } this.FinishSequence(); }
void OnTriggerStay(Collider other) { if (onCoolDown || !other.CompareTag("Player")) return; if (playerDamageComponent == null) playerDamageComponent = other.GetComponent(typeof(IDamageable)) as IDamageable; playerDamageComponent.TakeDirectDamage(m_DamagePerSecond, m_IgnoreArmor); if (m_IsEntraving) other.GetComponent<PlayerController>().Entrave(m_EntraveDuration); onCoolDown = true; Invoke("ReleaseCooldown", 1.1f); }
public void Target(IDamageable m) { if (!this.Caster.CanSee(m)) { this.Caster.SendLocalizedMessage(500237); // Target can not be seen. } else if (this.CheckHSequence(m)) { Mobile source = this.Caster; Mobile target = m as Mobile; SpellHelper.Turn(source, m); if(target != null) SpellHelper.CheckReflect((int)this.Circle, ref source, ref target); double damage = 0; if (Core.AOS) { damage = this.GetNewAosDamage(19, 1, 5, m); } else if (target != null) { damage = Utility.Random(10, 7); if (this.CheckResisted(target)) { damage *= 0.75; target.SendLocalizedMessage(501783); // You feel yourself resisting magical energy. } damage *= this.GetDamageScalar(target); } if (damage > 0) { source.MovingParticles(m, 0x36D4, 7, 0, false, true, 9502, 4019, 0x160); source.PlaySound(Core.AOS ? 0x15E : 0x44B); SpellHelper.Damage(this, m, damage, 0, 100, 0, 0, 0); } } this.FinishSequence(); }
public void Target(IDamageable m) { Mobile mob = m as Mobile; if (!this.Caster.CanSee(m)) { this.Caster.SendLocalizedMessage(500237); // Target can not be seen. } else if (this.CheckHSequence(m)) { SpellHelper.Turn(this.Caster, m); if(mob != null) SpellHelper.CheckReflect((int)this.Circle, this.Caster, ref mob); double damage = 0; if (Core.AOS) { damage = this.GetNewAosDamage(23, 1, 4, m); } else if (mob != null) { damage = Utility.Random(12, 9); if (this.CheckResisted(mob)) { damage *= 0.75; mob.SendLocalizedMessage(501783); // You feel yourself resisting magical energy. } damage *= this.GetDamageScalar(mob); } Effects.SendBoltEffect(m, true, 0); if (damage > 0) { SpellHelper.Damage(this, m, damage, 0, 0, 0, 0, 100); } } this.FinishSequence(); }
public override void Attack( Unit targetUnit, IDamageable hittee ) { ammoLeft--; shotLine.enabled = true; shotLine.SetPosition( 0, barrel.position ); if( hittee is Unit ) { shotLine.SetPosition( 1, targetUnit.spots.torso.position ); } else if( hittee is Obstruction ) { shotLine.SetPosition( 1, ( hittee as Obstruction ).transform.position ); } else { shotLine.SetPosition( 1, targetUnit.spots.torso.position + BaseClass.Randomize( Vector3.one ) ); } StartCoroutine( AttackCoroutine() ); animation.Play( "fire" ); }
public void Attack(IDamageable defenderCharachter) { var msg = new StringBuilder(); msg.AppendFormat("Triggered against {0}: ", ((Atom)defenderCharachter).Name); var tpc = Dice.Throws(20) + Bonus; var defenderCA = defenderCharachter.CA; if (tpc >= defenderCA) { var actualDmg = Damage.CalculateDamage(); msg.AppendFormat("HIT! ({0} vs. {1})", tpc, defenderCA); NotifyListeners(msg.ToString()); defenderCharachter.SufferDamage(actualDmg); } else { msg.AppendFormat("MISSED... ({0} vs. {1})", tpc, defenderCA); NotifyListeners(msg.ToString()); } }
public void Target(IDamageable m) { Mobile defender = m as Mobile; if (!this.Caster.CanSee(m)) { this.Caster.SendLocalizedMessage(500237); // Target can not be seen. } else if (this.Caster.CanBeHarmful(m) && this.CheckSequence()) { Mobile attacker = this.Caster; SpellHelper.Turn(this.Caster, m); if(defender != null) SpellHelper.CheckReflect((int)this.Circle, this.Caster, ref defender); InternalTimer t = new InternalTimer(this, attacker, defender != null ? defender : m); t.Start(); } this.FinishSequence(); }
public virtual int GetNewAosDamage(int bonus, int dice, int sides, bool playerVsPlayer, double scalar, IDamageable damageable) { Mobile target = damageable as Mobile; int damage = Utility.Dice(dice, sides, bonus) * 100; int inscribeSkill = GetInscribeFixed(m_Caster); int scribeBonus = inscribeSkill >= 1000 ? 10 : inscribeSkill / 200; int damageBonus = scribeBonus + (Caster.Int / 10) + SpellHelper.GetSpellDamageBonus(m_Caster, target, CastSkill, playerVsPlayer); int evalSkill = GetDamageFixed(m_Caster); int evalScale = 30 + ((9 * evalSkill) / 100); damage = AOS.Scale(damage, evalScale); damage = AOS.Scale(damage, 100 + damageBonus); damage = AOS.Scale(damage, (int)(scalar * 100)); return(damage / 100); }
//goes through all the AItargets, evaluates how preferable it is to attack the target, //whether the Character can see/hear the target and chooses the most preferable target within //sight/hearing range public void UpdateTargets(Character character) { var prevAiTarget = selectedAiTarget; selectedAiTarget = null; selectedTargetMemory = null; targetValue = 0.0f; UpdateTargetMemories(); foreach (AITarget target in AITarget.List) { if (Level.Loaded != null && target.WorldPosition.Y > Level.Loaded.Size.Y) { continue; } float valueModifier = 0.0f; float dist = 0.0f; Character targetCharacter = target.Entity as Character; //ignore the aitarget if it is the Character itself if (targetCharacter == character) { continue; } if (targetCharacter != null) { if (targetCharacter.IsDead) { if (eatDeadPriority == 0.0f) { continue; } valueModifier = eatDeadPriority; } else if (targetCharacter.SpeciesName == "human") { if (attackHumans == 0.0f) { continue; } valueModifier = attackHumans; } else { EnemyAIController enemy = targetCharacter.AIController as EnemyAIController; if (enemy != null) { if (enemy.combatStrength > combatStrength) { valueModifier = attackStronger; } else if (enemy.combatStrength < combatStrength) { valueModifier = attackWeaker; } else { continue; } } } } else if (target.Entity != null && attackRooms != 0.0f) { IDamageable targetDamageable = target.Entity as IDamageable; if (targetDamageable != null && targetDamageable.Health <= 0.0f) { continue; } //skip the target if it's a room and the character is already inside a sub if (character.AnimController.CurrentHull != null && target.Entity is Hull) { continue; } valueModifier = attackRooms; } if (valueModifier == 0.0f) { continue; } dist = Vector2.Distance(character.WorldPosition, target.WorldPosition); //if the target has been within range earlier, the character will notice it more easily //(i.e. remember where the target was) if (targetMemories.ContainsKey(target)) { dist *= 0.5f; } //ignore target if it's too far to see or hear if (dist > target.SightRange * sight && dist > target.SoundRange * hearing) { continue; } AITargetMemory targetMemory = FindTargetMemory(target); valueModifier = valueModifier * targetMemory.Priority / dist; if (Math.Abs(valueModifier) > Math.Abs(targetValue)) { Vector2 rayStart = character.AnimController.Limbs[0].SimPosition; Vector2 rayEnd = target.SimPosition; if (target.Entity.Submarine != null && character.Submarine == null) { rayStart -= ConvertUnits.ToSimUnits(target.Entity.Submarine.Position); } Body closestBody = Submarine.CheckVisibility(rayStart, rayEnd); Structure closestStructure = (closestBody == null) ? null : closestBody.UserData as Structure; if (selectedAiTarget == null || Math.Abs(valueModifier) > Math.Abs(targetValue)) { selectedAiTarget = target; selectedTargetMemory = targetMemory; targetValue = valueModifier; } } } if (selectedAiTarget != prevAiTarget) { wallAttackPos = Vector2.Zero; } }
public bool Contains(IDamageable d) { return(m_Contexts.ContainsKey(d)); }
public virtual int GetNewAosDamage(int bonus, int dice, int sides, bool playerVsPlayer, double scalar, IDamageable damageable) { Mobile target = damageable as Mobile; int damage = Utility.Dice(dice, sides, bonus) * 100; int damageBonus = 0; int inscribeSkill = GetInscribeFixed(m_Caster); int inscribeBonus = (inscribeSkill + (1000 * (inscribeSkill / 1000))) / 200; damageBonus += inscribeBonus; int intBonus = Caster.Int / 10; damageBonus += intBonus; damageBonus += SpellHelper.GetSpellDamageBonus(m_Caster, target, CastSkill, playerVsPlayer); damage = AOS.Scale(damage, 100 + damageBonus); if (target != null && Feint.Registry.ContainsKey(target) && Feint.Registry[target].Enemy == Caster) { damage -= (int)((double)damage * ((double)Feint.Registry[target].DamageReduction / 100)); } int evalSkill = GetDamageFixed(m_Caster); int evalScale = 30 + ((9 * evalSkill) / 100); damage = AOS.Scale(damage, evalScale); damage = AOS.Scale(damage, (int)(scalar * 100)); #region Skill Mastery SkillMasterySpell spell = SkillMasterySpell.GetHarmfulSpell(Caster, typeof(TribulationSpell)); if (spell != null) { spell.AbsorbDamage(ref damage); } #endregion return(damage / 100); }
public void Swap(GameObject n_enemy) { //enable current enemy c_enemy.transform.parent = null; CapsuleCollider col = c_enemy.GetComponent <CapsuleCollider>(); col.enabled = true; c_rb = c_enemy.GetComponent <Rigidbody>(); c_rb.isKinematic = false; c_rb.useGravity = true; // c_enemy.GetComponent<MeshRenderer>().enabled = true; for (int i = 0; i < c_enemy.transform.childCount - 1; i++) { c_enemy.transform.GetChild(i).GetComponent <SkinnedMeshRenderer>().enabled = true; // } if (dmgScript.Threshold() > 0) { c_enemy.GetComponent <Animator>().enabled = true; // c_enemy.GetComponent <AgentScript>().enabled = true; c_enemy.GetComponent <EnemyPOV>().enabled = true; c_enemy.GetComponent <NavMeshAgent>().enabled = true; } else { col.radius = .2f; c_enemy.transform.Rotate(-2, 0, 0); c_enemy.tag = "Corpse"; } //disable new enemy n_enemy.GetComponent <Collider>().enabled = false; // n_enemy.GetComponent<MeshRenderer>().enabled = false; for (int i = 0; i < c_enemy.transform.childCount - 1; i++) { n_enemy.transform.GetChild(i).GetComponent <SkinnedMeshRenderer>().enabled = false; } c_rb = n_enemy.GetComponent <Rigidbody>(); c_rb.isKinematic = true; c_rb.useGravity = false; var destination = n_enemy.transform.position; var originalPos = player.transform.position; player.transform.position = destination; n_enemy.GetComponent <Animator>().enabled = false; n_enemy.GetComponentInChildren <SkinnedMeshRenderer>().enabled = false; n_enemy.GetComponent <NavMeshAgent>().enabled = false; n_enemy.GetComponent <EnemyPOV>().enabled = false; n_enemy.GetComponent <AgentScript>().enabled = false; ch.peak = 0; if (reorient == true) { print(n_enemy.transform.rotation.eulerAngles.y); player.transform.localEulerAngles = new Vector3(0, n_enemy.transform.rotation.eulerAngles.y, 0); } n_enemy.transform.parent = player.transform; if (dmgScript.Threshold() <= 0) { // dmgScript.Dead(); } c_enemy = n_enemy; dmgScript = c_enemy.GetComponent <IDamageable>(); //gethealth ph.setHealth(n_enemy.GetComponent <EnemyHealth>().currentHealth); // }
public FireBurnsDOT(int damage, IDamageable target) : this(damage) { Target = target; }
public void Remove(IDamageable d) { m_Contexts.Remove(d); }
public override void OnAttack(IDamageable target) { base.OnAttack(target); this.target = target; }
private void Awake() { _damageable = GetComponent <IDamageable>(); _freezable = GetComponent <Freezeable>(); LastFireHitTime = float.NegativeInfinity; }
public override bool DoActionCombat() { IDamageable c = m_Mobile.Combatant; m_Mobile.Warmode = true; if (c == null || c.Deleted || !c.Alive || c is Mobile mobile && mobile.IsDeadBondedPet || !m_Mobile.CanSee(c) || !m_Mobile.CanBeHarmful(c, false) || c.Map != m_Mobile.Map) { // Our combatant is deleted, dead, hidden, or we cannot hurt them // Try to find another combatant if (AcquireFocusMob(m_Mobile.RangePerception, m_Mobile.FightMode, false)) { m_Mobile.DebugSay("Something happened to my combatant, so I am going to fight {0}", m_Mobile.FocusMob.Name); m_Mobile.Combatant = c = m_Mobile.FocusMob; m_Mobile.FocusMob = null; } else { m_Mobile.DebugSay("Something happened to my combatant, and nothing is around. I am on guard."); Action = ActionType.Guard; return(true); } } if (!m_Mobile.InLOS(c)) { if (AcquireFocusMob(m_Mobile.RangePerception, m_Mobile.FightMode, false)) { m_Mobile.Combatant = c = m_Mobile.FocusMob; m_Mobile.FocusMob = null; } } if (!m_Mobile.InRange(c, m_Mobile.RangePerception)) { // They are somewhat far away, can we find something else? if (AcquireFocusMob(m_Mobile.RangePerception, m_Mobile.FightMode, false)) { m_Mobile.Combatant = m_Mobile.FocusMob; m_Mobile.FocusMob = null; } else if (!m_Mobile.InRange(c, m_Mobile.RangePerception * 3)) { m_Mobile.Combatant = null; } c = m_Mobile.Combatant; if (c == null) { m_Mobile.DebugSay("My combatant has fled, so I am on guard"); Action = ActionType.Guard; return(true); } } if (!m_Mobile.Controlled && !m_Mobile.Summoned && m_Mobile.CheckCanFlee()) { m_Mobile.DebugSay("I am going to flee from {0}", c.Name); Action = ActionType.Flee; return(true); } if (m_Mobile.Spell == null && DateTime.UtcNow > m_NextCastTime && m_Mobile.InRange(c, 12)) { // We are ready to cast a spell Spell spell; Mobile toDispel = FindDispelTarget(true); if (m_Mobile.Poisoned) // Top cast priority is cure { m_Mobile.DebugSay("I am going to cure myself"); spell = new CureSpell(m_Mobile, null); } else if (toDispel != null) // Something dispellable is attacking us { m_Mobile.DebugSay("I am going to dispel {0}", toDispel); spell = DoDispel(toDispel); } else if (c is Mobile hMobile && (hMobile.Spell is HealSpell || hMobile.Spell is GreaterHealSpell) && !hMobile.Poisoned) // They have a heal spell out { spell = new BloodOathSpell(m_Mobile, null); } else { spell = ChooseSpell(c); } // Now we have a spell picked // Move first before casting if (toDispel != null) { if (m_Mobile.InRange(toDispel, 10)) { RunFrom(toDispel); } else if (!m_Mobile.InRange(toDispel, 12)) { RunTo(toDispel); } } else if (c is Mobile m) { RunTo(m); } if (spell != null) { spell.Cast(); } TimeSpan delay; if (spell is DispelSpell) { delay = TimeSpan.FromSeconds(m_Mobile.ActiveSpeed); } else { delay = GetDelay(); } m_NextCastTime = DateTime.UtcNow + delay; }
public virtual Spell ChooseSpell(IDamageable c) { Spell spell = CheckCastHealingSpell(); if (spell != null) { return(spell); } if (!(c is Mobile)) { return(null); } Mobile mob = c as Mobile; double damage = (m_Mobile.Skills[SkillName.SpiritSpeak].Value - mob.Skills[SkillName.MagicResist].Value) / 10 + (mob.Player ? 18 : 30); if (damage > c.Hits) { spell = new ManaDrainSpell(m_Mobile, null); } switch (Utility.Random(16)) { case 0: case 1: case 2: // Poison them { m_Mobile.DebugSay("Attempting to BloodOath"); if (!mob.Poisoned) { spell = new BloodOathSpell(m_Mobile, null); } break; } case 3: // Bless ourselves. { m_Mobile.DebugSay("Blessing myself"); spell = new BlessSpell(m_Mobile, null); break; } case 4: case 5: case 6: // Curse them. { m_Mobile.DebugSay("Attempting to curse"); spell = GetRandomCurseSpell(); break; } case 7: // Paralyze them. { m_Mobile.DebugSay("Attempting to paralyze"); if (m_Mobile.Skills[SkillName.Magery].Value > 50.0) { spell = new ParalyzeSpell(m_Mobile, null); } break; } case 8: // Drain mana { m_Mobile.DebugSay("Attempting to drain mana"); spell = GetRandomManaDrainSpell(); break; } case 9: // Blood oath them { m_Mobile.DebugSay("Attempting to blood oath"); if (m_Mobile.Skills[SkillName.Necromancy].Value > 30 && BloodOathSpell.GetBloodOath(mob) != m_Mobile) { spell = new BloodOathSpell(m_Mobile, null); } break; } } return(spell); }
public void RunFrom(IDamageable m) { Run((Direction)((int)m_Mobile.GetDirectionTo(m) - 4) & Direction.Mask); }
/// <summary> /// When called triggers attack /// </summary> public void StartAttack() { if (combatState != PlayerCombatState.None) { return; } hitState = HitState.None; //layerMask = LayerMask.GetMask("Enemy"); RaycastHit hitInfo = new RaycastHit(); RaycastHit enemyHitRay = new RaycastHit(); Vector2 stepSize = new Vector2(2 * rayProps.checkAngles.x / rayProps.steps, 2 * rayProps.checkAngles.y / rayProps.steps); for (float x = -rayProps.checkAngles.x; x <= rayProps.checkAngles.x; x += stepSize.x) { for (float y = -rayProps.checkAngles.y; y <= rayProps.checkAngles.y; y += stepSize.y) { Ray ray = new Ray(transform.position + rayProps.offset, transform.rotation * Quaternion.AngleAxis(y, Vector3.forward) * Quaternion.AngleAxis(x, Vector3.up) * Vector3.forward); if (Physics.Raycast(ray, out hitInfo, rayProps.checkDistance, layerMask)) { if (hitInfo.collider.CompareTag("Shield")) { hitState |= HitState.Shield; } if (hitInfo.collider.CompareTag("Enemy")) { hitState |= HitState.Enemy; enemyHitRay = hitInfo; } } } } if ((hitState & HitState.Enemy) == HitState.Enemy) { //Hit enemy if (((transform.position - enemyHitRay.collider.gameObject.transform.position) / 2f).magnitude > 1) { characterController.Move(-(transform.position - enemyHitRay.collider.gameObject.transform.position) / 2f); } transform.LookAt(enemyHitRay.collider.gameObject.transform); transform.eulerAngles = new Vector3(0, transform.eulerAngles.y, 0); //enemyHitRay.collider.gameObject.GetComponent<HealthController>().Damage(100000); IDamageable damageable = (IDamageable)enemyHitRay.collider.gameObject.GetComponent(typeof(IDamageable)); AttackResponse attackResponse = damageable.Damage(new Attack(15, Attack.AttackType.Heavy)); GameEvents.current.combat.AttackEvent(enemyHitRay.collider.gameObject, gameObject, new Attack(15, Attack.AttackType.Heavy), attackResponse); if (attackResponse.HitType == AttackResponse.HitResult.Blocked) { StartCoroutine(StagerPlayer(combatProps.stageredProps.shieldHit)); } else { GameEvents.current.player.DamageEnemy(); StartCoroutine(AttackDur()); } } if (hitState == HitState.Shield) { //Stager player StartCoroutine(StagerPlayer(combatProps.stageredProps.shieldHit)); } }
private void GetTargetEntity() { targetEntity = null; if (Character.AnimController.CurrentHull != null) { wallAttackPos = Vector2.Zero; return; } //check if there's a wall between the target and the Character Vector2 rayStart = Character.SimPosition; Vector2 rayEnd = selectedAiTarget.SimPosition; if (selectedAiTarget.Entity.Submarine != null && Character.Submarine == null) { rayStart -= ConvertUnits.ToSimUnits(selectedAiTarget.Entity.Submarine.Position); } Body closestBody = Submarine.CheckVisibility(rayStart, rayEnd); if (Submarine.LastPickedFraction == 1.0f || closestBody == null) { wallAttackPos = Vector2.Zero; return; } Structure wall = closestBody.UserData as Structure; if (wall == null) { wallAttackPos = Submarine.LastPickedPosition; if (selectedAiTarget.Entity.Submarine != null && Character.Submarine == null) { wallAttackPos -= ConvertUnits.ToSimUnits(selectedAiTarget.Entity.Submarine.Position); } } else { int sectionIndex = wall.FindSectionIndex(ConvertUnits.ToDisplayUnits(Submarine.LastPickedPosition)); float sectionDamage = wall.SectionDamage(sectionIndex); for (int i = sectionIndex - 2; i <= sectionIndex + 2; i++) { if (wall.SectionBodyDisabled(i)) { sectionIndex = i; break; } if (wall.SectionDamage(i) > sectionDamage) { sectionIndex = i; } } wallAttackPos = wall.SectionPosition(sectionIndex); //if (wall.Submarine != null) wallAttackPos += wall.Submarine.Position; wallAttackPos = ConvertUnits.ToSimUnits(wallAttackPos); } targetEntity = closestBody.UserData as IDamageable; }
public static int MobileNotoriety(Mobile source, IDamageable damageable) { Mobile target = damageable as Mobile; if (target == null) { return(Notoriety.CanBeAttacked); } if (target.Blessed) { return(Notoriety.Invulnerable); } if (target is BaseVendor vendor && vendor.IsInvulnerable) { return(Notoriety.Invulnerable); } if (target is PlayerVendor || target is TownCrier) { return(Notoriety.Invulnerable); } EnemyOfOneContext context = EnemyOfOneSpell.GetContext(source); if (context != null && context.IsEnemy(target)) { return(Notoriety.Enemy); } if (PVPArenaSystem.IsEnemy(source, target)) { return(Notoriety.Enemy); } if (PVPArenaSystem.IsFriendly(source, target)) { return(Notoriety.Ally); } if (target.IsStaff()) { return(Notoriety.CanBeAttacked); } var bc = target as BaseCreature; if (source.Player && bc != null) { Mobile master = bc.GetMaster(); if (master != null && master.IsStaff()) { return(Notoriety.CanBeAttacked); } master = bc.ControlMaster; if (master != null && !bc.ForceNotoriety) { if (source == master && CheckAggressor(target.Aggressors, source)) { return(Notoriety.CanBeAttacked); } if (CheckAggressor(source.Aggressors, bc)) { return(Notoriety.CanBeAttacked); } return(MobileNotoriety(source, master)); } } if (target.Murderer) { return(Notoriety.Murderer); } if (target.Body.IsMonster && IsSummoned(bc)) { if (!(target is BaseFamiliar) && !(target is ArcaneFey) && !(target is Golem)) { return(Notoriety.Murderer); } } if (bc != null && (bc.AlwaysMurderer || bc.IsAnimatedDead)) { return(Notoriety.Murderer); } if (target.Criminal) { return(Notoriety.Criminal); } Guild sourceGuild = GetGuildFor(source.Guild as Guild, source); Guild targetGuild = GetGuildFor(target.Guild as Guild, target); if (sourceGuild != null && targetGuild != null) { if (sourceGuild == targetGuild) { return(Notoriety.Ally); } if (sourceGuild.IsAlly(targetGuild)) { return(Notoriety.Ally); } if (sourceGuild.IsEnemy(targetGuild)) { return(Notoriety.Enemy); } } if (ViceVsVirtueSystem.Enabled && ViceVsVirtueSystem.IsEnemy(source, target) && (ViceVsVirtueSystem.EnhancedRules || source.Map == ViceVsVirtueSystem.Facet)) { return(Notoriety.Enemy); } if (Stealing.ClassicMode && target is PlayerMobile mobile && mobile.PermaFlags.Contains(source)) { return(Notoriety.CanBeAttacked); } if (bc != null && bc.AlwaysAttackable) { return(Notoriety.CanBeAttacked); } if (CheckHouseFlag(source, target, target.Location, target.Map)) { return(Notoriety.CanBeAttacked); } //If Target is NOT A baseCreature, OR it's a BC and the BC is initial innocent... if (!(bc != null && ((BaseCreature)target).InitialInnocent)) { if (!target.Body.IsHuman && !target.Body.IsGhost && !IsPet(target as BaseCreature) && !(target is PlayerMobile)) { return(Notoriety.CanBeAttacked); } } if (CheckAggressor(source.Aggressors, target)) { return(Notoriety.CanBeAttacked); } if (source is PlayerMobile pm && CheckPetAggressor(pm, target)) { return(Notoriety.CanBeAttacked); } if (CheckAggressed(source.Aggressed, target)) { return(Notoriety.CanBeAttacked); } if (source is PlayerMobile playerMobile && CheckPetAggressed(playerMobile, target)) { return(Notoriety.CanBeAttacked); } if (bc != null) { if (bc.AlwaysInnocent) { return(Notoriety.Innocent); } if (bc.Controlled && bc.ControlOrder == OrderType.Guard && bc.ControlTarget == source) { return(Notoriety.CanBeAttacked); } } if (source is BaseCreature creature) { Mobile master = creature.GetMaster(); if (master != null) { if (CheckAggressor(master.Aggressors, target)) { return(Notoriety.CanBeAttacked); } if (MobileNotoriety(master, target) == Notoriety.CanBeAttacked) { return(Notoriety.CanBeAttacked); } if (target is BaseCreature) { return(Notoriety.CanBeAttacked); } } } return(Notoriety.Innocent); }
private void Awake() { damageable = GetComponentInParent <IDamageable>(); }
}//end of lerp movment public void AdjecentFoe(int column, int row) { //checking right if (column + 1 <= GameManager.NodeManager.columns - 1) { if (GameManager.NodeManager.allNodes[column + 1, row].occupant is IDamageable) { IDamageable target = (IDamageable)GameManager.NodeManager.allNodes[column + 1, row].occupant; target.TakeDamage(Character); } } //checking left if (column - 1 >= 0) { if (GameManager.NodeManager.allNodes[column - 1, row].occupant is IDamageable) { IDamageable target = (IDamageable)GameManager.NodeManager.allNodes[column - 1, row].occupant; target.TakeDamage(Character); } } //checking Up if (row + 1 <= GameManager.NodeManager.rows - 1) { if (GameManager.NodeManager.allNodes[column, row + 1].occupant is IDamageable) { IDamageable target = (IDamageable)GameManager.NodeManager.allNodes[column, row + 1].occupant; target.TakeDamage(Character); } } //checking down if (row - 1 >= 0) { if (GameManager.NodeManager.allNodes[column, row - 1].occupant is IDamageable) { //adding the ndoe to our potential nodes IDamageable target = (IDamageable)GameManager.NodeManager.allNodes[column, row - 1].occupant; target.TakeDamage(Character); } } //checking top left if (column - 1 >= 0 && row + 1 <= GameManager.NodeManager.rows - 1) { if (GameManager.NodeManager.allNodes[column - 1, row + 1].occupant is IDamageable) { //adding the ndoe to our potential nodes IDamageable target = (IDamageable)GameManager.NodeManager.allNodes[column - 1, row + 1].occupant; target.TakeDamage(Character); } } //checking top right if (column + 1 <= GameManager.NodeManager.columns - 1 && row + 1 <= GameManager.NodeManager.rows - 1) { if (GameManager.NodeManager.allNodes[column + 1, row + 1].occupant is IDamageable) { //adding the ndoe to our potential nodes IDamageable target = (IDamageable)GameManager.NodeManager.allNodes[column + 1, row + 1].occupant; target.TakeDamage(Character); } } //checking bottom right if (column + 1 < -GameManager.NodeManager.columns - 1 && row - 1 >= 0) { if (GameManager.NodeManager.allNodes[column + 1, row - 1].occupant is IDamageable) { //adding the ndoe to our potential nodes IDamageable target = (IDamageable)GameManager.NodeManager.allNodes[column + 1, row - 1].occupant; target.TakeDamage(Character); } } //checking bottom right if (column - 1 >= 0 && row - 1 >= 0) { if (GameManager.NodeManager.allNodes[column - 1, row - 1].occupant is IDamageable) { //adding the ndoe to our potential nodes IDamageable target = (IDamageable)GameManager.NodeManager.allNodes[column - 1, row - 1].occupant; target.TakeDamage(Character); } } }
public void Target(IPoint3D p, Item item) { if (!Caster.CanSee(p)) { Caster.SendLocalizedMessage(500237); // Target can not be seen. } else if (SpellHelper.CheckTown(p, Caster) && (item != null || CheckSequence())) { if (item != null) { if (item is MaskOfKhalAnkur mask) { mask.Charges--; } if (item is PendantOfKhalAnkur pendant) { pendant.Charges--; } } SpellHelper.Turn(Caster, p); if (p is Item pItem) { p = pItem.GetWorldLocation(); } List <IDamageable> targets = new List <IDamageable>(); foreach (var target in AcquireIndirectTargets(p, 2)) { targets.Add(target); } int count = Math.Max(1, targets.Count); Effects.PlaySound(p, Caster.Map, 0x160); for (var index = 0; index < targets.Count; index++) { IDamageable id = targets[index]; Mobile m = id as Mobile; double damage = GetNewAosDamage(51, 1, 5, id is PlayerMobile, id); if (count > 2) { damage = (damage * 2) / count; } IDamageable source = Caster; IDamageable target = id; if (SpellHelper.CheckReflect(this, ref source, ref target)) { Timer.DelayCall(TimeSpan.FromSeconds(.5), () => { source.MovingParticles(target, item != null ? 0xA1ED : 0x36D4, 7, 0, false, true, 9501, 1, 0, 0x100); }); } if (m != null) { damage *= GetDamageScalar(m); } Caster.DoHarmful(id); SpellHelper.Damage(this, target, damage, 0, 100, 0, 0, 0); Caster.MovingParticles(id, item != null ? 0xA1ED : 0x36D4, 7, 0, false, true, 9501, 1, 0, 0x100); } ColUtility.Free(targets); } FinishSequence(); }
// Update is called once per frame void Update() { if (cur_spr > min_spr) { cur_spr = cur_spr - spr_de; if (cur_spr < 0) { cur_spr = 0; } } if (equipped && pMenu.activeSelf == false && oMenu.activeSelf == false && goScreen.activeSelf == false && winScreen.activeSelf == false) { //draws line from gunEnd to center of screen RaycastHit hit; Vector3 rayOrigin = fpsCam.ViewportToWorldPoint(new Vector3(.5f, .5f, 0)); if (reloading && Time.time > nextFireTime) { transform.Translate(0, 0, -2); reloading = !reloading; } //shoot function, automatic weapons, nearly identical to semi-auto, see below else if (automatic && Input.GetButton("Fire1") && (Time.time > nextFireTime)) { if (cur_clip > 0) { if ((Time.time - nextFireTime) < perfectFireTime) //remember to place in automatic { cur_spr = cur_spr + spr_in; if (cur_spr > spread) { cur_spr = spread; } print(cur_spr); } /* else * { * cur_spr = min_spr; * }*/ nextFireTime = Time.time + fireRate; cur_clip = cur_clip - 1; Vector2 off_spr = Random.insideUnitCircle.normalized * cur_spr; off_x = off_spr.x; off_y = off_spr.y; Vector3 spr = Quaternion.AngleAxis(off_x, Vector3.right) * Quaternion.AngleAxis(off_y, Vector3.up) * fpsCam.transform.forward; //Debug.DrawRay(fpsCam.transform.position, spr * 100, Color.red, 5f); if (Physics.Raycast(rayOrigin, spr, out hit, range)) { GameObject n_enemy = hit.collider.gameObject; IDamageable dmgScript = hit.collider.gameObject.GetComponent <EnemyHealth>(); if (dmgScript != null) { n_enemy.GetComponent <EnemyPOV>().hit(); dmgScript.Damage(damage, hit.point); if (dmgScript.Health() <= (dmgScript.Threshold())) { //print("hit"); dmgScript.SetNextThreshold(dmgScript.Health() - dmgScript.Increment()); sm.Swap(n_enemy); } } if (hit.rigidbody != null) { hit.rigidbody.AddForce(-hit.normal * 100f); } //debug, draws line from gun end to center of screen lineRenderer.SetPosition(0, gunEnd.position); lineRenderer.SetPosition(1, hit.point); } StartCoroutine(ShotEffect(off_x, off_y)); } else if (Time.time > nextFireTime) { //empty gun sound } } //shoot function semi-auto else if (Input.GetButtonDown("Fire1") && (Time.time > nextFireTime)) { if (cur_clip > 0) { if ((Time.time - nextFireTime) < perfectFireTime) //remember to place in automatic { cur_spr = cur_spr + spr_in; if (cur_spr > spread) { cur_spr = spread; } print(cur_spr); } //sets next time on clock when player can fire again nextFireTime = Time.time + fireRate; cur_clip = cur_clip - 1; //calculates spread on weapon, randomly picks point within circle with a radius of 'spread' Vector2 off_spr = Random.insideUnitCircle.normalized * cur_spr; off_x = off_spr.x; off_y = off_spr.y; Vector3 spr = Quaternion.AngleAxis(off_x, Vector3.right) * Quaternion.AngleAxis(off_y, Vector3.up) * fpsCam.transform.forward; if (Physics.Raycast(rayOrigin, spr, out hit, range)) { GameObject n_enemy = hit.collider.gameObject; IDamageable dmgScript = hit.collider.gameObject.GetComponent <EnemyHealth>(); //checks if shot object is damageable if (dmgScript != null) { //hurt enemy for 'damage' dmgScript.Damage(damage, hit.point); n_enemy.GetComponent <EnemyPOV>().hit(); //If enemy's health is <= threshold, possess, set new threshold for possessed enemy for later if (dmgScript.Health() <= (dmgScript.Threshold())) { dmgScript.SetNextThreshold(dmgScript.Health() - dmgScript.Increment()); sm.Swap(n_enemy); } } //shot effects physics based object if (hit.rigidbody != null) { hit.rigidbody.AddForce(-hit.normal * 100f); } lineRenderer.SetPosition(0, gunEnd.position); lineRenderer.SetPosition(1, hit.point); } StartCoroutine(ShotEffect(off_x, off_y)); } else if (Time.time > nextFireTime) { //empty gun sound } } //reloads if 'r' is pressed else if (Input.GetKeyDown("r") && cur_clip != clip) { Reload(); } //sets next available firetime after reload is called else if (reloading && Time.time > nextFireTime) { transform.Translate(0, 0, -2); reloading = !reloading; } } ammoCount.SetText(cur_clip + "/" + cur_reserve); }
public override void OnHit(Mobile attacker, IDamageable damageable, double damageBonus) { if (AmmoType != null && attacker.Player && damageable is Mobile && !((Mobile)damageable).Player && (((Mobile)damageable).Body.IsAnimal || ((Mobile)damageable).Body.IsMonster) && 0.4 >= Utility.RandomDouble()) { ((Mobile)damageable).AddToBackpack(Ammo); } if (Core.ML && m_Velocity > 0) { int bonus = (int)attacker.GetDistanceToSqrt(damageable); if (bonus > 0 && m_Velocity > Utility.Random(100)) { AOS.Damage(damageable, attacker, bonus * 3, 100, 0, 0, 0, 0); if (attacker.Player) { attacker.SendLocalizedMessage(1072794); // Your arrow hits its mark with velocity! } if (damageable is Mobile && ((Mobile)damageable).Player) { ((Mobile)damageable).SendLocalizedMessage(1072795); // You have been hit by an arrow with velocity! } } } base.OnHit(attacker, damageable, damageBonus); }
public virtual int GetNewAosDamage(int bonus, int dice, int sides, bool playerVsPlayer, IDamageable damageable) { return(GetNewAosDamage(bonus, dice, sides, playerVsPlayer, 1.0, damageable)); }
public virtual bool OnFired(Mobile attacker, IDamageable damageable) { WeaponAbility ability = WeaponAbility.GetCurrentAbility(attacker); // Respect special moves that use no ammo if (ability != null && ability.ConsumeAmmo == false) { return true; } if (attacker.Player) { BaseQuiver quiver = attacker.FindItemOnLayer(Layer.Cloak) as BaseQuiver; Container pack = attacker.Backpack; int lowerAmmo = AosAttributes.GetValue(attacker, AosAttribute.LowerAmmoCost); if (quiver == null || Utility.Random(100) >= lowerAmmo) { // consume ammo if (quiver != null && quiver.ConsumeTotal(AmmoType, 1)) { quiver.InvalidateWeight(); } else if (pack == null || !pack.ConsumeTotal(AmmoType, 1)) { return false; } } else if (quiver.FindItemByType(AmmoType) == null && (pack == null || pack.FindItemByType(AmmoType) == null)) { // lower ammo cost should not work when we have no ammo at all return false; } } attacker.MovingEffect(damageable, EffectID, 18, 1, false, false); return true; }
public static bool Mobile_AllowHarmful(Mobile from, IDamageable damageable) { Mobile target = damageable as Mobile; if (from == null || target == null || from.IsStaff() || target.IsStaff()) { return(true); } Map map = from.Map; if (map != null && (map.Rules & MapRules.HarmfulRestrictions) == 0) { return(true); // In felucca, anything goes } BaseCreature bc = from as BaseCreature; if (!from.Player && !(bc != null && bc.GetMaster() != null && bc.GetMaster().IsPlayer())) { if (!CheckAggressor(from.Aggressors, target) && !CheckAggressed(from.Aggressed, target) && target is PlayerMobile pm && pm.CheckYoungProtection(from)) { return(false); } return(true); // Uncontrolled NPCs are only restricted by the young system } // Summons should follow the same rules as their masters if (from is BaseCreature summon && summon.Summoned && summon.SummonMaster != null) { from = summon.SummonMaster; } if (target is BaseCreature mobSummon && mobSummon.Summoned && mobSummon.SummonMaster != null) { target = mobSummon.SummonMaster; } Guild fromGuild = GetGuildFor(from.Guild as Guild, from); Guild targetGuild = GetGuildFor(target.Guild as Guild, target); if (fromGuild != null && targetGuild != null) { if (fromGuild == targetGuild || fromGuild.IsAlly(targetGuild) || fromGuild.IsEnemy(targetGuild)) { return(true); // Guild allies or enemies can be harmful } } if (ViceVsVirtueSystem.Enabled && ViceVsVirtueSystem.EnhancedRules && ViceVsVirtueSystem.IsEnemy(from, damageable)) { return(true); } if (target is BaseCreature creature) { if (creature.Controlled) { return(false); // Cannot harm other controlled mobiles } if (creature.Summoned && from != creature.SummonMaster) { return(false); // Cannot harm other controlled mobiles } } if (target.Player) { return(false); // Cannot harm other players } if (!(target is BaseCreature baseCreature && baseCreature.InitialInnocent)) { if (Notoriety.Compute(from, target) == Notoriety.Innocent) { return(false); // Cannot harm innocent mobiles } } return(true); }
public void Setup(IDamageable damageable, Team team, Transform attachPoint) { healthBar.Setup(damageable, team); attachPointMirror.Setup(attachPoint); damageable.OnDie += OnDamageableDied; }
public static bool TakesDamageFrom(this IDamageable victim, IDamager damager) { return(!victim.DamageHandler.ObjectIsInvincible && (damager.DamageType & victim.TakesDamageFrom) > 0); }
public void RemoveEntity(IDamageable entity) { DamageableEntities.Remove(entity); }
public virtual void EndPickTarget(Mobile from, IDamageable target, OrderType order) { if (m_Mobile.Deleted || !m_Mobile.Controlled || !from.InRange(m_Mobile, 14) || from.Map != m_Mobile.Map || !from.CheckAlive()) { return; } bool isOwner = (from == m_Mobile.ControlMaster); bool isFriend = (!isOwner && m_Mobile.IsPetFriend(from)); if (!isOwner && !isFriend) { return; } else if (isFriend && order != OrderType.Follow && order != OrderType.Stay && order != OrderType.Stop) { return; } if (order == OrderType.Attack) { if (target is BaseCreature && ((BaseCreature)target).IsScaryToPets && m_Mobile.IsScaredOfScaryThings) { m_Mobile.SayTo(from, "Your pet refuses to attack this creature!"); return; } if ((SolenHelper.CheckRedFriendship(from) && (target is RedSolenInfiltratorQueen || target is RedSolenInfiltratorWarrior || target is RedSolenQueen || target is RedSolenWarrior || target is RedSolenWorker)) || (SolenHelper.CheckBlackFriendship(from) && (target is BlackSolenInfiltratorQueen || target is BlackSolenInfiltratorWarrior || target is BlackSolenQueen || target is BlackSolenWarrior || target is BlackSolenWorker))) { from.SendAsciiMessage("You can not force your pet to attack a creature you are protected from."); return; } if (target is BaseFactionGuard) { m_Mobile.SayTo(from, "Your pet refuses to attack the guard."); return; } } if (m_Mobile.CheckControlChance(from)) { m_Mobile.ControlTarget = target; m_Mobile.ControlOrder = order; } }
// Use this for initialization void Start() { // Init control playerTurn = true; playerNum = GameMaster.Instance.Turn; die = new Die (); die.Reseed (Environment.TickCount); damage = 0; // Init IDamageable objects // Create the enemy GameMaster.Instance.CreateEnemy(HostileType.Bandit, "Bandit"); // Get the enemyID from the list of enemy IDs; since this a 1v1 fight there should only be a single ID enemyID = GameMaster.Instance.EnemyIdentifiers[0]; // Get the enemy entity enemyEntity = (Bandit)EntityManager.Instance.GetEntity(enemyID); // Set the stats of the enemy enemyEntity.AttackPower = die.Roll(1, 9) + 5; enemyEntity.DefencePower = die.Roll(1, 9) + 5; // Set sprite of enemy if(enemyEntity.AttackPower > enemyEntity.DefencePower) { GameObject.Find ("Battler2Sprite").GetComponent<Image> ().sprite = Resources.Load<Sprite> ("Bandit1"); } //end if else { GameObject.Find ("Battler2Sprite").GetComponent<Image> ().sprite = Resources.Load<Sprite> ("Bandit2"); } // Set the enemy enemy = (IDamageable) enemyEntity; // Get the player's merchant GameMaster.Instance.LoadPlayers (); playerMerchant = (Merchant)GameMaster.Instance.GetPlayerScript(playerNum).Entity; playerAttack = playerMerchant.AttackPower; playerDefense = playerMerchant.DefencePower; GameObject.Find ("Battler1Sprite").GetComponent<Image> ().sprite = playerMerchant.GetSprite (2); // Set the player player = (IDamageable)playerMerchant; // Set background if(GameMaster.Instance.BattleMap == BattleMap.area01) { GameObject.Find("Background").GetComponent<Image>().sprite = Resources.Load<Sprite> ("BattleBackgrounds/Battle_Desert"); } //end if else if(GameMaster.Instance.BattleMap == BattleMap.area02) { GameObject.Find("Background").GetComponent<Image>().sprite = Resources.Load<Sprite> ("BattleBackgrounds/Battle_Euro"); } //end else if else if(GameMaster.Instance.BattleMap == BattleMap.area03) { GameObject.Find("Background").GetComponent<Image>().sprite = Resources.Load<Sprite> ("BattleBackgrounds/Battle_Metro"); } //end if else { GameObject.Find("Background").GetComponent<Image>().sprite = Resources.Load<Sprite> ("BattleBackgrounds/Battle_Snow"); } //end else // Init and set HUD objects GameObject.Find("Canvas").transform.Find("PlayerInventory").gameObject.SetActive(false); GameObject.Find("Canvas").transform.Find("AllyInventory").gameObject.SetActive(false); GameObject.Find("Canvas").transform.Find("Tooltip").gameObject.SetActive(false); playerName = GameObject.Find ("Battler1Name").GetComponent<Text> (); playerName.text = GameMaster.Instance.GetPlayerName (playerNum); enemyName = GameObject.Find ("Battler2Name").GetComponent<Text> (); GameObject.Find ("Battler1Attack").GetComponent<Text> ().text = playerMerchant.AttackPower.ToString (); GameObject.Find ("Battler2Attack").GetComponent<Text> ().text = enemyEntity.AttackPower.ToString (); GameObject.Find ("Battler1Defense").GetComponent<Text> ().text = playerMerchant.DefencePower.ToString (); GameObject.Find ("Battler2Defense").GetComponent<Text> ().text = enemyEntity.DefencePower.ToString (); playerHealth = GameObject.Find ("Battler1Health").GetComponent<Text> (); playerHealth.text = player.Health.ToString (); enemyHealth = GameObject.Find ("Battler2Health").GetComponent<Text> (); enemyHealth.text = enemy.Health.ToString (); playerBar = GameObject.Find ("Battler1HealthLeft").GetComponent<RectTransform> (); enemyBar = GameObject.Find ("Battler2HealthLeft").GetComponent<RectTransform> (); fightBoxText = GameObject.Find ("FightText").GetComponent<Text> (); // Init fight box and flavor fightBoxText.text = "The battlers square off!"; linesOfText = 1; verbs = new List<string>(); verbs.Add ("attacked"); verbs.Add ("retaliated against"); verbs.Add ("hammered"); verbs.Add ("struck"); verbs.Add ("lashed at"); // Check if the player is an AI if (playerMerchant.GameObj.GetComponent<Player>().IsAI) { // Disable the fight buttons GameObject.Find("AttackButtons/HeadButton").GetComponent<Button>().interactable = false; GameObject.Find("AttackButtons/TorsoButton").GetComponent<Button>().interactable = false; GameObject.Find("AttackButtons/FeintButton").GetComponent<Button>().interactable = false; } }
protected abstract void OnHit(IDamageable hit);
public override void OnMiss(Mobile attacker, IDamageable damageable) { if (attacker.Player && 0.4 >= Utility.RandomDouble()) { if (Core.SE) { PlayerMobile p = attacker as PlayerMobile; if (p != null && AmmoType != null) { Type ammo = AmmoType; if (p.RecoverableAmmo.ContainsKey(ammo)) { p.RecoverableAmmo[ammo]++; } else { p.RecoverableAmmo.Add(ammo, 1); } if (!p.Warmode) { if (m_RecoveryTimer == null) { m_RecoveryTimer = Timer.DelayCall(TimeSpan.FromSeconds(10), p.RecoverAmmo); } if (!m_RecoveryTimer.Running) { m_RecoveryTimer.Start(); } } } } else { Point3D loc = damageable.Location; Ammo.MoveToWorld( new Point3D(loc.X + Utility.RandomMinMax(-1, 1), loc.Y + Utility.RandomMinMax(-1, 1), loc.Z), damageable.Map); } } base.OnMiss(attacker, damageable); }
protected void applyDamage(IDamageable dmgable, float amount) { dmgable.damage(amount, gameObject); }
void OnDamageableDied(IDamageable damageable) { damageable.OnDie -= OnDamageableDied; Destroy(gameObject); }
/// <summary> /// Change the interface to fit with the new controlledEntity /// </summary> public void ChangeInterface(IControllable newControllable) { controlledEntity = newControllable; healtBarBackground = new Rectangle(offsetX, WindowHeight - offsetY - healthbarHeight, healthbarWidth, healthbarHeight); }
public void SetTarget(IDamageable target, float damage) { target.Damage(damage); }
public int DoAttack(IDamageable target) { var damage = Character.Attributes.Attack; return(target.TakeDamage(Character, damage)); }