|
|
public class ThunderCloud
{
public static Counter ThunderCloudCounter = new Counter(700000);
byte[] Buffer;
public ushort X = 0, Y = 0;
public uint UID = 0;
public uint OwnerID;
public GameState Owner;
public DateTime EndTime;
public bool Dead = false;
public bool ThunderBolt = false;
public Time32 LastCloudAttack;
public ThunderCloud(GameState client, ushort X, ushort Y)
{
Owner = client;
Owner.Entity.Cloud = this;
EndTime = DateTime.Now.AddSeconds(24);
this.X = X;
this.Y = Y;
OwnerID = client.Entity.UID;
UID = ThunderCloudCounter.Next;
string _Name = "Thundercloud";
byte[] Packet_2035 = new byte[68 + 8];
Writer.WriteUInt16((ushort)(Packet_2035.Length - 8), 0, Packet_2035);
Writer.WriteUInt16(2035, 2, Packet_2035);
Writer.WriteUInt32(UID, 4, Packet_2035);
Writer.WriteUInt32(4264, 8, Packet_2035);
Packet_2035[12] = 3;
Writer.WriteUInt32(980, 6, Packet_2035);//mesh
Packet_2035[24] = 14;
Writer.WriteUInt32(22348141, 26, Packet_2035);
Writer.WriteString(_Name, 30, Packet_2035);
Buffer = new byte[8 + 321 + _Name.Length + 36];
Writer.WriteUInt16((ushort)(Buffer.Length - 8), 0, Buffer);
Writer.WriteUInt16(10014, 2, Buffer);
Writer.WriteUInt32((uint)Time32.timeGetTime().GetHashCode(), 4, Buffer);
Writer.WriteUInt32(980, 8, Buffer);//Mesh
Writer.WriteUInt32(UID, 12, Buffer);//Uid
var seconds = System.Math.Abs((EndTime - DateTime.Now).TotalSeconds);
Writer.WriteUInt32((uint)((seconds * 10000) / 24), 111, Buffer);//Time
Writer.WriteUInt32(140, 117, Buffer);//Level
Writer.WriteUInt32(X, 119, Buffer);
Writer.WriteUInt32(Y, 121, Buffer);
Writer.WriteUInt32(5, 125, Buffer);
Writer.WriteUInt32(client.Entity.UID, 274, Buffer);//OwnerUID
Buffer[278] = 1;
Buffer[220] = 1;
Writer.WriteUInt16(768, 270, Buffer);
Writer.WriteStringList(new List<string>() { _Name, "", "", "", "", "", "" }, 321, Buffer);
MsgActionProto d = new MsgActionProto();
d.UID = UID;
d.ID = MsgActionEmulator.SpawnEffect;
d.Facing = (byte)client.Entity.Facing;
client.Send(Packet_2035);
client.Send(Buffer);
client.SendScreen(MsgActionEmulator.SendPacket(d));
client.Map.AddCloud(this);
}
public void DisposeCloud(GameState c)
{
if (c != null)
if (c.Map.Clouds.ContainsKey(UID))
{
MsgActionProto Action = new MsgActionProto();
Action.ID = 135;
Action.UID = UID;
Action.TimeStamp = (uint)Time32.Now.GetHashCode();
c.SendScreen(MsgActionEmulator.SendPacket(Action));
c.Map.Clouds.Remove(UID);
ThunderBolt = false;
if (Owner != null)
Owner.Entity.ThunderBolt = false;
Dead = true;
}
}
public void SendSpawn(GameState Owner, bool p)
{
var seconds = System.Math.Abs((EndTime - DateTime.Now).TotalSeconds);
if (seconds > 24) seconds = 0;
Writer.WriteUInt32((uint)((seconds * 10000) / 24), 111, Buffer);//Time
Owner.Send(Buffer);
}
}
else if (DBSpell.ID == (ushort)Enums.SpellID.ThundercloudAttack)
{
if (Time32.Now >= player.CCPD.AddSeconds(20))
{
player.CCPD = Time32.Now;
Damage = Base.MulDiv((int)Damage, (int)(DBSpell.Damage + increasedmg), 100);
Update = true;
}
}
}
if (!Update)
{
Damage = Base.MulDiv((int)Damage, (int)((DBSpell != null) ? DBSpell.Damage : Program.PhysicalDamage), 100);
}
if (killer.Name == "Thundercloud") return;
if (killer.EntityFlag == Game.EntityFlag.Monster)
{
if (killer.Owner != null)
killer = killer.Owner.Entity;
else
return;
}
if (!client.MySpells.ClientSpells.ContainsKey((ushort)Enums.SpellID.Thundercloud))
client.MySpells.Add(stream, (ushort)Enums.SpellID.Thundercloud);
if (!client.MySpells.ClientSpells.ContainsKey((ushort)Enums.SpellID.Thundercloud))
client.MySpells.Add(stream, (ushort)Enums.SpellID.Thundercloud);
#region ThunderCloud
foreach (var Cloud in Map.Clouds.Values)
{
if (Cloud == null) continue;
if (Kernel.GetDistance(Cloud.X, Cloud.Y, Owner.Entity.X, Owner.Entity.Y) > 16) continue;
Cloud.SendSpawn(Owner, false);
}
#endregion
#region thunderCloud
foreach (var Cloud in client.Map.Clouds.Values)
{
if (Cloud == null) continue;
if (Kernel.GetDistance(Cloud.X, Cloud.Y, client.Entity.X, client.Entity.Y) > 16) continue;
if (DateTime.Now > Cloud.EndTime || Cloud.Owner == null)
{
Cloud.DisposeCloud(client);
return;
}
#region ThunderCloud
if (!Cloud.Dead && Time32.Now > Cloud.LastCloudAttack.AddSeconds(Cloud.ThunderBolt == true ? 1 : 2))
{
if (client.Entity.Cloud != null)
{
using (var rec = new ServerSockets.RecycledPacket())
{
var stream = rec.GetStream();
Dictionary<ushort, Database.MagicType.Magic> Spells;
ushort SpellID = 12840;
if (Kernel.Magic.TryGetValue(SpellID, out Spells))
{
Database.MagicType.Magic spell;
if (Spells.TryGetValue(0, out spell))
{
Game.MsgServer.MsgSpellAnimation MsgSpell = new Game.MsgServer.MsgSpellAnimation(Cloud.UID
, 0, Cloud.X, Cloud.Y, 13190
, 0, 0);
uint Experience = 0;
foreach (Interfaces.IMapObject obj in client.Screen.Objects)
{
if (obj.MapObjType == MapObjectType.Monster)
{
var monster = obj as Game.Entity;
if (Kernel.GetDistance(obj.X, obj.Y, Cloud.X, Cloud.Y) <= 8)
{
if (Game.MsgServer.AttackHandler.CheckAttack.CanAttackMonster.Verified(client, monster, spell))
{
Game.MsgServer.MsgSpellAnimation.SpellObj AnimationObj;
Game.MsgServer.AttackHandler.Calculate.Physical.OnMonster(client.Entity, monster, spell, out AnimationObj);
AnimationObj.Damage = AnimationObj.Damage * 5 / 50;
Experience += Game.MsgServer.AttackHandler.ReceiveAttack.Monster.Execute(stream, AnimationObj, client, monster);
MsgSpell.Targets.Enqueue(AnimationObj);
break;
}
}
}
if (obj.MapObjType == MapObjectType.Entity && client.Entity.UID != obj.UID)
{
var target = obj as Game.Entity;
if (Kernel.GetDistance(obj.X, obj.Y, Cloud.X, Cloud.Y) <= 8)
{
if (Game.MsgServer.AttackHandler.CheckAttack.CanAttackPlayer.Verified(client, target, spell))
{
Game.MsgServer.MsgSpellAnimation.SpellObj AnimationObj;
Game.MsgServer.AttackHandler.Calculate.Range.OnPlayer(client.Entity, target, spell, out AnimationObj);
AnimationObj.Damage = AnimationObj.Damage * 5 / 50;
Game.MsgServer.AttackHandler.ReceiveAttack.Player.Execute(stream, AnimationObj, client, target);
MsgSpell.Targets.Enqueue(AnimationObj);
break;
}
}
}
}
Game.MsgServer.AttackHandler.Updates.IncreaseExperience.Up(stream, client, Experience);
MsgSpell.SetStream(stream);
MsgSpell.Send(client);
}
}
}
}
}
#endregion
}
#endregion
public SafeDictionary<uint, Game.MsgServer.AttackHandler.ThunderCloud> Clouds = new SafeDictionary<uint, Game.MsgServer.AttackHandler.ThunderCloud>();
public void AddCloud(Game.MsgServer.AttackHandler.ThunderCloud entity)
{
if (!this.Clouds.ContainsKey(entity.UID))
this.Clouds.Add(entity.UID, entity);
}
private static void _timerCallBack(Map map, int time)
{
Time32 now = new Time32(time);
foreach (Entity monster in map.Entities.Values.ToList())
{
if (monster == null || monster.Name == "Thundercloud") continue;
if (monster.Dead)
{
if (now > monster.DeathStamp.AddSeconds(monster.MonsterInfo.RespawnTime))
{
monster.X = (ushort)(monster.MonsterInfo.BoundX + Kernel.Random.Next(0, monster.MonsterInfo.BoundCX));
monster.Y = (ushort)(monster.MonsterInfo.BoundY + Kernel.Random.Next(0, monster.MonsterInfo.BoundCY));
for (int count = 0; count < monster.MonsterInfo.BoundCX * monster.MonsterInfo.BoundCY; count++)
{
if (!map.Floor[monster.X, monster.Y, MapObjectType.Monster, null])
{
monster.X = (ushort)(monster.MonsterInfo.BoundX + Kernel.Random.Next(0, monster.MonsterInfo.BoundCX));
monster.Y = (ushort)(monster.MonsterInfo.BoundY + Kernel.Random.Next(0, monster.MonsterInfo.BoundCY));
}
else
break;
}
if (map.Floor[monster.X, monster.Y, MapObjectType.Monster] || monster.X == monster.MonsterInfo.BoundX && monster.Y == monster.MonsterInfo.BoundY)
{
monster.Hitpoints = monster.MaxHitpoints;
monster.RemoveFlag(MsgUpdate.Flags.Ghost);
monster.RemoveFlag(MsgUpdate.Flags.Dead);
monster.RemoveFlag(MsgUpdate.Flags.FadeAway);
foreach (var z in Program.Values)
{
if (z.Map.ID == monster.MapID && z.GetDistance(monster) <= Constants.pScreenDistance)
{
UpdateProto Proto = new UpdateProto();
Proto.Time = (uint)Time32.timeGetTime().GetHashCode();
Proto.UID = monster.UID;
Proto.update = new UpdateFlag[2];
Proto.update[0] = new UpdateFlag();
Proto.update[0].Type = (byte)MsgUpdate.DataType.MaxHitpoints;
Proto.update[0].value = monster.MaxHitpoints;
Proto.update[1] = new UpdateFlag();
Proto.update[1].Type = (byte)MsgUpdate.DataType.Hitpoints;
Proto.update[1].value = monster.Hitpoints;
z.SendScreen(MsgUpdate.SendPacket(Proto));
z.Send(z.Entity.PlayerProto(monster, 0));
monster.ClearFlags();
z.Screen.FullWipe();
z.Screen.Reload(null);
}
}
}
}
}
else
{
if (monster.ToxicFogLeft > 0)
{
if (monster.MonsterInfo.Boss)
{
monster.ToxicFogLeft = 0;
continue;
}
if (now > monster.ToxicFogStamp.AddSeconds(2))
{
monster.ToxicFogLeft--;
monster.ToxicFogStamp = now;
if (monster.Hitpoints > 1)
{
var suse = new SpellUse(true);
suse.Attacker = monster.UID;
suse.SpellID = 10010;
monster.MonsterInfo.SendScreen(suse);
}
}
}
}
}
}
ThundercloudAttack = 13190,
| الذين يشاهدون محتوى الموضوع الآن : 1 ( الأعضاء 0 والزوار 1) | |
|
| الموضوع | كاتب الموضوع | المنتدى | مشاركات | آخر مشاركة |
| حل مشكلة اسكلة [DaggerStorm] بتاعة الارشر | The.SniperR | تطوير سيرفرات كونكر | 2 | 2021-09-02 12:54 AM |
| حل مشكله الويند ولكر ال بيضرب في التون | MeGo | تطوير سيرفرات كونكر | 4 | 2020-05-13 04:23 PM |
| بخصوص اسكلة ال thunderrampage بتاعت الثاندر | nova | مشكلات السيرفيرات كونكر الشخصيه | 1 | 2019-12-06 01:34 PM |
| مشكلة بخصوص اسكلة الويند ولكر thundercloud | ابو مروان | مشكلات السيرفيرات كونكر الشخصيه | 21 | 2019-08-21 10:43 PM |
| مشكلة فى اسكلة بتاعت الننجا بعد ما نزلت شخصية تانية | osama | مشكلات السيرفيرات كونكر الشخصيه | 4 | 2019-08-08 09:13 PM |