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); } } } }
public virtual void NextAttackSpellGo(NextAttackEffect nae) { if ( cast.id == 0 ) { SpellFaillure( SpellFailedReason.Fizzled ); return; } if ( primarySpellTarget is BaseSpawner ) return; bool miss = false; ArrayList hittedSecTargs = new ArrayList(); ArrayList exeSecTargs = new ArrayList(); ArrayList secondarySpellTargets = new ArrayList(); if ( SpellTemplate.SpellEffects[ cast.id ] != null ) { int off = 4; Converter.ToBytes( cast.id, tempBuff, ref off ); Converter.ToBytes( (byte)0, tempBuff, ref off ); if (this is Character) (this as Character ).Send( OpCodes.SMSG_CAST_RESULT, tempBuff, off ); bool cut = true; if(SpellTemplate.SpellEffects[ cast.id ] is NextAttackEffectDelegate) { if(SpellTargeting.spellTargets[cast.id] != null) if((SpellTargeting.spellTargets[cast.id] as String).Split('|')[0] == "6" && MultipleTargets.multipleTargets[cast.id] == null) { miss = (cast.baseability as SpellTemplate).MissAndRessistTest(primarySpellTarget as Object,this); (primarySpellTarget as Mobile ).LastOffender = this; SendSMSGSpellGo(cast, this, primarySpellTarget as Mobile,null, null); NextAttackEffectDelegate stse = (NextAttackEffectDelegate)SpellTemplate.SpellEffects[ cast.id ]; cut = stse( cast.baseability, this, primarySpellTarget as Mobile,nae.number ); } else if ((SpellTargeting.spellTargets[cast.id] as String).Split('|')[0] == "6" && MultipleTargets.multipleTargets[cast.id] != null) { (primarySpellTarget as Mobile).LastOffender = this; miss = (cast.baseability as SpellTemplate).MissAndRessistTest(primarySpellTarget as Object,this); secondarySpellTargets = SpellTargets.closeTargets(primarySpellTarget as Mobile,cast.radius,(int)MultipleTargets.multipleTargets[cast.id],TargetType.Enemy); foreach(Mobile mob in secondarySpellTargets) { bool check = cast.baseability.CheckSpellTargetMultiple(this,mob); bool m = (cast.baseability as SpellTemplate).MissAndRessistTest(mob,this); if(check && !m) {hittedSecTargs.Add(mob); miss = false;} if(check) exeSecTargs.Add(mob); } SendSMSGSpellGo(cast, this, primarySpellTarget as Mobile,secondarySpellTargets, exeSecTargs); NextAttackEffectDelegateMultiple stse = (NextAttackEffectDelegateMultiple)SpellTemplate.SpellEffects[ cast.id ]; cut = stse( cast.baseability, this, primarySpellTarget as Mobile,hittedSecTargs,nae.number ); } } if(cut) { this.NextAttackEffects.Remove(nae); } else nae.number++; this.primarySpellTarget = null; cast.baseability = null; cast.castingtime = 0; cast.cool = 0; cast.id = 0; cast.manacost = 0; cast.type = 0; cast.duration = 0; cast.radius = 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; }