예제 #1
0
        public static void HandleClearProjectile(int index, ref byte[] data)
        {
            int ProjectileNum;
            int Targetindex;

            Enums.TargetType TargetType;
            int        TargetZone;
            int        mapNum;
            int        Damage;
            int        armor;
            int        npcnum;
            ByteStream buffer = new ByteStream(data);

            ProjectileNum = buffer.ReadInt32();
            Targetindex   = buffer.ReadInt32();
            TargetType    = (Enums.TargetType)buffer.ReadInt32();
            TargetZone    = buffer.ReadInt32();
            buffer.Dispose();

            mapNum = S_Players.GetPlayerMap(index);

            switch (MapProjectiles[mapNum, ProjectileNum].OwnerType)
            {
            case (byte)Enums.TargetType.Player:
            {
                if (MapProjectiles[mapNum, ProjectileNum].Owner == index)
                {
                    switch (TargetType)
                    {
                    case Enums.TargetType.Player:
                    {
                        if (S_NetworkConfig.IsPlaying(Targetindex))
                        {
                            if (Targetindex != index)
                            {
                                if (S_Players.CanPlayerAttackPlayer(index, Targetindex, true) == true)
                                {
                                    // Get the damage we can do
                                    Damage = S_Players.GetPlayerDamage(index) + Projectiles[MapProjectiles[mapNum, ProjectileNum].ProjectileNum].Damage;

                                    // if the npc blocks, take away the block amount
                                    armor  = Convert.ToInt32(S_Players.CanPlayerBlockHit(Targetindex));
                                    Damage = Damage - armor;

                                    // randomise for up to 10% lower than max hit
                                    Damage = S_GameLogic.Random(1, Damage);

                                    if (Damage < 1)
                                    {
                                        Damage = 1;
                                    }

                                    S_Players.AttackPlayer(index, Targetindex, Damage);
                                }
                            }
                        }

                        break;
                    }

                    case Enums.TargetType.Npc:
                    {
                        npcnum = modTypes.MapNpc[mapNum].Npc[Targetindex].Num;
                        if (S_Players.CanPlayerAttackNpc(index, Targetindex, true) == true)
                        {
                            // Get the damage we can do
                            Damage = S_Players.GetPlayerDamage(index) + Projectiles[MapProjectiles[mapNum, ProjectileNum].ProjectileNum].Damage;

                            // if the npc blocks, take away the block amount
                            armor  = 0;
                            Damage = Damage - armor;

                            // randomise from 1 to max hit
                            Damage = S_GameLogic.Random(1, Damage);

                            if (Damage < 1)
                            {
                                Damage = 1;
                            }

                            S_Players.PlayerAttackNpc(index, Targetindex, Damage);
                        }

                        break;
                    }
                    }
                }

                break;
            }
            }

            ClearMapProjectile(mapNum, ProjectileNum);
        }