Example #1
0
		public virtual void CastOnSelf(bool fromObject, int spell, ushort type )
		{
			if ( this is Character )
			{
				( this as Character ).StopAttacking();
			
				if(!fromObject) if(!cast.baseability.CheckSpell(this,this)) return;
			}
			if ( fromObject || HaveSpell( spell ) )
			{
				spellTarget = this;
				targetedItem = null;

				if ( cast.castingtime == 0 )
				{
					SpellStart();
				}
				else
				{
					//spellTarget = null;
					//01 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00  61 0A 00 00 00 01 B8 0B 00 00 00 00
					int offset = 4;
					Converter.ToBytes( Guid, tempBuff, ref offset );
					Converter.ToBytes( Guid, tempBuff, ref offset );
					Converter.ToBytes( cast.id, tempBuff, ref offset );
					Converter.ToBytes( (ushort)0x100, tempBuff, ref offset );
					Converter.ToBytes( (ushort)cast.castingtime, tempBuff, ref offset );
					Converter.ToBytes( 0, tempBuff, ref offset );
					ToAllPlayerNear( OpCodes.SMSG_SPELL_START, tempBuff, offset );	
						
					spellCastTimer = new SpellCastTimer( new SpellStartRun( this.SpellStart ), cast.castingtime );
				}		
			}
		}
Example #2
0
		public virtual void ZoneCastSpell( int spell, ushort type, float x, float y, float z )
		{
			float[] zone = {x,y,z};
			if (this is Character)
			{
				if(!cast.baseability.CheckSpell(this,null)) return;
			}
			if ( HaveSpell( spell ) )
			{
				spellTargetX = x;
				spellTargetY = y;
				spellTargetZ = z;
				targetedItem = null;
				spellTarget = null;
				/*
				F6 00 00 00 00 00 00 00 
				F6 00 00 00 00 00 00 00 
				48 08 00 00 
				00 01 B8 0B 00 00 40 00 06 BF CF 44 FB C3 D1 44 6F 0F F1 42 
				*/
				if ( cast.castingtime <= 0 )
				{
					SpellStart();
				}
				else
				{
					int offset = 4;
					Converter.ToBytes( Guid, tempBuff, ref offset );
					Converter.ToBytes( Guid, tempBuff, ref offset );
					Converter.ToBytes( cast.id, tempBuff, ref offset );
					Converter.ToBytes( (ushort)0x100, tempBuff, ref offset );
					Converter.ToBytes( cast.castingtime, tempBuff, ref offset );
					Converter.ToBytes( cast.type, tempBuff, ref offset );					
					Converter.ToBytes( spellTargetX, tempBuff, ref offset );
					Converter.ToBytes( spellTargetY, tempBuff, ref offset );
					Converter.ToBytes( spellTargetZ, tempBuff, ref offset );
					ToAllPlayerNear( OpCodes.SMSG_SPELL_START, tempBuff, offset );	

					spellCastTimer = new SpellCastTimer( new SpellStartRun( this.SpellStart ), (int)cast.castingtime );
				}
			}
		}
Example #3
0
		public virtual void SingleTargetCastSpell( Object target, int spell, ushort type )
		{
			if ( this is Character )
			{
				//( this as Character ).StopAttacking();
				if(!cast.baseability.CheckSpell(this,target)) return;
			}
			if(SpellTemplate.SpellEffects[cast.id] is NextAttackEffectDelegate && ( type & 0x2 ) != 0 )
			{
				Mobile mob = (Mobile)target;
				if(mob != null)
				{
					NextAttackEffect nae = new NextAttackEffect(cast.baseability,(NextAttackEffectDelegate)SpellTemplate.SpellEffects[cast.id]);
					this.nextAttackEffects.Add(nae);
					
					int offset = 4;
					
					Converter.ToBytes( (ulong)Guid, tempBuff, ref offset );
					Converter.ToBytes( (ulong)Guid, tempBuff, ref offset );
					Converter.ToBytes( (uint)cast.id, tempBuff, ref offset );
					Converter.ToBytes( (ushort)cast.type, tempBuff, ref offset );
					Converter.ToBytes( (uint)cast.castingtime, tempBuff, ref offset );
					Converter.ToBytes( (ushort)cast.type, tempBuff, ref offset );				
					Converter.ToBytes( (ulong)target.Guid, tempBuff, ref offset );
					
					ToAllPlayerNear( OpCodes.SMSG_SPELL_START, tempBuff, offset );	
				}
				else
					this.SpellFaillure(SpellFailedReason.InvalidTarget);
			}
			else
			{
				if (this.combatTimer != null) this.combatTimer.Stop();
				if ( HaveSpell( spell ) )
				{
					cast.type = type;
					targetedItem = null;				
					spellTarget = target;
					if ( cast.castingtime == 0 )
					{
					
						SpellStart();
					
					}
					else					
					{
					
				
						int offset = 4;
						// 00 26 31 01 
						//EA 01 00 00 00 00 00 00 
						//31 02 00 00 00 00 00 00 
						//85 00 00 00 
						//00 01 
						//DC 05 00 00 
						//02 00 
						//EA 01 00 00 00 00 00 00
						Converter.ToBytes( (ulong)Guid, tempBuff, ref offset );
						Converter.ToBytes( (ulong)Guid, tempBuff, ref offset );
						Converter.ToBytes( (uint)cast.id, tempBuff, ref offset );
						Converter.ToBytes( (ushort)0x100, tempBuff, ref offset );
						Converter.ToBytes( (uint)cast.castingtime, tempBuff, ref offset );
						Converter.ToBytes( (ushort)cast.type, tempBuff, ref offset );				
						Converter.ToBytes( (ulong)target.Guid, tempBuff, ref offset );

						ToAllPlayerNear( OpCodes.SMSG_SPELL_START, tempBuff, offset );	
					
						spellCastTimer = new SpellCastTimer( new SpellStartRun( this.SpellStart ), (int)cast.castingtime);
					
					}
				}
			}
		}
