Example #1
0
 private void timerSearchProcess_Tick(object sender, EventArgs e)
 {
     if (processAttached)
     {
         if (CwRam.memory.process.HasExited)
         {
             //HotkeyManager.Deinit();
             if (editor != null && !editor.IsDisposed)
             {
                 editor.Dispose();
             }
             processAttached          = false;
             buttonEditor.Enabled     = false;
             checkBoxZoomHack.Enabled = false;
         }
         else
         {
             CwRam.RemoveFog();
             if (BridgeTCPUDP.status == Resources.BridgeStatus.Playing)
             {
                 CwRam.SetName(linkLabelUser.Text);
             }
         }
     }
     else
     {
         var processes = Process.GetProcessesByName("Cube");
         if (processes.Length == 0)
         {
             Text = "Exceed Bridge (detached)";
             return;
         }
         try {
             CwRam.memory = new ProcessMemory(processes[0]);
         }
         catch (System.ComponentModel.Win32Exception) {
             return; //process just started and isnt fully available yet, try again next iteration
         }
         Text = "Exceed Bridge (attached)";
         buttonEditor.Enabled     = true;
         checkBoxZoomHack.Enabled = true;
         processAttached          = true;
         //HotkeyManager.Init(this);
     }
 }
Example #2
0
 private void checkBoxZoomHack_CheckedChanged(object sender, EventArgs e)
 {
     CwRam.ZoomHack(checkBoxZoomHack.Checked);
 }
Example #3
0
        public static void OnHotkey(int hotkeyID)
        {
            HotkeyID hotkey = (HotkeyID)hotkeyID;

            if (hotkey == HotkeyID.teleport_to_town)
            {
                CwRam.SetMode(Mode.teleport_to_city, 0);
                return;
            }

            bool spec  = players[guid].specialization == 1;
            bool space = hotkeyID == 1;

            switch ((EntityClass)players[guid].entityClass)
            {
            case EntityClass.Rogue when spec:
                #region ninja
                if (hotkey == HotkeyID.ctrlSpace)
                {
                    #region dash
                    CwRam.SetMode(Mode.spin_run, 0);
                    #endregion
                    break;
                }
                #region blink
                if (players.ContainsKey(lastTarget))
                {
                    CwRam.Teleport(players[guid].position);
                }
                #endregion
                break;

                #endregion
            case EntityClass.Rogue:
                #region assassin
                if (hotkey == HotkeyID.ctrlSpace)
                {
                    #region confusion
                    var specialMove = new SpecialMove()
                    {
                        Guid = guid,
                        Id   = SpecialMoveID.confusion,
                    };
                    SendUDP(specialMove.data);
                    #endregion
                }
                else
                {
                    #region shadow step
                    var specialMove = new SpecialMove()
                    {
                        Guid = guid,
                        Id   = SpecialMoveID.shadowStep,
                    };
                    SendUDP(specialMove.data);
                    #endregion
                }
                break;

                #endregion
            case EntityClass.Warrior when spec:
                #region guardian
                if (hotkey == HotkeyID.ctrlSpace)
                {
                    #region taunt
                    var specialMove = new SpecialMove()
                    {
                        Guid = lastTarget,
                        Id   = SpecialMoveID.taunt,
                    };
                    SendUDP(specialMove.data);
                    #endregion
                }
                else
                {
                    #region steel wall
                    CwRam.SetMode(Mode.boss_skill_block, 0);
                    #endregion
                }
                break;

                #endregion
            case EntityClass.Warrior:
                #region berserk
                if (hotkey == HotkeyID.ctrlSpace)
                {
                    #region boulder toss
                    CwRam.SetMode(Mode.boulder_toss, 0);
                    #endregion
                }
                else
                {
                    #region earth shatter
                    CwRam.SetMode(Mode.earth_shatter, 0);
                    #endregion
                }
                break;

                #endregion
            case EntityClass.Mage when spec:
                #region watermage
                if (hotkey == HotkeyID.ctrlSpace)
                {
                    #region splash
                    CwRam.SetMode(Mode.splash, 0);
                    #endregion
                }
                else
                {
                    #region ice wave
                    //TODO
                    #endregion
                }
                break;

                #endregion
            case EntityClass.Mage:
                #region firemage
                if (hotkey == HotkeyID.ctrlSpace)
                {
                    #region lava
                    CwRam.SetMode(Mode.lava, 0);
                    #endregion
                }
                else
                {
                    #region beam
                    CwRam.SetMode(Mode.fireray, 0);
                    #endregion
                }
                break;

                #endregion
            case EntityClass.Ranger when spec:
                #region scout
                if (hotkey == HotkeyID.ctrlSpace)
                {
                    #region shrapnel
                    //TODO
                    #endregion
                }
                else
                {
                    #region smoke bomb
                    var specialMove = new SpecialMove()
                    {
                        Guid = guid,
                        Id   = SpecialMoveID.smokeBomb,
                    };
                    SendUDP(specialMove.data);

                    var fakeSmoke = new ServerUpdate();
                    fakeSmoke.particles.Add(new ServerUpdate.Particle()
                    {
                        count    = 1000,
                        spread   = 5f,
                        type     = ParticleType.noGravity,
                        size     = 0.3f,
                        velocity = new Resources.Utilities.FloatVector(),
                        color    = new Resources.Utilities.FloatVector()
                        {
                            x = 1f,
                            y = 1f,
                            z = 1f
                        },
                        alpha    = 1f,
                        position = players[specialMove.Guid].position
                    });
                    fakeSmoke.Write(cwriter);
                    #endregion
                }
                break;

                #endregion
            case EntityClass.Ranger:
                #region sniper
                if (hotkey == HotkeyID.ctrlSpace)
                {
                    #region cursed arrow
                    //TODO
                    #endregion
                }
                else
                {
                    #region arrow rain
                    //TODO
                    #endregion
                }
                break;

                #endregion
            default:
                break;
            }
            CwRam.memory.WriteInt(CwRam.EntityStart + 0x1164, 3);//mana cubes
        }
