コード例 #1
0
        internal static void PlayerFireProjectile(int index, int IsSkill = 0)
        {
            int ProjectileSlot = 0;
            int ProjectileNum  = 0;
            int mapNum         = 0;
            int i = 0;

            mapNum = S_Players.GetPlayerMap(index);

            // Find a free projectile
            for (i = 1; i <= MAX_PROJECTILES; i++)
            {
                if (MapProjectiles[mapNum, i].ProjectileNum == 0)
                {
                    ProjectileSlot = i;
                    break;
                }
            }

            // Check for no projectile, if so just overwrite the first slot
            if (ProjectileSlot == 0)
            {
                ProjectileSlot = 1;
            }

            // Check for skill, if so then load data acordingly
            if (IsSkill > 0)
            {
                ProjectileNum = Types.Skill[IsSkill].Projectile;
            }
            else
            {
                ProjectileNum = Types.Item[S_Players.GetPlayerEquipment(index, Enums.EquipmentType.Weapon)].Projectile;
            }

            if (ProjectileNum == 0)
            {
                return;
            }

            {
                MapProjectiles[mapNum, ProjectileSlot].ProjectileNum = ProjectileNum;
                MapProjectiles[mapNum, ProjectileSlot].Owner         = index;
                MapProjectiles[mapNum, ProjectileSlot].OwnerType     = (byte)Enums.TargetType.Player;
                MapProjectiles[mapNum, ProjectileSlot].Dir           = (byte)S_Players.GetPlayerDir(index);
                MapProjectiles[mapNum, ProjectileSlot].X             = S_Players.GetPlayerX(index);
                MapProjectiles[mapNum, ProjectileSlot].Y             = S_Players.GetPlayerY(index);
                MapProjectiles[mapNum, ProjectileSlot].Timer         = S_General.GetTimeMs() + 60000;
            }

            SendProjectileToMap(mapNum, ProjectileSlot);
        }