Modme Forums

Trigger that spawns on a certain round

Game Modding | Call of Duty: Black Ops 3 | Scripting


Magicman:

I would like to make a trigger_hurt to spawn in on a specific round. For example on round 5 if I want to force the players out of a room


Vertasea:

If you are still looking for a way to do that, I just made this small script for you.

/*
In radiant add a "trigger_hurt"
Add a KVP to the "trigger_hurt"
Give it a "targetname" = "damage"

Make sure you edit the dmg kvp. The default value of 5 will kill you pretty quick
Copy paste as many of them as you need. Save and add these 2 functions to the bottom of your zm_mapname.gsc

Make sure to thread the function Example:
inside of your function main()
add this:
level thread damage_to_player();

change the ROUND_NUMBER from 2 to whatever round you want.

Compile, link, play... :)
*/

#define ROUND_NUMBER            2       // What round you want to the damage to start happening on
function damage_to_player(){

    foreach( trigger in GetEntArray( "damage", "targetname" ) ){
        trigger thread triggerSetup();
    }
}

function triggerSetup(){

    self TriggerEnable( false );

    while( true ){

        if( level.round_number == ROUND_NUMBER ){

            self TriggerEnable( true );
            break;
        }
        WAIT_SERVER_FRAME;
    }
}


Magicman:

If you are still looking for a way to do that, I just made this small script for you.

/*
In radiant add a "trigger_hurt"
Add a KVP to the "trigger_hurt"
Give it a "targetname" = "damage"

Make sure you edit the dmg kvp. The default value of 5 will kill you pretty quick
Copy paste as many of them as you need. Save and add these 2 functions to the bottom of your zm_mapname.gsc

Make sure to thread the function Example:
inside of your function main()
add this:
level thread damage_to_player();

change the ROUND_NUMBER from 2 to whatever round you want.

Compile, link, play... :)
*/

#define ROUND_NUMBER            2       // What round you want to the damage to start happening on
function damage_to_player(){

    foreach( trigger in GetEntArray( "damage", "targetname" ) ){
        trigger thread triggerSetup();
    }
}

function triggerSetup(){

    self TriggerEnable( false );

    while( true ){

        if( level.round_number == ROUND_NUMBER ){

            self TriggerEnable( true );
            break;
        }
        WAIT_SERVER_FRAME;
    }
}


Much appreciated, worked absolutely perfectly


MyNameIsNobody:

If you would be so kind as to help one more person, how would you implement this but to where it stops damaging the player after x amount of rounds, then starts again at x amount of rounds etc? I need to learn to script but haven't had the time to yet.


Vertasea:

If you would be so kind as to help one more person, how would you implement this but to where it stops damaging the player after x amount of rounds, then starts again at x amount of rounds etc? I need to learn to script but haven't had the time to yet.


You would set it up pretty much the same, but there are many ways to do it for "x" amount of rounds. You can use notifies or waittills. To many ways to do it, but here you can do this and it will damage the player if they are touching the trigger every even round so round 2, 4, 6, 8 ,10, ect...

function damage_to_player(){

    foreach( trigger in GetEntArray( "damage", "targetname" ) ){
        trigger thread triggerSetup();
    }
}

function triggerSetup(){

    level.damage_rounds = 2;

    while( true ){

        self toggleDamage();
        level waittill( "start_of_round" );
    }
}

function toggleDamage(){

    if( level.round_number == level.damage_rounds ){
        self TriggerEnable( true );
        level.damage_rounds = level.damage_rounds + 2;
    }
    else{
        self TriggerEnable( false );
    }
}


MyNameIsNobody:

Ok thanks a million for the help!