::ChargingBeastSetup <- function(player) {
    player.ValidateScriptScope();
    local scope = player.GetScriptScope();

    // we create a game_text entity and store the handle in the player's scope so we can access it later
    if(!scope.rawin("chargeMeterText") || !scope.chargeMeterText.IsValid()) {
        scope.chargeMeterText <- SpawnEntityFromTable("game_text", {
            targetname = "charge_text"
            channel = 4
            message = ""
            color = "255 0 0"
            holdtime = 1.5
            x = 0.7
            y = 0.9
            spawnflags = 0 // as spawnflags is 0, this will only show to the activator
        });
    }

    scope.nextChargeTime <- Time();
}
::fullBar <- "////////////////////";
::emptyBar <- "--------------------";
::AttemptBeastCharge <- function(player) {
    local scope = player.GetScriptScope()

    // if the current time is past the nextChargeTime, then we do the charge
    if(Time() > scope.nextChargeTime) {
        player.AddCond(17)
        EntFireByHandle(scope.chargeHurt, "Enable", null, 0, null, null)
        EntFireByHandle(player, "$RemoveCond", "17", 2, null, null)
        EntFireByHandle(scope.chargeHurt, "Disable", null, 2, null, null)

        scope.nextChargeTime = Time() + 12

        // here is the charge display
        local delay = 2
        for (local i = 0.0 ; i < 20.0 ; i += 1.0) {

            local barString = "[" + fullBar.slice(20-i) + emptyBar.slice(i) + "]"
            EntFireByHandle(scope.chargeMeterText, "$SetData$m_iszMessage", barString, (i/2) + delay, null, null)
            EntFireByHandle(scope.chargeMeterText, "Display", null, (i/2) + delay + 0.1, player, null)
        }
        EntFireByHandle(scope.chargeMeterText, "$SetData$m_iszMessage", "Ready!", 10 + delay, null, null)
        EntFireByHandle(scope.chargeMeterText, "Display", null, 10.1 + delay, player, null)
        EntFireByHandle(scope.chargeMeterText, "$SetData$m_iszMessage", "", 12 + delay, null, null)
    }
}
::BeastChargeDamage <- function(victim, player) {
    local damageAmt = 100
    victim.TakeDamageEx(player, player, player.GetActiveWeapon(), Vector(0,0,0), player.GetOrigin(), damageAmt, 1)
}
::ThisIsAPieceOfShit <- function(mimic, player) {
    player.ValidateScriptScope()
    player.GetScriptScope().chuckingthemhealthkits <- mimic
    // ClientPrint(player,3,"mimic" + player.GetScriptScope().chuckingthemhealthkits.tostring())
    // ClientPrint(player,3,"mimic owner" + player.GetScriptScope().chuckingthemhealthkits.GetOwner().tostring())
}
::ItsSoHot <- function(mimic, player) {
    player.ValidateScriptScope()
    player.GetScriptScope().pasoquevoyardiendo <- mimic
    // ClientPrint(player,3,"mimic" + player.GetScriptScope().pasoquevoyardiendo.tostring())
    // ClientPrint(player,3,"mimic owner" + player.GetScriptScope().pasoquevoyardiendo.GetOwner().tostring())
}
::RegisterMimicToPlayer <- function(mimic, player, name) {
    player.ValidateScriptScope()
    player.GetScriptScope()[name] <- mimic
}