float CalcDamage(DamageCVars a_damage) { float AccEvaMod = 1; float AccEvaScale = (evade + a_damage.attackerAcc); float evadeFinal = 0; if (block) { evadeFinal = evade * 2.5f; } else { evadeFinal = evade; } AccEvaMod = ((evadeFinal - a_damage.attackerAcc) / AccEvaScale) * -1; if (block && AccEvaMod > 0) { AccEvaMod = 0; } if (currentState == Action.STAGGERED && AccEvaMod < 0) { AccEvaMod = 0; } float armorMod = 1 - (armor / (armor + 100)); //float blockMod = 1; Debug.Log(evadeFinal + "-" + a_damage.attackerAcc + "=" + (evadeFinal - a_damage.attackerAcc) + "/" + AccEvaScale + "= " + AccEvaMod); Debug.Log("Damage:" + a_damage.amount + " * ArmorReduction:" + armorMod + " = " + (a_damage.amount * armorMod) + " Hit Damage: +" + a_damage.amount + " * " + AccEvaMod + " = " + (a_damage.amount * AccEvaMod)); //Debug.Log(); return(Mathf.Round(Mathf.Max((a_damage.amount * armorMod) + (a_damage.amount * AccEvaMod), 0))); }
//---------------------------------------------------------------ActiveFunctions------------------------------------------------- public float GetHit(float xPush, float yPush, DamageCVars a_damage) { float finalDamage = CalcDamage(a_damage); if (!block) { endurance -= finalDamage; } if (block) { blockFrames = 4; action = 4; } if (finalDamage > 0) { hitPoints -= finalDamage; if (endurance <= 0 || currentState == Action.STAGGERED) { Stagger(); } if (!defend) { velocity = new Vector2(xPush, yPush) / body.weight; } else { velocity = (new Vector2(xPush, yPush) / body.weight) / 2; } } BattleManager.Manager.TraceDamage(center + new Vector3(0, Random.Range(body.height / 2, body.height / 2 + 0.5f), 0), finalDamage); comboHits++; comboDamage += finalDamage; comboTime = 1.5f; return(finalDamage); //hitEffect = 1; }
//===========================================================FIXEDUPDATE===================================================== void FixedUpdate() { // Uncontrolled: ----------------------------------------UNCONTROLLED---------------------------------------------------- // VARIABLESUPDATE VariablesUpdate(); // Neutral Animation /*if (currentState == Action.NEUTRAL) * { * NeutralAnimation(); * }*/ if (currentState == Action.DOWN) { thisAnimation.Play("dead"); } // Controlled: ------------------------------------------CONTROLLED------------------------------------------------------ if (currentState == Action.NEUTRAL && !airborne && actionPoints >= 1) { NeutralAnimation(); // Neutral actions // Moving if (movementX != 0) { facing = movementX; if (movementX >= 1) { position.x += moveSpeed * actionSpeed; } else if (movementX <= -1) { position.x -= moveSpeed * actionSpeed; } } // Lane Change if (movementY != 0) { if (movementY >= 1 && position.lane < BattleManager.Manager.field.lanes - 1) { laneChange += actionSpeed; } else if (movementY <= -1 && position.lane > 0) { laneChange -= actionSpeed; } } else { laneChange = 0; } if (laneChange >= 30) { position.lane += 1; laneChange = 0; } if (laneChange <= -30) { position.lane -= 1; laneChange = 0; } // Block if (defend) { currentState = Action.ACTING; action = blockDelay; blockFrames = blockDelay; } // Jumping /*if (jump && airborne == false) * { * velocity.y = jumpStrength; * jump = false; * }*/ } // Using a Basic Attack ---------------------------------ATTACKING------------------------------------------------------- if (attackBasic && canAction) { Debug.Log("Basic attack Input!"); ExecuteAction(BattlerAction.BasicAttack); actionPoints -= 1; } // Using a Mat Skill --------------------------------------------- if (matSkill && canAction) { // Side attack if (movementX != 0) { facing = movementX; Debug.Log("Side attack Input!"); ExecuteAction(skills.materialSide); } else if (movementY != 0) { // UP Attack if (movementY > 0) { Debug.Log("Up attack Input!"); ExecuteAction(skills.materialUp); }//Down Attack else if (movementY < 0) { Debug.Log("Down attack Input!"); ExecuteAction(skills.materialDown); } }// Neutral Attack else { Debug.Log("Neutral attack Input!"); ExecuteAction(skills.materialNeutral); } actionPoints -= 1; } // UnControlled2 ----------------------------------------UNCONTROLLED2--------------------------------------------------- // While Attacking(Acting) ==============================WHILEACTING===================================================== // Action Execution if (currentState == Action.ACTING) { if (execution >= currentFrame + 1) { currentFrame++; currentFrameExecuted = false; } //make hits on strike frames If action is an atttack foreach (BAStrike sFrame in currentAction.strikeFrames) { if (currentFrame == sFrame.frame && !currentFrameExecuted) { SetAttHitBox(1.3f); // Hit other battlers for (int i = 0; i < BattleManager.Manager.AllBattlers.Count; i++) { // Other battlers if (BattleManager.Manager.AllBattlers[i] != this && BattleManager.Manager.AllBattlers[i].alliance != alliance && BattleManager.Manager.AllBattlers[i].alive) { // Not itself, not same team and is alive if (attachedHitBox.HitTest(BattleManager.Manager.AllBattlers[i].hurtBox)) { // If a target is hit! DamageCVars damageV = new DamageCVars(); damageV.amount = Mathf.Round(sFrame.power * attackDamage); damageV.attackerAcc = accuracy; BattleManager.Manager.AllBattlers[i].GetHit(sFrame.push * facing, sFrame.lift, damageV); } } } } } foreach (BAMovement i in currentAction.movementFrames) { if (currentFrame == i.frame && !currentFrameExecuted) { velocity = new Vector2(i.forward * facing, i.jump); } } // canAttack in combo frames if (execution > currentAction.executionFrames && execution <= currentAction.comboLimit) { //canAttack = true; } else { canAttack = false; } currentFrameExecuted = true; execution += actionSpeed; } // PHYSICSUPDATE PhysicsUpdate(); }
//===========================================================FIXEDUPDATE===================================================== void FixedUpdate() { // Uncontrolled: ----------------------------------------UNCONTROLLED---------------------------------------------------- // VARIABLESUPDATE VariablesUpdate(); // Neutral Animation /*if (currentState == Action.NEUTRAL) { NeutralAnimation(); }*/ if (currentState == Action.DOWN) { thisAnimation.Play("dead"); } // Controlled: ------------------------------------------CONTROLLED------------------------------------------------------ if (currentState == Action.NEUTRAL && !airborne && actionPoints >= 1) { NeutralAnimation(); // Neutral actions // Moving if (movementX != 0) { facing = movementX; if (movementX >= 1) { position.x += moveSpeed * actionSpeed; } else if (movementX <= -1) { position.x -= moveSpeed * actionSpeed; } } // Lane Change if (movementY != 0) { if (movementY >= 1 && position.lane < BattleManager.Manager.field.lanes - 1) { laneChange += actionSpeed; } else if (movementY <= -1 && position.lane > 0) { laneChange -= actionSpeed; } } else { laneChange = 0; } if (laneChange >= 30) { position.lane += 1; laneChange = 0; } if (laneChange <= -30) { position.lane -= 1; laneChange = 0; } // Block if (defend) { currentState = Action.ACTING; action = blockDelay; blockFrames = blockDelay; } // Jumping /*if (jump && airborne == false) { velocity.y = jumpStrength; jump = false; }*/ } // Using a Basic Attack ---------------------------------ATTACKING------------------------------------------------------- if (attackBasic && canAction) { Debug.Log("Basic attack Input!"); ExecuteAction(BattlerAction.BasicAttack); actionPoints -= 1; } // Using a Mat Skill --------------------------------------------- if (matSkill && canAction) { // Side attack if (movementX != 0) { facing = movementX; Debug.Log("Side attack Input!"); ExecuteAction(skills.materialSide); } else if (movementY != 0) { // UP Attack if (movementY > 0) { Debug.Log("Up attack Input!"); ExecuteAction(skills.materialUp); }//Down Attack else if (movementY < 0) { Debug.Log("Down attack Input!"); ExecuteAction(skills.materialDown); } }// Neutral Attack else { Debug.Log("Neutral attack Input!"); ExecuteAction(skills.materialNeutral); } actionPoints -= 1; } // UnControlled2 ----------------------------------------UNCONTROLLED2--------------------------------------------------- // While Attacking(Acting) ==============================WHILEACTING===================================================== // Action Execution if (currentState == Action.ACTING) { if (execution >= currentFrame + 1) { currentFrame++; currentFrameExecuted = false; } //make hits on strike frames If action is an atttack foreach (BAStrike sFrame in currentAction.strikeFrames) { if (currentFrame == sFrame.frame && !currentFrameExecuted) { SetAttHitBox(1.3f); // Hit other battlers for (int i = 0; i < BattleManager.Manager.AllBattlers.Count; i++) {// Other battlers if (BattleManager.Manager.AllBattlers[i] != this && BattleManager.Manager.AllBattlers[i].alliance != alliance && BattleManager.Manager.AllBattlers[i].alive) {// Not itself, not same team and is alive if (attachedHitBox.HitTest(BattleManager.Manager.AllBattlers[i].hurtBox)) { // If a target is hit! DamageCVars damageV = new DamageCVars(); damageV.amount = Mathf.Round(sFrame.power * attackDamage); damageV.attackerAcc = accuracy; BattleManager.Manager.AllBattlers[i].GetHit(sFrame.push * facing, sFrame.lift, damageV); } } } } } foreach (BAMovement i in currentAction.movementFrames) { if (currentFrame == i.frame && !currentFrameExecuted) { velocity = new Vector2(i.forward * facing, i.jump); } } // canAttack in combo frames if (execution > currentAction.executionFrames && execution <= currentAction.comboLimit) { //canAttack = true; } else { canAttack = false; } currentFrameExecuted = true; execution += actionSpeed; } // PHYSICSUPDATE PhysicsUpdate(); }
float CalcDamage(DamageCVars a_damage) { float AccEvaMod = 1; float AccEvaScale = (evade + a_damage.attackerAcc); float evadeFinal = 0; if (block) { evadeFinal = evade * 2.5f; } else { evadeFinal = evade; } AccEvaMod = ((evadeFinal - a_damage.attackerAcc) / AccEvaScale) * -1; if (block && AccEvaMod > 0) { AccEvaMod = 0; } if (currentState == Action.STAGGERED && AccEvaMod < 0) { AccEvaMod = 0; } float armorMod = 1 - (armor / (armor + 100)); //float blockMod = 1; Debug.Log(evadeFinal + "-"+a_damage.attackerAcc+"="+(evadeFinal - a_damage.attackerAcc)+"/"+ AccEvaScale + "= "+AccEvaMod); Debug.Log("Damage:" + a_damage.amount + " * ArmorReduction:" + armorMod + " = " + (a_damage.amount * armorMod) + " Hit Damage: +" + a_damage.amount + " * " + AccEvaMod + " = " + (a_damage.amount * AccEvaMod)); //Debug.Log(); return Mathf.Round(Mathf.Max((a_damage.amount * armorMod) + (a_damage.amount * AccEvaMod), 0)); }
//---------------------------------------------------------------ActiveFunctions------------------------------------------------- public float GetHit(float xPush, float yPush, DamageCVars a_damage) { float finalDamage = CalcDamage(a_damage); if (!block) { endurance -= finalDamage; } if (block) { blockFrames = 4; action = 4; } if (finalDamage > 0) { hitPoints -= finalDamage; if (endurance <= 0 || currentState == Action.STAGGERED) { Stagger(); } if (!defend) { velocity = new Vector2(xPush, yPush) / body.weight; } else { velocity = (new Vector2(xPush, yPush) / body.weight) / 2; } } BattleManager.Manager.TraceDamage(center + new Vector3(0, Random.Range(body.height / 2, body.height / 2 + 0.5f), 0), finalDamage); comboHits++; comboDamage += finalDamage; comboTime = 1.5f; return finalDamage; //hitEffect = 1; }