Example #4
0
        public static void ProcessDatagram(byte[] datagram)
        {
            var serverUpdate = new ServerUpdate();

            switch ((DatagramID)datagram[0])
            {
            case DatagramID.entityUpdate:
                #region entityUpdate
                var entityUpdate = new EntityUpdate(datagram);

                if (entityUpdate.guid == guid)
                {
                    CwRam.Teleport(entityUpdate.position);
                    break;
                }
                else
                {
                    entityUpdate.Write(cwriter);
                }

                if (players.ContainsKey(entityUpdate.guid))
                {
                    entityUpdate.Merge(players[entityUpdate.guid]);
                }
                else
                {
                    players.Add(entityUpdate.guid, entityUpdate);
                }

                if (entityUpdate.name != null)
                {
                    RefreshPlayerlist();
                }
                break;

                #endregion
            case DatagramID.attack:
                #region attack
                var attack = new Attack(datagram);

                var hit = new Hit()
                {
                    target    = attack.Target,
                    damage    = attack.Damage,
                    critical  = attack.Critical ? 1 : 0,
                    stuntime  = attack.Stuntime,
                    position  = players[attack.Target].position,
                    isYellow  = attack.Skill,
                    type      = attack.Type,
                    showlight = (byte)(attack.ShowLight ? 1 : 0)
                };
                serverUpdate.hits.Add(hit);
                serverUpdate.Write(cwriter);
                break;

                #endregion
            case DatagramID.shoot:
                #region shoot
                var shootDatagram = new Resources.Datagram.Shoot(datagram);

                var shootPacket = new Resources.Packet.Shoot()
                {
                    position   = shootDatagram.Position,
                    velocity   = shootDatagram.Velocity,
                    scale      = shootDatagram.Scale,
                    particles  = shootDatagram.Particles,
                    projectile = shootDatagram.Projectile,
                    chunkX     = (int)shootDatagram.Position.x / 0x1000000,
                    chunkY     = (int)shootDatagram.Position.y / 0x1000000
                };
                serverUpdate.shoots.Add(shootPacket);
                serverUpdate.Write(cwriter);
                break;

                #endregion
            case DatagramID.proc:
                #region proc
                var proc = new Proc(datagram);

                var passiveProc = new PassiveProc()
                {
                    target   = proc.Target,
                    type     = proc.Type,
                    modifier = proc.Modifier,
                    duration = proc.Duration
                };
                serverUpdate.passiveProcs.Add(passiveProc);
                serverUpdate.Write(cwriter);
                break;

                #endregion
            case DatagramID.chat:
                #region chat
                var chat        = new Chat(datagram);
                var chatMessage = new ChatMessage()
                {
                    sender  = chat.Sender,
                    message = chat.Text
                };
                try {
                    chatMessage.Write(cwriter, true);
                }
                catch (Exception ex) {
                    if (!(ex is NullReferenceException || ex is ObjectDisposedException))
                    {
                        throw;
                    }
                }
                if (chat.Sender == 0)
                {
                    form.Log(chat.Text + "\n", Color.Magenta);
                }
                else
                {
                    form.Log(players[chat.Sender].name + ": ", Color.Cyan);
                    form.Log(chat.Text + "\n", Color.White);
                }
                break;

                #endregion
            case DatagramID.time:
                #region time
                var igt = new InGameTime(datagram);

                var time = new Time()
                {
                    time = igt.Time
                };
                time.Write(cwriter);
                break;

                #endregion
            case DatagramID.interaction:
                #region interaction
                var interaction = new Interaction(datagram);

                var entityAction = new EntityAction()
                {
                    chunkX = interaction.ChunkX,
                    chunkY = interaction.ChunkY,
                    index  = interaction.Index,
                    type   = ActionType.staticInteraction
                };
                //serverUpdate..Add();
                //serverUpdate.Write(cwriter);
                break;

                #endregion
            case DatagramID.staticUpdate:
                #region staticUpdate
                var staticUpdate = new StaticUpdate(datagram);

                var staticEntity = new ServerUpdate.StaticEntity()
                {
                    chunkX   = (int)(staticUpdate.Position.x / (65536 * 256)),
                    chunkY   = (int)(staticUpdate.Position.y / (65536 * 256)),
                    id       = staticUpdate.Id,
                    type     = (int)staticUpdate.Type,
                    position = staticUpdate.Position,
                    rotation = (int)staticUpdate.Direction,
                    size     = staticUpdate.Size,
                    closed   = staticUpdate.Closed ? 1 : 0,
                    time     = staticUpdate.Time,
                    guid     = staticUpdate.User
                };
                var staticServerUpdate = new ServerUpdate();
                staticServerUpdate.statics.Add(staticEntity);
                staticServerUpdate.Write(cwriter, true);
                break;

                #endregion
            case DatagramID.block:
                //var block = new Block(datagram);
                //TODO
                break;

            case DatagramID.particle:
                #region particle
                var particleDatagram = new Resources.Datagram.Particle(datagram);

                var particleSubPacket = new ServerUpdate.Particle()
                {
                    position = particleDatagram.Position,
                    velocity = particleDatagram.Velocity,
                    color    = new Resources.Utilities.FloatVector()
                    {
                        x = particleDatagram.Color.R / 255,
                        y = particleDatagram.Color.G / 255,
                        z = particleDatagram.Color.B / 255
                    },
                    alpha  = particleDatagram.Color.A / 255,
                    size   = particleDatagram.Size,
                    count  = particleDatagram.Count,
                    type   = particleDatagram.Type,
                    spread = particleDatagram.Spread
                };
                serverUpdate.particles.Add(particleSubPacket);
                serverUpdate.Write(cwriter, true);
                break;

                #endregion
            case DatagramID.connect:
                #region connect
                var connect = new Connect(datagram);
                guid = connect.Guid;

                var join = new Join()
                {
                    guid = guid,
                    junk = new byte[0x1168]
                };
                join.Write(cwriter, true);

                var mapseed = new MapSeed()
                {
                    seed = connect.Mapseed
                };
                mapseed.Write(cwriter, true);
                break;

                #endregion
            case DatagramID.disconnect:
                #region disconnect
                var disconnect = new Disconnect(datagram);
                var pdc        = new EntityUpdate()
                {
                    guid      = disconnect.Guid,
                    hostility = 255,     //workaround for DC because i dont like packet2
                    HP        = 0
                };
                pdc.Write(cwriter);
                players.Remove(disconnect.Guid);
                RefreshPlayerlist();
                break;

                #endregion
            case DatagramID.specialMove:
                var specialMove = new SpecialMove(datagram);
                switch (specialMove.Id)
                {
                case SpecialMoveID.taunt:
                    if (players.ContainsKey(specialMove.Guid))
                    {
                        CwRam.Teleport(players[specialMove.Guid].position);
                        CwRam.Freeze(5000);
                    }
                    break;

                case SpecialMoveID.cursedArrow:
                    break;

                case SpecialMoveID.arrowRain:
                    break;

                case SpecialMoveID.shrapnel:
                    break;

                case SpecialMoveID.smokeBomb:
                    var smoke = new ServerUpdate();
                    smoke.particles.Add(new ServerUpdate.Particle()
                    {
                        count    = 1000,
                        spread   = 5f,
                        type     = ParticleType.noGravity,
                        size     = 5f,
                        velocity = new Resources.Utilities.FloatVector(),
                        color    = new Resources.Utilities.FloatVector()
                        {
                            x = 1f,
                            y = 1f,
                            z = 1f
                        },
                        alpha    = 1f,
                        position = players[specialMove.Guid].position
                    });
                    smoke.Write(cwriter);
                    break;

                case SpecialMoveID.iceWave:
                    break;

                case SpecialMoveID.confusion:
                    break;

                case SpecialMoveID.shadowStep:
                    break;

                default:
                    break;
                }
                break;

            default:
                break;
            }
        }
