Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- case 12070://TwilightDance
- {
- if (CanUseSpell(spell, attacker.Owner))
- {
- PrepareSpell(spell, attacker.Owner);
- LayTrapThree Line = new LayTrapThree(attacker.X,
- X, attacker.Y, Y, 15);
- SpellUse suse = new SpellUse(true);
- suse.Attacker = attacker.UID;
- suse.Attacker1 = attacker.UID;
- suse.SpellID = SpellID;
- suse.SpellUseSpell = UseSpell;
- suse.SpellLevel = attacker.Owner.Spells[SpellID].Level;
- suse.X = X;
- suse.Y = Y;
- int Stamp = 300;
- ushort Color = 2;
- List<Network.GamePackets.FloorItem> Items = new List<FloorItem>();
- foreach (var coords in Line.LCoords)
- {
- if (!attacker.FloorSpells.ContainsKey(SpellID))
- attacker.FloorSpells.TryAdd(SpellID, new Game.Features.FloorSpell.ClientFloorSpells(attacker.UID, X, Y, suse.SpellUseSpell, spell));
- var FloorItem = new Game.Features.FloorSpell(40, (ushort)coords.X, (ushort)coords.Y, Color, spell, Stamp);
- attacker.FloorSpells[spellID].AddItem(FloorItem);
- Color++;
- Stamp += 400;
- attacker.Owner.SendScreen(FloorItem.FloorPacket, true);
- }
- attacker.Owner.SendScreen(suse, true);
- }
- break;
- }
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- namespace Conquer_Online_Server.Game.Features
- {
- public class FloorSpell
- {
- public Time32 Stamp = new Time32();
- public Network.GamePackets.FloorItem FloorPacket;
- public Database.SpellInformation DBSkill;
- public FloorSpell(uint ID, ushort X, ushort Y, ushort color, Database.SpellInformation _DBSkill, int MillisecondsStamp)
- {
- FloorPacket = new Network.GamePackets.FloorItem(true);
- FloorPacket.UID = Network.GamePackets.FloorItem.FloorUID.Next;
- FloorPacket.ItemID = ID;
- FloorPacket.X = X;
- FloorPacket.Y = Y;
- FloorPacket.ItemColor = (Enums.Color)color;
- FloorPacket.Type = Network.GamePackets.FloorItem.Effect;
- Stamp = Time32.Now.AddMilliseconds(MillisecondsStamp);
- DBSkill = _DBSkill;
- }
- public unsafe class ClientFloorSpells
- {
- public List<FloorSpell> Spells = new List<FloorSpell>();
- public Network.GamePackets.SpellUse SpellPacket;
- public Database.SpellInformation DBSkill;
- public ushort X;
- public ushort Y;
- public byte LevelHu;
- public uint UID;
- private object SyncRoot;
- public ClientFloorSpells(uint _UID, ushort _X, ushort _Y, byte _LevelHu, Database.SpellInformation _DBSkill)
- {
- DBSkill = _DBSkill;
- SyncRoot = new object();
- X = _X;
- Y = _Y;
- LevelHu = _LevelHu;
- UID = _UID;
- }
- public void CreateMsgSpell(uint Target)
- {
- SpellPacket = new Network.GamePackets.SpellUse(true);
- SpellPacket.Attacker = UID;
- SpellPacket.Attacker1 = Target;
- SpellPacket.X = X;
- SpellPacket.Y = Y;
- SpellPacket.SpellID = DBSkill.ID;
- SpellPacket.SpellLevel = DBSkill.Level;
- SpellPacket.soul = LevelHu;
- }
- public bool CheckInvocke(Time32 Now, FloorSpell spell)
- {
- if (Now > spell.Stamp)
- {
- return true;
- }
- return false;
- }
- public void RemoveItem(FloorSpell item)
- {
- lock (SyncRoot)
- Spells.Remove(item);
- }
- public void SendView(Client.GameState client)
- {
- client.SendScreen(SpellPacket, true);
- }
- public void AddItem(FloorSpell item)
- {
- lock (SyncRoot)
- Spells.Add(item);
- }
- }
- }
- }
- public static void CreateTimerFactories()
- {
- MonsterBuffers = new TimerRule<GameState>(monsterBuffersCallback, 500);
- Guards = new TimerRule<GameState>(guardsCallback, 700);
- MatrixMobs = new TimerRule<GameState>(MatrixMobsCallback, 700);
- AliveMonsters = new TimerRule<GameState>(aliveMonstersCallback, 500);
- Items = new TimerRule<GameState>(itemsCallback, 1000);
- FloorSpells = new TimerRule<GameState>(FloorSpellsCallBack, 100);
- }
- private static void FloorSpellsCallBack(GameState client, int time)
- {
- if (!client.Socket.Alive)
- {
- client.Screen.DisposeTimers();
- return;
- }
- if (client.Entity == null)
- return;
- if (client.Map == null)
- return;
- Time32 Now = new Time32(time);
- if (client.Entity.FloorSpells.Count != 0)
- {
- foreach (var ID in client.Entity.FloorSpells)
- {
- switch (ID.Key)
- {
- case 12070://TwilightDance:
- {
- var spellclient = ID.Value;
- Queue<Game.Features.FloorSpell> RemoveSpells = new Queue<Game.Features.FloorSpell>();
- foreach (var spell in spellclient.Spells)
- {
- if (spellclient.CheckInvocke(Now, spell))
- {
- RemoveSpells.Enqueue(spell);
- spellclient.CreateMsgSpell(100);
- var attack = new Attack(true);
- attack.Attacker = client.Entity.UID;
- attack.AttackType = Attack.Melee;
- foreach (Interfaces.IMapObject _obj in client.Screen.Objects)
- {
- if (_obj == null)
- continue;
- if (_obj.MapObjType == MapObjectType.Monster || _obj.MapObjType == MapObjectType.Player)
- {
- var attacked = _obj as Entity;
- if (Kernel.GetDistance(spell.FloorPacket.X, spell.FloorPacket.Y, attacked.X, attacked.Y) < 3)
- {
- if (!Game.Attacking.Handle.CanAttack(client.Entity, attacked, spell.DBSkill, false))
- continue;
- attack.Effect1 = Attack.AttackEffects.None;
- uint damage = Game.Attacking.Calculate.Melee(client.Entity, attacked, spell.DBSkill, ref attack, spellclient.LevelHu);
- damage += (uint)(damage * 55) / 100;
- spellclient.SpellPacket.Effect1 = attack.Effect1;
- attack.Damage = damage;
- Game.Attacking.Handle.ReceiveAttack(client.Entity, attacked, attack, damage, spell.DBSkill);
- spellclient.SpellPacket.AddTarget(attacked.UID, damage, attack);
- }
- }
- else if (_obj.MapObjType == MapObjectType.SobNpc)
- {
- var attackedsob = _obj as SobNpcSpawn;
- if (Kernel.GetDistance(spell.FloorPacket.X, spell.FloorPacket.Y, attackedsob.X, attackedsob.Y) < 3)
- {
- if (!Game.Attacking.Handle.CanAttack(client.Entity, attackedsob, spell.DBSkill))
- continue;
- attack.Effect1 = Attack.AttackEffects.None;
- uint damage = Game.Attacking.Calculate.Melee(client.Entity, attackedsob, ref attack);
- attack.Damage = damage;
- Game.Attacking.Handle.ReceiveAttack(client.Entity, attackedsob, attack, damage, spell.DBSkill);
- spellclient.SpellPacket.AddTarget(attackedsob.UID, damage, attack);
- }
- }
- }
- spellclient.SendView(client);
- Network.GamePackets.Data datap = new Data(true);
- datap.UID = spell.FloorPacket.UID;
- datap.dwParam = (uint)((spell.FloorPacket.Y << 16) | spell.FloorPacket.X);
- datap.wParam2 = (ushort)(spell.FloorPacket.Y - 2);
- datap.wParam1 = (ushort)(spell.FloorPacket.X - 3);
- datap.ID = Network.GamePackets.Data.RemoveTrap;
- client.SendScreen(datap, true);
- spell.FloorPacket.Type = Network.GamePackets.FloorItem.RemoveEffect;
- client.SendScreen(spell.FloorPacket, true);
- }
- }
- while (RemoveSpells.Count > 0)
- spellclient.RemoveItem(RemoveSpells.Dequeue());
- if (spellclient.Spells.Count == 0)
- {
- Game.Features.FloorSpell.ClientFloorSpells FloorSpell;
- client.Entity.FloorSpells.TryRemove(spellclient.DBSkill.ID, out FloorSpell);
- }
- break;
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement