Ejemplo n.º 1
0
    public static void    AddProperty(sdActorInterface actor, Hashtable dst, Operation op, OpParameter param)
    {
        switch (op.dwOperationPara0)
        {
        case (int)HeaderProto.EOpreationFlag.OPREATION_FLAG_MOD_HP: {
            int hp = ModifyProperty_Template("HP", "MaxHP", op, param, dst);
            actor.AddHP(hp);
        } break;

        case (int)HeaderProto.EOpreationFlag.OPREATION_FLAG_MOD_SP: {
            int sp = ModifyProperty_Template("SP", "MaxSP", op, param, dst);
            actor.AddSP(sp);
        } break;
        }
    }
Ejemplo n.º 2
0
    public DamageResult testHurt(sdActorInterface _gameActor, Hashtable _state, sdActorInterface targetActor, int hitPointIndex, HeaderProto.ESkillEffect bySkillEffect)
    {
        DamageResult dr;

        dr.damage     = 0;
        dr.bubbleType = Bubble.BubbleType.eBT_BaseHurt;
        dr.attracker  = _gameActor;

        Hashtable recProp = targetActor.GetProperty();

        if (recProp == null)
        {
            return(dr);
        }
        SkillProperty skillProp = new SkillProperty();

        int   dmgMin            = (int)_gameActor["AtkDmgMin"];
        int   dmgMax            = (int)_gameActor["AtkDmgMax"];
        int   iceAtt            = (int)_gameActor["IceAtt"];
        int   fireAtt           = (int)_gameActor["FireAtt"];
        int   poisonAtt         = (int)_gameActor["PoisonAtt"];
        int   thunerAtt         = (int)_gameActor["ThunderAtt"];
        int   intervalPerAttack = (int)_gameActor["AttSpeed"];       // ms per attack
        float attackPerSecond   = 1000.0f / (float)intervalPerAttack;
        int   d10000            = ((int[])_state["dwAtkPowerPer[10]"])[hitPointIndex];
        int   dx = ((int[])_state["dwDmg[10]"])[hitPointIndex];
        int   byPeriodicDamageType = 0;                   //(int)_state.stateData["byPeriodicDamage"];

        Hashtable attTable = new Hashtable();
        int       phyAtt   = dmgMin;

        //如果最小攻击力 大于 最大攻击力 直接取最小攻击力...
        if (dmgMax > dmgMin)
        {
            phyAtt = Random.Range(dmgMin, dmgMax);
        }

        float iPercentFix = 0.0f;
        int   iDamageFix  = 0;

        switch ((EPeriodicDamage)byPeriodicDamageType)
        {
        ///每波伤害相同...
        case    EPeriodicDamage.PERIODIC_DAMAGE_SAME: {} break;

        ///固定值递增:Data + DataPeriodic * (Index)...
        case    EPeriodicDamage.PERIODIC_DAMAGE_INCREASE: {
            iDamageFix = (int)_state["dwPeriodicTraumaHP"] * (hitPointIndex + 1);
        } break;

        ///百分比递增:HP*(Data + DataPeriodic * (Index))...
        case        EPeriodicDamage.PERIODIC_DAMAGE_INCREASE_PERCENT: {
            iPercentFix = ((int)_state["dwPeriodicTraumaHP"] / 10000.0f) * (hitPointIndex + 1);
        } break;

        ///固定值递减:Data - DataPeriodic * (Index)...
        case    EPeriodicDamage.PERIODIC_DAMAGE_DECREASE: {
            iDamageFix = -(int)_state["dwPeriodicTraumaHP"] * (hitPointIndex + 1);
        } break;

        ///百分比递减:HP*(Data - DataPeriodic * (Index))...
        case    EPeriodicDamage.PERIODIC_DAMAGE_DECREASE_PERCENT: {
            iPercentFix = -((int)_state["dwPeriodicTraumaHP"] / 10000.0f) * (hitPointIndex + 1);
        } break;

        ///第一波伤害最大,其余伤害相同,第一波伤害计算公式:...
        ///固定值方式:Data - DataPeriodic...
        case    EPeriodicDamage.PERIODIC_DAMAGE_FIRST: {
            if (hitPointIndex == 0)
            {
                iDamageFix = (int)_state["dwPeriodicTraumaHP"];
            }
        } break;

        ///百分比方式:HP*(Data + DataPeriodic)...
        case    EPeriodicDamage.PERIODIC_DAMAGE_FIRST_PERCENT: {
            if (hitPointIndex == 0)
            {
                iPercentFix = ((int)_state["dwPeriodicTraumaHP"] / 10000.0f);
            }
        } break;

        ///最后一波伤害最大,其余伤害相同,第一波伤害计算公式:
        ///固定值方式:Data + DataPeriodic
        case        EPeriodicDamage.PERIODIC_DAMAGE_END: {
            if (hitPointIndex == -1)
            {
                iPercentFix = (int)_state["dwPeriodicTraumaHP"];
            }
        } break;

        ///百分比方式:HP*(Data + DataPeriodic)...
        case    EPeriodicDamage.PERIODIC_DAMAGE_END_PERCENT: {
            if (hitPointIndex == -1)
            {
                iPercentFix = ((int)_state["dwPeriodicTraumaHP"] / 10000.0f);
            }
        } break;
        }
        int skillHit    = (int)_state["dwHitPer"];
        int skillCri    = (int)_state["dwCriticalPer"];
        int skillCriDmg = (int)_state["dwCriticalDmgPer"];

        skillProp.atk        = phyAtt;
        skillProp.iceAtk     = iceAtt;
        skillProp.fireAtk    = fireAtt;
        skillProp.poisonAtk  = poisonAtt;
        skillProp.thunderAtk = thunerAtt;
        skillProp.Y          = (float)d10000 / 10000.0f;
        skillProp.Z          = dx;
        skillProp.YZFix      = iPercentFix;
        skillProp.ZFix       = iDamageFix;
        skillProp.hitRate    = (float)_gameActor["Hit"] * fPropertyScale + (float)_gameActor["HitPer"] * 0.0001f + (skillHit) * 0.0001f;
        int pierce = _gameActor["Pierce"];

        skillProp.passThrough = (float)pierce / (float)(pierce + (int)recProp["Level"] * 270 + 2700);

        skillProp.superAttack  = (float)_gameActor["CriDmg"] * 0.0001f + (skillCriDmg) * 0.0001f;
        skillProp.superRate    = (float)_gameActor["Cri"] * fPropertyScale + (float)_gameActor["CriPer"] * 0.0001f + (skillCri) * 0.0001f;
        skillProp.attPerSecond = attackPerSecond;
        if (_state.ContainsKey("dwDamagePer"))
        {
            skillProp.damagePer = ((int)_state["dwDamagePer"]) * 0.0001f;
        }
        else
        {
            skillProp.damagePer = 1.0f;
        }
        if (_gameActor.Property.ContainsKey("HurtOtherModify"))
        {
            skillProp.hurtOtherModify = ((int)_gameActor["HurtOtherModify"]) * 0.0001f;
        }
        else
        {
            skillProp.hurtOtherModify = 0.0f;
        }

        //属性修正aaa
        int attAttr = (int)_state["byDamegePro"];

        if (attAttr == 0)
        {
            skillProp.type = SkillType.Skill_Physic;
        }
        else if (attAttr == 1)
        {
            skillProp.type = SkillType.Skill_Ice;
        }
        else if (attAttr == 2)
        {
            skillProp.type = SkillType.Skill_Fire;
        }
        else if (attAttr == 3)
        {
            skillProp.type = SkillType.Skill_Poison;
        }
        else if (attAttr == 4)
        {
            skillProp.type = SkillType.Skill_Thunder;
        }
        skillProp.PropertyModify = CalulatePropertyModify(_gameActor, attAttr);
        ///体型修正aaaa
        skillProp.BodyTypeModify = CalulateBodyModify(_state, targetActor);
        //控制状态修正aaa
        skillProp.StateModify = CalulateStateModify(_gameActor, targetActor);

        SkillDefProperty defProp = new SkillDefProperty();

        defProp.level = (int)recProp["Level"];
        defProp.def   = (int)recProp["Def"];
        int dodge = (int)recProp["Dodge"];

        defProp.dodgeRate  = dodge * fPropertyScale;
        defProp.dodgeRate += ((int)recProp["DodgePer"]) * 0.0001f;
        defProp.fireDef    = (int)recProp["FireDef"];
        defProp.iceDef     = (int)recProp["IceDef"];
        defProp.poisonDef  = (int)recProp["PoisonDef"];
        int criDmgDef = (int)recProp["CriDmgDef"];

        defProp.superDef   = (float)criDmgDef * 0.0001f;
        defProp.thunderDef = (int)recProp["ThunderDef"];
        int flex = (int)recProp["Flex"];

        defProp.toughness = (float)flex * fPropertyScale;
        if (recProp.ContainsKey("BeHurtModify"))
        {
            defProp.beHurtModify = ((int)recProp["BeHurtModify"]) * 0.0001f;
        }
        else
        {
            defProp.beHurtModify = 0.0f;
        }

        bool isNormalAtk = false;

        if (attAttr == 0)
        {
            isNormalAtk = true;
        }

        bool isSuper;
        bool bDodge;

        dr.damage = CalculateAttack(skillProp, defProp, isNormalAtk, bySkillEffect, out isSuper, out bDodge);
        CalculateBubbleType(_state, _gameActor, targetActor, isSuper, bDodge, ref dr);
        if (bySkillEffect == HeaderProto.ESkillEffect.SKILL_EFFECT_CURE_HP)
        {
            targetActor.AddHP(dr.damage);
        }
        else if (bySkillEffect == HeaderProto.ESkillEffect.SKILL_EFFECT_CURE_MP)
        {
            targetActor.AddSP(dr.damage);
        }
        else if (bySkillEffect == HeaderProto.ESkillEffect.SKILL_EFFECT_DAMAGE_SP)
        {
            targetActor.AddSP(-dr.damage);
        }
        else
        {
            if (targetActor.CheckDebuffState(HeaderProto.ECreatureActionState.CREATURE_ACTION_STATE_UNBEAT))
            {
                dr.bubbleType = Bubble.BubbleType.eBT_Dodge;
                dr.damage     = 0;
            }
            targetActor.OnHurt(dr);
        }
        if (_state.Contains("WeaponHitType"))
        {
            targetActor.DoHittedAudio((string)_state["WeaponHitType"]);
        }
        if (targetActor.actorType == ActorType.AT_Monster && dr.damage > 0)
        {
            sdGameMonster monster     = (sdGameMonster)targetActor;
            int           monsterType = (int)monster.Property["BodyType"];
            if (_state.Contains("ParentID") && _state.Contains("dwTemplateID"))            //临时代码判断是技能伤害aa
            {
                int id = (int)_state["dwTemplateID"];
                _gameActor.OnAttackRestore(id, dr.damage, monsterType);
            }
        }
        //是否打断被击目标的某些buffer
        if (_state.ContainsKey("BreakState"))
        {
            int[] buffID = (int[])(_state["BreakState"]);
            if (buffID.Length == 2)
            {
                targetActor.RemoveBuff(buffID[0], buffID[1]);
            }
        }
        return(dr);
    }