Example #1
0
		public virtual int Hit( Mobile m, float dmgBonus,bool pass, ref int amountBlocked, ref int amountAbsorbed )
		{			
			Item weapon = activeWeapon;
			if ( Level < m.Level - 7 )
			{
				lastAttack = AttackStatus.Dodge;
				m.lastAttackToMe = AttackStatus.Dodge;
				return -1;	
			}			
			float critChance = CriticalChanceCalculation(weapon,m);
			float dif = SkillDifCalculation(weapon,m);
			float hitChance = HitChanceCalculation(weapon,m,dif);
		
			bool criticalStrike = false;
			
			#region critical and hit test
			int roll =Utility.Random( 100 );	

			if ((int)critChance >= roll )
			{
				#region Critical hit trigger done
				ArrayList al = new ArrayList();
				ArrayList pal = new ArrayList();
				foreach( AuraReleaseTimer art in aura )
				{
					int a = art.aura.OnCriticalHit;
					if ( a != -1 )
						al.Add( art );
				}
				foreach( PermanentAura art in permanentAura )
				{
					int a = art.aura.OnCriticalHit;
					if ( a != -1 )
						al.Add( art );
				}
				foreach( object obj in al )
				{
					if(obj is AuraReleaseTimer)
					{ 
						AuraReleaseTimer art = (AuraReleaseTimer)obj;
						int a = art.aura.OnCriticalHit;
						if ( a != -1 )
							if(Triggers[ a ] != null)
								( Triggers[ a ] as OnCriticalHitTrigger )( this, m, art.ae );
					}
					if(obj is PermanentAura)
					{ 
						PermanentAura art = (PermanentAura)obj;
						int a = art.aura.OnCriticalHit;
						if ( a != -1 )
							if(Triggers[ a ] != null)
								( Triggers[ a ] as OnCriticalHitTrigger )( this, m, Abilities.abilities[(int)art.Id] );
					}
				}
				#endregion
				
				#region Critical hit done Triggers
				ArrayList al2 = new ArrayList();
				ArrayList pal2 = new ArrayList();
				foreach( AuraReleaseTimer art in aura )
				{
					int a = art.aura.OnCriticalHitDone;
					if ( a != -1 )
						al2.Add( art );
				}
				foreach( PermanentAura art in permanentAura)
				{
					int a = art.aura.OnCriticalHitDone;
					if ( a != -1 )
						pal2.Add( art );
				}
				foreach( object obj in al2 )
				{
					if(obj is AuraReleaseTimer)
					{ 
						AuraReleaseTimer art = (AuraReleaseTimer)obj;
					
						int a = art.aura.OnCriticalHitDone;
						if ( a != -1 )
							if(Triggers[ a ] != null) 
								( Triggers[ a ] as OnCriticalHitDoneTrigger )(this, m, art.ae );
					}
					if(obj is PermanentAura)
					{ 
						PermanentAura art = (PermanentAura)obj;
						int a = art.aura.OnCriticalHitDone;
						if ( a != -1 )
							if(Triggers[ a ] != null)
								( Triggers[ a ] as OnCriticalHitDoneTrigger )(this, m, Abilities.abilities[(int)art.Id] );
					}
				}
				#endregion
				
					
				/*bovie*/
					
				/*bovie*/	
				lastAttack = AttackStatus.Critical;
				m.lastAttackToMe = AttackStatus.Critical;
				criticalStrike = true;
			}
			else if((int)hitChance <= roll)
			{
				lastAttack = AttackStatus.NormalHit;
				m.lastAttackToMe = AttackStatus.NormalHit;
			}
			else 
			{
				lastAttack = AttackStatus.Loose;
				m.lastAttackToMe = AttackStatus.Loose;
				return 0;
			}
			#endregion

			if (!pass)
			{
				float parryChance = ParryChanceCalculation(m,dif);

				#region Parry test
				roll = Utility.Random( 100 );
				if (parryChance >= roll)
				{
					lastAttack = AttackStatus.Parry;
					m.lastAttackToMe = AttackStatus.Parry;
					return -2;	
				}
				#endregion			

				float dodgeChance = DodgeChanceCalculation(m,dif);

				#region Dodge test
				roll = Utility.Random( 100 );
				if (dodgeChance >= roll)
				{
					lastAttack = AttackStatus.Dodge;
					m.lastAttackToMe = AttackStatus.Dodge;
					return -1;	
				}
				#endregion
			}


			float damage = DamageDoneCalculation(m,dmgBonus,criticalStrike,weapon);
			float blockChance = BlockChanceCalculation(m,dif);
			if (!pass)
			{
				#region Block test + block reduction	
				roll = Utility.Random( 100 );
				// shield specialization
				if (blockChance >= roll)
				{
					lastAttack = AttackStatus.Block;
					m.lastAttackToMe = AttackStatus.Block;
					amountBlocked = m.Block + m.Str/30;
					damage -= amountBlocked;
					#region talents
					// shield specialization
					if ( m.HaveTalent(Talents.ShieldSpecialization) )
					{
						AuraEffect af = (AuraEffect)m.GetTalentEffect(Talents.ShieldSpecialization);
						roll = Utility.Random( 100 );
						if ( roll < af.H )
						{
							m.GainMana(m,(Abilities.abilities[af.AdditionalSpell] as SpellTemplate).S1);
						}
					}
					#endregion
				}
		
				#endregion
			}
			#region Armor reduction
			float armor = ArmorReductionCalculation(m); 
			damage = damage * (1 - armor);
			#endregion

			#region immune
			if (m.ImmunePhysicalDamage)
			{
				lastAttack = AttackStatus.Immune;
				m.lastAttackToMe = AttackStatus.Immune;
				return 0;
			}
			#endregion
			
			#region absorb
			amountAbsorbed = (int)damage;
			damage =(int)m.DamageAbsorbCombat(damage);
			amountAbsorbed -= (int)damage;
			if ( damage < 0 )
			{
				this.lastAttack = AttackStatus.Absorb;
				m.lastAttackToMe = AttackStatus.Absorb;	
				return 0;
			}
			#endregion

			#region Targets modificators 
			damage = DamageTakenCalculation(m,damage);
			#endregion
			damage = m.ManaShieldLost(this,(int)damage);
			#region other effects
			
			switch (this.Classe)
			{
					#region warrior
				case Classes.Warrior:
					// deep wounds 
					if (this.lastAttack == AttackStatus.Critical)
					{
						/*if ( src.HaveTalent( Talents.DeepWounds) )
						{
							AuraEffect ae = (AuraEffect)src.GetTalentEffect( Talents.DeepWounds );
								
								AuraEffect af = (AuraEffect)Abilities.abilities[ae.AdditionalSpell];
								float modif = (float)ae.S1/100;
								af.ApplyDot(this, m, (int)(damage*modif), af.T1, af.Duration(this));
							
						}*/
						if ( m.HaveTalent( Talents.BloodCraze) )
						{
							AuraEffect ae = (AuraEffect)m.GetTalentEffect( Talents.BloodCraze );
							SpellTemplate st = (SpellTemplate)Abilities.abilities[ae.AdditionalSpell];
							HotAura aura = new HotAura(st,m,m,(int)(m.BaseHitPoints*((float)st.S1/100)/(st.Duration(m)/st.T1)),st.Duration(m),st.T1);
							
						}

					}
					//Mace specialization
					/*if ( src.HaveTalent( Talents.MaceSpecialization) && weapon.SubClass == 4 )
					{
						AuraEffect ae = (AuraEffect)src.GetTalentEffect( Talents.MaceSpecialization );
						roll = Utility.Random( 100 );
						if(roll < ae.H)
						{
							AuraEffect af = (AuraEffect)Abilities.abilities[ae.AdditionalSpell];
							Aura aura = new Aura();
							aura.ForceStun = true;
							m.AddAura(this, af,aura,true);
						}
					}*/
					//int SwordSpecializationEffect = 0x14af5e;
					/*if ( src.HaveTalent( Talents.SwordSpecialization) && weapon.SubClass == 15 )
					{
						AuraEffect ae = (AuraEffect)src.GetTalentEffect( Talents.SwordSpecialization );
					roll = Utility.Random( 100 );	
					if(roll < ae.H)
						{
							this.AdditionnalStates.Add(SwordSpecializationEffect);
						}
					}*/
					if ( this.HaveTalent( Talents.UnbridledWrath) )
					{
						AuraEffect ae = (AuraEffect)this.GetTalentEffect( Talents.UnbridledWrath );
						roll = Utility.Random( 100 );
						if(roll < ae.H)
						{
							this.GainMana(this,1);
						}
					}
					
					break;
					#endregion
			}
			#endregion
			if ( damage > 0 )
				this.SkillUpWeapon(weapon);
			return (int)damage;
		}
