public override void OnScoreHit(
            Agent affectedAgent,
            Agent affectorAgent,
            WeaponComponentData attackerWeapon,
            bool isBlocked,
            float damage,
            float movementSpeedDamageModifier,
            float hitDistance,
            AgentAttackType attackType,
            float shotDifficulty,
            BoneBodyPartType victimHitBodyPart)
        {
            bool flag1 = affectorAgent != null && affectorAgent.IsMainAgent;

            if (affectorAgent == null || affectedAgent == null || (!affectorAgent.IsHuman || !affectedAgent.IsHuman))
            {
                return;
            }
            HighlightsController.Highlight highlight = new HighlightsController.Highlight();
            highlight.Start = Mission.Current.Time;
            highlight.End   = Mission.Current.Time;
            bool flag2 = false;

            if (flag1 && (double)shotDifficulty >= 7.5)
            {
                highlight.HighlightType = this.GetHighlightTypeWithId("hlid_high_ranged_shot_difficulty");
                flag2 = true;
            }
            if (flag1 && affectedAgent.HasMount && (attackType == AgentAttackType.Standard && affectorAgent.HasMount) && affectorAgent.IsDoingPassiveAttack)
            {
                highlight.HighlightType = this.GetHighlightTypeWithId("hlid_couched_lance_against_mounted_opponent");
                flag2 = true;
            }
            if (this._isFirstImpact && affectorAgent.Formation != null && (affectorAgent.Formation.IsCavalry() && affectorAgent.Formation.MovementOrder == (object)MovementOrder.MovementOrderCharge) && this.CanSaveHighlight(this.GetHighlightTypeWithId("hlid_cavalry_charge_first_impact"), affectedAgent.Position))
            {
                this._cavalryChargeHitTimes.RemoveAll((Predicate <float>)(ht => (double)ht + 3.0 < (double)Mission.Current.Time));
                this._cavalryChargeHitTimes.Add(Mission.Current.Time);
                if (this._cavalryChargeHitTimes.Count >= 5)
                {
                    highlight.HighlightType = this.GetHighlightTypeWithId("hlid_cavalry_charge_first_impact");
                    highlight.Start         = this._cavalryChargeHitTimes[0];
                    highlight.End           = this._cavalryChargeHitTimes.Last <float>();
                    flag2 = true;
                    this._isFirstImpact = false;
                    this._cavalryChargeHitTimes.Clear();
                }
            }
            if (!flag2)
            {
                return;
            }
            this.SaveHighlight(highlight, affectedAgent.Position);
        }
示例#2
0
 public override void OnScoreHit(
     Agent affectedAgent,
     Agent affectorAgent,
     WeaponComponentData attackerWeapon,
     bool isBlocked,
     float damage,
     float movementSpeedDamageModifier,
     float hitDistance,
     AgentAttackType attackType,
     float shotDifficulty,
     BoneBodyPartType victimHitBodyPart)
 {
     if (!GameNetwork.IsServer || isBlocked || (affectorAgent == affectedAgent || affectorAgent.MissionPeer == null) || (double)damage <= 0.0)
     {
         return;
     }
     affectedAgent.AddHitter(affectorAgent.MissionPeer, damage, affectorAgent.IsFriendOf(affectedAgent));
 }
 public KillingBlow(
     Blow b,
     Vec3 ragdollImpulsePoint,
     Vec3 ragdollImpulseAmount,
     int deathAction,
     int weaponItemKind,
     Agent.KillInfo overrideKillInfo = Agent.KillInfo.Invalid)
 {
     this.RagdollImpulseLocalPoint = ragdollImpulsePoint;
     this.RagdollImpulseAmount     = ragdollImpulseAmount;
     this.DeathAction             = deathAction;
     this.OverrideKillInfo        = overrideKillInfo;
     this.DamageType              = b.DamageType;
     this.AttackType              = b.AttackType;
     this.OwnerId                 = b.OwnerId;
     this.BoneIndex               = b.BoneIndex;
     this.WeaponClass             = (int)b.WeaponRecord.WeaponClass;
     this.BlowPosition            = b.Position;
     this.WeaponRecordWeaponFlags = b.WeaponRecord.WeaponFlags;
     this.WeaponItemKind          = weaponItemKind;
     this.InflictedDamage         = b.InflictedDamage;
     this.IsMissile               = b.IsMissile;
     this.IsValid                 = true;
 }