Example #5
0
        private static void ProcessClientPacket(int packetID)
        {
            switch ((PacketID)packetID)
            {
            case PacketID.EntityUpdate:
                #region entityUpdate
                var entityUpdate = new EntityUpdate(creader);
                if (dynamicEntities.ContainsKey(entityUpdate.guid))
                {
                    entityUpdate.Filter(dynamicEntities[entityUpdate.guid]);
                    entityUpdate.Merge(dynamicEntities[entityUpdate.guid]);
                }
                else
                {
                    dynamicEntities.Add(entityUpdate.guid, entityUpdate);
                }
                if (entityUpdate.name != null)
                {
                    RefreshPlayerlist();
                }
                if (!entityUpdate.IsEmpty)
                {
                    SendUDP(entityUpdate.CreateDatagram());
                }
                break;

                #endregion
            case PacketID.EntityAction:
                #region entity action
                EntityAction entityAction = new EntityAction(creader);
                switch (entityAction.type)
                {
                case ActionType.Talk:
                    #region Talk
                    break;

                    #endregion
                case ActionType.StaticInteraction:
                    #region StaticInteraction
                    ChatMessage x = new ChatMessage()
                    {
                        message = "You can't use this, your hands are too small.",
                        sender  = 0
                    };
                    SendToClient(x);
                    break;

                    #endregion
                case ActionType.PickUp:
                    #region PickUp
                    break;

                    #endregion
                case ActionType.Drop:         //send item back to dropper because dropping is disabled to prevent chatspam
                    #region Drop
                    if (form.radioButtonDestroy.Checked)
                    {
                        SendToClient(new ChatMessage()
                        {
                            message = "item destroyed",
                            sender  = 0,
                        });
                    }
                    else
                    {
                        var serverUpdate = new ServerUpdate();
                        var pickup       = new ServerUpdate.Pickup()
                        {
                            guid = guid,
                            item = entityAction.item
                        };
                        serverUpdate.pickups.Add(pickup);
                        if (form.radioButtonDuplicate.Checked)
                        {
                            serverUpdate.pickups.Add(pickup);
                        }
                        SendToClient(serverUpdate);
                    }
                    break;

                    #endregion
                case ActionType.CallPet:
                    #region CallPet
                    break;

                    #endregion
                default:
                    //unknown type
                    break;
                }
                break;

                #endregion
            case PacketID.Hit:
                #region hit
                var hit    = new Hit(creader);
                var attack = new Attack()
                {
                    Target    = (ushort)hit.target,
                    Damage    = hit.damage,
                    Direction = hit.direction,
                    Stuntime  = hit.stuntime,
                    Skill     = hit.isYellow,
                    Type      = hit.type,
                    ShowLight = hit.showlight,
                    Critical  = hit.critical
                };
                SendUDP(attack.data);
                lastTarget = attack.Target;
                break;

                #endregion
            case PacketID.PassiveProc:
                #region passiveProc
                var passiveProc = new PassiveProc(creader);
                switch (passiveProc.type)
                {
                case ProcType.Bulwalk:
                    SendToClient(new ChatMessage()
                    {
                        message = string.Format("bulwalk: {0}% dmg reduction", 1.0f - passiveProc.modifier),
                        sender  = 0,
                    });
                    break;

                case ProcType.WarFrenzy:
                    break;

                case ProcType.Camouflage:
                    break;

                case ProcType.Poison:
                    break;

                case ProcType.UnknownA:
                    break;

                case ProcType.ManaShield:
                    SendToClient(new ChatMessage()
                    {
                        message = string.Format("manashield: {0}", passiveProc.modifier),
                        sender  = 0,
                    });
                    break;

                case ProcType.UnknownB:
                    break;

                case ProcType.UnknownC:
                    break;

                case ProcType.FireSpark:
                    break;

                case ProcType.Intuition:
                    break;

                case ProcType.Elusiveness:
                    break;

                case ProcType.Swiftness:
                    break;

                default:
                    break;
                }
                var proc = new Proc()
                {
                    Target   = (ushort)passiveProc.target,
                    Type     = passiveProc.type,
                    Modifier = passiveProc.modifier,
                    Duration = passiveProc.duration
                };
                SendUDP(proc.data);
                break;

                #endregion
            case PacketID.Shoot:
                #region shoot
                var shoot      = new Shoot(creader);
                var projectile = new Projectile()
                {
                    Position  = shoot.position,
                    Velocity  = shoot.velocity,
                    Scale     = shoot.scale,
                    Particles = shoot.particles,
                    Type      = shoot.projectile,
                    Source    = (ushort)shoot.attacker,
                };
                SendUDP(projectile.data);
                break;

                #endregion
            case PacketID.Chat:
                #region chat
                var chatMessage = new ChatMessage(creader);
                if (chatMessage.message.ToLower() == @"/plane")
                {
                    Console.Beep();
                    var serverUpdate = new ServerUpdate()
                    {
                        blockDeltas = new Vox("model.vox").Parse(),
                    };
                    foreach (var block in serverUpdate.blockDeltas)
                    {
                        block.position.x += 0x802080; //(int)(dynamicEntities[guid].position.x / 0x10000);//8286946;
                        block.position.y += 0x802080; //(int)(dynamicEntities[guid].position.y / 0x10000);//8344456;
                        block.position.z += 150;      // (int)(dynamicEntities[guid].position.z / 0x10000);//220;
                    }
                    SendToClient(serverUpdate);
                }
                if (chatMessage.message.ToLower() == @"/spawn")
                {
                    CwRam.Teleport(new LongVector()
                    {
                        x = 0x8020800000,
                        y = 0x8020800000,
                        z = 0,
                    });
                    break;
                }
                var chat = new Chat()
                {
                    Sender = guid,    //client doesn't send this
                    Text   = chatMessage.message
                };
                SendUDP(chat.data);
                break;

                #endregion
            case PacketID.Chunk:
                #region chunk
                var chunk = new Chunk(creader);
                break;

                #endregion
            case PacketID.Sector:
                #region sector
                var sector = new Sector(creader);
                break;

                #endregion
            case PacketID.Version:
                #region version
                var version = new ProtocolVersion(creader);
                if (version.version != 3)
                {
                    version.version = 3;
                    SendToClient(version);
                }
                else
                {
                    SendToClient(new Join()
                    {
                        guid = guid,
                        junk = new byte[0x1168]
                    });
                    SendToClient(new MapSeed()
                    {
                        seed = mapseed
                    });
                    foreach (var dynamicEntity in dynamicEntities.Values.ToList())
                    {
                        SendToClient(dynamicEntity);
                    }
                }
                break;

                #endregion
            default:
                form.Log("unknown client packet\n", Color.Magenta);
                break;
            }
        }
