Ejemplo n.º 1
0
		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);
		}
Ejemplo n.º 2
0
		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);
			}
			
			
		}
Ejemplo n.º 3
0
		public bool applyHPBoostsToTeam(MoveQueueItem aItem,CommentaryManager aCommentary) {
			if(containsMonster(aItem.actioningMonster)) {
				ESplashRange splash = aItem.moveData.splashRange;
				float splashPrecent = aItem.moveData.splashPercent;
				
				EMonsterPos target = aItem.targetMonster;
				
				BetterList<BattleMonster> targets = getBoostTargetsForMove(target,aItem.moveData,(BattleMonster) aItem.actioningMonster);
				if(targets.size>0) {
					for(int i = 0;i<targets.size;i++) {
						applyHPBoostEffectToMonster(aItem.actioningMonster,aItem.moveData,targets[i],aCommentary);
					}
				} else {
					
				}
				return false;
			} else {

			}
			return false;
		}
Ejemplo n.º 4
0
		public void applyHPEffectToTeam(MoveQueueItem aItem,CommentaryManager aCommentaryManager) {
			// Does this team contain the offensive monster?
			if(containsMonster(aItem.actioningMonster)) {
				if(aItem.moveData.isBoost) {
					//this.applyStatusEffectToMonster(
				}
			} else {
				ESplashRange splash = aItem.moveData.splashRange;
				float splashPrecent = aItem.moveData.splashPercent;
				
				EMonsterPos target = aItem.targetMonster;
				BetterList<BattleMonster> targets = getTargetsForMove(target,aItem.moveData);
				
				
				for(byte c = 0;c<targets.size;c++) {
					if(c == 0) {
						if(accuracyShouldHit(aItem.moveData,aItem.actioningMonster.accuracy,targets[c].agility)) {
							aItem.addHitMonster(targets[c]);
							applyHPEffectToMonster(aItem.actioningMonster,aItem.moveData,1.0f,targets[c],aCommentaryManager,aItem.actionPosition);
						} else {
							targets[c].addMissedMessage(aItem.moveData);
						}
					} else {
						if(accuracyShouldHit(aItem.moveData,aItem.actioningMonster.accuracy,targets[c].agility)) {
							aItem.addHitMonster(targets[c]);
							applyHPEffectToMonster(aItem.actioningMonster,aItem.moveData,splashPrecent,targets[c],aCommentaryManager,aItem.actionPosition);
						} else {
							targets[c].addMissedMessage(aItem.moveData);
						}
					}
				}
			}
		} 
Ejemplo n.º 5
0
		public float applyStatusEffectToTeam(MoveQueueItem aItem,CommentaryManager aCommentary) {
			EStatusEffects allStatusApplied = EStatusEffects.None;
			float delay = 0.0f;
			if(containsMonster(aItem.actioningMonster)) {
				
			} else {
				ESplashRange splash = aItem.moveData.splashRange;
				float splashPercent = aItem.moveData.splashPercent;
				
				BetterList<BattleMonster> targets = aItem.hitMonsters;
				
				for(byte c = 0;c<targets.size;c++) {
						EStatusEffects effectsApplied = EStatusEffects.None;
						if(c == 0) {
							delay += applyStatusEffectToMonster(aItem.actioningMonster,aItem.moveData,1.0f,targets[c]);
							
						} else {
							delay += applyStatusEffectToMonster(aItem.actioningMonster,aItem.moveData,splashPercent,targets[c]);
						}
						allStatusApplied = allStatusApplied | effectsApplied;
					}
				}
			return delay;
			}
Ejemplo n.º 6
0
		public float applyStatEffectToTeam(MoveQueueItem aItem,CommentaryManager aCommentary) {
			EStatusEffects allStatusApplied = EStatusEffects.None;
			ESplashRange splash = aItem.moveData.splashRange;
			float splashPrecent = aItem.moveData.splashPercent;
			float delayAmount = 0.0f;
			if(containsMonster(aItem.actioningMonster)) {
				if(boostsMyTeam(splash)) {
					EMonsterPos target = aItem.targetMonster;
					BetterList<BattleMonster> targets = this.getBoostTargetsForMove(target,aItem.moveData,(BattleMonster) aItem.actioningMonster);
					for(byte c = 0;c<targets.size;c++) {
						delayAmount += applyStatEffectsToMonster(targets[c],aItem.moveData,aItem);
					}
				}
			} else {
				EMonsterPos target = aItem.targetMonster;
				BetterList<BattleMonster> targets = this.getTargetsForMove(target,aItem.moveData);
				if(!boostsMyTeam(splash)) {
					targets = aItem.hitMonsters;
					for(byte c = 0;c<targets.size;c++) {
						delayAmount+= applyStatEffectsToMonster(targets[c],aItem.moveData,aItem);
					}
				}
			}
			return delayAmount;
		}
Ejemplo n.º 7
0
		public void OnDestroy() {
			REF = null;
		}
Ejemplo n.º 8
0
		public void Start() {
			REF = this;
		}
Ejemplo n.º 9
0
		protected void baseCreate() {
			
				if(commentaryEngine!=null) {
					_commentaryManager = commentaryEngine.GetComponent<CommentaryManager>();
					}
				if(BattleInit.REF!=null) // We might be a multiplayer game
				_background = BattleBGLibrary.getBattleBG(BattleInit.REF.battleBackground);
				
				blackScreen.GetComponent<Renderer>().sortingLayerName = "MiddleLayer";
				blackScreen.transform.localScale = new Vector3(Screen.width*2,Screen.height*2,1);
			}