silbinarywolf / sw-zombie-fortress

A VScript mod that aims to be a faithful reimplementation of the Zombie Fortress mode made originally with SourceMod
Other
0 stars 0 forks source link

fix issue where dispenser still dispenses ammo and gives health #4

Closed silbinarywolf closed 1 year ago

silbinarywolf commented 1 year ago

We have a fix sorted for next release:

function OnGameEvent_player_builtobject(params) {
    if (!hasInitialized) {
        return;
    }
    // note(jae): 2023-08-06
    // From ZF Vanilla sourcemod, these are the mapping for "object"
    // #define PLAYERBUILTOBJECT_ID_DISPENSER  0
    // #define PLAYERBUILTOBJECT_ID_TELENT     1
    // #define PLAYERBUILTOBJECT_ID_TELEXIT    2
    // #define PLAYERBUILTOBJECT_ID_SENTRY     3
    local object = params.object;
    local index = params.index;

    // 1. Handle dispenser rules.
    //    Disable dispensers when they begin construction.
    //    Increase max health to 250 (default level 1 is 150).
    if(object == 0) {
        local building = EntIndexToHScript(index);
        NetProps.SetPropInt(building, "m_iMaxHealth", 250);
        // Dispenser *seemingly* gets enabled after it's finished building, so lets
        // disable it every second for 15 seconds to ensure it stays disabled
        // after build.
        //
        // This also keeps it disabled after moving it.
        for (local delayInSeconds = 0; delayInSeconds < 15; delayInSeconds++) {
            EntFireByHandle(building, "Disable", "", delayInSeconds, null, null);
        }
    }
}
silbinarywolf commented 1 year ago

Fixed in v0.2.0 https://github.com/silbinarywolf/sw-zombie-fortress/pull/10