private void applyHPEffectToMonster(BattleMonsterWithMoves aAttacker,MoveLibItem aMove,float aSplashPercent,BattleMonsterWithMoves aDefending,CommentaryManager aCommentaryManager,EMonsterPos aAttackersPosition) { //Damage = ((((2 * Level / 5 + 2) * AttackStat * AttackPower / DefenseStat) / 50) + 2) * STAB * Weakness/Resistance * RandomNumber / 100 BattleBase.DebugText("BattleTeamWithMoves->applyHPEffectToMonster"); PassiveEffect attackersEffect = getAttackHPHitPassiveEffect((BattleMonster) aAttacker,(BattleMonster) aDefending,aMove); PassiveEffect defendersEffect = getDefenderHPHitPassiveEffect((BattleMonster) aAttacker,(BattleMonster) aDefending,aMove); if(CommentaryManager.REF!=null) { CommentaryManager.REF.passiveEffect = attackersEffect; CommentaryManager.REF.battleMonster = (BattleMonster) aAttacker; } if((int) aMove.powerOnlyIfTheseStatusEffects>0&&((aDefending.statusEffects&aMove.powerOnlyIfTheseStatusEffects)==EStatusEffects.None)) { return; } float attackStatPower = aAttacker.rangeAttack; float defenseStat = aDefending.rangeDefense; if(aMove.rangeStatus == ERangedStatus.Melee) { attackStatPower = aAttacker.meleeAttack; defenseStat = aDefending.meleeDefense; } bool criticalHitRandom = BattleRandomizer.random < (aMove.criticalHitChance*aAttacker.criticalHitChanceMultiplier); float dmg = 0; float selfHitPercent = aMove.selfInflictPercent; bool criticalApplied = false; if(criticalHitRandom) { if(aDefending.criticalHitImmune) { BattleBase.DebugText("Critical hit immune"); } else { attackStatPower *= 2; criticalApplied = true; BattleBase.DebugText("Critical hit being applied"); } } else { BattleBase.DebugText("No critical hit"); } switch(aMove.powerApplicationType) { case(EPowerApplicationTypes.Normal): float attackPower = aMove.getPower(aAttacker.unlockLevelForMove(aMove));; float stab = 1.0f; if(aMove.elementType==aAttacker.monster.elementType) { stab = 1.15f; } else if(aMove.elementType==aAttacker.monster.secondaryType) { stab = 1.075f; } int random = (int) (BattleRandomizer.random*15)+85; if(attackStatPower == 0) { } if(attackersEffect!=null) { if(!attackersEffect.applyToSelf) { // My attackers effect does something to the opponent. attackStatPower = attackStatPower * attackersEffect.getEffectOnAttackPower(aMove.rangeStatus,aMove.elementType); selfHitPercent += attackersEffect.moveRef.selfInflictPercent; } } BattleBase.DebugText("Defending Monster is: "+aDefending.name+" - Level: "+aDefending.monster.level); float weaknessStrength = aDefending.getWeaknessStrengthToElement(aMove.elementType); if(weaknessStrength>1f) this.onMonsterCommentary((BattleMonster) aDefending,"Effective vs. "+aDefending.monster.name,ECommentaryMessageType.DmgEffective); else if(weaknessStrength<1f) { this.onMonsterCommentary((BattleMonster) aDefending,"Ineffective vs. "+aDefending.monster.name,ECommentaryMessageType.DmgInEffective); } BattleBase.DebugText("Random in use is: "+random+" - Move element is: "+aMove.elementType.Name+", Move Range: "+aMove.rangeStatus+",Range Defense: "+aDefending.meleeDefense+" - Melee Defense: "+aDefending.rangeDefense); if(attackPower>0) dmg = ((((2 * aAttacker.monster.level / 5 + 2) * attackStatPower * attackPower / defenseStat) / 50) + 2) * stab * aDefending.getWeaknessStrengthToElement(aMove.elementType) * random / 100; dmg = (float) Math.Ceiling(dmg*2); BattleBase.DebugText("((((2 * "+aAttacker.monster.level+" / 5 + 2) * "+attackStatPower+" * "+attackPower+" / "+defenseStat+") / 50) + 2) * "+stab+" * "+aDefending.getWeaknessStrengthToElement(aMove.elementType)+" * "+random+" / 100"); BattleBase.DebugText("Dmg to apply is: "+dmg); break; case(EPowerApplicationTypes.PowerIsPercentOfHP): dmg = (aMove.power/100)*aDefending.monster.MaxHP; break; } if(defendersEffect!=null) { if(defendersEffect.applyToSelf) { } else { this.applyStatusEffectToMonster(aDefending,defendersEffect.moveRef,1.0f,aAttacker); } } if(aDefending.oneHitKOImmune&&aDefending.hp==aDefending.monster.MaxHP&&dmg>=aDefending.monster.MaxHP) { dmg = aDefending.monster.MaxHP-1f; } EMonsterPos defendingPosition = monsterPositionByMonster(aDefending as BattleMonster); if(dmg>0) { dmg = dmg*aSplashPercent; if(dmg>aDefending.hp) { dmg = aDefending.hp; } BattleBase.DebugText("HP before is: "+aDefending.hp); aDefending.takeHP(dmg,this._position,defendingPosition,criticalApplied); BattleBase.DebugText("HP after is: "+aDefending.hp); } if(selfHitPercent>0f&&aSplashPercent==1f) { float selfDamage = dmg * selfHitPercent; BattleBase.DebugText("Self hit damage is "+selfDamage); aAttacker.takeHP((int) selfDamage,otherPosition(),aAttackersPosition); } else { float selfHeal = dmg * selfHitPercent*-1;; if(selfHeal>0f) aAttacker.addHP(selfHeal,otherPosition(),aAttackersPosition); } }
private void applyHPBoostEffectToMonster(BattleMonsterWithMoves aBooster,MoveLibItem aMove,BattleMonsterWithMoves aBoosted,CommentaryManager aCommentaryManagern) { float attackStatPower = aBooster.rangeAttack; float defenseStat = aBoosted.rangeDefense; if(aMove.rangeStatus == ERangedStatus.Melee) { attackStatPower = aBooster.meleeAttack; defenseStat = aBoosted.meleeDefense; } float dmg = 0; float selfHitPercent = aMove.selfInflictPercent; bool criticalApplied = false; switch(aMove.powerApplicationType) { case(EPowerApplicationTypes.Normal): float attackPower = aMove.getPower(aBooster.unlockLevelForMove(aMove));; float stab = 1.0f; if(aMove.elementType==aBooster.monster.elementType) { stab = 1.5f; } else if(aMove.elementType==aBooster.monster.secondaryType) { stab = 1.25f; } int random = (int) (BattleRandomizer.random*15)+85; if(attackStatPower == 0) { } float weaknessStrength = aBoosted.getWeaknessStrengthToElement(aMove.elementType); if(attackPower>0) dmg = ((((2 * aBooster.monster.level / 5 + 2) * attackStatPower * attackPower / defenseStat) / 50) + 2) * stab * aBoosted.getWeaknessStrengthToElement(aMove.elementType) * random / 100; dmg = (float) Math.Ceiling(dmg*2); BattleBase.DebugText("((((2 * "+aBooster.monster.level+" / 5 + 2) * "+attackStatPower+" * "+attackPower+" / "+defenseStat+") / 50) + 2) * "+stab+" * "+aBoosted.getWeaknessStrengthToElement(aMove.elementType)+" * "+random+" / 100"); BattleBase.DebugText("Dmg to apply is: "+dmg); break; case(EPowerApplicationTypes.PowerIsPercentOfHP): dmg = (aMove.power/100)*aBooster.monster.MaxHP; break; } if(selfHitPercent>0f) { float selfDamage = dmg * selfHitPercent; aBooster.takeHP((int) selfDamage,otherPosition(),aBooster.myPosition); } else { float selfHeal = dmg * selfHitPercent*-1;; if(selfHeal>0f) aBooster.addHP(selfHeal,otherPosition(),aBooster.myPosition); } EMonsterPos defendingPosition = monsterPositionByMonster(aBoosted as BattleMonster); if(dmg>0) aBoosted.addHP(dmg,this._position,defendingPosition); this.applyStatusEffectToMonster(aBooster,aMove,1f,aBoosted); }