public DestroyBuildingTypeCondition(ConditionVO vo, IConditionParent parent) : base(vo, parent)
        {
            this.buildingMatchType = StringUtils.ParseEnum <BuildingType>(this.prepareArgs[1]);
            this.any = (this.buildingMatchType == BuildingType.Any);
            this.buildingsDestroyed = 0;
            this.buildingsToDestroy = 0;
            if (!this.prepareArgs[0].Contains("%"))
            {
                this.buildingsToDestroy = Convert.ToInt32(this.prepareArgs[0], CultureInfo.InvariantCulture);
                return;
            }
            this.byPercent = true;
            string text = this.prepareArgs[0];

            text = text.Substring(0, text.get_Length() - 1);
            int percent = Convert.ToInt32(text, CultureInfo.InvariantCulture);

            if (this.any && this.byPercent)
            {
                this.buildingsToDestroy = percent;
                return;
            }
            EntityController        entityController = Service.Get <EntityController>();
            NodeList <BuildingNode> nodeList         = entityController.GetNodeList <BuildingNode>();
            int num = 0;

            for (BuildingNode buildingNode = nodeList.Head; buildingNode != null; buildingNode = buildingNode.Next)
            {
                if (this.IsBuildingValid(buildingNode.BuildingComp))
                {
                    num++;
                }
            }
            this.buildingsToDestroy = IntMath.GetPercent(percent, num);
        }
Beispiel #2
0
        public DestroyBuildingUidCondition(ConditionVO vo, IConditionParent parent) : base(vo, parent)
        {
            this.buildingMatchUid = this.prepareArgs[1].ToLower();
            this.any = (this.buildingMatchUid == "any");
            this.buildingsDestroyed = 0;
            this.buildingsToDestroy = 0;
            string text = this.prepareArgs[0];

            if (text.Contains("%"))
            {
                this.byPercent = true;
                text           = text.Substring(0, text.Length - 1);
                int percent = Convert.ToInt32(text);
                if (this.any && this.byPercent)
                {
                    this.buildingsToDestroy = percent;
                    return;
                }
                EntityController        entityController = Service.EntityController;
                NodeList <BuildingNode> nodeList         = entityController.GetNodeList <BuildingNode>();
                int num = 0;
                for (BuildingNode buildingNode = nodeList.Head; buildingNode != null; buildingNode = buildingNode.Next)
                {
                    if (this.IsBuildingValid(buildingNode.BuildingComp))
                    {
                        num++;
                    }
                }
                this.buildingsToDestroy = IntMath.GetPercent(percent, num);
            }
            else
            {
                this.buildingsToDestroy = Convert.ToInt32(text);
            }
        }
Beispiel #3
0
        public int ApplyHealthFragment(IHealthComponent healthComponent, HealthFragment fragment, List <int> damageMultipliers, int damagePercentage, bool fromSplash, bool fromBeam, SmartEntity source)
        {
            if (healthComponent == null || healthComponent.IsDead() || damagePercentage == 0)
            {
                return(0);
            }
            int health = healthComponent.Health;
            int num    = fragment.Quantity;

            if (fromSplash)
            {
                num = fragment.SplashQuantity;
            }
            int rawDamage = num;

            if (damageMultipliers != null)
            {
                int healthMultiplier = this.GetHealthMultiplier(healthComponent, damageMultipliers);
                num = num * healthMultiplier / 100;
            }
            SmartEntity    target         = (SmartEntity)((ComponentBase)healthComponent).Entity;
            BuffController buffController = Service.Get <BuffController>();

            if (fragment.Type == HealthType.Healing)
            {
                buffController.ApplyActiveBuffs(target, BuffModify.HealDefense, ref damagePercentage, 100);
            }
            else
            {
                buffController.ApplyActiveBuffs(target, BuffModify.Defense, ref damagePercentage, 100);
                if (fromSplash)
                {
                    buffController.ApplyActiveBuffs(target, BuffModify.SplashDefense, ref damagePercentage, 100);
                }
            }
            num = IntMath.GetPercent(damagePercentage, num);
            if (fragment.Type == HealthType.Healing)
            {
                healthComponent.Health += num;
                if (healthComponent.Health > healthComponent.MaxHealth)
                {
                    healthComponent.Health = healthComponent.MaxHealth;
                }
            }
            else
            {
                healthComponent.Health -= num;
                if (healthComponent.Health <= 0)
                {
                    healthComponent.Health = 0;
                }
            }
            int num2 = healthComponent.Health - health;
            EntityHealthChangedData cookie = new EntityHealthChangedData(source, target, num2, rawDamage, fromBeam);

            Service.Get <EventManager>().SendEvent(EventId.EntityHealthChanged, cookie);
            this.HandleHealthChange(healthComponent, num2);
            return(num2);
        }
Beispiel #4
0
        public RetainBuildingCondition(ConditionVO vo, IConditionParent parent, ConditionMatchType matchType) : base(vo, parent)
        {
            this.matchType  = matchType;
            this.buildingId = this.prepareArgs[1];
            this.any        = (this.buildingId == "any");
            if (matchType == ConditionMatchType.Uid)
            {
                this.level = Service.StaticDataController.Get <BuildingTypeVO>(this.buildingId).Lvl;
            }
            else if (!this.any && this.prepareArgs.Length > 2)
            {
                this.level = Convert.ToInt32(this.prepareArgs[2]);
            }
            else
            {
                this.level = 0;
            }
            this.buildingsDestroyed = 0;
            this.buildingsToDestroy = 0;
            EntityController        entityController = Service.EntityController;
            NodeList <BuildingNode> nodeList         = entityController.GetNodeList <BuildingNode>();
            BuildingNode            buildingNode     = nodeList.Head;
            int num = 0;

            while (buildingNode != null)
            {
                if (this.IsBuildingValid(buildingNode.BuildingComp))
                {
                    num++;
                }
                buildingNode = buildingNode.Next;
            }
            if (this.prepareArgs[0].Contains("%"))
            {
                this.byPercent = true;
                string text = this.prepareArgs[0];
                text = text.Substring(0, text.Length - 1);
                int percent = 100 - Convert.ToInt32(text);
                if (this.any && this.byPercent)
                {
                    this.buildingsToDestroy = percent;
                    return;
                }
                this.buildingsToDestroy = IntMath.GetPercent(percent, num);
            }
            else
            {
                this.buildingsToDestroy = num - Convert.ToInt32(this.prepareArgs[0]);
            }
        }
Beispiel #5
0
        public void ApplyStacks(ref int modifyValue, int modifyValueMax)
        {
            int num = this.BuffType.Values[this.armorTypeIndex];

            switch (this.BuffType.ApplyAs)
            {
            case BuffApplyAs.Relative:
                modifyValue += this.StackSize * num;
                return;

            case BuffApplyAs.Absolute:
                modifyValue = this.StackSize * num;
                return;

            case BuffApplyAs.RelativePercent:
                for (int i = 0; i < this.StackSize; i++)
                {
                    modifyValue += IntMath.GetPercent(num, modifyValue);
                }
                return;

            case BuffApplyAs.AbsolutePercent:
                for (int j = 0; j < this.StackSize; j++)
                {
                    modifyValue = IntMath.GetPercent(num, modifyValue);
                }
                return;

            case BuffApplyAs.RelativePercentOfMax:
                modifyValue += this.StackSize * IntMath.GetPercent(num, modifyValueMax);
                return;

            case BuffApplyAs.AbsolutePercentOfMax:
                modifyValue = this.StackSize * IntMath.GetPercent(num, modifyValueMax);
                return;

            default:
                return;
            }
        }