Exemplo n.º 1
0
        private static void doWeaponDamage(ActionPackage aPack)
        {
            Item aWeapon = ActionUtils.getWeapon(aPack.Owner);
            Item dArmor  = ActionUtils.getArmor(aPack.Target);

            float aSkill = ActionUtils.getSkill(aPack.Owner, aPack.ActionDef.DamageDef.SkillName);
            float dSkill = ActionUtils.getSkill(aPack.Target, SkillName.AVOIDANCE);

            float aStat = ActionUtils.getStat(aPack.Owner, aPack.ActionDef.DamageDef.StatType);
            float dStat = ActionUtils.getStat(aPack.Target, ActionUtils.getOppositeStat(aPack.ActionDef.DamageDef.StatType));

            float aKnow = ActionUtils.getKnowledge(aPack.Owner, aPack.Target);
            float dKnow = ActionUtils.getKnowledge(aPack.Target, aPack.Owner);

            float aProb = ActionUtils.getStatProbability((float)aSkill, (float)aStat, aKnow, (float)aWeapon.Speed);
            float dProb = ActionUtils.getStatProbability((float)dSkill, (float)dStat, dKnow, (float)dArmor.Mobility);

            float hitProb = ActionUtils.getHitProbability(dProb, aProb, 1.75f, 0.15f);

            int damage = ActionUtils.getDamage(hitProb, aSkill, aStat, aWeapon.Lethality, dArmor.Mitigation,
                                               ActionUtils.getStat(aPack.Target, StatType.ENDURANCE));

            Position pos = ComponentMapper.get <Position> (aPack.Target);

            UtilFactory.createDirectDamage(damage,
                                           aPack.ActionDef.DamageDef.DamageType,
                                           aPack.Target,
                                           pos);

            Position newPos = new Position(pos.Pos + new Vector2(rand.Next(16) + 8, 0), Vector2.Zero);

            if (damage == 0)
            {
                UIFactory.createFloatingText("MISS",
                                             "DAMAGE",
                                             Color.White,
                                             500,
                                             newPos);
            }
            else
            {
                UIFactory.createFloatingText("" + damage,
                                             "DAMAGE",
                                             DamageUtils.getDamageColor(aPack.ActionDef.DamageDef.DamageType),
                                             500,
                                             newPos);
            }

            AwardUtils.attemptSkillAward(aPack.Owner, aPack.Target, aSkill, dSkill, aPack.ActionDef.DamageDef.SkillName, 1);
            AwardUtils.attemptStatAward(aPack.Owner, aPack.Target, aStat, dStat, aPack.ActionDef.DamageDef.StatType, 1);
            AwardUtils.attemptStatAward(aPack.Target, aPack.Owner,
                                        ActionUtils.getStat(aPack.Target, StatType.ENDURANCE), aStat,
                                        StatType.ENDURANCE, 1);
        }
Exemplo n.º 2
0
        private static void doStaticDamage(ActionPackage aPack)
        {
            int      dmg = rand.Next(aPack.ActionDef.DamageDef.Min, aPack.ActionDef.DamageDef.Max);
            Position pos = ComponentMapper.get <Position> (aPack.Target);

            UtilFactory.createDirectDamage(dmg,
                                           aPack.ActionDef.DamageDef.DamageType,
                                           aPack.Target,
                                           pos);

            Position newPos = new Position(pos.Pos + new Vector2(rand.Next(16) + 8, 0), Vector2.Zero);

            UIFactory.createFloatingText("" + dmg,
                                         "DAMAGE",
                                         DamageUtils.getDamageColor(aPack.ActionDef.DamageDef.DamageType),
                                         500,
                                         newPos);
        }