UGX-Mods Login

or login with an authentication provider below
Sign In with Google
Sign In with Twitter
Sign In with Discord
Sign In with Steam
Sign In with Facebook
Sign In with Twitch

Spawning power ups

broken avatar :(
Created 10 years ago
by niick555
0 Members and 1 Guest are viewing this topic.
9,758 views
broken avatar :(
×
broken avatar :(
Location: br
Date Registered: 8 June 2015
Last active: 9 years ago
Posts
38
Respect
Forum Rank
Legless Crawler
Primary Group
Member
×
niick555's Groups
niick555's Contact & Social Links
Good night, all right?
I am adding a new power up on my map, but I'm having some problems and is very difficult to test the power up playing till you drop in luck... Is there any way to spawn the power up whenever you start the game to facilitate? I tried using a script_struct, but it did not work...

Thank you!
This topic contains a post which is marked as the Best Answer. Click here to view it.
broken avatar :(
×
broken avatar :(
Location: esMadrid
Date Registered: 27 March 2015
Last active: 5 years ago
Posts
371
Respect
Forum Rank
Perk Hacker
Primary Group
Member
My Contact & Social Links
More
Personal Quote
JIGGLYPUFF used SING! YOU fell asleep!
Signature
×
Soy-Yo's Groups
Soy-Yo's Contact & Social LinksSoy-yoElCerdoRey
I've made a script to do this.
You have to edit _zombiemode_powerups:
Replace this line entire function:
Code Snippet
Plaintext
special_powerup_drop(drop_point)
with this:
Code Snippet
Plaintext
special_powerup_drop(drop_point,drop_what)
{
// if( level.powerup_drop_count == level.zombie_vars["zombie_powerup_drop_max_per_round"] )
// {
// println( "^3POWERUP DROP EXCEEDED THE MAX PER ROUND!" );
// return;
// }

if( !isDefined(level.zombie_include_powerups) || level.zombie_include_powerups.size == 0 )
{
return;
}

powerup = spawn ("script_model", drop_point + (0,0,40));

// never drop unless in the playable area
playable_area = getentarray("playable_area","targetname");
//chris_p - fixed bug where you could not have more than 1 playable area trigger for the whole map
valid_drop = false;
for (i = 0; i < playable_area.size; i++)
{
if (powerup istouching(playable_area[i]))
{
valid_drop = true;
break;
}
}

if(!valid_drop)
{
powerup Delete();
return;
}
   
    // Soy-yo's add
    if( isDefined( drop_what ) )
        powerup special_drop_setup( drop_what );
    else
        powerup special_drop_setup();
}
And:
Code Snippet
Plaintext
special_drop_setup()
with this:
Code Snippet
Plaintext
special_drop_setup(powerup)
{
//powerup = undefined;
    // Soy-yo's edit
    is_powerup = true;
    if( !isDefined( powerup ) )
    {
        powerup = get_next_powerup();
        // Always give something at lower rounds or if a player is in last stand mode.
        if ( level.round_number <= 10 || maps\_laststand::player_num_in_laststand() )
        {
            powerup = get_next_powerup();
        }
        // Gets harder now
        else
        {
            powerup = level.zombie_special_drop_array[ RandomInt(level.zombie_special_drop_array.size) ];
            if ( level.round_number > 15 &&
                 ( RandomInt(100) < (level.round_number - 15)*5 ) )
            {
                powerup = "nothing";
            }
        }
       
        //MM test  Change this if you want the same thing to keep spawning
    // powerup = "dog";
        switch ( powerup )
        {
        // Don't need to do anything special
        case "nuke":
        case "insta_kill":
        case "double_points":
        case "carpenter":
            break;

        // Limit max ammo drops because it's too powerful
        case "full_ammo":
            if ( level.round_number > 10 &&
                 ( RandomInt(100) < (level.round_number - 10)*5 ) )
            {
                // Randomly pick another one
                powerup = level.zombie_powerup_array[ RandomInt(level.zombie_powerup_array.size) ];
            }
            break;

        case "dog":
            if ( level.round_number >= 15 )
            {
                is_powerup = false;
                dog_spawners = GetEntArray( "special_dog_spawner", "targetname" );
                maps\_zombiemode_dogs::special_dog_spawn( dog_spawners, 1 );
                //iprintlnbold( "Samantha Sez: No Powerup For You!" );
                thread play_sound_2d( "sam_nospawn" );
            }
            else
            {
                powerup = get_next_powerup();
            }
            break;

        // Nothing drops!!
        default: // "nothing"
            is_powerup = false;
            Playfx( level._effect["lightning_dog_spawn"], self.origin );
            playsoundatposition( "pre_spawn", self.origin );
            wait( 1.5 );
            playsoundatposition( "bolt", self.origin );

            Earthquake( 0.5, 0.75, self.origin, 1000);
            PlayRumbleOnPosition("explosion_generic", self.origin);
            playsoundatposition( "spawn", self.origin );

            wait( 1.0 );
            //iprintlnbold( "Samantha Sez: No Powerup For You!" );
            thread play_sound_2d( "sam_nospawn" );
            self Delete();
        }
    }
    else
    {
        if( powerup != "nuke" && powerup != "insta_kill" && powerup != "double_points" && powerup != "carpenter" && powerup != "full_ammo" )
            is_powerup = false;
    }

if ( is_powerup )
{
Playfx( level._effect["lightning_dog_spawn"], self.origin );
playsoundatposition( "pre_spawn", self.origin );
wait( 1.5 );
playsoundatposition( "bolt", self.origin );

Earthquake( 0.5, 0.75, self.origin, 1000);
PlayRumbleOnPosition("explosion_generic", self.origin);
playsoundatposition( "spawn", self.origin );

// wait( 0.5 );

struct = level.zombie_powerups[powerup];
self SetModel( struct.model_name );

//TUEY Spawn Powerup
playsoundatposition("spawn_powerup", self.origin);

self.powerup_name = struct.powerup_name;
self.hint = struct.hint;

if( IsDefined( struct.fx ) )
{
self.fx = struct.fx;
}

self PlayLoopSound("spawn_powerup_loop");

self thread powerup_timeout();
self thread powerup_wobble();
self thread powerup_grab();
}
}
But you have to edit this second function first:
Add your powerup in this line:
Code Snippet
Plaintext
if( powerup != "nuke" && powerup != "insta_kill" && powerup != "double_points" && powerup != "carpenter" && powerup != "full_ammo" )

And now you can place a script_struct in your map and create a script that gets its origin and call this function
Code Snippet
Plaintext
special_powerup_drop( <YOUR_STRUCT_ORIGIN>, <POWERUP_NAME> )

This should work because I'm using it in my map. Hope it helps. :)
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 11 March 2014
Last active: 5 years ago
Posts
264
Respect
Forum Rank
Mr. Elemental
Primary Group
Member
Signature
"Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live."
×
buttkicker845's Groups
buttkicker845's Contact & Social Links
you could also do it by commenting out all the add_zombie_powerup except the one for your powerup which would mean only your powerup will be dropped. and then by editing
Code Snippet
Plaintext
        set_zombie_var( "zombie_powerup_drop_increment", 	2000 );	// lower this to make drop happen more often
set_zombie_var( "zombie_powerup_drop_max_per_round", 4 ); // increase this to make more drops per round
to something like this
Code Snippet
Plaintext
       
         set_zombie_var( "zombie_powerup_drop_increment", 500 ); // lower this to make drop happen more often
          set_zombie_var( "zombie_powerup_drop_max_per_round", 500 ); // increase this to make more drops per round
then your drop will be the only drop and will spawn many times in one round
and then when you are done testing just replace the variables, and uncomment the add_zombie_powerup lines
Marked as best answer by niick555 10 years ago
broken avatar :(
×
broken avatar :(
Location: br
Date Registered: 8 June 2015
Last active: 9 years ago
Posts
38
Respect
Forum Rank
Legless Crawler
Primary Group
Member
×
niick555's Groups
niick555's Contact & Social Links
you could also do it by commenting out all the add_zombie_powerup except the one for your powerup which would mean only your powerup will be dropped. and then by editing
Code Snippet
Plaintext
        set_zombie_var( "zombie_powerup_drop_increment", 	2000 );	// lower this to make drop happen more often
set_zombie_var( "zombie_powerup_drop_max_per_round", 4 ); // increase this to make more drops per round
to something like this
Code Snippet
Plaintext
       
         set_zombie_var( "zombie_powerup_drop_increment", 500 ); // lower this to make drop happen more often
          set_zombie_var( "zombie_powerup_drop_max_per_round", 500 ); // increase this to make more drops per round
then your drop will be the only drop and will spawn many times in one round
and then when you are done testing just replace the variables, and uncomment the add_zombie_powerup lines

I've made a script to do this.
You have to edit _zombiemode_powerups:
Replace this line entire function:
Code Snippet
Plaintext
special_powerup_drop(drop_point)
with this:
Code Snippet
Plaintext
special_powerup_drop(drop_point,drop_what)
{
// if( level.powerup_drop_count == level.zombie_vars["zombie_powerup_drop_max_per_round"] )
// {
// println( "^3POWERUP DROP EXCEEDED THE MAX PER ROUND!" );
// return;
// }

if( !isDefined(level.zombie_include_powerups) || level.zombie_include_powerups.size == 0 )
{
return;
}

powerup = spawn ("script_model", drop_point + (0,0,40));

// never drop unless in the playable area
playable_area = getentarray("playable_area","targetname");
//chris_p - fixed bug where you could not have more than 1 playable area trigger for the whole map
valid_drop = false;
for (i = 0; i < playable_area.size; i++)
{
if (powerup istouching(playable_area[i]))
{
valid_drop = true;
break;
}
}

if(!valid_drop)
{
powerup Delete();
return;
}
   
    // Soy-yo's add
    if( isDefined( drop_what ) )
        powerup special_drop_setup( drop_what );
    else
        powerup special_drop_setup();
}
And:
Code Snippet
Plaintext
special_drop_setup()
with this:
Code Snippet
Plaintext
special_drop_setup(powerup)
{
//powerup = undefined;
    // Soy-yo's edit
    is_powerup = true;
    if( !isDefined( powerup ) )
    {
        powerup = get_next_powerup();
        // Always give something at lower rounds or if a player is in last stand mode.
        if ( level.round_number <= 10 || maps\_laststand::player_num_in_laststand() )
        {
            powerup = get_next_powerup();
        }
        // Gets harder now
        else
        {
            powerup = level.zombie_special_drop_array[ RandomInt(level.zombie_special_drop_array.size) ];
            if ( level.round_number > 15 &&
                 ( RandomInt(100) < (level.round_number - 15)*5 ) )
            {
                powerup = "nothing";
            }
        }
       
        //MM test  Change this if you want the same thing to keep spawning
    // powerup = "dog";
        switch ( powerup )
        {
        // Don't need to do anything special
        case "nuke":
        case "insta_kill":
        case "double_points":
        case "carpenter":
            break;

        // Limit max ammo drops because it's too powerful
        case "full_ammo":
            if ( level.round_number > 10 &&
                 ( RandomInt(100) < (level.round_number - 10)*5 ) )
            {
                // Randomly pick another one
                powerup = level.zombie_powerup_array[ RandomInt(level.zombie_powerup_array.size) ];
            }
            break;

        case "dog":
            if ( level.round_number >= 15 )
            {
                is_powerup = false;
                dog_spawners = GetEntArray( "special_dog_spawner", "targetname" );
                maps\_zombiemode_dogs::special_dog_spawn( dog_spawners, 1 );
                //iprintlnbold( "Samantha Sez: No Powerup For You!" );
                thread play_sound_2d( "sam_nospawn" );
            }
            else
            {
                powerup = get_next_powerup();
            }
            break;

        // Nothing drops!!
        default: // "nothing"
            is_powerup = false;
            Playfx( level._effect["lightning_dog_spawn"], self.origin );
            playsoundatposition( "pre_spawn", self.origin );
            wait( 1.5 );
            playsoundatposition( "bolt", self.origin );

            Earthquake( 0.5, 0.75, self.origin, 1000);
            PlayRumbleOnPosition("explosion_generic", self.origin);
            playsoundatposition( "spawn", self.origin );

            wait( 1.0 );
            //iprintlnbold( "Samantha Sez: No Powerup For You!" );
            thread play_sound_2d( "sam_nospawn" );
            self Delete();
        }
    }
    else
    {
        if( powerup != "nuke" && powerup != "insta_kill" && powerup != "double_points" && powerup != "carpenter" && powerup != "full_ammo" )
            is_powerup = false;
    }

if ( is_powerup )
{
Playfx( level._effect["lightning_dog_spawn"], self.origin );
playsoundatposition( "pre_spawn", self.origin );
wait( 1.5 );
playsoundatposition( "bolt", self.origin );

Earthquake( 0.5, 0.75, self.origin, 1000);
PlayRumbleOnPosition("explosion_generic", self.origin);
playsoundatposition( "spawn", self.origin );

// wait( 0.5 );

struct = level.zombie_powerups[powerup];
self SetModel( struct.model_name );

//TUEY Spawn Powerup
playsoundatposition("spawn_powerup", self.origin);

self.powerup_name = struct.powerup_name;
self.hint = struct.hint;

if( IsDefined( struct.fx ) )
{
self.fx = struct.fx;
}

self PlayLoopSound("spawn_powerup_loop");

self thread powerup_timeout();
self thread powerup_wobble();
self thread powerup_grab();
}
}
But you have to edit this second function first:
Add your powerup in this line:
Code Snippet
Plaintext
if( powerup != "nuke" && powerup != "insta_kill" && powerup != "double_points" && powerup != "carpenter" && powerup != "full_ammo" )

And now you can place a script_struct in your map and create a script that gets its origin and call this function
Code Snippet
Plaintext
special_powerup_drop( <YOUR_STRUCT_ORIGIN>, <POWERUP_NAME> )

This should work because I'm using it in my map. Hope it helps. :)

Thank you for the tips! The two worked fine, but taking a look at the source code of the game, I found a way I preferred... No need to edit anything in the source code, and adding using less code (the method is the same used to spawn one power up at the last dog):

Code Snippet
Plaintext
powerup_spawn() {
struct_origin = getEnt("struct_origin", "targetname");
power_up_origin = struct_origin.origin;

wait 5;

if( IsDefined( power_up_origin ) ) {
players = get_players();

for ( i = 0; i < level.zombie_powerup_array.size; i++ )
{
if ( level.zombie_powerup_array[i] == "full_ammo" ) //powerup name
{
level.zombie_powerup_index = i;
break;
}
}

level.zombie_vars["zombie_drop_item"] = 1;
level.powerup_drop_count = 0;
level thread maps\_zombiemode_powerups::powerup_drop( power_up_origin );
}
}
broken avatar :(
×
broken avatar :(
Location: esMadrid
Date Registered: 27 March 2015
Last active: 5 years ago
Posts
371
Respect
Forum Rank
Perk Hacker
Primary Group
Member
My Contact & Social Links
More
Personal Quote
JIGGLYPUFF used SING! YOU fell asleep!
×
Soy-Yo's Groups
Soy-Yo's Contact & Social LinksSoy-yoElCerdoRey
Thank you for the tips! The two worked fine, but taking a look at the source code of the game, I found a way I preferred... No need to edit anything in the source code, and adding using less code (the method is the same used to spawn one power up at the last dog):

Code Snippet
Plaintext
powerup_spawn() {
struct_origin = getEnt("struct_origin", "targetname");
power_up_origin = struct_origin.origin;

wait 5;

if( IsDefined( power_up_origin ) ) {
players = get_players();

for ( i = 0; i < level.zombie_powerup_array.size; i++ )
{
if ( level.zombie_powerup_array[i] == "full_ammo" ) //powerup name
{
level.zombie_powerup_index = i;
break;
}
}

level.zombie_vars["zombie_drop_item"] = 1;
level.powerup_drop_count = 0;
level thread maps\_zombiemode_powerups::powerup_drop( power_up_origin );
}
}
Oh, that's true. That was the script I was trying to use in my map but I couldn't find it. :P
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 14 September 2013
Last active: 6 years ago
Posts
1,895
Respect
Forum Rank
Zombie Destroyer
Primary Group
Scripter
My Groups
More
My Contact & Social Links
More
Personal Quote
BE ORIGINAL
Signature
×
MakeCents's Groups
Mapper Has released one or more maps to the UGX-Mods community.
Scripter Has shown effort and knowledge in the area of scripting while being a part of the UGX-Mods community.
BO3 Modtools Alpha
BO3 Modtools Alpha
This user has access to the Black Ops 3 Modtools Alpha
I do something similar.

I add this to the top of powerups init function:

Code Snippet
Plaintext
level.testpowerup = 1;//used to spawn powerups every 3 seconds to test
if(IsDefined( level.testpowerup ) && level.testpowerup) thread TestPowerups();

And I have this down in the gsc:

Code Snippet
Plaintext
//MakeCents added for testing
TestPowerups(){
flag_wait( "all_players_connected" );
players = get_players(  );
start = players[0].origin;
while(1){
wait(3);
force_powerup_drop(start);
}
}
//MakeCents added for testing
force_powerup_drop(drop_point)
{
rand_drop = randomint(100);
powerup = maps\_zombiemode_net::network_safe_spawn( "powerup", 1, "script_model", drop_point + (0,0,20));
if(!powerup validdrop()){
powerup delete();
return;
}
powerup powerup_setup();
powerup thread powerup_timeout();
powerup thread powerup_wobble();
powerup thread powerup_grab();

level.zombie_vars["zombie_drop_item"] = 0;
}

This continually drops random powerups every 3 seconds where the player starts, but obviously could be modified to play a specific powerup, editing powerup_setup, or adding powerup_setup where the call is but in your own unique way. Or simply by commenting out the ones you don't need to test for a little.


Also on a side note, you may want to start marking best answers in your posts. I have seen you have many post where you thank people but don't mark them or yourself as the best answer. This is nice so people don't keep looking at it to help, creates less frustration, and those that help do appreciate it.
Last Edit: February 10, 2016, 06:09:41 pm by MakeCents
broken avatar :(
×
broken avatar :(
Location: nl
Date Registered: 22 September 2013
Last active: 6 months ago
Posts
326
Respect
Forum Rank
Perk Hacker
Primary Group
Mapper
My Groups
More
Personal Quote
Zombie Mapper and Gamer
Signature
My Custom Zombie Maps:

- Nazi zombie Legion
- City of Hell
- The Abandoned Mine
- The Last Undead House (Finished)

more custom zombie maps coming soon
×
gamer9294's Groups
Mapper Has released one or more maps to the UGX-Mods community.
gamer9294's Contact & Social Links
hi man,

you can also try this out, this is the way I use it to test a new powerup.


open the file:

dlc3_code.gsc

in your mods folder (root/mods/your_mapname/maps/... )

if you don't have the dlc3_code.gsc  file then copy it from raw/maps/... to your mods folder in your maps folder.


open the dlc3_code.gsc file and search for this:

Code Snippet
Plaintext
include_powerups()
{
include_powerup( "nuke" );
include_powerup( "insta_kill" );
include_powerup( "double_points" );
include_powerup( "full_ammo" );
include_powerup( "carpenter" );
}

now disable the powerups that you don't want to use for testing the new powerup,  as example:

Code Snippet
Plaintext
include_powerups()
{
// include_powerup( "nuke" );
// include_powerup( "insta_kill" );
// include_powerup( "double_points" );
// include_powerup( "full_ammo" );
// include_powerup( "carpenter" );
include_powerup( "your_powerupname_here" );
}

your_powerupname_here = the powerup that you have and that you want to test it.

and after you have compiled your map and build the mod then you can test your new powerup and only the new powerup will spawn out of the zombies :)


and if you are done then you can remove the   //  by the include_powerups that you have it look like this:


Code Snippet
Plaintext
include_powerups()
{
include_powerup( "nuke" );
include_powerup( "insta_kill" );
include_powerup( "double_points" );
include_powerup( "full_ammo" );
include_powerup( "carpenter" );
include_powerup( "your_powerupname_here" );
}

I hope for you that this will help you  8)


best regards,
Gamer9294

 
Loading ...