Example #2
0
		public virtual int RangedHit( Mobile m, float dmgBonus,bool pass, ref int amountBlocked, ref int amountAbsorbed )
		{
			Item weapon = this.RangedWeapon;
			Item ammo = this.RangedAmmo;
			if(weapon != null)
			{
				if (this is Character)
					if(weapon.InventoryType == InventoryTypes.Thrown)
					{
						(this as Character).ConsumeItemByIdUpTo(weapon.Id,1);
					}
					else
					{
						(this as Character).ConsumeItemByIdUpTo(ammo.Id,1);
					}
					
			
				float critChance = RangedCriticalChanceCalculation(weapon,m);
				float dif = SkillDifCalculation(weapon,m);
				float hitChance = RangedHitChanceCalculation(weapon,m,dif);
		
				bool criticalStrike = false;
			
				#region critical and hit test
				int roll =Utility.Random( 100 );	
				bool test = false;

				if ((int)critChance >= roll || test)
				{
					#region Critical hit trigger done
					ArrayList al = new ArrayList();
					ArrayList pal = new ArrayList();
					foreach( AuraReleaseTimer art in aura )
					{
						int a = art.aura.OnCriticalHit;
						if ( a != -1 )
							al.Add( art );
					}
					foreach( PermanentAura art in permanentAura )
					{
						int a = art.aura.OnCriticalHit;
						if ( a != -1 )
							al.Add( art );
					}
					foreach( object obj in al )
					{
						if(obj is AuraReleaseTimer)
						{ 
							AuraReleaseTimer art = (AuraReleaseTimer)obj;
							int a = art.aura.OnCriticalHit;
							if ( a != -1 )
								if(Triggers[ a ] != null)
									( Triggers[ a ] as OnCriticalHitTrigger )( this, m, art.ae );
						}
						if(obj is PermanentAura)
						{ 
							PermanentAura art = (PermanentAura)obj;
							int a = art.aura.OnCriticalHit;
							if ( a != -1 )
								if(Triggers[ a ] != null)
									( Triggers[ a ] as OnCriticalHitTrigger )( this, m, Abilities.abilities[(int)art.Id] );
						}
					}
					#endregion
				
					#region Critical hit done Triggers
					ArrayList al2 = new ArrayList();
					ArrayList pal2 = new ArrayList();
					foreach( AuraReleaseTimer art in aura )
					{
						int a = art.aura.OnCriticalHitDone;
						if ( a != -1 )
							al2.Add( art );
					}
					foreach( PermanentAura art in permanentAura)
					{
						int a = art.aura.OnCriticalHitDone;
						if ( a != -1 )
							pal2.Add( art );
					}
					foreach( object obj in al2 )
					{
						if(obj is AuraReleaseTimer)
						{ 
							AuraReleaseTimer art = (AuraReleaseTimer)obj;
					
							int a = art.aura.OnCriticalHitDone;
							if ( a != -1 )
								if(Triggers[ a ] != null) 
									( Triggers[ a ] as OnCriticalHitDoneTrigger )(this, m, art.ae );
						}
						if(obj is PermanentAura)
						{ 
							PermanentAura art = (PermanentAura)obj;
							int a = art.aura.OnCriticalHitDone;
							if ( a != -1 )
								if(Triggers[ a ] != null)
									( Triggers[ a ] as OnCriticalHitDoneTrigger )(this, m, Abilities.abilities[(int)art.Id] );
						}
					}
					#endregion
			
					/*bovie*/
					
					/*bovie*/	
					lastAttack = AttackStatus.Critical;
					m.lastAttackToMe = AttackStatus.Critical;
					criticalStrike = true;
				}
				else if((int)hitChance >= roll)
				{
					lastAttack = AttackStatus.NormalHit;
					m.lastAttackToMe = AttackStatus.NormalHit;
				}
				else 
				{
					lastAttack = AttackStatus.Loose;
					m.lastAttackToMe = AttackStatus.Loose;
					return 0;
				}
				#endregion

				if (!pass)
				{
					float dodgeChance = RangedDodgeChanceCalculation(m,dif);
	
					#region Dodge test
					roll = Utility.Random( 100 );
					if (dodgeChance >= roll)
					{
						lastAttack = AttackStatus.Dodge;
						m.lastAttackToMe = AttackStatus.Dodge;
						return 0;	
					}
					#endregion
				}


				float damage = RangedDamageDoneCalculation(m,dmgBonus,criticalStrike,weapon);
				float blockChance = RangedBlockChanceCalculation(m,dif);
				if (!pass)
				{
					#region Block test + block reduction	
					roll = Utility.Random( 100 );
				
					if (blockChance >= roll)
					{
						lastAttack = AttackStatus.Block;
						m.lastAttackToMe = AttackStatus.Block;
						amountBlocked = m.Block + m.Str/30;
						damage -= amountBlocked;
						#region talents
						// shield specialization
						if ( m.HaveTalent(Talents.ShieldSpecialization) )
						{
							AuraEffect af = (AuraEffect)m.GetTalentEffect(Talents.ShieldSpecialization);
							roll = Utility.Random( 100 );
							if ( roll < af.H )
							{
								m.GainMana(m,(Abilities.abilities[af.AdditionalSpell] as SpellTemplate).S1);
							}
						}
						#endregion
					}
		
					#endregion
				}
				#region Armor reduction
				float armor = ArmorReductionCalculation(m); 
				damage = damage * (1 - armor);
				#endregion

				#region immune
				if (m.ImmunePhysicalDamage)
				{
					lastAttack = AttackStatus.Immune;
					m.lastAttackToMe = AttackStatus.Immune;
					return 0;
				}
				#endregion
			
				#region absorb
				damage =(int)m.DamageAbsorbCombat(damage);
				if ( damage < 0 )
				{
					this.lastAttack = AttackStatus.Absorb;
					m.lastAttackToMe = AttackStatus.Absorb;	
					return 0;
				}
				#endregion

				#region Targets modificators 
				damage = RangedDamageTakenCalculation(m,damage);
				#endregion
				damage = m.ManaShieldLost(this,(int)damage);
				#region other effects
			
				switch (this.Classe)
				{
						#region warrior
					case Classes.Warrior:
					
						if ( this.HaveTalent( Talents.UnbridledWrath) )
						{
							AuraEffect ae = (AuraEffect)this.GetTalentEffect( Talents.UnbridledWrath );
							roll = Utility.Random( 100 );
							if(roll < ae.H)
							{
								this.GainMana(this,1);
							}
						}
					
						break;
						#endregion
				}
				#endregion

				if ( damage > 0 && this is Character)
					this.SkillUpWeapon(weapon);
				return (int)damage;
			}
			else 
				return 0;
		}