Example #6
0
        private static void ProcessDatagram(byte[] datagram)
        {
            var  serverUpdate      = new ServerUpdate();
            bool writeServerUpdate = false;

            switch ((DatagramID)datagram[0])
            {
            case DatagramID.DynamicUpdate:
                #region entityUpdate
                var entityUpdate = new EntityUpdate(datagram);
                if (status == BridgeStatus.Playing)
                {
                    if (entityUpdate.guid == guid)
                    {
                        CwRam.Teleport(entityUpdate.position);
                        break;
                    }
                    SendToClient(entityUpdate);
                }

                if (dynamicEntities.ContainsKey(entityUpdate.guid))
                {
                    entityUpdate.Merge(dynamicEntities[entityUpdate.guid]);
                }
                else
                {
                    dynamicEntities.Add(entityUpdate.guid, entityUpdate);
                }

                if (entityUpdate.name != null)
                {
                    RefreshPlayerlist();
                }
                break;

                #endregion
            case DatagramID.Attack:
                #region attack
                var attack = new Attack(datagram);
                CwRam.Knockback(attack.Direction);
                var hit = new Hit()
                {
                    target    = attack.Target,
                    damage    = attack.Damage,
                    direction = attack.Direction,
                    critical  = attack.Critical,
                    stuntime  = attack.Stuntime,
                    position  = dynamicEntities[attack.Target].position,
                    isYellow  = attack.Skill,
                    type      = attack.Type,
                    showlight = attack.ShowLight,
                };
                serverUpdate.hits.Add(hit);
                writeServerUpdate = true;
                break;

                #endregion
            case DatagramID.Projectile:
                #region Projectile
                var projectile = new Projectile(datagram);

                var shoot = new Shoot()
                {
                    attacker   = projectile.Source,
                    position   = projectile.Position,
                    velocity   = projectile.Velocity,
                    scale      = projectile.Scale,
                    particles  = projectile.Particles,
                    mana       = projectile.Particles,
                    projectile = projectile.Type,
                    chunkX     = (int)projectile.Position.x / 0x1000000,
                    chunkY     = (int)projectile.Position.y / 0x1000000
                };
                var angle = Math.Atan2(shoot.velocity.y, shoot.velocity.x);
                shoot.position.x += (long)(Math.Cos(angle) * 0x10000);
                shoot.position.y += (long)(Math.Sin(angle) * 0x10000);

                serverUpdate.shoots.Add(shoot);
                writeServerUpdate = true;
                break;

                #endregion
            case DatagramID.Proc:
                #region proc
                var proc = new Proc(datagram);
                if (proc.Type == ProcType.Poison && proc.Target == guid)
                {
                    var su = new ServerUpdate();
                    su.hits.Add(new Hit()
                    {
                        damage   = proc.Modifier,
                        target   = guid,
                        position = dynamicEntities[guid].position,
                    });
                    bool tick()
                    {
                        bool f = status == BridgeStatus.Playing && dynamicEntities[guid].HP > 0;

                        if (f)
                        {
                            SendToClient(su);
                        }
                        return(!f);
                    }

                    Tools.DoLater(tick, 500, 7);
                }
                var passiveProc = new PassiveProc()
                {
                    target   = proc.Target,
                    type     = proc.Type,
                    modifier = proc.Modifier,
                    duration = proc.Duration
                };
                serverUpdate.passiveProcs.Add(passiveProc);
                writeServerUpdate = true;
                break;

                #endregion
            case DatagramID.Chat:
                #region chat
                var chat        = new Chat(datagram);
                var chatMessage = new ChatMessage()
                {
                    sender  = chat.Sender,
                    message = chat.Text
                };
                if (status == BridgeStatus.Playing)
                {
                    SendToClient(chatMessage);
                }
                if (chat.Sender == 0)
                {
                    form.Log(chat.Text + "\n", Color.Magenta);
                }
                else
                {
                    form.Log(dynamicEntities[chat.Sender].name + ": ", Color.Cyan);
                    form.Log(chat.Text + "\n", Color.White);
                }
                break;

                #endregion
            case DatagramID.Time:
                #region time
                var igt = new InGameTime(datagram);

                var time = new Time()
                {
                    time = igt.Milliseconds
                };
                if (status == BridgeStatus.Playing)
                {
                    SendToClient(time);
                }
                break;

                #endregion
            case DatagramID.Interaction:
                #region interaction
                var interaction  = new Interaction(datagram);
                var entityAction = new EntityAction()
                {
                    chunkX = interaction.ChunkX,
                    chunkY = interaction.ChunkY,
                    index  = interaction.Index,
                    type   = ActionType.StaticInteraction
                };
                writeServerUpdate = true;
                break;

                #endregion
            case DatagramID.StaticUpdate:
                #region staticUpdate
                var staticUpdate = new StaticUpdate(datagram);

                var staticEntity = new ServerUpdate.StaticEntity()
                {
                    chunkX   = (int)(staticUpdate.Position.x / (65536 * 256)),
                    chunkY   = (int)(staticUpdate.Position.y / (65536 * 256)),
                    id       = staticUpdate.Id,
                    type     = staticUpdate.Type,
                    position = staticUpdate.Position,
                    rotation = (int)staticUpdate.Direction,
                    size     = staticUpdate.Size,
                    closed   = staticUpdate.Closed,
                    time     = staticUpdate.Time,
                    guid     = staticUpdate.User
                };
                serverUpdate.statics.Add(staticEntity);
                writeServerUpdate = true;
                break;

                #endregion
            case DatagramID.Block:
                //var block = new Block(datagram);
                //TODO
                break;

            case DatagramID.Particle:
                #region particle
                var particleDatagram = new Particle(datagram);

                var particleSubPacket = new ServerUpdate.Particle()
                {
                    position = particleDatagram.Position,
                    velocity = particleDatagram.Velocity,
                    color    = new Resources.Utilities.FloatVector()
                    {
                        x = particleDatagram.Color.R / 255,
                        y = particleDatagram.Color.G / 255,
                        z = particleDatagram.Color.B / 255
                    },
                    alpha  = particleDatagram.Color.A / 255,
                    size   = particleDatagram.Size,
                    count  = particleDatagram.Count,
                    type   = particleDatagram.Type,
                    spread = particleDatagram.Spread
                };
                serverUpdate.particles.Add(particleSubPacket);
                break;

                #endregion
            case DatagramID.RemoveDynamicEntity:
                #region RemoveDynamicEntity
                var rde = new RemoveDynamicEntity(datagram);
                entityUpdate = new EntityUpdate()
                {
                    guid      = rde.Guid,
                    hostility = (Hostility)255,     //workaround for DC because i dont like packet2
                    HP        = 0
                };
                if (status == BridgeStatus.Playing)
                {
                    SendToClient(entityUpdate);
                }
                dynamicEntities.Remove(rde.Guid);
                RefreshPlayerlist();
                break;

                #endregion
            case DatagramID.SpecialMove:
                #region speicalMove
                var specialMove = new SpecialMove(datagram);
                switch (specialMove.Id)
                {
                case SpecialMoveID.Taunt:
                    if (dynamicEntities.ContainsKey(specialMove.Guid))
                    {
                        if (status == BridgeStatus.Playing)
                        {
                            CwRam.Teleport(dynamicEntities[specialMove.Guid].position);
                            CwRam.Freeze(5000);
                        }
                    }
                    break;

                case SpecialMoveID.CursedArrow:
                    break;

                case SpecialMoveID.ArrowRain:
                    break;

                case SpecialMoveID.Shrapnel:
                    var su        = new ServerUpdate();
                    var blood_hit = new Hit()
                    {
                        damage = 5f,
                        target = specialMove.Guid,
                    };
                    su.hits.Add(blood_hit);
                    var blood_particles = new ServerUpdate.Particle()
                    {
                        count    = 10,
                        spread   = 2f,
                        type     = ParticleType.Normal,
                        size     = 0.1f,
                        velocity = new FloatVector()
                        {
                            z = 1f,
                        },
                        color = new FloatVector()
                        {
                            x = 1f,
                            y = 0f,
                            z = 0f
                        },
                        alpha = 1f,
                    };
                    su.particles.Add(blood_particles);
                    bool tick()
                    {
                        bool f = status == BridgeStatus.Playing && dynamicEntities[specialMove.Guid].HP > 0;

                        if (f)
                        {
                            blood_hit.position = blood_particles.position = dynamicEntities[specialMove.Guid].position;
                            SendToClient(su);
                        }
                        return(!f);
                    }

                    Tools.DoLater(tick, 50, 100);
                    break;

                case SpecialMoveID.SmokeBomb:
                    serverUpdate.particles.Add(new ServerUpdate.Particle()
                    {
                        count    = 1000,
                        spread   = 5f,
                        type     = ParticleType.NoGravity,
                        size     = 5f,
                        velocity = new Resources.Utilities.FloatVector(),
                        color    = new Resources.Utilities.FloatVector()
                        {
                            x = 1f,
                            y = 1f,
                            z = 1f
                        },
                        alpha    = 1f,
                        position = dynamicEntities[specialMove.Guid].position
                    });
                    writeServerUpdate = true;
                    break;

                case SpecialMoveID.IceWave:
                    if (specialMove.Guid != guid)          //distance small enough
                    {
                        CwRam.Freeze(3000);
                    }
                    serverUpdate.particles.Add(new ServerUpdate.Particle()
                    {
                        count    = 100,
                        spread   = 4f,
                        type     = ParticleType.NoGravity,
                        size     = 0.3f,
                        velocity = new FloatVector(),
                        color    = new FloatVector()
                        {
                            x = 0f,
                            y = 1f,
                            z = 1f
                        },
                        alpha    = 1f,
                        position = dynamicEntities[specialMove.Guid].position
                    });
                    serverUpdate.particles.Add(new ServerUpdate.Particle()
                    {
                        count    = 100,
                        spread   = 10f,
                        type     = ParticleType.NoGravity,
                        size     = 0.1f,
                        velocity = new FloatVector(),
                        color    = new FloatVector()
                        {
                            x = 1f,
                            y = 1f,
                            z = 1f
                        },
                        alpha    = 1f,
                        position = dynamicEntities[specialMove.Guid].position
                    });
                    serverUpdate.particles.Add(new ServerUpdate.Particle()
                    {
                        count    = 100,
                        spread   = 2f,
                        type     = ParticleType.NoGravity,
                        size     = 0.7f,
                        velocity = new FloatVector(),
                        color    = new FloatVector()
                        {
                            x = 0f,
                            y = 0f,
                            z = 1f
                        },
                        alpha    = 1f,
                        position = dynamicEntities[specialMove.Guid].position
                    });
                    writeServerUpdate = true;
                    break;

                case SpecialMoveID.Confusion:
                    break;

                case SpecialMoveID.ShadowStep:
                    break;

                default:
                    break;
                }
                break;

                #endregion
            default:
                form.Log("unknown datagram ID: " + datagram[0], Color.Red);
                break;
            }
            if (status == BridgeStatus.Playing && writeServerUpdate)
            {
                SendToClient(serverUpdate);
            }
        }