Example #4
0
		public virtual bool SpellExecutionStart(Casting cast,object target,bool fromObject)
		{			
			
			this.primarySpellTarget = target;
			if(this.spellTarget == null && target is Object ) this.spellTarget = target as Object;
			if (!fromObject)
			{
				if(!cast.baseability.CheckSpellCaster(this)) return false;
				if(!(primarySpellTarget is SpellXYZtarget) || !(primarySpellTarget is Item))
					if(!cast.baseability.CheckSpellTarget(this,primarySpellTarget as Object)) return false;
			}
			
			if(cast.id == 75)
			{	
				if(this.combatTimer != null) this.combatTimer.Stop();
				if(this.combatTimer != null) Console.WriteLine("stop1" + this.combatTimer.Delay);
				if(this is Character)
				{
					if((this as Character).SecondCombatTimer != null) (this as Character).SecondCombatTimer.Stop();
					if((this as Character).SecondCombatTimer != null) Console.WriteLine("stop1");
					if((this as Character).FirstCombatTimer != null) (this as Character).FirstCombatTimer.Stop();
					if((this as Character).FirstCombatTimer != null) Console.WriteLine("stop2" );
				}
				#region AutoShot
				if (target is Mobile)
				{
					SpellTemplate st = (SpellTemplate)cast.baseability;
					SingleTargetSpellEffect stse =( SingleTargetSpellEffect)SpellTemplate.SpellEffects[cast.id];
					stse(st,this,target as Mobile);
				}
				#endregion
			}
			else if(SpellTemplate.SpellEffects[cast.id] != null)
			{
				#region attack speed spells with projectile
				if((SpellTemplate.SpellEffects[cast.id] is SingleTargetSpellEffectAttackSpeedRanged) || (SpellTemplate.SpellEffects[cast.id] is SingleTargetSpellEffectAttackSpeedRangedMultiple))
				{	
					if(this.combatTimer != null) this.combatTimer.Stop();
					if(this.combatTimer != null) Console.WriteLine("stop1" + this.combatTimer.Delay);
					if(this is Character)
					{
						if((this as Character).SecondCombatTimer != null) (this as Character).SecondCombatTimer.Stop();
						if((this as Character).SecondCombatTimer != null) Console.WriteLine("stop1");
						if((this as Character).FirstCombatTimer != null) (this as Character).FirstCombatTimer.Stop();
						if((this as Character).FirstCombatTimer != null) Console.WriteLine("stop2" );
					}
				{
						
					Mobile mob = (Mobile)target;
					if(mob != null)
					{
							
						this.OnSpellTemplateResults(cast.baseability,mob);
						Item weapon = this.RangedWeapon;
						Item ammo = this.RangedAmmo;
							
						if (weapon == null)
						{
								
							this.SpellFaillure(SpellFailedReason.YourWeaponHandIsEmpty);
							return false;
						}
													
						if((weapon.InventoryType == InventoryTypes.Thrown))
							ammo = weapon;
						bool skip = false;
						foreach(object obj in this.AdditionnalStates)
						{
							if(obj is RangedUseTimer)
							{
								RangedUseTimer rut = (RangedUseTimer)obj;
								if(rut.cast.id == this.cast.id)
								{
									Console.WriteLine("UHHUHHUHHHUHHU");
									#region Cast Result send
									this.SpellFaillure(SpellFailedReason.AbilityIsntReadyYet);
									#endregion
									skip = true;
								}

							}
						}
						if(!skip)
						{
							if(cast.castingtime > 0)
							{
								RangedUseTimer rut1 = new RangedUseTimer(this.cast,this,(int)(this.RangedAttackSpeed*1000) + cast.castingtime);
							}
							else
							{
								RangedUseTimer rut1 = new RangedUseTimer(this.cast,this,(int)(this.RangedAttackSpeed*1000));
							}
							int offset = 4;
							Converter.ToBytes( this.Guid, this.tempBuff, ref offset );
							Converter.ToBytes( this.Guid, this.tempBuff, ref offset );
							Converter.ToBytes( cast.id, this.tempBuff, ref offset );
							Converter.ToBytes( (short)0x22, this.tempBuff, ref offset );
							Converter.ToBytes( (uint)0x000001c7, this.tempBuff, ref offset );
							Converter.ToBytes( (ushort)0x2, this.tempBuff, ref offset );
							Converter.ToBytes( mob.Guid, this.tempBuff, ref offset );
							if(ammo != null)
							{
								Console.WriteLine("ommo ok");
								Converter.ToBytes( (uint)ammo.Model, this.tempBuff, ref offset );
								Converter.ToBytes( (uint)ammo.InventoryType, this.tempBuff, ref offset );
							}
							this.ToAllPlayerNear( OpCodes.SMSG_SPELL_START, this.tempBuff, offset );
							
							spellCastTimer = new SpellCastTimer( new SpellStartRun( this.SpellStart ), (int)500 );

							
						}

					}
				}
			
				}
					#endregion 
					#region NextAttackEffectDelegate + multiple one
				else if(SpellTemplate.SpellEffects[cast.id] is NextAttackEffectDelegate )
				{
					if (target is Mobile)
					{
						Mobile mob = (Mobile)target;
						if(mob != null)
						{
							this.OnSpellTemplateResults(cast.baseability,mob);
						
							NextAttackEffect nae = new NextAttackEffect(cast.baseability,(NextAttackEffectDelegate)SpellTemplate.SpellEffects[cast.id]);
							this.nextAttackEffects.Add(nae);
					
							int offset = 4;
					
							Converter.ToBytes( (ulong)Guid, tempBuff, ref offset );
							Converter.ToBytes( (ulong)Guid, tempBuff, ref offset );
							Converter.ToBytes( (uint)cast.id, tempBuff, ref offset );
							Converter.ToBytes( (ushort)cast.type, tempBuff, ref offset );
							Converter.ToBytes( (uint)cast.castingtime, tempBuff, ref offset );
							Converter.ToBytes( (ushort)cast.type, tempBuff, ref offset );				
							Converter.ToBytes( (ulong)mob.Guid, tempBuff, ref offset );
					
							ToAllPlayerNear( OpCodes.SMSG_SPELL_START, tempBuff, offset );	
						}
						else
							this.SpellFaillure(SpellFailedReason.InvalidTarget);
					}
					else
						this.SpellFaillure(SpellFailedReason.InvalidTarget);
				}
				else if(SpellTemplate.SpellEffects[cast.id] is NextAttackEffectDelegateMultiple )
				{
					if (target is Mobile)
					{
						Mobile mob = (Mobile)target;
						if(mob != null)
						{
							this.OnSpellTemplateResults(cast.baseability,mob);
						
							NextAttackEffect nae = new NextAttackEffect(cast.baseability,(NextAttackEffectDelegateMultiple)SpellTemplate.SpellEffects[cast.id]);
							this.nextAttackEffects.Add(nae);
					
							int offset = 4;
					
							Converter.ToBytes( (ulong)Guid, tempBuff, ref offset );
							Converter.ToBytes( (ulong)Guid, tempBuff, ref offset );
							Converter.ToBytes( (uint)cast.id, tempBuff, ref offset );
							Converter.ToBytes( (ushort)cast.type, tempBuff, ref offset );
							Converter.ToBytes( (uint)cast.castingtime, tempBuff, ref offset );
							Converter.ToBytes( (ushort)cast.type, tempBuff, ref offset );				
							Converter.ToBytes( (ulong)mob.Guid, tempBuff, ref offset );
					
							ToAllPlayerNear( OpCodes.SMSG_SPELL_START, tempBuff, offset );	
						}
						else
							this.SpellFaillure(SpellFailedReason.InvalidTarget);
					}
					else
						this.SpellFaillure(SpellFailedReason.InvalidTarget);
				}
					#endregion
					#region base
				else
				{
					if(this.combatTimer != null) this.combatTimer.Stop();
					if(this.combatTimer != null) Console.WriteLine("stop1" + this.combatTimer.Delay);
					if(this is Character)
					{
						if((this as Character).SecondCombatTimer != null) (this as Character).SecondCombatTimer.Stop();
						if((this as Character).SecondCombatTimer != null) Console.WriteLine("stop1");
						if((this as Character).FirstCombatTimer != null) (this as Character).FirstCombatTimer.Stop();
						if((this as Character).FirstCombatTimer != null) Console.WriteLine("stop2" );
					}
					this.SendSMSGSpellStart(cast,this,this.primarySpellTarget);
					if(cast.castingtime <=0)
					{
						SpellStart();
					}
					else
					{
						
						spellCastTimer = new SpellCastTimer( new SpellStartRun( this.SpellStart ), (int)cast.castingtime );

					}
				}
				#endregion
			}
			return true;
		
		}