// Update is called once per frame void Update() { if(disableTime > 0) { disableTime -= Time.deltaTime; if(disableTime <= 0) { horAttack.SetActive(false); vertAttack.SetActive(false); straightAttack.SetActive(false); } } if(Input.GetKeyDown(setStraightAttackKey)) { attackType = AttackTypes.Straight; shoot.attackType = attackType; //StraightAttack(); } if(Input.GetKeyDown(setHorizontalAttackKey)) { attackType = AttackTypes.Horizontal; shoot.attackType = attackType; //HorizontalAttack(); } if(Input.GetKeyDown(setVerticalAttackKey)) { attackType = AttackTypes.Verticle; shoot.attackType = attackType; //VerticleAttack(); } }
void RecieveInjury(AttackTypes typeOfAttack) { if(!hasRagdoll) { if(typeOfAttack == AttackTypes.Straight) { renderer.material.color = Color.red; } if(typeOfAttack == AttackTypes.Horizontal) { renderer.material.color = Color.blue; } if(typeOfAttack == AttackTypes.Verticle) { renderer.material.color = Color.green; } } else { GameObject child = (GameObject) Instantiate(ragdoll, transform.position, transform.rotation); RagDollScript ragdollscript = child.GetComponent<RagDollScript>(); ragdollscript.SendMessage("SetImpact", hitByBullet); gameObject.SetActive(false); Destroy(gameObject); } }
public CreateCommand(IEngine engine, string name, int health, int damage, BehaviorTypes behavior, AttackTypes attack) : base(engine) { this.name = name; this.health = health; this.damage = damage; this.behavior = behavior; this.attack = attack; }
public static IAttack Create(int damage, AttackTypes type) { var attackType = type; var attackDamage = damage; switch (attackType) { case AttackTypes.Blobplode: return new BlobplodeAttack(attackDamage, attackType); case AttackTypes.PutridFart: return new PutridFartAttack(attackDamage, attackType); default: throw new NotSupportedException("Invalid type supplied"); } }
public static IBlob Create(string name, int health, int damage, BehaviorTypes behavior, AttackTypes attack) { int blobHealth = health; int attackDamage = new int(); if (attack == AttackTypes.PutridFart) { attackDamage = damage; } else if (attack == AttackTypes.Blobplode) { attackDamage = 2 * damage; } IAttack blobAttack = AttackFactory.Create(attackDamage, attack); IBehavior blobBehavior = BehaviorFactory.Create(behavior); return new Blob(name, blobHealth, damage, blobAttack, blobBehavior); }
/// <summary> /// Enforcing a damage where the attacker exists /// </summary> /// <param name="target">Target</param> /// <param name="attacker">Attacker</param> /// <param name="damage">Damage (if percentage 1-100)</param> /// <param name="absorbDamage">Damage absorb = shield transfer (if percentage 1-100)</param> /// <param name="calculationType">Calculation type (defined or percentage)</param> /// <param name="attackType">Type of attack</param> public void EnforceDamage(AbstractAttackable target, AbstractAttacker attacker, int damage, int absorbDamage, DamageCalculationTypes calculationType, AttackTypes attackType) { if (target == null) { Out.QuickLog("Something went wrong enforcing damage, target is null", LogKeys.ERROR_LOG); throw new Exception("Target is null, cannot damage"); } if (attacker == null) { Out.QuickLog("Something went wrong enforcing damage, attacker is null", LogKeys.ERROR_LOG); throw new Exception("Attacker is null, cannot damage"); } if (damage == 0 && absorbDamage == 0) { // damage finished return; } _pendingDamages.Enqueue(new PendingDamage(target, attacker, damage, absorbDamage, calculationType, attackType)); }
void EndOfAttack() { if (!movement.isAttacking) { return; } if (curForceDurtaion <= Time.time && attackType != AttackTypes.TopDown) { rigidBody.velocity = Vector2.zero; } //End of attack and pause anim if (timeBtwAttacks <= Time.time || (attackType == AttackTypes.TopDown && movement.isOnGround)) { movement.canFlip = true; attackState = AttackState.End; //rigidBody.velocity = Vector2.zero; //anim.speed = 1f; //Switch animation from air attack to grounded if (airLightCombo + airStrongCombo + airJointCombo > 0 && movement.isOnGround) { movement.isAttacking = false; attackType = default; } } //Pause attack state for give little time for next attack if (attackDuration <= Time.time || (attackType == AttackTypes.TopDown && movement.isOnGround)) { movement.isAttacking = false; attackType = default; attributes.SetAnimationSpeed(attributes.AnimSpeed); //attributes.speedDivisor = 1f; } }
public Boss2(Vector2 Position) { this.Position = Position; AttackType = AttackTypes.None; MissilesPhaseTimer = 0; LaserPhaseTimer = 0; CoolDown = 0; Destroy = 90; IsAlive = false; Speed = new Vector2(-5, 0); if (SuperTank2.Difficulty == DifficultyChoices.Normal) { MaxResist = 400; } else if (SuperTank2.Difficulty == DifficultyChoices.Hard) { MaxResist = 1000; } else if (SuperTank2.Difficulty == DifficultyChoices.Expert) { MaxResist = 2150; } }
public void UpdateAttackTypeTimer() { int Type = SuperTank2.Randomizer.Next(CoolDown + 10); Type /= (CoolDown + 10 / 10); if (Type < 5) { AttackType = AttackTypes.None; } else if (Type < 8) { AttackType = AttackTypes.Missiles; } else { AttackType = AttackTypes.Laser; } AttackTypeTimer = 150; if (AttackType == AttackTypes.None) { AttackTypeTimer = 50 + CoolDown; CoolDown = 0; } else if (AttackType == AttackTypes.Missiles) { MissilesTimer = 1; CoolDown += 20; } else { CoolDown += 50; } }
public void SetAttackTimer(AttackTypes at, long value) { AttackTimers[at] = value; }
public BlobplodeAttack(int damage, AttackTypes types) : base(damage, types) { }
public bool IsAttackReady(AttackTypes at) { return(AttackTimers[at] <= 0); }
public static bool ParseAttackData(Character chr, Packet packet, out AttackData data, AttackTypes type) { // Don't accept zombies if (chr.PrimaryStats.HP == 0) { data = null; return(false); } // Normal weapon + sword boost gives about 500, so we need to go faster if (false && packet.PacketCreationTime - chr.LastAttackPacket < 350) { Trace.WriteLine($"{packet.PacketCreationTime - chr.LastAttackPacket}"); if (chr.AssertForHack(chr.FastAttackHackCount++ > 5, $"Fast attack hack, type {type}")) { chr.FastAttackHackCount = 0; data = null; return(false); } } chr.LastAttackPacket = packet.PacketCreationTime; AttackData ad = new AttackData(); byte hits; byte targets; int skillid = 0; data = null; if (type != AttackTypes.Summon) { ad.RandomNumber = chr.RndActionRandomizer.Random(); byte TByte = packet.ReadByte(); skillid = packet.ReadInt(); if (skillid != 0) { if (!chr.Skills.Skills.ContainsKey(skillid)) { return(false); // Hacks } ad.SkillLevel = chr.Skills.Skills[skillid]; } else { ad.SkillLevel = 0; } if (skillid == Constants.ChiefBandit.Skills.MesoExplosion) { ad.IsMesoExplosion = true; } targets = (byte)(TByte / 0x10); hits = (byte)(TByte % 0x10); ad.Option = packet.ReadByte(); var b = packet.ReadByte(); ad.Action = (byte)(b & 0x7F); ad.FacesLeft = (b >> 7) == 1; ad.AttackType = packet.ReadByte(); } else { ad.SummonID = packet.ReadInt(); ad.AttackType = packet.ReadByte(); targets = 1; hits = 1; } if (type == AttackTypes.Ranged) { ad.StarItemSlot = packet.ReadShort(); BaseItem item = chr.Inventory.GetItem(2, ad.StarItemSlot); if (ad.StarItemSlot == 0) { if (!chr.PrimaryStats.BuffSoulArrow.IsSet()) { chr.DesyncedSoulArrows++; if (chr.AssertForHack(chr.DesyncedSoulArrows > 5, "Trying to use no arrow without Soul Arrow " + chr.DesyncedSoulArrows + " times.")) //Allow up to 5 arrows due to buff desync { return(false); } } else { chr.DesyncedSoulArrows = 0; } ad.StarID = -1; } else if (chr.AssertForHack(item == null, "Attempting to use nonexistent item for ranged attack")) { return(false); } else { ad.StarID = item.ItemID; } ad.ShootRange = packet.ReadByte(); } ad.Targets = targets; ad.Hits = hits; ad.SkillID = skillid; for (byte i = 0; i < targets; i++) { var ai = new AttackData.AttackInfo() { MobMapId = packet.ReadInt(), HitAction = packet.ReadByte() }; var b = packet.ReadByte(); ai.ForeAction = (byte)(b & 0x7F); ai.FacesLeft = b >> 7 == 1; ai.FrameIndex = packet.ReadByte(); if (!ad.IsMesoExplosion) { ai.CalcDamageStatIndex = packet.ReadByte(); } ai.HitPosition = new Pos(packet); ai.PreviousMobPosition = new Pos(packet); if (type == AttackTypes.Summon) { packet.Skip(1); } if (ad.IsMesoExplosion) { hits = packet.ReadByte(); } ai.Damages = new List <int>(hits); if (ad.IsMesoExplosion) { // Hit delay is basically set to 0, because // they did not send it to the server. // Technically they use the previous hit info, // but that would be also set to zero... wut for (byte j = 0; j < hits; j++) { int dmg = packet.ReadInt(); ad.TotalDamage += dmg; ai.Damages.Add(dmg); } } else { if (type != AttackTypes.Summon) { ai.HitDelay = packet.ReadShort(); } for (byte j = 0; j < hits; j++) { int dmg = packet.ReadInt(); ad.TotalDamage += dmg; ai.Damages.Add(dmg); } } ad.Attacks.Add(ai); } ad.PlayerPosition = new Pos(packet); data = ad; if (ad.Hits != 0) { foreach (var ai in ad.Attacks) { var mobId = chr.Field.GetMob(ai.MobMapId)?.MobID; if (mobId == null) { continue; } // Make sure we update the damage log. chr.UpdateDamageLog( ad.SkillID, ad.SkillLevel, mobId.Value, ai.Damages.Min(), ai.Damages.Max() ); } } return(true); }
public void SetAttackTypeEnum() => this.AttackType = ((AttackTypes[])Enum.GetValues(typeof(AttackTypes))) .FirstOrDefault(x => x.ToDisplay() == this.AttackTypeName);
/// <summary> /// Merges damage, heals and spells from a pet into this participant. /// Tanking is not merged. /// All data will be prefixed with "pet:" to distinguish it from the owner. e.g. "pet:slash" vs "slash" /// </summary> public void MergePet(FightParticipant pet) { foreach (var at in pet.AttackTypes) { at.Type = "pet:" + at.Type; //owner.AttackTypes.Add(hit); var match = AttackTypes.FirstOrDefault(x => x.Type == at.Type); if (match != null) { match.Merge(at); } else { AttackTypes.Add(at); } } foreach (var spell in pet.Spells.Where(x => x.Type == "hit")) { spell.Name = "pet:" + spell.Name; var match = Spells.FirstOrDefault(x => x.Type == spell.Type && x.Name == spell.Name); if (match != null) { match.Merge(spell); } else { Spells.Add(spell); } } OutboundHitCount += pet.OutboundHitCount; OutboundHitSum += pet.OutboundHitSum; OutboundMissCount += pet.OutboundMissCount; // merges DPS and HPS intervals (but not TankDPS or InboundHPS) for (var i = 0; i < pet.DPS.Count; i++) { while (DPS.Count <= i) { DPS.Add(0); } DPS[i] += pet.DPS[i]; } for (var i = 0; i < pet.HPS.Count; i++) { while (HPS.Count <= i) { HPS.Add(0); } HPS[i] += pet.HPS[i]; } // removing the pet has the downside of hiding pet tanking //Participants.Remove(pet); // clear the damage on the pet but keep it for tanking stats pet.OutboundHitCount = 0; pet.OutboundHitSum = 0; pet.OutboundMissCount = 0; pet.AttackTypes.Clear(); //pet.Spells.Clear(); pet.Spells.RemoveAll(x => x.Type == "hit"); // leave heals on pet so it shows on the healer list pet.DPS.Clear(); pet.HPS.Clear(); }
public PutridFartAttack(int damage, AttackTypes types) : base(damage, types) { }
public static IBlob Create(string name, int health, int damage, BehaviorTypes behavior, AttackTypes attack) { int blobHealth = health; int attackDamage = new int(); if (attack == AttackTypes.PutridFart) { attackDamage = damage; } else if (attack == AttackTypes.Blobplode) { attackDamage = 2 * damage; } IAttack blobAttack = AttackFactory.Create(attackDamage, attack); IBehavior blobBehavior = BehaviorFactory.Create(behavior); return(new Blob(name, blobHealth, damage, blobAttack, blobBehavior)); }
public void OnAttackEnd() { ActiveAttack = AttackTypes.None; IsAttacking = false; }
public Attack(int damage, AttackTypes types) { this.Damage = damage; this.Types = types; }
public override void TakeDamage(AttackTypes _attackType) { base.TakeDamage(_attackType); IncreaseHitCracks(); }
// Use this for initialization void Start() { attackType = AttackTypes.Straight; }
void OnGUI() { //Use PreExisting Prefab /* if(isEdit) { newTitle = newUnit.title; newName = newUnit.title; // newHealth = newUnit.health; newSpeed = newUnit.speed; newDefenseType = newUnit.defenseType; newDefenseRating = newUnit.defenseRating; newSprite = newUnit.sprite; newAnimator = newUnit.animator; isEdit = false; } */ prefabType = (PrefabTypes)EditorGUILayout.EnumPopup (prefabType); EditorGUILayout.Space (); switch (prefabType) { case PrefabTypes.Tower: type = "Tower"; isUnit = false; /*hasSecondAtk = true; atk2IsActive = false; canMine = true; mineIsActive = true;*/ break; case PrefabTypes.Unit: EditorGUILayout.BeginHorizontal (); unitType = (UnitTypes)EditorGUILayout.EnumPopup (unitType); type = unitType.ToString (); EditorGUILayout.Space (); EditorGUILayout.EndHorizontal (); EditorGUILayout.Space (); isUnit = true; /*hasSecondAtk = false; atk2IsActive = false; canMine = false; mineIsActive = false;*/ break; } EditorGUILayout.BeginHorizontal (); EditorGUI.indentLevel = 0; EditorGUILayout.LabelField ("Title: ", GUILayout.Width (35)); newTitle = EditorGUILayout.TextField (newTitle, GUILayout.Width (200), GUILayout.ExpandWidth(true)); EditorGUILayout.LabelField ("Unique:", GUILayout.Width (50), GUILayout.ExpandWidth(false)); isUnique = EditorGUILayout.Toggle(isUnique, GUILayout.Width (10), GUILayout.ExpandWidth(false)); EditorGUILayout.Space (); EditorGUILayout.EndHorizontal (); EditorGUILayout.Space (); if (isUnique) { EditorGUILayout.BeginHorizontal (); EditorGUI.indentLevel = 1; EditorGUILayout.LabelField ("Name: ", GUILayout.Width (60)); newName = EditorGUILayout.TextField (newName,GUILayout.Width (200), GUILayout.ExpandWidth(true)); EditorGUILayout.EndHorizontal (); EditorGUI.indentLevel = 0; } else { newName = newTitle; } EditorGUILayout.Space (); newSprite = (Sprite)EditorGUILayout.ObjectField ("Sprite: ", newSprite, typeof(Sprite), true); EditorGUILayout.Space (); //Animator??? newAnimator = (Animator)EditorGUILayout.ObjectField ("Animator: ", newAnimator, typeof(Animator), true); EditorGUILayout.Space (); EditorGUILayout.BeginHorizontal (); EditorGUI.indentLevel = 1; EditorGUILayout.LabelField ("Health: ", GUILayout.Width (80)); newHealth = EditorGUILayout.IntField (newHealth); EditorGUILayout.Space (); if (isUnit) { EditorGUILayout.LabelField ("Speed:", GUILayout.Width (80)); newSpeed = EditorGUILayout.FloatField (newSpeed); EditorGUILayout.Space (); } EditorGUILayout.EndHorizontal (); EditorGUILayout.Space (); EditorGUILayout.BeginHorizontal (); EditorGUI.indentLevel = 1; EditorGUILayout.LabelField ("Defense: ", GUILayout.Width (80)); newDefenseType = (Defenses)EditorGUILayout.EnumPopup (newDefenseType, GUILayout.Width (100)); //EditorGUILayout.Space (); EditorGUILayout.LabelField ("Rating:", GUILayout.Width (60)); newDefenseRating = EditorGUILayout.FloatField (newDefenseRating, GUILayout.Width (40)); EditorGUILayout.Space (); EditorGUILayout.EndHorizontal (); EditorGUILayout.Space (); EditorGUILayout.Space (); EditorGUILayout.BeginHorizontal (); EditorGUI.indentLevel = 0; EditorGUILayout.LabelField ("Attack :", GUILayout.Width (150)); EditorGUILayout.Space (); atk1IsActive = EditorGUILayout.Toggle (atk1IsActive, GUILayout.Width (30)); EditorGUILayout.EndHorizontal (); EditorGUILayout.BeginHorizontal (); EditorGUI.indentLevel = 1; EditorGUILayout.LabelField ("Object: ", GUILayout.Width (80)); newAttack1Projectile = (GameObject)EditorGUILayout.ObjectField (newAttack1Projectile, typeof(GameObject), true);//, GUILayout.Width(100)); EditorGUILayout.LabelField ("Damage: ", GUILayout.Width(80)); atk1Damage = EditorGUILayout.FloatField (atk1Damage); EditorGUILayout.EndHorizontal (); atk1Type = (AttackTypes)EditorGUILayout.EnumPopup("Type: ", atk1Type); EditorGUILayout.BeginHorizontal (); EditorGUILayout.LabelField ("Range: ", GUILayout.Width (80)); atk1Range = EditorGUILayout.FloatField (atk1Range); EditorGUILayout.LabelField ("CoolDown: ",GUILayout.Width (80)); atk1CD = EditorGUILayout.FloatField (atk1CD); EditorGUILayout.EndHorizontal (); EditorGUILayout.BeginHorizontal (); EditorGUILayout.LabelField ("Accuracy: ", GUILayout.Width (80)); atk1Accuracy = EditorGUILayout.FloatField (atk1Accuracy); EditorGUILayout.LabelField ("Speed: ", GUILayout.Width (80)); atk1Speed = EditorGUILayout.FloatField (atk1Speed); EditorGUILayout.EndHorizontal (); EditorGUILayout.Space(); EditorGUILayout.BeginHorizontal (); EditorGUILayout.Space (); hasSecondAtk = EditorGUILayout.Toggle ("Has Second Attack: ", hasSecondAtk); EditorGUILayout.EndHorizontal (); EditorGUILayout.Space (); EditorGUILayout.Space (); if(hasSecondAtk) { EditorGUILayout.BeginHorizontal (); EditorGUI.indentLevel = 0; EditorGUILayout.LabelField ("Attack 2 :", GUILayout.Width (150)); EditorGUILayout.Space (); atk2IsActive = EditorGUILayout.Toggle (atk2IsActive, GUILayout.Width (30)); EditorGUILayout.EndHorizontal (); EditorGUILayout.BeginHorizontal (); EditorGUI.indentLevel = 1; EditorGUILayout.LabelField ("Object: ", GUILayout.Width (80)); newAttack2Projectile = (GameObject)EditorGUILayout.ObjectField (newAttack1Projectile, typeof(GameObject), true); EditorGUILayout.LabelField ("Damage: ", GUILayout.Width(80)); atk2Damage = EditorGUILayout.FloatField (atk1Damage); EditorGUILayout.EndHorizontal (); atk2Type = (AttackTypes)EditorGUILayout.EnumPopup ("Type: ", atk2Type); EditorGUILayout.BeginHorizontal (); EditorGUILayout.LabelField ("Range: ", GUILayout.Width(80)); atk2Range = EditorGUILayout.FloatField (atk2Range); EditorGUILayout.LabelField ("CoolDown: ", GUILayout.Width (80)); atk2CD = EditorGUILayout.FloatField (atk2CD); EditorGUILayout.EndHorizontal (); EditorGUILayout.BeginHorizontal (); EditorGUILayout.LabelField ("Accuracy: ", GUILayout.Width (80)); atk2Accuracy = EditorGUILayout.FloatField (atk2Accuracy); EditorGUILayout.LabelField ("Speed: ", GUILayout.Width (80)); atk2Speed = EditorGUILayout.FloatField (atk2Speed); EditorGUILayout.EndHorizontal (); atk2OnGC = EditorGUILayout.Toggle ("On GC: ", atk2OnGC); } EditorGUI.indentLevel = 1; EditorGUILayout.Space (); EditorGUILayout.BeginHorizontal (); EditorGUILayout.Space (); canMine = EditorGUILayout.Toggle ("Can Mine: ", canMine); EditorGUILayout.EndHorizontal (); EditorGUILayout.Space (); if(canMine) { ///Needs to Include: /// Mining Range, Mining Cooldown, Mining Efficiency x4 /// EditorGUILayout.BeginHorizontal (); EditorGUI.indentLevel= 0; EditorGUILayout.LabelField ("Mining: ", GUILayout.Width (150)); EditorGUILayout.Space (); mineIsActive = EditorGUILayout.Toggle (mineIsActive, GUILayout.Width (30)); EditorGUILayout.EndHorizontal (); EditorGUILayout.BeginHorizontal (); EditorGUI.indentLevel = 1; EditorGUILayout.LabelField ("Range: ", GUILayout.Width (80)); mineRange = EditorGUILayout.FloatField (mineRange); EditorGUILayout.LabelField ("CoolDown: ", GUILayout.Width (80)); mineCD = EditorGUILayout.FloatField (mineCD); EditorGUILayout.EndHorizontal (); EditorGUILayout.BeginHorizontal (); EditorGUI.indentLevel = 2; EditorGUILayout.LabelField ("Iron: ", GUILayout.Width (80)); mineEffIron = EditorGUILayout.FloatField (mineEffIron); EditorGUILayout.LabelField ("Lode: ", GUILayout.Width (80)); mineEffLode = EditorGUILayout.FloatField (mineEffLode); EditorGUILayout.Space (); EditorGUILayout.EndHorizontal (); EditorGUILayout.BeginHorizontal (); EditorGUILayout.LabelField ("Brin: ", GUILayout.Width (80)); mineEffBrin = EditorGUILayout.FloatField (mineEffBrin); EditorGUILayout.LabelField ("Mithril: ", GUILayout.Width (80)); mineEffMith = EditorGUILayout.FloatField (mineEffMith); EditorGUILayout.Space (); EditorGUILayout.EndHorizontal (); } EditorGUILayout.Space (); if(GUILayout.Button ("Register " + type)) { //Build a New Prefab GameObject newUnit = (GameObject.Find ("UnitPrefab")); newUnit.name = newName; string folder = "Tower"; if(isUnit) { folder = "Units"; } string path = AssetDatabase.GenerateUniqueAssetPath ("Assets/Prefabs/" + folder + "/" + newUnit.name + ".prefab"); PrefabUtility.CreatePrefab (path, newUnit); //if(size == medium) var capsule = newUnit.GetComponent<CapsuleCollider>(); capsule.radius = 1; capsule.height = 4; var body = newUnit.AddComponent<BodyScript>(); body.title = newTitle; //body.speed = newSpeed; body.maxHealth = newHealth; body.health = newHealth; body.defenseRating = newDefenseRating; body.defenseType = newDefenseType.ToString (); if(isUnit) { //var seeker = newUnit.AddComponent<Seeker>(); var controller = newUnit.AddComponent<CharacterController>(); controller.radius = 0; controller.height = 0; var walker = newUnit.AddComponent<WalkScript>(); walker.baseSpeed = newSpeed; var funnelMod = newUnit.AddComponent<Pathfinding.FunnelModifier>(); //funnelMod.priority = 2; var alternMod = newUnit.AddComponent<Pathfinding.AlternativePath>(); //alternMod.priority = 3; } var attack = newUnit.AddComponent<AttackScript>(); attack.attackIsActive = atk1IsActive; attack.attackProjectile = newAttack1Projectile; attack.attackDamage = atk1Damage; attack.attackType = atk1Type; attack.attackRange = atk1Range; attack.attackCooldown = atk1CD; attack.attackAccuracy = atk1Accuracy; attack.attackSpeed = atk1Speed; if(hasSecondAtk) { attack.attack2IsActive = atk2IsActive; attack.attack2Projectile = newAttack2Projectile; attack.attack2Damage = atk2Damage; attack.attack2Type = atk2Type; attack.attack2Range = atk2Range; attack.attack2Cooldown = atk2CD; attack.attack2Accuracy = atk2Accuracy; attack.attack2Speed = atk2Speed; attack.attack2OnGC = atk2OnGC; } if(canMine) { var mine = newUnit.AddComponent<MiningScript>(); mine.miningRange = mineRange; mine.miningCooldown = mineCD; mine.ironMiningRate = mineEffIron; mine.lodestoneMiningRate = mineEffLode; mine.brinmistrMiningRate = mineEffBrin; mine.mithrilMiningRate = mineEffMith; } } }
public void OnGroundPoundBegin() { ActiveAttack = AttackTypes.GroundPound; IsAttacking = true; }
public override void Update(float TimeEllapsed) { if (AttackType == AttackTypes.None) { if (Position.X <= 104) { Speed.X = SpeedX * TimeEllapsed; } else if (Position.X >= 920) { Speed.X = -SpeedX * TimeEllapsed; } --AttackTypeTimer; if (AttackTypeTimer <= 0) { UpdateAttackTypeTimer(); } } else if (AttackType == AttackTypes.Missiles) { --MissilesTimer; if (MissilesTimer <= 0) { UpdateMissilesTimer(); } ++MissilesPhaseTimer; if (MissilesPhaseTimer >= 150) { MissilesPhaseTimer = 0; AttackType = AttackTypes.None; } if (Position.X <= 507) { Speed.X = SpeedX * TimeEllapsed; } else if (Position.X >= 518) { Speed.X = -SpeedX * TimeEllapsed; } else { Position.X = 512; Speed.X = 0; } } else if (AttackType == AttackTypes.Laser) { LaserPhaseTimer += 1; if (LaserPhaseTimer < 90) { new LaserParticle(new Vector2(Position.X - 20 + SuperTank2.Randomizer.Next(40), Position.Y + 118), SuperTank2.Randomizer.Next(360) * SuperTank2.DegToRad, SuperTank2.Randomizer.NextDouble() * 5).AddParticule(); } else if (LaserPhaseTimer == 90) { ActiveLaser = new LaserWeapon(new Vector2(Position.X, Position.Y + 111)); EnemyAttack.AddEnemyAttack(ActiveLaser); } else if (ActiveLaser.Lifetime <= 0) { LaserPhaseTimer = 0; AttackType = AttackTypes.None; } Vehicule Near = null; float DistanceMin = float.MaxValue; for (int V = 0; V < Vehicule.ArrayVehicule.Length; V++) { float Distance = Vector2.Distance(Position, Vehicule.ArrayVehicule[V].Position); if (Distance < DistanceMin) { DistanceMin = Distance; Near = Vehicule.ArrayVehicule[V]; } } if (Position.X <= Near.Position.X - Speed.X) { if (LaserPhaseTimer < 90) { Speed.X = SpeedX * 0.6f * TimeEllapsed; } else { Speed.X = SpeedX * 0.2f * TimeEllapsed; } } else if (Position.X >= Near.Position.X + Speed.X) { if (LaserPhaseTimer < 90) { Speed.X = -SpeedX * 0.6f * TimeEllapsed; } else { Speed.X = -SpeedX * 0.2f * TimeEllapsed; } } else { Position.X = Near.Position.X; Speed.X = 0; } } Position += Speed; UpdateTransformationMatrix(); if (ActiveLaser != null) { ActiveLaser.Position.X = Position.X; } if (Resist <= 0) { if (Destroy > 0) { Destroy--; new FlameParticle(new Vector2(Position.X + SuperTank2.Randomizer.Next(300) - 150, Position.Y + SuperTank2.Randomizer.Next(100) - 50), Vector2.Zero).AddParticule(); } else { IsAlive = false; } } }
/// <summary> /// Merge data from another participant into this participant. /// </summary> public void Merge(FightParticipant p, int intervalOffset = 0, int timeOffset = 0) { OutboundMissCount += p.OutboundMissCount; OutboundHitCount += p.OutboundHitCount; OutboundHitSum += p.OutboundHitSum; OutboundStrikeCount += p.OutboundStrikeCount; InboundMissCount += p.InboundMissCount; InboundHitCount += p.InboundHitCount; InboundHitSum += p.InboundHitSum; InboundMeleeCount += p.InboundMeleeCount; InboundMeleeSum += p.InboundMeleeSum; InboundRiposteSum += p.InboundRiposteSum; //InboundSpellCount += p.InboundSpellCount; //InboundSpellSum += p.InboundSpellSum; InboundStrikeCount += p.InboundStrikeCount; OutboundHealSum += p.OutboundHealSum; InboundHealSum += p.InboundHealSum; InboundFullHealSum += p.InboundFullHealSum; DeathCount += p.DeathCount; // merge intervals starting at 'intervalOffset' base for (var i = 0; i < p.DPS.Count; i++) { while (DPS.Count <= intervalOffset + i) { DPS.Add(0); } DPS[intervalOffset + i] += p.DPS[i]; } for (var i = 0; i < p.TankDPS.Count; i++) { while (TankDPS.Count <= intervalOffset + i) { TankDPS.Add(0); } TankDPS[intervalOffset + i] += p.TankDPS[i]; } for (var i = 0; i < p.HPS.Count; i++) { while (HPS.Count <= intervalOffset + i) { HPS.Add(0); } HPS[intervalOffset + i] += p.HPS[i]; } for (var i = 0; i < p.InboundHPS.Count; i++) { while (InboundHPS.Count <= intervalOffset + i) { InboundHPS.Add(0); } InboundHPS[intervalOffset + i] += p.InboundHPS[i]; } foreach (var at in p.AttackTypes) { var _at = AttackTypes.FirstOrDefault(x => x.Type == at.Type); if (_at == null) { _at = new FightHit(); _at.Type = at.Type; AttackTypes.Add(_at); } _at.Merge(at); } foreach (var dt in p.DefenseTypes) { var _dt = DefenseTypes.FirstOrDefault(x => x.Type == dt.Type); if (_dt == null) { _dt = new FightMiss(); _dt.Type = dt.Type; DefenseTypes.Add(_dt); } _dt.Merge(dt); } foreach (var h in p.Heals) { var _h = Heals.FirstOrDefault(x => x.Target == h.Target); if (_h == null) { _h = new FightHeal(); _h.Target = h.Target; Heals.Add(_h); } _h.Merge(h); } foreach (var s in p.Spells) { var _s = Spells.FirstOrDefault(x => x.Name == s.Name && x.Type == s.Type); if (_s == null) { _s = new FightSpell(); _s.Type = s.Type; _s.Name = s.Name; //_s.Times = // todo Spells.Add(_s); } _s.Merge(s); } // disabled - merging buffs will create duplicates if fights overlap and include the same buff // it would be better to recreate buffs after merging p.Buffs.Clear(); // >= 0 avoids any pre fight buffs //foreach (var b in p.Buffs.Where(x => x.Time >= 0)) //{ // if (timeOffset == 0) // Buffs.Add(b); // else // Buffs.Add(new FightBuff { Name = b.Name, Time = b.Time + timeOffset }); //} }
/// <summary> /// Creating an attack for every sort of entity /// </summary> /// <param name="attacker">Attacker</param> /// <param name="target">Target</param> /// <param name="type">Type</param> /// <param name="lootId">Optional</param> /// <param name="amount">Optional</param> public void CreateCombat(AbstractAttacker attacker, AbstractAttackable target, AttackTypes type, string lootId = "", int amount = 0) { CreateAttackCombat(new PendingAttack(attacker, target, type, lootId, amount)); }
private Animator playerAnim; //same anim as the PlayerMOvement Script, so be carefull; // Start is called before the first frame update void Start() { playerAnim = GetComponent <Animator>(); atkTypeAnim = 0; currentAttack = AttackTypes.None; }
public static float Damage(Unit source, Unit target, int damage, Elements damageType, AttackTypes attackType) { if (!target.isAlive) { return(0); } float incomeDamage = damage * source.GetDamageFactor() + source.GetDamageSummand(); return(target.TakeDamage(incomeDamage, damageType, attackType)); }
public OldCharacterCard(string name, int cost, int loyalty, Factions faction, Player owner, AttackTypes type, int atk, int rng, int def) : base(name, cost, loyalty, faction, owner) { init(type, atk, rng, def); }
public bool Deserialize(JSON_SkillParam json) { if (json == null) { return(false); } this.iname = json.iname; this.name = json.name; this.expr = json.expr; this.motion = json.motnm; this.effect = json.effnm; this.defend_effect = json.effdef; this.weapon = json.weapon; this.tokkou = json.tktag; this.tk_rate = json.tkrate; this.type = (ESkillType)json.type; this.timing = (ESkillTiming)json.timing; this.condition = (ESkillCondition)json.cond; this.target = (ESkillTarget)json.target; this.line_type = (ELineType)json.line; this.lvcap = (OInt)json.cap; this.cost = (OInt)json.cost; this.count = (OInt)json.count; this.rate = (OInt)json.rate; this.select_range = (ESelectType)json.sran; this.range_min = (OInt)json.rangemin; this.range_max = (OInt)json.range; this.select_scope = (ESelectType)json.ssco; this.scope = (OInt)json.scope; this.effect_height = (OInt)json.eff_h; this.back_defrate = (OInt)json.bdb; this.side_defrate = (OInt)json.sdb; this.ignore_defense_rate = (OInt)json.idr; this.job = json.job; this.SceneName = json.scn; this.ComboNum = (OInt)json.combo_num; this.ComboDamageRate = (OInt)(100 - Math.Abs(json.combo_rate)); this.IsCritical = (OBool)(json.is_cri != 0); this.JewelDamageType = (JewelDamageTypes)json.jdtype; this.JewelDamageValue = (OInt)json.jdv; this.IsJewelAbsorb = (OBool)(json.jdabs != 0); this.DuplicateCount = (OInt)json.dupli; this.CollaboMainId = json.cs_main_id; this.CollaboHeight = (OInt)json.cs_height; this.KnockBackRate = (OInt)json.kb_rate; this.KnockBackVal = (OInt)json.kb_val; this.DamageDispType = (eDamageDispType)json.dmg_dt; this.ReplaceTargetIdLists.Clear(); if (json.rp_tgt_ids != null) { foreach (string rpTgtId in json.rp_tgt_ids) { this.ReplaceTargetIdLists.Add(rpTgtId); } } this.ReplaceChangeIdLists.Clear(); if (json.rp_chg_ids != null) { foreach (string rpChgId in json.rp_chg_ids) { this.ReplaceChangeIdLists.Add(rpChgId); } } if (this.ReplaceTargetIdLists.Count != this.ReplaceChangeIdLists.Count) { this.ReplaceTargetIdLists.Clear(); this.ReplaceChangeIdLists.Clear(); } this.AbilityReplaceTargetIdLists.Clear(); if (json.ab_rp_tgt_ids != null) { foreach (string abRpTgtId in json.ab_rp_tgt_ids) { this.AbilityReplaceTargetIdLists.Add(abRpTgtId); } } this.AbilityReplaceChangeIdLists.Clear(); if (json.ab_rp_chg_ids != null) { foreach (string abRpChgId in json.ab_rp_chg_ids) { this.AbilityReplaceChangeIdLists.Add(abRpChgId); } } if (this.AbilityReplaceTargetIdLists.Count != this.AbilityReplaceChangeIdLists.Count) { this.AbilityReplaceTargetIdLists.Clear(); this.AbilityReplaceChangeIdLists.Clear(); } this.CollaboVoiceId = json.cs_voice; this.CollaboVoicePlayDelayFrame = json.cs_vp_df; this.flags = (SkillFlags)0; if (json.cutin != 0) { this.flags |= SkillFlags.ExecuteCutin; } if (json.isbtl != 0) { this.flags |= SkillFlags.ExecuteInBattle; } if (json.chran != 0) { this.flags |= SkillFlags.EnableChangeRange; } if (json.sonoba != 0) { this.flags |= SkillFlags.SelfTargetSelect; } if (json.pierce != 0) { this.flags |= SkillFlags.PierceAttack; } if (json.hbonus != 0) { this.flags |= SkillFlags.EnableHeightRangeBonus; } if (json.ehpa != 0) { this.flags |= SkillFlags.EnableHeightParamAdjust; } if (json.utgt != 0) { this.flags |= SkillFlags.EnableUnitLockTarget; } if (json.ctbreak != 0) { this.flags |= SkillFlags.CastBreak; } if (json.mpatk != 0) { this.flags |= SkillFlags.JewelAttack; } if (json.fhit != 0) { this.flags |= SkillFlags.ForceHit; } if (json.suicide != 0) { this.flags |= SkillFlags.Suicide; } this.hp_cost = (OInt)json.hp_cost; this.hp_cost_rate = (OInt)Math.Min(Math.Max(json.hp_cost_rate, 0), 100); this.random_hit_rate = (OInt)json.rhit; this.effect_type = (SkillEffectTypes)json.eff_type; this.effect_calc = (SkillParamCalcTypes)json.eff_calc; this.effect_rate = new SkillRankUpValue(); this.effect_rate.ini = (OInt)json.eff_rate_ini; this.effect_rate.max = (OInt)json.eff_rate_max; this.effect_value = new SkillRankUpValue(); this.effect_value.ini = (OInt)json.eff_val_ini; this.effect_value.max = (OInt)json.eff_val_max; this.effect_range = new SkillRankUpValue(); this.effect_range.ini = (OInt)json.eff_range_ini; this.effect_range.max = (OInt)json.eff_range_max; this.effect_hprate = (OInt)json.eff_hprate; this.effect_mprate = (OInt)json.eff_mprate; this.effect_dead_rate = (OInt)json.eff_durate; this.effect_lvrate = (OInt)json.eff_lvrate; this.attack_type = (AttackTypes)json.atk_type; this.attack_detail = (AttackDetailTypes)json.atk_det; this.element_type = (EElement)json.elem; this.element_value = (SkillRankUpValue)null; if (this.element_type != EElement.None) { this.element_value = new SkillRankUpValue(); this.element_value.ini = (OInt)json.elem_ini; this.element_value.max = (OInt)json.elem_max; } this.cast_type = (ECastTypes)json.ct_type; this.cast_speed = (SkillRankUpValue)null; if (this.type == ESkillType.Skill && (json.ct_spd_ini != 0 || json.ct_spd_max != 0)) { this.cast_speed = new SkillRankUpValue(); this.cast_speed.ini = (OInt)json.ct_spd_ini; this.cast_speed.max = (OInt)json.ct_spd_max; } this.absorb_damage_rate = (OInt)json.abs_d_rate; this.reaction_damage_type = (DamageTypes)json.react_d_type; this.reaction_det_lists.Clear(); if (json.react_dets != null) { foreach (AttackDetailTypes reactDet in json.react_dets) { this.reaction_det_lists.Add(reactDet); } } if (this.reaction_damage_type != DamageTypes.None) { this.control_damage_value = new SkillRankUpValue(); this.control_damage_value.ini = (OInt)json.ctrl_d_ini; this.control_damage_value.max = (OInt)json.ctrl_d_max; this.control_damage_calc = (SkillParamCalcTypes)json.ctrl_d_calc; } this.control_ct_rate = (SkillRankUpValue)null; this.control_ct_value = (SkillRankUpValue)null; if (this.control_ct_calc == SkillParamCalcTypes.Fixed || json.ct_val_ini != 0 || json.ct_val_max != 0) { this.control_ct_rate = new SkillRankUpValue(); this.control_ct_rate.ini = (OInt)json.ct_rate_ini; this.control_ct_rate.max = (OInt)json.ct_rate_max; this.control_ct_value = new SkillRankUpValue(); this.control_ct_value.ini = (OInt)json.ct_val_ini; this.control_ct_value.max = (OInt)json.ct_val_max; this.control_ct_calc = (SkillParamCalcTypes)json.ct_calc; } this.target_buff_iname = json.t_buff; this.target_cond_iname = json.t_cond; this.self_buff_iname = json.s_buff; this.self_cond_iname = json.s_cond; this.shield_type = (ShieldTypes)json.shield_type; this.shield_damage_type = (DamageTypes)json.shield_d_type; this.shield_turn = (SkillRankUpValue)null; this.shield_value = (SkillRankUpValue)null; if (this.shield_type != ShieldTypes.None && this.shield_damage_type != DamageTypes.None) { this.shield_turn = new SkillRankUpValue(); this.shield_turn.ini = (OInt)json.shield_turn_ini; this.shield_turn.max = (OInt)json.shield_turn_max; this.shield_value = new SkillRankUpValue(); this.shield_value.ini = (OInt)json.shield_ini; this.shield_value.max = (OInt)json.shield_max; } SkillEffectTypes effectType = this.effect_type; switch (effectType) { case SkillEffectTypes.Teleport: case SkillEffectTypes.Changing: case SkillEffectTypes.Throw: this.scope = (OInt)0; this.select_scope = ESelectType.Cross; break; case SkillEffectTypes.RateDamage: if (this.attack_type == AttackTypes.None) { this.attack_type = AttackTypes.PhyAttack; break; } break; default: if (effectType == SkillEffectTypes.Attack || effectType == SkillEffectTypes.ReflectDamage) { goto case SkillEffectTypes.RateDamage; } else { break; } } if (this.select_range == ESelectType.Laser) { this.select_scope = ESelectType.Laser; this.scope = (OInt)Math.Max((int)this.scope, 1); } else { switch (this.select_range) { case ESelectType.LaserSpread: this.select_scope = ESelectType.LaserSpread; break; case ESelectType.LaserWide: this.select_scope = ESelectType.LaserWide; break; case ESelectType.LaserTwin: this.select_scope = ESelectType.LaserTwin; break; case ESelectType.LaserTriple: this.select_scope = ESelectType.LaserTriple; break; } switch (this.select_scope) { case ESelectType.LaserSpread: case ESelectType.LaserWide: case ESelectType.LaserTwin: case ESelectType.LaserTriple: this.scope = (OInt)1; break; } } return(true); }
public static string ToDisplay( this AttackTypes value) => DisplayTexts[(int)value];
private int attack(int attacksLaunched, AttackTypes attackType) { int chance = -1; int bonusHit = 0; bool bonusHitParseAttempt = int.TryParse(this.bonusHitChance.Text, out bonusHit); bool bonusDamageParseAttempt = Dice.parseable(this.bonusDamageTextBox.Text); if (!bonusHitParseAttempt) { this.logger.logBoth(String.Format("Bonus Hit Chance could not be parsed. Input: {0}, setting to 0", this.bonusHitChance.Text)); this.bonusHitChance.Text = "0"; bonusHit = 0; } if (!bonusDamageParseAttempt) { this.logger.logBoth(String.Format("Bonus Damage could not be parsed. Input: {0}, setting to 0", this.bonusDamageTextBox.Text)); this.bonusDamageTextBox.Text = "0"; } switch (attackType) { case (AttackTypes.Melee): chance = meleeHitChance(); break; case (AttackTypes.ShortRangeSingle): chance = shortRangeShotChance(true); break; case (AttackTypes.ShortRangeBurst): chance = shortRangeShotChance(false); break; case (AttackTypes.LongRange): chance = longRangeShotChance(); break; default: this.logger.logBoth(String.Format("A weird error occured at the attack() function. The attackType is: {0}", attackType.ToString())); return 0; } this.logger.logBoth(String.Format("Hit Chance: {0}, Bonus Hit Chance: {1}, Bonus Damage: {2}", chance.ToString(), bonusHit.ToString(), this.bonusDamageTextBox.Text)); chance += bonusHit; attacksLaunched *= ((AttackTypes) this.comboAttackingMethod.SelectedItem).Equals(AttackTypes.ShortRangeBurst) ? ((Weapon) this.comboWeapon.SelectedItem).ShotsPerBurst : 1; int[] damages = attackDamage(attacksLaunched); int totalDamage = 0; Dice dice = new Dice(1, Math.Max(100, chance), this.logger); dynamic attacker = (dynamic) this.comboAttackingUnit.SelectedItem; int rolled = -1; foreach (int damage in damages) { rolled = dice.getRoll(); if (rolled < attacker.StatID.CriticalChance) // Critical Hit { this.logger.logBoth(String.Format("Critical Hit: {0} < {1}", rolled.ToString(), attacker.StatID.CriticalChance)); this.logger.logBoth(String.Format("Damage Taken: {0}", (damageReduction(damage) * 2).ToString())); totalDamage += damageReduction(damage) * 2; continue; } if (rolled > Math.Max(100, chance) - (10 - attacker.StatID.Luck)) // Critical Failure { this.logger.logBoth(String.Format("Critical Failure: {0} > {1}", rolled.ToString(), (Math.Max(100, chance) - (10 - attacker.StatID.Luck)).ToString())); this.logger.logBoth("Ending Calculations."); return totalDamage; } if (rolled <= chance) // Hit { this.logger.logBoth(String.Format("Hit: {0} < {1}", rolled.ToString(), chance.ToString())); this.logger.logBoth(String.Format("Damage Taken: {0}", damageReduction(damage).ToString())); totalDamage += damageReduction(damage); continue; } else if (rolled > chance) // Miss { this.logger.logBoth(String.Format("Miss: {0} > {1}", rolled.ToString(), chance.ToString())); continue; } else { this.logger.logBoth("There's a problem, contact the product owner and send the log file (It's in the same directory)"); return 0; } } this.textDamageDealt.Text = totalDamage.ToString(); return totalDamage; }
public bool Deserialize(JSON_SkillParam json) { if (json == null) { return(false); } this.iname = json.iname; this.name = json.name; this.expr = json.expr; this.motion = json.motnm; this.effect = json.effnm; this.defend_effect = json.effdef; this.weapon = json.weapon; this.tokkou = json.tktag; this.tk_rate = json.tkrate; this.type = (ESkillType)json.type; this.timing = (ESkillTiming)json.timing; this.condition = (ESkillCondition)json.cond; this.target = (ESkillTarget)json.target; this.line_type = (ELineType)json.line; this.lvcap = (OInt)json.cap; this.cost = (OInt)json.cost; this.count = (OInt)json.count; this.rate = (OInt)json.rate; this.select_range = (ESelectType)json.sran; this.range_min = (OInt)json.rangemin; this.range_max = (OInt)json.range; this.select_scope = (ESelectType)json.ssco; this.scope = (OInt)json.scope; this.effect_height = (OInt)json.eff_h; this.back_defrate = (OInt)json.bdb; this.side_defrate = (OInt)json.sdb; this.ignore_defense_rate = (OInt)json.idr; this.job = json.job; this.SceneName = json.scn; this.ComboNum = (OInt)json.combo_num; this.ComboDamageRate = (OInt)(100 - Math.Abs(json.combo_rate)); this.IsCritical = (OBool)(json.is_cri != 0); this.JewelDamageType = (JewelDamageTypes)json.jdtype; this.JewelDamageValue = (OInt)json.jdv; this.IsJewelAbsorb = (OBool)(json.jdabs != 0); this.DuplicateCount = (OInt)json.dupli; this.CollaboMainId = json.cs_main_id; this.CollaboHeight = (OInt)json.cs_height; this.KnockBackRate = (OInt)json.kb_rate; this.KnockBackVal = (OInt)json.kb_val; this.KnockBackDir = (eKnockBackDir)json.kb_dir; this.KnockBackDs = (eKnockBackDs)json.kb_ds; this.DamageDispType = (eDamageDispType)json.dmg_dt; this.ReplaceTargetIdLists = (List <string>)null; if (json.rp_tgt_ids != null) { this.ReplaceTargetIdLists = new List <string>(); foreach (string rpTgtId in json.rp_tgt_ids) { this.ReplaceTargetIdLists.Add(rpTgtId); } } this.ReplaceChangeIdLists = (List <string>)null; if (json.rp_chg_ids != null && this.ReplaceTargetIdLists != null) { this.ReplaceChangeIdLists = new List <string>(); foreach (string rpChgId in json.rp_chg_ids) { this.ReplaceChangeIdLists.Add(rpChgId); } } if (this.ReplaceTargetIdLists != null && this.ReplaceChangeIdLists != null && this.ReplaceTargetIdLists.Count != this.ReplaceChangeIdLists.Count) { this.ReplaceTargetIdLists.Clear(); this.ReplaceChangeIdLists.Clear(); } this.AbilityReplaceTargetIdLists = (List <string>)null; if (json.ab_rp_tgt_ids != null) { this.AbilityReplaceTargetIdLists = new List <string>(); foreach (string abRpTgtId in json.ab_rp_tgt_ids) { this.AbilityReplaceTargetIdLists.Add(abRpTgtId); } } this.AbilityReplaceChangeIdLists = (List <string>)null; if (json.ab_rp_chg_ids != null && this.AbilityReplaceTargetIdLists != null) { this.AbilityReplaceChangeIdLists = new List <string>(); foreach (string abRpChgId in json.ab_rp_chg_ids) { this.AbilityReplaceChangeIdLists.Add(abRpChgId); } } if (this.AbilityReplaceTargetIdLists != null && this.AbilityReplaceChangeIdLists != null && this.AbilityReplaceTargetIdLists.Count != this.AbilityReplaceChangeIdLists.Count) { this.AbilityReplaceTargetIdLists.Clear(); this.AbilityReplaceChangeIdLists.Clear(); } this.CollaboVoiceId = json.cs_voice; this.CollaboVoicePlayDelayFrame = json.cs_vp_df; this.TeleportType = (eTeleportType)json.tl_type; this.TeleportTarget = (ESkillTarget)json.tl_target; this.TeleportHeight = json.tl_height; this.TeleportIsMove = json.tl_is_mov != 0; this.TrickId = json.tr_id; this.TrickSetType = (eTrickSetType)json.tr_set; this.BreakObjId = json.bo_id; this.MapEffectDesc = json.me_desc; this.WeatherRate = json.wth_rate; this.WeatherId = json.wth_id; this.ElementSpcAtkRate = json.elem_tk; this.MaxDamageValue = json.max_dmg; this.CutInConceptCardId = json.ci_cc_id; this.JudgeHpVal = json.jhp_val; this.JudgeHpCalc = (SkillParamCalcTypes)json.jhp_calc; this.AcFromAbilId = json.ac_fr_ab_id; this.AcToAbilId = json.ac_to_ab_id; this.AcTurn = json.ac_turn; this.EffectHitTargetNumRate = (OInt)json.eff_htnrate; this.AbsorbAndGive = (eAbsorbAndGive)json.aag; this.TargetEx = (eSkillTargetEx)json.target_ex; this.JumpSpcAtkRate = json.jmp_tk; this.flags = (SkillFlags)0; if (json.cutin != 0) { this.flags |= SkillFlags.ExecuteCutin; } if (json.isbtl != 0) { this.flags |= SkillFlags.ExecuteInBattle; } if (json.chran != 0) { this.flags |= SkillFlags.EnableChangeRange; } if (json.sonoba != 0) { this.flags |= SkillFlags.SelfTargetSelect; } if (json.pierce != 0) { this.flags |= SkillFlags.PierceAttack; } if (json.hbonus != 0) { this.flags |= SkillFlags.EnableHeightRangeBonus; } if (json.ehpa != 0) { this.flags |= SkillFlags.EnableHeightParamAdjust; } if (json.utgt != 0) { this.flags |= SkillFlags.EnableUnitLockTarget; } if (json.ctbreak != 0) { this.flags |= SkillFlags.CastBreak; } if (json.mpatk != 0) { this.flags |= SkillFlags.JewelAttack; } if (json.fhit != 0) { this.flags |= SkillFlags.ForceHit; } if (json.suicide != 0) { this.flags |= SkillFlags.Suicide; } if (json.sub_actuate != 0) { this.flags |= SkillFlags.SubActuate; } if (json.is_fixed != 0) { this.flags |= SkillFlags.FixedDamage; } if (json.f_ulock != 0) { this.flags |= SkillFlags.ForceUnitLock; } if (json.ad_react != 0) { this.flags |= SkillFlags.AllDamageReaction; } if (json.ig_elem != 0) { this.flags |= SkillFlags.IgnoreElement; } if (json.is_pre_apply != 0) { this.flags |= SkillFlags.PrevApply; } if (json.jhp_over != 0) { this.flags |= SkillFlags.JudgeHpOver; } if (json.is_mhm_dmg != 0) { this.flags |= SkillFlags.MhmDamage; } if (json.ac_is_self != 0) { this.flags |= SkillFlags.AcSelf; } if (json.ac_is_reset != 0) { this.flags |= SkillFlags.AcReset; } if (json.is_htndiv != 0) { this.flags |= SkillFlags.HitTargetNumDiv; } if (json.is_no_ccc != 0) { this.flags |= SkillFlags.NoChargeCalcCT; } if (json.jmpbreak != 0) { this.flags |= SkillFlags.JumpBreak; } this.hp_cost = (OInt)json.hp_cost; this.hp_cost_rate = (OInt)Math.Min(Math.Max(json.hp_cost_rate, 0), 100); this.random_hit_rate = (OInt)json.rhit; this.effect_type = (SkillEffectTypes)json.eff_type; this.effect_calc = (SkillParamCalcTypes)json.eff_calc; this.effect_rate = new SkillRankUpValue(); this.effect_rate.ini = (OInt)json.eff_rate_ini; this.effect_rate.max = (OInt)json.eff_rate_max; this.effect_value = new SkillRankUpValue(); this.effect_value.ini = (OInt)json.eff_val_ini; this.effect_value.max = (OInt)json.eff_val_max; this.effect_range = new SkillRankUpValue(); this.effect_range.ini = (OInt)json.eff_range_ini; this.effect_range.max = (OInt)json.eff_range_max; this.effect_hprate = (OInt)json.eff_hprate; this.effect_mprate = (OInt)json.eff_mprate; this.effect_dead_rate = (OInt)json.eff_durate; this.effect_lvrate = (OInt)json.eff_lvrate; this.attack_type = (AttackTypes)json.atk_type; this.attack_detail = (AttackDetailTypes)json.atk_det; this.element_type = (EElement)json.elem; this.element_value = (SkillRankUpValue)null; if (this.element_type != EElement.None) { this.element_value = new SkillRankUpValue(); this.element_value.ini = (OInt)json.elem_ini; this.element_value.max = (OInt)json.elem_max; } this.cast_type = (ECastTypes)json.ct_type; this.cast_speed = (SkillRankUpValue)null; if (this.type == ESkillType.Skill && (json.ct_spd_ini != 0 || json.ct_spd_max != 0)) { this.cast_speed = new SkillRankUpValue(); this.cast_speed.ini = (OInt)json.ct_spd_ini; this.cast_speed.max = (OInt)json.ct_spd_max; } this.absorb_damage_rate = (OInt)json.abs_d_rate; this.reaction_damage_type = (DamageTypes)json.react_d_type; this.reaction_det_lists = (List <AttackDetailTypes>)null; if (json.react_dets != null) { this.reaction_det_lists = new List <AttackDetailTypes>(); foreach (AttackDetailTypes reactDet in json.react_dets) { this.reaction_det_lists.Add(reactDet); } } this.control_ct_rate = (SkillRankUpValue)null; this.control_ct_value = (SkillRankUpValue)null; if (this.control_ct_calc == SkillParamCalcTypes.Fixed || json.ct_val_ini != 0 || json.ct_val_max != 0) { this.control_ct_rate = new SkillRankUpValue(); this.control_ct_rate.ini = (OInt)json.ct_rate_ini; this.control_ct_rate.max = (OInt)json.ct_rate_max; this.control_ct_value = new SkillRankUpValue(); this.control_ct_value.ini = (OInt)json.ct_val_ini; this.control_ct_value.max = (OInt)json.ct_val_max; this.control_ct_calc = (SkillParamCalcTypes)json.ct_calc; } this.target_buff_iname = json.t_buff; this.target_cond_iname = json.t_cond; this.self_buff_iname = json.s_buff; this.self_cond_iname = json.s_cond; this.shield_type = (ShieldTypes)json.shield_type; this.shield_damage_type = (DamageTypes)json.shield_d_type; this.shield_turn = (SkillRankUpValue)null; this.shield_value = (SkillRankUpValue)null; if (this.shield_type != ShieldTypes.None && this.shield_damage_type != DamageTypes.None) { this.shield_turn = new SkillRankUpValue(); this.shield_turn.ini = (OInt)json.shield_turn_ini; this.shield_turn.max = (OInt)json.shield_turn_max; this.shield_value = new SkillRankUpValue(); this.shield_value.ini = (OInt)json.shield_ini; this.shield_value.max = (OInt)json.shield_max; if (json.shield_reset != 0) { this.flags |= SkillFlags.ShieldReset; } } if (this.reaction_damage_type != DamageTypes.None || this.shield_damage_type != DamageTypes.None) { this.control_damage_rate = new SkillRankUpValue(); this.control_damage_rate.ini = (OInt)json.ctrl_d_rate_ini; this.control_damage_rate.max = (OInt)json.ctrl_d_rate_max; this.control_damage_value = new SkillRankUpValue(); this.control_damage_value.ini = (OInt)json.ctrl_d_ini; this.control_damage_value.max = (OInt)json.ctrl_d_max; this.control_damage_calc = (SkillParamCalcTypes)json.ctrl_d_calc; } SkillEffectTypes effectType = this.effect_type; switch (effectType) { case SkillEffectTypes.Teleport: case SkillEffectTypes.Changing: case SkillEffectTypes.Throw: this.scope = (OInt)0; this.select_scope = ESelectType.Cross; break; case SkillEffectTypes.RateDamage: if (this.attack_type == AttackTypes.None) { this.attack_type = AttackTypes.PhyAttack; break; } break; default: if (effectType == SkillEffectTypes.Attack || effectType == SkillEffectTypes.ReflectDamage || effectType == SkillEffectTypes.RateDamageCurrent) { goto case SkillEffectTypes.RateDamage; } else { break; } } if (this.select_range == ESelectType.Laser) { this.select_scope = ESelectType.Laser; this.scope = (OInt)Math.Max((int)this.scope, 1); } else { switch (this.select_range) { case ESelectType.LaserSpread: this.select_scope = ESelectType.LaserSpread; break; case ESelectType.LaserWide: this.select_scope = ESelectType.LaserWide; break; case ESelectType.LaserTwin: this.select_scope = ESelectType.LaserTwin; break; case ESelectType.LaserTriple: this.select_scope = ESelectType.LaserTriple; break; } switch (this.select_scope) { case ESelectType.LaserSpread: case ESelectType.LaserWide: case ESelectType.LaserTwin: case ESelectType.LaserTriple: this.scope = (OInt)1; break; } } if (this.TeleportType != eTeleportType.None) { if (!this.IsTargetGridNoUnit && this.TeleportType != eTeleportType.BeforeSkill) { this.target = ESkillTarget.GridNoUnit; } if (this.IsTargetTeleport) { if (this.IsCastSkill()) { this.cast_speed = (SkillRankUpValue)null; } if ((int)this.scope != 0) { this.scope = (OInt)0; } } } if (this.IsTargetValidGrid && !this.IsTrickSkill()) { this.target = ESkillTarget.GridNoUnit; } if (this.timing == ESkillTiming.Auto && this.effect_type == SkillEffectTypes.Attack) { this.effect_type = SkillEffectTypes.Buff; } return(true); }
// **************************************************** // ** These must be wired up via Unity's timeline ****** // **************************************************** public void OnAttackBegin() { ActiveAttack = AttackTypes.Swing; IsAttacking = true; }
public void UpdateAttackTimer(AttackTypes at) { AttackTimers[at] -= 50; //timer update time }
public void OnUppercutBegin() { ActiveAttack = AttackTypes.Uppercut; IsAttacking = true; }
public void CalculateMeleeDamage(Unit victim, uint damage, out UnitStructs.CalcDamageInfo damageInfo, AttackTypes attackType) { damageInfo = new UnitStructs.CalcDamageInfo { attacker = this.Guid, target = victim.Guid, damageSchoolMask = 0, attackType = attackType, damage = 0, cleanDamage = 0, absorb = 0, resist = 0, blocked_amount = 0, TargetState = 0, HitInfo = 0, procAttacker = ProcFlags.NONE, procVictim = ProcFlags.NONE, procEx = ProcFlagsExLegacy.NONE }; if (victim == null) { if (this.IsTypeOf(ObjectTypes.TYPE_PLAYER)) { ((Player)this).LeaveCombat(); } return; } if (this.IsDead || victim.IsDead) { if (this.IsTypeOf(ObjectTypes.TYPE_PLAYER)) { ((Player)this).LeaveCombat(); } return; } // Select HitInfo/procAttacker/procVictim flag based on attack type switch (attackType) { case AttackTypes.BASE_ATTACK: damageInfo.procAttacker = ProcFlags.DONE_MELEE_AUTO_ATTACK | ProcFlags.DONE_MAINHAND_ATTACK; damageInfo.procVictim = ProcFlags.TAKEN_MELEE_AUTO_ATTACK; break; case AttackTypes.OFFHAND_ATTACK: damageInfo.procAttacker = ProcFlags.DONE_MELEE_AUTO_ATTACK | ProcFlags.DONE_OFFHAND_ATTACK; damageInfo.procVictim = ProcFlags.TAKEN_MELEE_AUTO_ATTACK; damageInfo.HitInfo = HitInfo.OFFHAND; break; default: return; } // Physical Immune check damageInfo.damage += CalculateDamage(damageInfo.attackType, false, true); // Add melee damage bonus //damage = MeleeDamageBonusDone(damageInfo.target, damage, damageInfo.attackType); //damage = damageInfo.target.MeleeDamageBonusTaken(this, damage, damageInfo.attackType); // Calculate armor reduction //if (IsDamageReducedByArmor((SpellSchoolMask)(damageInfo.damageSchoolMask))) //{ //damageInfo.damage = CalcArmorReducedDamage(damageInfo.target, damage, NULL, damageInfo.attackType); //damageInfo.cleanDamage += damage - damageInfo.damage; //} float critChance = 5 + ((float)this.Agility.Current / (this.Level < 3 || this.Agility.Current < 3 ? 1 : this.Level / 3)); //Just a quick dummy formula for crit percentage; 5% base + 1% for each (1/3 level X agility) bool isCrit = (new Random().Next(0, 100) <= critChance); damageInfo.TargetState = RollMeleeOutcome(victim); switch (damageInfo.TargetState) { case VictimStates.VS_EVADE: damageInfo.HitInfo |= HitInfo.MISS | HitInfo.SWINGNOHITSOUND; damageInfo.procEx |= ProcFlagsExLegacy.EVADE; damageInfo.damage = 0; damageInfo.cleanDamage = 0; return; case VictimStates.VS_NONE: damageInfo.HitInfo |= HitInfo.MISS; damageInfo.procEx |= ProcFlagsExLegacy.MISS; damageInfo.damage = 0; damageInfo.cleanDamage = 0; break; case VictimStates.VS_WOUND: if (isCrit) { damageInfo.HitInfo |= HitInfo.CRITICALHIT; damageInfo.procEx |= ProcFlagsExLegacy.CRITICAL_HIT; // Crit bonus calc damageInfo.damage += damageInfo.damage; //float mod = 0.0f; // Apply SPELL_AURA_MOD_ATTACKER_RANGED_CRIT_DAMAGE or SPELL_AURA_MOD_ATTACKER_MELEE_CRIT_DAMAGE //if (damageInfo.attackType == RANGED_ATTACK) //mod += damageInfo.target.GetTotalAuraModifier(SPELL_AURA_MOD_ATTACKER_RANGED_CRIT_DAMAGE); //else //mod += damageInfo.target.GetTotalAuraModifier(SPELL_AURA_MOD_ATTACKER_MELEE_CRIT_DAMAGE); // Increase crit damage from SPELL_AURA_MOD_CRIT_DAMAGE_BONUS //mod += (GetTotalAuraMultiplierByMiscMask(SPELL_AURA_MOD_CRIT_DAMAGE_BONUS, damageInfo.damageSchoolMask) - 1.0f) * 100; //if (mod != 0) //AddPct(damageInfo.damage, mod); } else { damageInfo.procEx |= ProcFlagsExLegacy.NORMAL_HIT; } break; case VictimStates.VS_PARRY: damageInfo.procEx |= ProcFlagsExLegacy.PARRY; damageInfo.cleanDamage += damageInfo.damage; damageInfo.damage = 0; break; case VictimStates.VS_DODGE: damageInfo.procEx |= ProcFlagsExLegacy.DODGE; damageInfo.cleanDamage += damageInfo.damage; damageInfo.damage = 0; break; case VictimStates.VS_BLOCK: //damageInfo.TargetState = VICTIMSTATE_HIT; damageInfo.procEx |= ProcFlagsExLegacy.BLOCK | ProcFlagsExLegacy.NORMAL_HIT; //30% damage blocked, double blocked amount if block is critical //damageInfo.blocked_amount = CalculatePct(damageInfo.damage, damageInfo.target.isBlockCritical() ? damageInfo.target.GetBlockPercent() * 2 : damageInfo.target.GetBlockPercent()); damageInfo.damage -= damageInfo.blocked_amount; damageInfo.cleanDamage += damageInfo.blocked_amount; break; } //Always apply HITINFO_AFFECTS_VICTIM in case its not a miss if (!Convert.ToBoolean(damageInfo.HitInfo & HitInfo.MISS)) { damageInfo.HitInfo |= HitInfo.AFFECTS_VICTIM; } float resilienceReduction = (this.Armor.BaseAmount + 400 + 85 * (int)this.Level); if (resilienceReduction > 0.75f) { resilienceReduction = 0.75f; } else if (resilienceReduction < 0) { resilienceReduction = 0; } damageInfo.resist = (uint)resilienceReduction; //Calculate absorb resist if ((int)damageInfo.damage > 0) { damageInfo.procVictim |= ProcFlags.TAKEN_DAMAGE; // Calculate absorb & resists //CalcAbsorbResist(damageInfo.target, SpellSchoolMask(damageInfo.damageSchoolMask), DIRECT_DAMAGE, damageInfo.damage, &damageInfo.absorb, &damageInfo.resist); if (damageInfo.absorb != 0) { damageInfo.HitInfo |= (damageInfo.damage - damageInfo.absorb == 0 ? HitInfo.FULL_ABSORB : HitInfo.PARTIAL_ABSORB); damageInfo.procEx |= ProcFlagsExLegacy.ABSORB; } if (damageInfo.resist != 0) { damageInfo.HitInfo |= (damageInfo.damage - damageInfo.resist == 0 ? HitInfo.FULL_RESIST : HitInfo.PARTIAL_RESIST); } damageInfo.damage -= damageInfo.absorb + damageInfo.resist; } else //Just incase { damageInfo.damage = 0; } if (damageInfo.damage < 0) { damageInfo.damage = 0; } if (damageInfo.cleanDamage < 0) { damageInfo.cleanDamage = 0; } // Rage calculation if (damageInfo.damage > 0) { if (this.Class == (byte)Classes.CLASS_WARRIOR) { this.Rage.Current = (this.Rage.Current / 10) + CalculateRageRegen(ref damageInfo, isCrit, victim, true); if (this.Rage.Current > 1000) { this.Rage.Current = 100; } } if (victim is Player && ((Player)victim).Class == (byte)Classes.CLASS_WARRIOR) { victim.Rage.Current = (victim.Rage.Current / 10) + CalculateRageRegen(ref damageInfo, isCrit, victim, false); if (victim.Rage.Current > 1000) { victim.Rage.Current = 100; } } } }
/// <summary> /// Secondary constructor /// </summary> /// <param name="target"></param> /// <param name="attacker"></param> /// <param name="damage"></param> /// <param name="absorbDamage"></param> /// <param name="calculationType"></param> /// <param name="attackType"></param> public PendingDamage(AbstractAttackable target, AbstractAttacker attacker, int damage, int absorbDamage, DamageCalculationTypes calculationType, AttackTypes attackType) : this(target, damage, absorbDamage, calculationType, attackType) { Attacker = attacker; }