Untitled

 avatar
unknown
plain_text
5 months ago
2.0 kB
2
Indexable
-- Phantom Reaver Gun Script

-- Initialize attributes
local PhantomReaver = {
    name = "Phantom Reaver",
    damage = 45,
    rateOfFire = 4, -- shots per second
    magazineSize = 30,
    reloadTime = 2, -- seconds
    range = 500, -- in meters
    specialAbility = "Spectral Burst",
    currentAmmo = 30,
    isReloading = false,
}

-- Function to shoot
function PhantomReaver:shoot(target)
    if self.isReloading then
        print("Reloading... Please wait.")
        return
    end

    if self.currentAmmo > 0 then
        print("Firing at " .. target .. "!")
        -- Calculate damage and effects
        self:dealDamage(target)
        self.currentAmmo = self.currentAmmo - 1
        print("Ammo left: " .. self.currentAmmo)

        -- Check if magazine is empty
        if self.currentAmmo == 0 then
            self:reload()
        end
    else
        print("Out of ammo! Reload required.")
    end
end

-- Function to deal damage
function PhantomReaver:dealDamage(target)
    print("Dealing " .. self.damage .. " damage to " .. target .. ".")
    -- Add additional effects like hit markers or sound effects here
end

-- Function to reload
function PhantomReaver:reload()
    print("Reloading... (Time: " .. self.reloadTime .. " seconds)")
    self.isReloading = true
    wait(self.reloadTime) -- Simulating reload time
    self.currentAmmo = self.magazineSize
    self.isReloading = false
    print("Reload complete! Ammo refilled to " .. self.currentAmmo)
end

-- Function to activate special ability
function PhantomReaver:activateSpecialAbility(target)
    if self.currentAmmo >= 5 then
        print("Activating " .. self.specialAbility .. " on " .. target .. "!")
        -- Special ability effects here
        self.currentAmmo = self.currentAmmo - 5
        print("Special ability activated! Ammo left: " .. self.currentAmmo)
    else
        print("Not enough ammo for special ability.")
    end
end

-- Example usage
PhantomReaver:shoot("Enemy Soldier")
PhantomReaver:activateSpecialAbility("Boss Enemy")
Editor is loading...
Leave a Comment