Exemple #1
0
    public override void Hurt(HitInfo info)
    {
        bool flag = false;

        if (info.damageTypes.Total() >= base.health)
        {
            base.health = 1000000f;
            this.myAI.CriticalDamage();
            flag = true;
        }
        base.Hurt(info);
        if (!flag)
        {
            BaseHelicopter.weakspot[] weakspotArray = this.weakspots;
            for (int i = 0; i < (int)weakspotArray.Length; i++)
            {
                BaseHelicopter.weakspot _weakspot = weakspotArray[i];
                string[] strArrays = _weakspot.bonenames;
                for (int j = 0; j < (int)strArrays.Length; j++)
                {
                    string str = strArrays[j];
                    if (info.HitBone == StringPool.Get(str))
                    {
                        _weakspot.Hurt(info.damageTypes.Total(), info);
                        this.myAI.WeakspotDamaged(_weakspot, info);
                    }
                }
            }
        }
    }
            public int DealDamage(HitInfo info)
            {
                int  pointValue  = 0;
                bool hitWeakSpot = false;

                BaseHelicopter.weakspot[] weakspotArray = Helicopter.weakspots;
                for (int i = 0; i < (int)weakspotArray.Length; i++)
                {
                    BaseHelicopter.weakspot _weakspot = weakspotArray[i];
                    string[] strArrays = _weakspot.bonenames;
                    for (int j = 0; j < strArrays.Length; j++)
                    {
                        string str = strArrays[j];
                        if (info.HitBone == StringPool.Get(str))
                        {
                            switch (str)
                            {
                            case "engine_col":
                                hitWeakSpot   = true;
                                EngineHealth -= info.damageTypes.Total();
                                pointValue    = config.Scoring.HeliHitPoints;
                                break;

                            case "tail_rotor_col":
                                hitWeakSpot = true;
                                TailHealth -= info.damageTypes.Total();
                                pointValue  = config.Scoring.RotorHitPoints;
                                if (TailHealth < 50)
                                {
                                    Helicopter.weakspots[i].WeakspotDestroyed();
                                }
                                break;

                            case "main_rotor_col":
                                hitWeakSpot = true;
                                MainHealth -= info.damageTypes.Total();
                                pointValue  = config.Scoring.RotorHitPoints;
                                if (MainHealth < 50)
                                {
                                    Helicopter.weakspots[i].WeakspotDestroyed();
                                }
                                break;
                            }
                        }
                    }
                }
                if (!hitWeakSpot)
                {
                    pointValue  = 1;
                    BodyHealth -= info.damageTypes.Total();
                }
                if (BodyHealth < 1 || EngineHealth < 1 || (TailHealth < 1 && MainHealth < 1))
                {
                    AI.CriticalDamage();
                }
                return(pointValue);
            }
    public void WeakspotDamaged(BaseHelicopter.weakspot weak, HitInfo info)
    {
        float single = UnityEngine.Time.realtimeSinceStartup - this.lastDamageTime;

        this.lastDamageTime = UnityEngine.Time.realtimeSinceStartup;
        BasePlayer initiator = info.Initiator as BasePlayer;
        bool       flag      = this.ValidStrafeTarget(initiator);
        bool       flag1     = (!flag ? false : this.CanStrafe());
        bool       flag2     = (flag ? false : this.CanUseNapalm());

        if (single < 5f && initiator != null && flag1 | flag2)
        {
            this.ExitCurrentState();
            this.State_Strafe_Enter(info.Initiator.transform.position, flag2);
        }
    }
            public int TakeDamage(HitInfo info)
            {
                if (isDieing)
                {
                    return(0);
                }

                int   pointValue  = 0;
                float damage      = info.damageTypes.Total();
                bool  hitWeakSpot = false;

                for (int i = 0; i < helicopter.weakspots.Length; i++)
                {
                    BaseHelicopter.weakspot _weakspot = helicopter.weakspots[i];
                    string[] strArrays = _weakspot.bonenames;
                    for (int j = 0; j < strArrays.Length; j++)
                    {
                        string str = strArrays[j];
                        if (info.HitBone == StringPool.Get(str))
                        {
                            switch (str)
                            {
                            case "engine_col":
                                hitWeakSpot = true;
                                stats[StatType.Engine].DealDamage(damage);
                                pointValue = instance.configData.Scoring.HeliHitPoints;
                                break;

                            case "tail_rotor_col":
                                hitWeakSpot = true;
                                stats[StatType.Tail].DealDamage(damage);
                                pointValue = instance.configData.Scoring.RotorHitPoints;
                                if (stats[StatType.Tail].value < 25)
                                {
                                    helicopter.weakspots[i].WeakspotDestroyed();
                                }
                                break;

                            case "main_rotor_col":
                                hitWeakSpot = true;
                                stats[StatType.Rotor].DealDamage(damage);
                                pointValue = instance.configData.Scoring.RotorHitPoints;
                                if (stats[StatType.Rotor].value < 25)
                                {
                                    helicopter.weakspots[i].WeakspotDestroyed();
                                }
                                break;
                            }
                        }
                    }
                }
                if (!hitWeakSpot)
                {
                    pointValue = 1;
                    stats[StatType.Body].DealDamage(damage);
                }
                if (stats[StatType.Body].value < 5 || stats[StatType.Engine].value < 5 || (stats[StatType.Tail].value < 5 && stats[StatType.Rotor].value < 5))
                {
                    KillHelicopter(true);
                    isDieing = true;
                    if (info?.InitiatorPlayer != null)
                    {
                        instance.EventManager.AddStats(info.InitiatorPlayer, EventManager.StatType.Choppers);
                    }
                }
                return(pointValue);
            }