示例#4
0
 public override void OnScoreHit(Agent affectedAgent, Agent affectorAgent, int affectorWeaponKind, bool isBlocked, float damage, float movementSpeedDamageModifier, float hitDistance, AgentAttackType attackType, float shotDifficulty, int weaponCurrentUsageIndex)
 {
     if (FireLordConfig.IgniteTargetWithFireSword &&
         _fireSwordEnabled && affectorAgent == Agent.Main && affectedAgent != null && affectedAgent.IsHuman)
     {
         if (FireArrowLogic.AgentFireDatas.ContainsKey(affectedAgent))
         {
             AgentFireData fireData = FireArrowLogic.AgentFireDatas[affectedAgent];
             if (!fireData.isBurning)
             {
                 fireData.firebar += (isBlocked) ? FireLordConfig.IgnitionPerFireSwordHit / 2 : FireLordConfig.IgnitionPerFireSwordHit;
                 fireData.attacker = affectorAgent;
             }
         }
         else
         {
             AgentFireData fireData = new AgentFireData();
             fireData.firebar += (isBlocked) ? FireLordConfig.IgnitionPerFireSwordHit / 2 : FireLordConfig.IgnitionPerFireSwordHit;
             fireData.attacker = affectorAgent;
             FireArrowLogic.AgentFireDatas.Add(affectedAgent, fireData);
         }
     }
 }
        public override void OnScoreHit(Agent affectedAgent, Agent affectorAgent, int affectorWeaponKind, bool isBlocked, float damage, float movementSpeedDamageModifier, float hitDistance, AgentAttackType attackType, float shotDifficulty, int weaponCurrentUsageIndex)
        {
            try
            {
                Hero affectorHero;

                if (!IsValidAffected(affectedAgent) || !IsValidAffector(affectorAgent, out affectorHero))
                {
                    return;
                }

                if (affectorHero != null)
                {
                    Hero captainHero   = null;
                    Hero commanderHero = null;
                    //If the affector is the player's companion, set the commander and captain as the player.
                    if (affectorHero != Hero.MainHero)
                    {
                        CharacterObject leaderCharacter = (CharacterObject)affectorAgent.Team.Leader.Character;
                        if (leaderCharacter.HeroObject == Hero.MainHero)
                        {
                            captainHero   = Hero.MainHero;
                            commanderHero = Hero.MainHero;
                        }
                    }
                    float hitPointRatio = (Math.Min(damage, affectedAgent.HealthLimit) / affectedAgent.HealthLimit) * 0.5f;
                    bool  isTeamKill    = affectorAgent.Team == affectedAgent.Team;
                    bool  isFatal       = affectedAgent.Health <= 0;

                    //MessageBox.Show($"Giving experience to {affectorAgent.Character.Name} in tournament.\nAffected:{affectedAgent.Character.Name}\nCaptain: {captainHero?.Name?.ToString()}");

                    SkillLevelingManager.OnCombatHit(affectorAgent.Character as CharacterObject, affectedAgent.Character as CharacterObject,
                                                     captainHero, commanderHero, movementSpeedDamageModifier, shotDifficulty, affectorWeaponKind, hitPointRatio, false, affectorAgent.HasMount,
                                                     isTeamKill, false, weaponCurrentUsageIndex, damage, isFatal);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show($"An error occurred during Tournament experience logic:\n\n{ex.ToStringFull()}");
            }
        }
        public int GetHitSound(
            bool isOwnerHumanoid,
            bool isCriticalBlow,
            bool isLowBlow,
            bool isNonTipThrust,
            AgentAttackType attackType,
            DamageTypes damageType)
        {
            int num;

            if (this.HasWeapon())
            {
                if (this.IsRanged || this.IsAmmo)
                {
                    switch (this.WeaponClass)
                    {
                    case WeaponClass.Stone:
                        num = !isCriticalBlow ? (!isLowBlow ? CombatSoundContainer.SoundCodeMissionCombatThrowingStoneMed : CombatSoundContainer.SoundCodeMissionCombatThrowingStoneLow) : CombatSoundContainer.SoundCodeMissionCombatThrowingStoneHigh;
                        break;

                    case WeaponClass.Boulder:
                        num = !isCriticalBlow ? (!isLowBlow ? CombatSoundContainer.SoundCodeMissionCombatBoulderMed : CombatSoundContainer.SoundCodeMissionCombatBoulderLow) : CombatSoundContainer.SoundCodeMissionCombatBoulderHigh;
                        break;

                    case WeaponClass.ThrowingAxe:
                        num = !isCriticalBlow ? (!isLowBlow ? CombatSoundContainer.SoundCodeMissionCombatThrowingAxeMed : CombatSoundContainer.SoundCodeMissionCombatThrowingAxeLow) : CombatSoundContainer.SoundCodeMissionCombatThrowingAxeHigh;
                        break;

                    case WeaponClass.ThrowingKnife:
                        num = !isCriticalBlow ? (!isLowBlow ? CombatSoundContainer.SoundCodeMissionCombatThrowingDaggerMed : CombatSoundContainer.SoundCodeMissionCombatThrowingDaggerLow) : CombatSoundContainer.SoundCodeMissionCombatThrowingDaggerHigh;
                        break;

                    case WeaponClass.Javelin:
                        num = !isCriticalBlow ? (!isLowBlow ? CombatSoundContainer.SoundCodeMissionCombatMissileMed : CombatSoundContainer.SoundCodeMissionCombatMissileLow) : CombatSoundContainer.SoundCodeMissionCombatMissileHigh;
                        break;

                    default:
                        num = !isCriticalBlow ? (!isLowBlow ? CombatSoundContainer.SoundCodeMissionCombatMissileMed : CombatSoundContainer.SoundCodeMissionCombatMissileLow) : CombatSoundContainer.SoundCodeMissionCombatMissileHigh;
                        break;
                    }
                }
                else if (this.IsShield)
                {
                    num = !this._isMaterialMetal ? CombatSoundContainer.SoundCodeMissionCombatWoodShieldBash : CombatSoundContainer.SoundCodeMissionCombatMetalShieldBash;
                }
                else if (attackType == AgentAttackType.Bash)
                {
                    num = CombatSoundContainer.SoundCodeMissionCombatBluntLow;
                }
                else
                {
                    if (isNonTipThrust)
                    {
                        damageType = DamageTypes.Blunt;
                    }
                    switch (damageType)
                    {
                    case DamageTypes.Cut:
                        num = !isCriticalBlow ? (!isLowBlow ? CombatSoundContainer.SoundCodeMissionCombatCutMed : CombatSoundContainer.SoundCodeMissionCombatCutLow) : CombatSoundContainer.SoundCodeMissionCombatCutHigh;
                        break;

                    case DamageTypes.Pierce:
                        num = !isCriticalBlow ? (!isLowBlow ? CombatSoundContainer.SoundCodeMissionCombatPierceMed : CombatSoundContainer.SoundCodeMissionCombatPierceLow) : CombatSoundContainer.SoundCodeMissionCombatPierceHigh;
                        break;

                    case DamageTypes.Blunt:
                        num = !isCriticalBlow ? (!isLowBlow ? CombatSoundContainer.SoundCodeMissionCombatBluntMed : CombatSoundContainer.SoundCodeMissionCombatBluntLow) : CombatSoundContainer.SoundCodeMissionCombatBluntHigh;
                        break;

                    default:
                        num = CombatSoundContainer.SoundCodeMissionCombatBluntMed;
                        break;
                    }
                }
            }
            else
            {
                num = isOwnerHumanoid ? (attackType != AgentAttackType.Kick ? (!isCriticalBlow ? (!isLowBlow ? CombatSoundContainer.SoundCodeMissionCombatPunchMed : CombatSoundContainer.SoundCodeMissionCombatPunchLow) : CombatSoundContainer.SoundCodeMissionCombatPunchHigh) : CombatSoundContainer.SoundCodeMissionCombatKick) : CombatSoundContainer.SoundCodeMissionCombatChargeDamage;
            }
            return(num);
        }
示例#7
0
        public override void OnScoreHit(Agent affectedAgent, Agent affectorAgent, int affectorWeaponKind, bool isBlocked, float damage, float movementSpeedDamageModifier, float hitDistance, AgentAttackType attackType, float shotDifficulty, int weaponUsageIndex)
        {
            if (affectorAgent == null)
            {
                return;
            }
            if (affectorAgent.Character == null || affectedAgent.Character == null)
            {
                return;
            }
            if (damage > affectedAgent.HealthLimit)
            {
                damage = affectedAgent.HealthLimit;
            }

            if (damage > 0 && affectedAgent.Team != affectorAgent.Team && _match != null)
            {
                try
                {
                    var pa = _match.GetParticipant(affectorAgent.Origin.UniqueSeed);
                    var pd = _match.GetParticipant(affectedAgent.Origin.UniqueSeed);
                    achievements[pa].DamageInfliced += damage;
                    achievements[pd].DamageTaken    += damage;
                }
                catch { }
            }
        }
        public override void OnScoreHit(Agent affectedAgent, Agent affectorAgent, int affectorWeaponKind, bool isBlocked, float damage, float movementSpeedDamageModifier, float hitDistance, AgentAttackType attackType, float shotDifficulty, int weaponCurrentUsageIndex)
        {
            try
            {
                //Check to see if the affector is a hero
                if (affectedAgent == null || affectedAgent.Character == null || affectorAgent == null || affectorAgent.Character == null || !affectorAgent.IsHero)
                {
                    return;
                }

                Hero affectorHero = ((CharacterObject)affectorAgent.Character).HeroObject;
                //If the hero is not the player or in the player's party, don't do anything
                if (affectorHero != null && (affectorHero == Hero.MainHero ||
                                             affectorHero.PartyBelongedTo != null && affectorHero.PartyBelongedTo == Hero.MainHero.PartyBelongedTo))
                {
                    Hero captainHero   = null;
                    Hero commanderHero = null;
                    //If the affector is the player's companion, set the commander and captain as the player.
                    if (affectorHero != Hero.MainHero)
                    {
                        CharacterObject leaderCharacter = (CharacterObject)affectorAgent.Team.Leader.Character;
                        if (leaderCharacter.HeroObject == Hero.MainHero)
                        {
                            captainHero   = Hero.MainHero;
                            commanderHero = Hero.MainHero;
                        }
                    }
                    float hitPointRatio = (Math.Min(damage, affectedAgent.HealthLimit) / affectedAgent.HealthLimit) * 0.5f;
                    bool  isTeamKill    = affectorAgent.Team == affectedAgent.Team;
                    bool  isFatal       = affectedAgent.Health <= 0;

                    SkillLevelingManager.OnCombatHit(affectorAgent.Character as CharacterObject, affectedAgent.Character as CharacterObject,
                                                     captainHero, commanderHero, movementSpeedDamageModifier, shotDifficulty, affectorWeaponKind, hitPointRatio, false, affectorAgent.HasMount,
                                                     isTeamKill, false, weaponCurrentUsageIndex, damage, isFatal);
                    //MessageBox.Show($"Did this!\nAffector:{affectorAgent.Character.Name}\nAffected:{affectedAgent.Character.Name}");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show($"An error occurred during Tournament experience logic:\n\n{ex.ToStringFull()}");
            }
        }