ZombieXR 1.4 Update

Discussion in 'Coding' started by Halt, Sep 13, 2017.

  1. Halt

    Halt Can I get a bite?
    Developer Admin

    Joined:
    Jan 3, 2016
    Messages:
    254
    Likes Received:
    234
    The past few days the DEV team has been hard at work to bring updates to the mod and maps.

    Mod Updates

    [FIXED]
    Point system error - If you killed any amount of zombies you had millions of points.
    [FIXED] Artillery Smoke - Sometimes did not dissipate after the strike was over.
    [NERFED] Sentry Damage - Has been changed from default to 5.
    [ADDED] Chat colors - Zombies chat green, survivors chat blue.

    Map Updates
    [FIXED] - zomxr_facility
    [CONVERTED] - zomxr_crustynutz
    [CONVERTED] - zomxr_castle_siege
    [CONVERTED] - zomxr_halo
    [CONVERTED] - zomxr_rage
    [ADDED] - zomxr_box


    We are still hard at work updating/converting countless maps from the previous mod. We will also be adding new features to the next mod update that include new perks.
     
  2. Halt

    Halt Can I get a bite?
    Developer Admin

    Joined:
    Jan 3, 2016
    Messages:
    254
    Likes Received:
    234
    With the current issues of the timer not running properly and some errors upon spawning i.e. zombies with guns or zombies not green. I revamped ALL blocks and pieces of code that deal with such matters, below I provided the old and new blocks/lines of code.

    Code:
    //Old
    public Action At_Player_Spawn(Handle event, const String:name[], bool:dontBroadcast)
    {
        new Client = GetClientOfUserId(GetEventInt(event, "userid"));
        PlayerSpawnTimer[Client] = false;
        bIsPlayerAlive[Client] = true;
        ZomPoints[Client] = 0;
        KillStreak[Client] = 0;
        PlayerTeam[Client] = TF2_GetClientTeam(Client);
        CreateTimer(2.0, SpawnTimer, GetEventInt(event, "userid"), TIMER_FLAG_NO_MAPCHANGE);
        if    (HasRoundStarted)
        {
            bIsPlayerZombie[Client] = true;
            CreateTimer(0.5, WeaponStrip, GetClientUserId(Client));
            SetEntityRenderColor(Client, 0, 255, 0, 255);
        }
        if    (!HasRoundStarted)
            bIsPlayerZombie[Client] = false;
        if    (PlayerTeam[Client] == TFTeam_Blue && HasRoundStarted && bIsPlayerZombie[Client])
            TF2_ChangeClientTeam(Client, TFTeam_Red);
        else if(PlayerTeam[Client] == TFTeam_Red && !HasRoundStarted)
        {
            TF2_ChangeClientTeam(Client, TFTeam_Blue);
            CreateTimer(0.5, RespawnPlayer, GetEventInt(event, "userid"));
        }
        if    (TF2_GetPlayerClass(Client) == TFClass_Spy)
            CreateTimer(0.3, RemoveSpyStuff, GetEventInt(event, "userid"), TIMER_FLAG_NO_MAPCHANGE);
     
        if    (!bIsPlayerZombie[Client])
            SetEntityRenderColor(Client, 255, 255, 255, 255);
    }
    
    
    //New
    public Action At_Player_Spawn(Handle event, const String:name[], bool:dontBroadcast)
    {
        new Client = GetClientOfUserId(GetEventInt(event, "userid"));
        PlayerSpawnTimer[Client] = false;
        bIsPlayerAlive[Client] = true;
        ZomPoints[Client] = 0;
        //KillStreak[Client] = 0;
        PlayerTeam[Client] = TF2_GetClientTeam(Client);
        CreateTimer(2.0, SpawnTimer, GetClientUserId(Client), TIMER_FLAG_NO_MAPCHANGE);
        if    (HasRoundStarted)
        {
            bIsPlayerZombie[Client] = true;
            CreateTimer(0.5, WeaponStrip, GetClientUserId(Client));
            SetEntityRenderColor(Client, 0, 255, 0, 255);
        }
        if    (HasRoundStarted && PlayerTeam[Client] == TFTeam_Blue)
        {
            TF2_ChangeClientTeam(Client, TFTeam_Red);
            CreateTimer(0.5, RespawnPlayer, GetClientUserId(Client));
        }
        else if(PlayerTeam[Client] == TFTeam_Red && !HasRoundStarted)
        {
            TF2_ChangeClientTeam(Client, TFTeam_Blue);
            CreateTimer(0.5, RespawnPlayer, GetClientUserId(Client));
        }
        if    (TF2_GetPlayerClass(Client) == TFClass_Spy)
            CreateTimer(0.3, RemoveSpyStuff, GetClientUserId(Client), TIMER_FLAG_NO_MAPCHANGE);
     
        if    (!HasRoundStarted)
            SetEntityRenderColor(Client, 255, 255, 255, 255);
    }
    
    
    //Old
    public Action At_Player_Death(Event event, const char[] name, bool dontBroadcast)
    {
        int Client = GetClientOfUserId(GetEventInt(event, "userid"));
        int Attacker = GetClientOfUserId(GetEventInt(event, "attacker"));
        if    (HasRoundStarted)
            bIsPlayerAlive[Client] = false;
        CreateTimer(0.3, RespawnPlayer, GetEventInt(event, "userid"), TIMER_FLAG_NO_MAPCHANGE);
        if    (bIsPlayerAlive[Attacker] && !bIsPlayerZombie[Attacker])
        {
            ZomPoints[Attacker] += 1;
            KillStreak[Attacker] += 1;
        }
        else if (bIsPlayerAlive[Attacker] && !bIsPlayerZombie[Attacker] && IsPlayerMember[Attacker])
        {
            ZomPoints[Attacker] += 2;
        }
        if    (!bIsPlayerZombie[Client] && bIsPlayerZombie[Attacker] && HasRoundStarted)
        {
            PrintToChatAll("\x07ff2929[\x0730FF31ZomXR\x07ff2929] - \x0730FF31%N \x07e3f010has eaten \x0730FF31%N!", Attacker, Client);
            if    (GetTeamClientCount(2) >= 5 && GetTeamClientCount(3) == 1 && HasRoundStarted)
            {
                for    (new LastMan = 1; LastMan <= MaxClients; LastMan++)
                {
                    if    (IsClientInGame(LastMan) && PlayerTeam[LastMan] == TFTeam_Blue && bIsPlayerAlive[LastMan])
                    {
                        CreateTimer(0.3, LastHumanTimer, LastMan, TIMER_FLAG_NO_MAPCHANGE); //Dont pass client thorugh timer
                    }
                }
            }
        }
        if    (TF2_GetClientTeam(Client) == TFTeam_Blue && bIsPlayerZombie[Client] == false && HasRoundStarted)
        {
            float coordinates[3];
            GetClientAbsOrigin(Client, coordinates);
            GetEntPropVector(Client, Prop_Send, "m_vecOrigin", coordinates);
          
            int Entity = CreateEntityByName("prop_dynamic_override");
            SetEntityModel(Entity, "models/props_gameplay/tombstone_tankbuster.mdl");
            TeleportEntity(Entity, coordinates, NULL_VECTOR, NULL_VECTOR);
            DispatchSpawn(Entity);
    
        }
        if    (GetTeamClientCount(2) >= 1 && GetTeamClientCount(3) <= 0 && HasRoundStarted)
        {
            ServerCommand("mp_forcewin 2");
            //CreateTimer(1.0, ResetRound, TIMER_FLAG_NO_MAPCHANGE)
            PrintToChatAll("\x07ff2929[\x0730FF31ZomXR\x07ff2929] - \x07e3f010Humanity has failed. Zombies Win!");
            EmitSoundToAll("ui/halloween_boss_summoned_monoculus.wav");
        }
    }
    
    
    //New
    public Action At_Player_Death(Event event, const char[] name, bool dontBroadcast)
    {
        int Client = GetClientOfUserId(GetEventInt(event, "userid"));
        int Attacker = GetClientOfUserId(GetEventInt(event, "attacker"));
        if    (HasRoundStarted)
            bIsPlayerAlive[Client] = false;
     
        if    (bIsPlayerAlive[Attacker] && !bIsPlayerZombie[Attacker])
            ZomPoints[Attacker] += 1;
     
        if    (!bIsPlayerZombie[Client] && bIsPlayerZombie[Attacker])
        {
            PrintToChatAll("\x07ff2929[\x0730FF31ZomXR\x07ff2929] - \x0730FF31%N \x07e3f010has eaten \x0730FF31%N!", Attacker, Client);
            if    (GetTeamClientCount(2) >= 5 && GetTeamClientCount(3) == 1 && HasRoundStarted)
            {
                for    (new LastMan = 1; LastMan <= MaxClients; LastMan++)
                {
                    if    (IsClientInGame(LastMan) && PlayerTeam[LastMan] == TFTeam_Blue && bIsPlayerAlive[LastMan])
                    {
                        CreateTimer(0.3, LastHumanTimer, GetClientUserId(LastMan), TIMER_FLAG_NO_MAPCHANGE); //Dont pass client thorugh timer
                    }
                }
            }
        }
     
        if    (TF2_GetClientTeam(Client) == TFTeam_Blue && bIsPlayerZombie[Client] == false && HasRoundStarted)
        {
            float coordinates[3];
            GetClientAbsOrigin(Client, coordinates);
            GetEntPropVector(Client, Prop_Send, "m_vecOrigin", coordinates);
          
            int Entity = CreateEntityByName("prop_dynamic_override");
            SetEntityModel(Entity, "models/props_gameplay/tombstone_tankbuster.mdl");
            TeleportEntity(Entity, coordinates, NULL_VECTOR, NULL_VECTOR);
            DispatchSpawn(Entity);
        }
     
        if    (GetTeamClientCount(2) >= 1 && GetTeamClientCount(3) <= 0 && HasRoundStarted)
        {
            ServerCommand("mp_forcewin 2");
            PrintToChatAll("\x07ff2929[\x0730FF31ZomXR\x07ff2929] - \x07e3f010Humanity has failed. Zombies Win!");
            EmitSoundToAll("ui/halloween_boss_summoned_monoculus.wav");
            CreateTimer(1.0, ResetGame);
        }
     
        CreateTimer(0.3, RespawnPlayer, GetClientUserId(Client), TIMER_FLAG_NO_MAPCHANGE);
    }
    
    
    //New
    public Action StartRound(Handle timer, any Data)
    {
        if    (!HasWaitingTimeEnded)
        {
            HasWaitingTimeEnded = true;
            ServerCommand("mp_cancelwaitingforplayers 1");
            CreateTimer(32.0, GetZombieTimer, TIMER_FLAG_NO_MAPCHANGE);
            PrintToChatAll("\x07ff2929[\x0730FF31ZomXR\x07ff2929] - \x07e3f010Next round begins in 30 seconds!");
        }
        else if    (HasWaitingTimeEnded)
        {
            HasRoundStarted = false;
            CreateTimer(30.0, GetZombieTimer, TIMER_FLAG_NO_MAPCHANGE);
            PrintToChatAll("\x07ff2929[\x0730FF31ZomXR\x07ff2929] - \x07e3f010Next round begins in 30 seconds!");
        }
    }
    
    public Action ResetGame(Handle timer, any Data) //InGameClients
    {
        for    (new IGC; IGC <= MaxClients; IGC++)
        {
            if    (IsClientInGame(IGC) && bIsPlayerZombie[IGC])
            {
                TF2_ChangeClientTeam(IGC, TFTeam_Blue);
                CreateTimer(0.5, RespawnPlayer, GetClientUserId(IGC));
                bIsPlayerZombie[IGC] = false;
            }
        }
    }
     
    Gadunka likes this.
  3. Halt

    Halt Can I get a bite?
    Developer Admin

    Joined:
    Jan 3, 2016
    Messages:
    254
    Likes Received:
    234
    Some of the large issues were passing clientID's through timers, instead we pass ClientUserId, to the timer then convert it to the ClientID inside said timer.

    I.e.

    Wrong
    Code:
    CreateTimer(0.3, RemoveSpyStuff, GetEventInt(event, "userid")
    Correct
    Code:
    CreateTimer(0.3, RemoveSpyStuff, GetClientUserId(Client)
     
  • Zombie Survival

    Coming in 2017
  • Our Thanks

    We'd like to thank all who play, run, and help develop the community further and to where it is at today. Past, present, and future members have returned when Black Sun Studios returns. We'd personally like to thank you all for taking part in this amazing community.
  • Join the Discord

    Our discord server can be found below, there you will find the regulars playing all games from Team Fortress 2, Dead by Daylight, Terraria, Garry's Mod, and more. Or just come chill in the lounge and chat with everyone and even listen to music. Check it out, its a good time. Click here to join our Discord server!