Example #7
0
        public static void OnHotkey(HotkeyID hotkey)
        {
            if (CwRam.AnyInterfaceOpen)
            {
                return;
            }
            if (hotkey == HotkeyID.TeleportToTown)
            {
                CwRam.SetMode(Mode.Teleport_To_City, 0);
                return;
            }
            var notification = new ChatMessage()
            {
                sender = 0,
            };
            bool spec = dynamicEntities[guid].specialization == 1;

            switch (dynamicEntities[guid].entityClass)
            {
            case EntityClass.Rogue when spec:
                #region ninja
                if (hotkey == HotkeyID.CtrlSpace)
                {
                    #region dash
                    notification.message = "using [dash]";
                    CwRam.SetMode(Mode.Spin_Run, 0);
                    #endregion
                }
                else
                {
                    #region blink
                    notification.message = "using [blink]";
                    if (dynamicEntities.ContainsKey(lastTarget))
                    {
                        CwRam.Teleport(dynamicEntities[lastTarget].position);
                    }
                    #endregion
                }
                break;

                #endregion
            case EntityClass.Rogue:
                #region assassin
                if (hotkey == HotkeyID.CtrlSpace)
                {
                    #region confusion
                    notification.message = "TODO: [confusion]";
                    var specialMove = new SpecialMove()
                    {
                        Guid = guid,
                        Id   = SpecialMoveID.Confusion,
                    };
                    SendUDP(specialMove.data);
                    #endregion
                }
                else
                {
                    #region shadow step
                    notification.message = "TOD: [shadow step]";
                    var specialMove = new SpecialMove()
                    {
                        Guid = guid,
                        Id   = SpecialMoveID.ShadowStep,
                    };
                    SendUDP(specialMove.data);
                    #endregion
                }
                break;

                #endregion
            case EntityClass.Warrior when spec:
                #region guardian
                if (hotkey == HotkeyID.CtrlSpace)
                {
                    #region taunt
                    notification.message = "using [taunt]";
                    var specialMove = new SpecialMove()
                    {
                        Guid = lastTarget,
                        Id   = SpecialMoveID.Taunt,
                    };
                    SendUDP(specialMove.data);
                    #endregion
                }
                else
                {
                    #region steel wall
                    notification.message = "using [steel wall]";
                    CwRam.SetMode(Mode.Boss_Skill_Block, 0);
                    #endregion
                }
                break;

                #endregion
            case EntityClass.Warrior:
                #region berserk
                if (hotkey == HotkeyID.CtrlSpace)
                {
                    #region boulder toss
                    notification.message = "using [boulder toss]";
                    CwRam.SetMode(Mode.Boulder_Toss, 0);
                    #endregion
                }
                else
                {
                    #region earth shatter
                    notification.message = "using [earth shatter]";
                    CwRam.SetMode(Mode.Earth_Shatter, 0);
                    #endregion
                }
                break;

                #endregion
            case EntityClass.Mage when spec:
                #region watermage
                if (hotkey == HotkeyID.CtrlSpace)
                {
                    #region splash
                    notification.message = "using [splash]";
                    CwRam.SetMode(Mode.Splash, 0);
                    #endregion
                }
                else
                {
                    #region ice wave
                    notification.message = "using [ice wave]";
                    var specialMove = new SpecialMove()
                    {
                        Guid = guid,
                        Id   = SpecialMoveID.IceWave,
                    };
                    SendUDP(specialMove.data);
                    #endregion
                }
                break;

                #endregion
            case EntityClass.Mage:
                #region firemage
                if (hotkey == HotkeyID.CtrlSpace)
                {
                    #region lava
                    notification.message = "using [lava]";
                    CwRam.SetMode(Mode.Lava, 0);
                    #endregion
                }
                else
                {
                    #region beam
                    notification.message = "using [fire ray]";
                    CwRam.SetMode(Mode.FireRay, 0);
                    #endregion
                }
                break;

                #endregion
            case EntityClass.Ranger when spec:
                #region scout
                if (hotkey == HotkeyID.CtrlSpace)
                {
                    #region shrapnel
                    notification.message = "using [shrapnel] bleeding test";
                    var specialMove = new SpecialMove()
                    {
                        Guid = guid,
                        Id   = SpecialMoveID.Shrapnel,
                    };
                    SendUDP(specialMove.data);
                    #endregion
                }
                else
                {
                    #region smoke bomb
                    notification.message = "using [smoke bomb]";
                    var specialMove = new SpecialMove()
                    {
                        Guid = guid,
                        Id   = SpecialMoveID.SmokeBomb,
                    };
                    SendUDP(specialMove.data);

                    var fakeSmoke = new ServerUpdate();
                    fakeSmoke.particles.Add(new ServerUpdate.Particle()
                    {
                        count    = 1000,
                        spread   = 5f,
                        type     = ParticleType.NoGravity,
                        size     = 0.3f,
                        velocity = new Resources.Utilities.FloatVector(),
                        color    = new Resources.Utilities.FloatVector()
                        {
                            x = 1f,
                            y = 1f,
                            z = 1f
                        },
                        alpha    = 1f,
                        position = dynamicEntities[specialMove.Guid].position
                    });
                    SendToClient(fakeSmoke);
                    #endregion
                }
                break;

                #endregion
            case EntityClass.Ranger:
                #region sniper
                if (hotkey == HotkeyID.CtrlSpace)
                {
                    #region cursed arrow
                    //TODO
                    notification.message = "TODO: [cursed arrow]";
                    #endregion
                }
                else
                {
                    #region arrow rain
                    //TODO
                    notification.message = "TODO: [arrow rain]";
                    //const int rainSize = 7;
                    //for (int x = 0; x < rainSize; x++) {
                    //    for (int y = 0; y < rainSize; y++) {
                    //        var projectile = new Projectile() {
                    //            Scale = 1f,
                    //            Type = ProjectileType.Arrow,
                    //            Source = guid,
                    //            Velocity = new FloatVector() { x = 0, y = 0, z = -1f },
                    //            Position = new LongVector() {
                    //                x = 0x8020800000,//dynamicEntities[guid].position.x + (long)((dynamicEntities[guid].rayHit.x + x - rainSize / 2) * 0x10000),
                    //                y = 0x8020800000,//dynamicEntities[guid].position.y + (long)((dynamicEntities[guid].rayHit.y + y - rainSize / 2) * 0x10000),
                    //                z = 0x01000000,//dynamicEntities[guid].position.z + (long)((dynamicEntities[guid].rayHit.z + 10) * 0x10000),
                    //            }
                    //        };
                    //        SendUDP(projectile.data);
                    //        ProcessDatagram(projectile.data);
                    //    }
                    //}
                    #endregion
                }
                break;
                #endregion
            }
            CwRam.memory.WriteInt(CwRam.EntityStart + 0x1164, 3);//mana cubes
            SendToClient(notification);
        }