Jump to content

Recommended Posts

Posted

I explain, the component makes the caculum of causing damage, and affects the value of a progress bar that represents the life, however if the player is inside the activator radiation zone, when returning to the main menu, which is another world different from the level, continues to remove the player's life.
 

ZoneVolume = {}
ZoneVolume.name = "ZoneVolume"
 
local ZONE_TYPES = {
    "ZoneRadiation",
    "ZoneGas",
    "ZoneOxygen",
    "ZoneMental",
    "ZoneDeath"
}
 
function ZoneVolume:Load()
 
    self.world = self.entity:GetWorld()
    -- Propiedades del editor
    self.zoneType = self.zoneType or 0
    self.damagePerSecond = self.damagePerSecond or 10
    self.damageInterval = self.damageInterval or 1000
 
    self.zoneName = ZONE_TYPES[self.zoneType + 1] or "ZoneRadiation"
 
    -- Estado interno
    self._inside = false
    self._wasInside = false
    self._accum = 0
    self.lastMillis = Millisecs()
 
    Print("🧪 Zona [" .. self.zoneName .. "] cargada. DPS: " .. self.damagePerSecond .. " cada " .. self.damageInterval .. "ms")
end
 
function ZoneVolume:Start()
    Print(" Zona [" .. self.zoneName .. "] activa.")
end
 
function ZoneVolume:Collide(ent, pos, normal, speed)
    if ent.name == "controller" then
        self._inside = true
        if not self._wasInside then
            Print("🚨 Ela ENTRÓ a " .. self.zoneName)
        end
        self._wasInside = true
    end
end
 
function ZoneVolume:Update()
    local now = Millisecs()
    local delta = now - self.lastMillis
    self.lastMillis = now
 
    -- Daño solo si sigue adentro
    if self._wasInside and self._inside then
                 
            self._accum = self._accum + delta
 
            local seconds = self._accum / 1000.0
            local damage = self.damagePerSecond * seconds
 
            if damage >= 1.0 then
                local rounded = math.floor(damage)
                self._accum = self._accum - (rounded * 1000 / self.damagePerSecond)
 
                if _G.uiLevel01  then
                    local vida = _G.uiLevel01:GetLife() * 100
                    local nueva = math.max(0, vida - rounded)
                    _G.uiLevel01:SetLife(nueva)
                    Print("☣️ Daño a Ela: -" .. rounded .. " | Vida: " .. nueva)
               
                end
            end
       
 
    elseif self._wasInside and not self._inside then
        -- Ela salió de la zona
        Print(" Ela SALIÓ de " .. self.zoneName)
        self._wasInside = false
        self._accum = 0
    end
 
    -- Reset para el siguiente frame
    self._inside = false
 
   Print(onLevel)
 
    if ActiveWindow():KeyHit(KEY_ESCAPE) then
           
    end
end
 
RegisterComponent("ZoneVolume", ZoneVolume)
return ZoneVolume

 

 

Astrocuco.thumb.png.c76e0fb3de2d6e437e7dca099625e11e.png

Murphy's Law: We don't fix bugs, we document them as features. – Murphy Games

  • Solution
Posted

Josh and I discussed the ability to pause a component by command but he hasn't gotten around to it as of yet.

What I do is use the Enabled flag until an engine command comes available.

 

function ZoneVolume:Update()
    If not self.Enabled then return end
    local now = Millisecs()
    local delta = now - self.lastMillis
    self.lastMillis = now
  • Like 1

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...