[Release] [GSC] Zombies Custom Powerup | Unlimited Ammo
-
So I was playing some zombies with a friend and wanted to do something with gsc. Just to remember the good old golden days. Thought of making a custom powerup and unlimited ammo seemed like a pretty cool one.
So it'll drop on the ground randomly just like any powerup, and when someone picks it up, every player gets unlimited ammo for 30secs. Duration can be easily changed, of course.
This is not intended for Turned or Grief. I have no idea what happens if you try to use them there. Nothing good I'd assume.
Cba'd to make it work with them because who needs unlimited ammo in Turned, and who tf plays Grief.
Other than that, should be all good. Managed to even spam myself with the powerup over 2000 times in a row with no issues.EDIT: Seems the shader I'm using for the icon wont load in all maps KMS KMS KMS KMS KMS KMS. I fucking cba trying to find one that works. Shit's fucking impossible. I can deal with a checkerboard icon in some maps.
Video
https://www.youtube.com/watch?v=M5qXeJAmdZ8
Picture
https://i.imgur.com/Amllzkw.jpgFull source for a minimal example script. Be sure to read the comments in there if you'll be doing any changes yourself.
#include maps\mp\_utility; #include common_scripts\utility; #include maps\mp\gametypes_zm\_hud_util; #include maps\mp\gametypes_zm\_hud_message; //important include #include maps\mp\zombies\_zm_powerups; init() { level thread onPlayerConnect(); //include and init the powerup include_zombie_powerup("unlimited_ammo"); //change the powerup duration if you want level.unlimited_ammo_duration = 30; //shitty model, cant find a good model list so cba //change to w/e if you have some nice model //galil works in all maps though, so be decent in that regard ig add_zombie_powerup("unlimited_ammo", "T6_WPN_AR_GALIL_WORLD", &"ZOMBIE_POWERUP_UNLIMITED_AMMO", ::func_should_always_drop, 0, 0, 0); powerup_set_can_pick_up_in_last_stand("unlimited_ammo", 1); } onPlayerConnect() { for(;;) { level waittill("connected", player); player thread onPlayerSpawned(); } } onPlayerSpawned() { self endon("disconnect"); level endon("game_ended"); for(;;) { self waittill("spawned_player"); if(self isHost() && !isDefined(level.unlimited_ammo_first_spawn)) { wait 2; //store the original custom powerup grab function, //if one exists (Origins, Buried, Grief & Turned) //note that this is not intended for Grief or Turned //I have no idea what will happen, probably pretty broken if(isDefined(level._zombiemode_powerup_grab)) level.original_zombiemode_powerup_grab = level._zombiemode_powerup_grab; //delayed defining of the custom function so we're sure to //override the function Origins and Buried defines for this level._zombiemode_powerup_grab = ::custom_powerup_grab; //message for the host to indicate that it should be all good wait 2; self iprintlnbold("^7Unlimited Ammo Custom Powerup Loaded!"); //gives host the ability to test the powerup at the start of the game //can be used to make sure it's actually working and all good //remove the line directly below to disable self thread test_the_powerup(); //whatever so this variable isn't undefined anymore level.unlimited_ammo_first_spawn = "fortnite!fortnite!!"; } } } test_the_powerup() { self endon("death"); self endon("disconnected"); self endon("testing_chance_ended"); level endon("game_ended"); wait 3; self iprintlnbold("^7Press ^1[{+smoke}] ^7to test, you have ^15 seconds^7."); self thread testing_duration_timeout(); for(;;) { if(self secondaryoffhandbuttonpressed()) { level specific_powerup_drop("unlimited_ammo", self.origin + VectorScale(AnglesToForward(self.angles), 70)); return; } wait .05; } } testing_duration_timeout() { self endon("death"); self endon("disconnected"); wait 5; self notify("testing_chance_ended"); } //fires when we grab any custom powerup custom_powerup_grab(s_powerup, e_player) { if (s_powerup.powerup_name == "unlimited_ammo") level thread unlimited_ammo_powerup(); //pass args onto the original custom powerup grab function else if (isDefined(level.original_zombiemode_powerup_grab)) level thread [[level.original_zombiemode_powerup_grab]](s_powerup, e_player); } unlimited_ammo_powerup() { foreach(player in level.players) { //if powerup is already on, turn it off player notify("end_unlimited_ammo"); //small cha ching sound for each player when someone picks up the powerup //cba'd to come up with anything better and don't have a list of sounds, //change to w/e if you want. player playsound("zmb_cha_ching"); player thread turn_on_unlimited_ammo(); player thread unlimited_ammo_on_hud(); player thread notify_unlimited_ammo_end(); } } unlimited_ammo_on_hud() { self endon("disconnect"); //hud elems for text & icon unlimited_ammo_hud_string = newclienthudelem(self); unlimited_ammo_hud_string.elemtype = "font"; unlimited_ammo_hud_string.font = "objective"; unlimited_ammo_hud_string.fontscale = 2; unlimited_ammo_hud_string.x = 0; unlimited_ammo_hud_string.y = 0; unlimited_ammo_hud_string.width = 0; unlimited_ammo_hud_string.height = int( level.fontheight * 2 ); unlimited_ammo_hud_string.xoffset = 0; unlimited_ammo_hud_string.yoffset = 0; unlimited_ammo_hud_string.children = []; unlimited_ammo_hud_string setparent(level.uiparent); unlimited_ammo_hud_string.hidden = 0; unlimited_ammo_hud_string maps/mp/gametypes_zm/_hud_util::setpoint("TOP", undefined, 0, level.zombie_vars["zombie_timer_offset"] - (level.zombie_vars["zombie_timer_offset_interval"] * 2)); unlimited_ammo_hud_string.sort = .5; unlimited_ammo_hud_string.alpha = 0; unlimited_ammo_hud_string fadeovertime(.5); unlimited_ammo_hud_string.alpha = 1; //cool powerup name, sounds like something that could actually be in the game //credits to "Banni" for it unlimited_ammo_hud_string setText("Bottomless Clip!"); unlimited_ammo_hud_string thread unlimited_ammo_hud_string_move(); unlimited_ammo_hud_icon = newclienthudelem(self); unlimited_ammo_hud_icon.horzalign = "center"; unlimited_ammo_hud_icon.vertalign = "bottom"; unlimited_ammo_hud_icon.x = -75; unlimited_ammo_hud_icon.y = 0; unlimited_ammo_hud_icon.alpha = 1; unlimited_ammo_hud_icon.hidewheninmenu = true; unlimited_ammo_hud_icon setshader("hud_icon_minigun", 40, 40); self thread unlimited_ammo_hud_icon_blink(unlimited_ammo_hud_icon); self thread destroy_unlimited_ammo_icon_hud(unlimited_ammo_hud_icon); } unlimited_ammo_hud_string_move() { wait .5; self fadeovertime(1.5); self moveovertime(1.5); self.y = 270; self.alpha = 0; wait 1.5; self destroy(); } //blinking times match the normal powerup hud blinking times unlimited_ammo_hud_icon_blink(elem) { level endon("disconnect"); self endon("disconnect"); self endon("end_unlimited_ammo"); time_left = level.unlimited_ammo_duration; for(;;) { //less than 5sec left on powerup, blink fast if(time_left <= 5) time = .1; //less than 10sec left on powerup, blink else if(time_left <= 10) time = .2; //over 20sec left, dont blink else { wait .05; time_left -= .05; continue; } elem fadeovertime(time); elem.alpha = 0; wait time; elem fadeovertime(time); elem.alpha = 1; wait time; time_left -= time * 2; } } destroy_unlimited_ammo_icon_hud(elem) { level endon("game_ended"); //timeout just in case aswell, shouldnt ever get used, but who knows if I missed something self waittill_any_timeout(level.unlimited_ammo_duration+1, "disconnect", "end_unlimited_ammo"); elem destroy(); } turn_on_unlimited_ammo() { level endon("game_ended"); self endon("disonnect"); self endon("end_unlimited_ammo"); for(;;) { //simply set the current mag to be full on a loop self setWeaponAmmoClip(self GetCurrentWeapon(), 150); wait .05; } } notify_unlimited_ammo_end() { level endon("game_ended"); self endon("disonnect"); self endon("end_unlimited_ammo"); wait level.unlimited_ammo_duration; //the same sound that plays when instakill powerup ends self playsound("zmb_insta_kill"); self notify("end_unlimited_ammo"); }
Download to a precompiled .gsc you can use:
https://www.mediafire.com/file/h501pdsime694jx/BO2-Zombies-Custom-Powerup-Unlimited-Ammo.zip/file
https://www.virustotal.com/gui/file/e7efd7e643d5f5e2a4aa29c32af186b13d314b0915687f13724b88ec890bd604/detectionHope someone finds some use, or maybe figures out how to add their own custom powerups, post them down below if you do.
And if you have any ideas for improvement, or other custom powerups, or any other custom stuff, post them down below. I might make them if I find them cool.~Ox
-
Nice work. If you want a challenge fix origins Easter egg with 4 people plus
-
H3X1C said in [GSC] Zombies Custom Powerup | Unlimited Ammo:
Nice work. If you want a challenge fix origins Easter egg with 4 people plus
Never really did easter eggs with my friends, so doubt I'd want to bother.
But well, what goes wrong with it? -
Ox_ crashes the server
-
H3X1C said in [GSC] Zombies Custom Powerup | Unlimited Ammo:
Ox_ crashes the server
Lol. At what point? What needs to be done to make it crash?
Keep in mind that I don't know how the easter egg is done. -
Hmm... maybe add death machine powerup?
-
Ox_ Thanks for sharing, this can be really useful. I'll keep my eye out for any servers with this feature
-
Ox_ Nice share, if you change func_should_always_drop like this you should be able to control whether the perk is enabled or not from the server cfg, you probably also want to rename it at the same time.
func_should_always_drop() { if(is_true(getdvarintdefault("sv_perk_unlimited_ammo",1))) { return 1; } return 0; }
is_true
needs#include common_scripts/utility;
andgetdvarintdefault
needs#include maps/mp/_utility;
You can do the same for the duration and replace
wait 20;
withwait getdvarintdefault("sv_perk_unlimited_ammo_duration",20);
Or if you don't want to do that you can also change it to
maps/mp/zombies/_zm_powerups::func_should_always_drop
to use the original one and make your code a bit tidier. -
Great thread OP Can't wait for people to make full mods for Zombies.
-
Mr. Android
Brings me back to Xbox 360 modding for WaW zombies. -
Ox_
there is something i dont like about loops with wait
just a personal thingturn_on_unlimited_ammo() { level endon("game_ended"); self endon("disonnect"); self endon("end_unlimited_ammo"); self setWeaponAmmoClip(self GetCurrentWeapon(), 150); //does it one time if you pick it up for(;;) { self waittill ( "weapon_fired"); //simply set the current mag to be full on a loop self setWeaponAmmoClip(self GetCurrentWeapon(), 150); } }
-
Xerxes said in [GSC] Zombies Custom Powerup | Unlimited Ammo:
Ox_ Nice share, if you change func_should_always_drop like this you should be able to control whether the perk is enabled or not from the server cfg, you probably also want to rename it at the same time.
func_should_always_drop() { if(is_true(getdvarintdefault("sv_perk_unlimited_ammo",1))) { return 1; } return 0; }
is_true
needs#include common_scripts/utility;
andgetdvarintdefault
needs#include maps/mp/_utility;
You can do the same for the duration and replace
wait 20;
withwait getdvarintdefault("sv_perk_unlimited_ammo_duration",20);
Or if you don't want to do that you can also change it to
maps/mp/zombies/_zm_powerups::func_should_always_drop
to use the original one and make your code a bit tidier.I haven't ever done stuff with servers, just hosting normally games with my friends, but good info for anyone who might care.
And dunno why I didn't just use the original function, lol.Enki said in [GSC] Zombies Custom Powerup | Unlimited Ammo:
Ox_
there is something i dont like about loops with wait
just a personal thingturn_on_unlimited_ammo() { level endon("game_ended"); self endon("disonnect"); self endon("end_unlimited_ammo"); self setWeaponAmmoClip(self GetCurrentWeapon(), 150); //does it one time if you pick it up for(;;) { self waittill ( "weapon_fired"); //simply set the current mag to be full on a loop self setWeaponAmmoClip(self GetCurrentWeapon(), 150); } }
Oh yeah, that's surely better.
Not sure why I haven't been doing that. Probably just something I picked up when I was a big noob and then it became a habit. -
Ox_ After some testing I've determined that in order for this mod to work you have to inject it at the lobby in Redacted. Which means as it is right now it won't work loaded as a mod on a Plutonium server. I'm guessing its both the include_powerup() and add_zombie_power() functions being ignored since the server thinks it has already loaded all powerups for the level. Is there some way to add powerups to the the level without injection at the lobby?
This is kinda weird though since adding weapons to the box works fine and its a similar methodology. Using
include_weapons() { include_weapon( "beretta93r_upgraded_zm", 1 ); } custom_add_weapons() { add_zombie_weapon( "beretta93r_upgraded_zm", undefined, &"ZOMBIE_WEAPON_BERETTA93r", 1000, "", "", undefined ); }
will put the upgraded b23r into the box on any map that has the b23r in its fast file.
-
JezuzLizard said in [GSC] Zombies Custom Powerup | Unlimited Ammo:
Ox_ After some testing I've determined that in order for this mod to work you have to inject it at the lobby in Redacted. Which means as it is right now it won't work loaded as a mod on a Plutonium server. I'm guessing its both the include_powerup() and add_zombie_power() functions being ignored since the server thinks it has already loaded all powerups for the level. Is there some way to add powerups to the the level without injection at the lobby?
This is kinda weird though since adding weapons to the box works fine and its a similar methodology. Using
include_weapons() { include_weapon( "beretta93r_upgraded_zm", 1 ); } custom_add_weapons() { add_zombie_weapon( "beretta93r_upgraded_zm", undefined, &"ZOMBIE_WEAPON_BERETTA93r", 1000, "", "", undefined ); }
will put the upgraded b23r into the box on any map that has the b23r in its fast file.
Uh, I have only used this via Redacted when doing testing, and then via Steam when playing with my friends.
So I can't comment on what quirks hosting it via a Plutonium server brings. Sorry.Maybe the Plutonium devs could offer some insight?
-
Ox_ Excuse me, but I was wondering if there's a file as of now or in the future that contains this code for this phenomenal custom unlimited ammo power-up, and if it can or will be easily inserted into the BO2 folder. I'm not very familiar with coding, likely along with some others on this forum, so it would be of great help if you could address whether or not it will be released publicly, or if it is and I'm too stupid to understand where it is. I would very much enjoy using this power-up during games, and many others would too.
-
AndreasOmeir said in [GSC] Zombies Custom Powerup | Unlimited Ammo:
Ox_ Excuse me, but I was wondering if there's a file as of now or in the future that contains this code for this phenomenal custom unlimited ammo power-up, and if it can or will be easily inserted into the BO2 folder. I'm not very familiar with coding, likely along with some others on this forum, so it would be of great help if you could address whether or not it will be released publicly, or if it is and I'm too stupid to understand where it is. I would very much enjoy using this power-up during games, and many others would too.
I've edited & improved it now.
It will now work on all maps (didn't work on Buried and Origins before, luckily randomly decided to test those maps and saw it doesn't work)
And also added a download to a precompiled .gcs. -
Ox_ I tested your rewrite of the mod and it works on Plutonium dedicated servers now!
-
JezuzLizard said in [GSC] Zombies Custom Powerup | Unlimited Ammo:
Ox_ I tested your rewrite of the mod and it works on Plutonium dedicated servers now!
Don't think I really know what that means. Is there something special about that stuff? Did it not work before? Never even been on any servers.
But anyway, glad to hear it's working. -
Ox_ Plutonium is a custom bo2 client that supports 8 player dedicated zombie servers on all maps. It doesn't support GSC injection and instead uses its own modloader similar to Redacted so dedicated servers can load custom GSC mods. The GSC modloader feature is relatively new so it seems to have some interesting behavior sometimes. Eg. your old code not working but your new code does for some reason that I'll look into at some point.
I recommend you try Plutonium sometime since it has a more active playerbase than steam bo2, you can actually find games for all maps usually.
Also, I used your mod as a base to add a few extra powerups in the game files as drops like, the bonus team points, perk bottle, and random weapon. So thanks for the new version again.
Last thing, is it possible for a world at war nacht der untoten style powerup display for the infinite ammo powerup? I think it would it say Infinite Ammo: 20 and tick down from 20 at the bottom of the screen.
-
JezuzLizard said in [GSC] Zombies Custom Powerup | Unlimited Ammo:
Ox_ Plutonium is a custom bo2 client that supports 8 player dedicated zombie servers on all maps. It doesn't support GSC injection and instead uses its own modloader similar to Redacted so dedicated servers can load custom GSC mods. The GSC modloader feature is relatively new so it seems to have some interesting behavior sometimes. Eg. your old code not working but your new code does for some reason that I'll look into at some point.
I recommend you try Plutonium sometime since it has a more active playerbase than steam bo2, you can actually find games for all maps usually.
Also, I used your mod as a base to add a few extra powerups in the game files as drops like, the bonus team points, perk bottle, and random weapon. So thanks for the new version again.
Last thing, is it possible for a world at war nacht der untoten style powerup display for the infinite ammo powerup? I think it would it say Infinite Ammo: 20 and tick down from 20 at the bottom of the screen.
Yeah I know what Plutonium is/does, just didn't know what quirks are related to hosting a server and loading custom gsc, thanks.
And about the old code not working, which map did you try? the old code didn't work in Buried & Origins, as described in the Original post. The delayed registering of the custom powerup pickup function fixed that.And cool that you added some stuff, maybe post it here if you want to share. Some other people might want to use them as well. Maybe I would use it as well next time I play zombies with my friends.
And about having a countdown or whatever to indicate when the powerup ends.
It most certainly is possible, but really cba right now at least. Already spend a few hrs trying to get the native style powerup hud to work via clientfields (as is done in the original game gsc), but every time I just errored out with client field mismatch error, and I have no idea why. So I lost motivation.The reason why I didn't at the very first go for drawing text on the screen, is because I don't remember from on top of my head how to draw 100% safe text. Been years and years since I properly did gsc (good old Xbox 360 RGH days). Would be super pissed if the game crashed due to an overflow on like round 40 or whatever.
I guess like aniprintln
would be safe to use. Looks maybe quite stupid though.
If you want aniprintln
solution, and don't know how to make it yourself, I can make it for you.