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

Replacing Wallbuys in Existing Stock Maps

broken avatar :(
Created 1 year ago
by marinescdude
0 Members and 1 Guest are viewing this topic.
1,039 views
broken avatar :(
×
broken avatar :(
Location: gb
Date Registered: 1 January 2016
Last active: 2 hours ago
Posts
12
Respect
Forum Rank
Legless Crawler
Primary Group
Member
My Contact & Social Links
More
Just thinking of  using TheSkyeLord's BO ports, seem to work for the mystery box...
Had a look around at some old WaW mods for reference, and initially thought to copy over _zm_weapons.gsc and edit init_weapon_upgrade like so:
Code Snippet
Plaintext
function init_weapon_upgrade()
{
    init_spawnable_weapon_upgrade();
   
    weapon_spawns = ;
    weapon_spawns = GetEntArray( "weapon_upgrade", "targetname" );

    for ( i = 0; i < weapon_spawns.size; i++ )
    {
        mapname = GetCurrentMap(); //no, this is Lua not GSC
        switch(mapname)
        {
        //Kino Der Toten
        case "zm_theater":
            switch ( weapon_spawns[i].zombie_weapon_upgrade )
            {
            case "ar_marksman": //Sheiva
                weapon_spawns[i].zombie_weapon_upgrade = "t5_olympia";
                break;
            case "pistol_burst": //RK5
                weapon_spawns[i].zombie_weapon_upgrade = "t5_m14";
                break;
            case "smg_burst": //Pharo
                weapon_spawns[i].zombie_weapon_upgrade = "t5_pm63";
                break;
            //Remove Vesper
            case "shotgun_precision": //Argus
                weapon_spawns[i].zombie_weapon_upgrade = "t5_stakeout";
                break;
            case "smg_waw_mp40":
                weapon_spawns[i].zombie_weapon_upgrade = "t5_mp40";
                break;
            case "ar_standard": //KN-44
                weapon_spawns[i].zombie_weapon_upgrade = "t5_mp5k";
                break;
            case "ar_accurate": //ICR-1
                weapon_spawns[i].zombie_weapon_upgrade = "t5_m16a1";
                break;
            case "pistol_fullauto": //L-CAR 9
                weapon_spawns[i].zombie_weapon_upgrade = "t5_mpl";
                break;
            case "smg_versatile": //VMP
                weapon_spawns[i].zombie_weapon_upgrade = "t5_ak74u";
                break;*/
            /*case "bowie_knife": //handle these later
                weapon_spawns[i].targetname = "bowie_upgrade";
                break;
            case "bouncingbetty":
                weapon_spawns[i].zombie_weapon_upgrade = "bouncingbetty";
                break;
            case "frag_grenade":
                weapon_spawns[i].zombie_weapon_upgrade = "stielhandgranate";
                break;*/
            }
            break;
       
           ...
       
       }
           
       weapon_spawns[i].weapon = GetWeapon( weapon_spawns[i].zombie_weapon_upgrade )
Spoiler: click to show...
maybe figure out the map-specific part of the code later
Then thought to move the code after that last line and test the switch statement for weapon_spawns[ i ].weapon instead with appropriate GetWeapon calls.
Tried doing similar in reset_wallbuys but I don't think that was meant to work either.

Maybe I'll get help starting on the chalk outlines as well while I'm at it...
Last Edit: March 12, 2023, 06:06:02 pm by marinescdude
broken avatar :(
×
broken avatar :(
Location: gb
Date Registered: 1 January 2016
Last active: 2 hours ago
Posts
12
Respect
Forum Rank
Legless Crawler
Primary Group
Member
My Contact & Social Links
More
After using Cerberus on a few mods I settled on adapting from https://steamcommunity.com/sharedfiles/filedetails/?id=2911456494
zm_swap_weapons.gsc
gamescript
#using scripts\codescripts\struct;
#using scripts\shared\aat_shared;
#using scripts\shared\ai\systems\gib;
#using scripts\shared\ai\zombie_utility;
#using scripts\shared\array_shared;
#using scripts\shared\callbacks_shared;
#using scripts\shared\clientfield_shared;
#using scripts\shared\flag_shared;
#using scripts\shared\laststand_shared;
#using scripts\shared\scene_shared;
#using scripts\shared\system_shared;
#using scripts\shared\util_shared;
#using scripts\zm\_util;
#using scripts\zm\_zm;
#using scripts\zm\_zm_equipment;
#using scripts\zm\_zm_perks;
#using scripts\zm\_zm_powerups;
#using scripts\zm\_zm_score;
#using scripts\zm\_zm_spawner;
#using scripts\zm\_zm_utility;
#using scripts\zm\_zm_weapons;

#namespace zm_swap_weapons;

function autoexec __init__sytem__()
{
    system::register("zm_swap_weapons", &init, &main, undefined);
}

function init()
{
}


function main()
{
    thread swap_chalk();
    level flag::wait_till("initial_blackscreen_passed");
}

function swap_wall_weapon()
{
    rk5 = 0;
    foreach(ent in struct::get_array("weapon_upgrade", "targetname"))
    {
        VAL = ent.zombie_weapon_upgrade;
        if(!isdefined(VAL))
        {
            continue;
        }
        switch( GetDvarString("mapname") )
        {
        case "zm_cosmodrome": //Ascension
            {
                switch(VAL)
                {
                    case "ar_marksman": //Sheiva
                    {
                        ent.zombie_weapon_upgrade = "t5_m14";
                        break;
                    }
                    case "pistol_burst": //RK5
                    {
                        if (rk5 == 0)
                            ent.zombie_weapon_upgrade = "t5_olympia";
                        else
                            ent.zombie_weapon_upgrade = "t5_mp5k";
                       
                        rk5 = 1;
                        break;
                    }
                break;
            }
        }
        if(isdefined(ent.target) && isdefined(VAL))
        {
            struct::get(ent.target, "targetname").model = GetWeapon(ent.zombie_weapon_upgrade).worldmodel;
        }
    }
}

function swap_chalk()
{
    foreach(ent in struct::get_array("weapon_upgrade", "targetname"))
    {
        VAL = ent.zombie_weapon_upgrade;
        if(!isdefined(VAL))
        {
            break;
        }
        switch(VAL)
        {
            case "t5_m14":
            {
                spawn_loc = struct::get(ent.target, "targetname");
                switch( GetDvarString("mapname") )
                {
                case "zm_theater": //Kino der Toten
                    {
                        ent.spawnmodel = util::spawn_model("wallbuy_m14", spawn_loc.origin, spawn_loc.angles);
                        break;
                    }
                case "zm_cosmodrome": //Ascension
                    {
                        ent.spawnmodel = util::spawn_model("wallbuy_m14", spawn_loc.origin + VectorScale((0, -1, 0), 1), spawn_loc.angles);
                        break;
                    }
                case "zm_temple": //Shangri-La
                    {
                        ent.spawnmodel = util::spawn_model("wallbuy_m14", spawn_loc.origin, spawn_loc.angles);
                        break;
                    }
                case "zm_moon":
                    {
                        ent.spawnmodel = util::spawn_model("wallbuy_m14", spawn_loc.origin, spawn_loc.angles);
                        break;
                    }
                }
                break;
            }
        }
    }
}
Very lucky the wallbuys are passed through to the script in the same order every time so we can replace the Ascension starting room RK5 with the Olympia and the other RK5 with the MP5K.
 
spawn_loc.origin + VectorScale((0, -1, 0), 1) allows adjusting the position of the chalk drawing so it matches up with the pop-up model
 
The chalk drawings themselves are spawned in with models (basically just a flat plane with UV set up to point to the relevant material) which I was lazy and unknowledgeable enough to just rip using Greyhound from https://steamcommunity.com/sharedfiles/filedetails/?id=2049603169 and re-export with Birdman's XModel Tools after conversion to .obj
 
The original chalk drawing textures are replaced with blank transparent .tiff images in texture_assets\t7_materials_zombie, easy enough to import in zm_mod.zone with an image,i_t7_zm_chalk_buy_arak_c  etc. entry
Some materials had to be added using APE because they aren't accessible by default (Argus, Pharo (i_t7_zm_chalk_buy_pharaoh_c), MP40, HVK-30).
 
 
zm_swap_weapons.csc
gamescript
#using scripts\codescripts\struct;
#using scripts\shared\callbacks_shared;
#using scripts\shared\clientfield_shared;
#using scripts\shared\flag_shared;
#using scripts\shared\system_shared;
#using scripts\shared\util_shared;
#using scripts\zm\_zm_utility;

#namespace zm_swap_weapons;

function autoexec __init__sytem__()
{
    system::register("zm_swap_weapons", &init, &main, undefined);
}

function init()
{
}

function main()
{
}

function swap_wall_weapon()
{
    //same as in zm_swap_weapons.gsc
}
Edit: To make it clearer, the zm_swap_weapons::swap_wall_weapon() function call should be put before the spawn_list/spawnable_weapon_spawns array set-up in the function. If you can't see those lines of code underneath where you've pasted, you're putting it in the wrong place.
Code Snippet
gamescript
#using scripts\zm\zm_swap_weapons;

//zm_weapons.gsc
function init_spawnable_weapon_upgrade()
{
    zm_swap_weapons::swap_wall_weapon();
   
    //pre-existing code, only copy above
    spawn_list = ;
    spawnable_weapon_spawns = struct::get_array( "weapon_upgrade", "targetname" );
    spawnable_weapon_spawns = ArrayCombine( spawnable_weapon_spawns, struct::get_array( "bowie_upgrade", "targetname" ), true, false );
    spawnable_weapon_spawns = ArrayCombine( spawnable_weapon_spawns, struct::get_array( "sickle_upgrade", "targetname" ), true, false );
    spawnable_weapon_spawns = ArrayCombine( spawnable_weapon_spawns, struct::get_array( "tazer_upgrade", "targetname" ), true, false );
    spawnable_weapon_spawns = ArrayCombine( spawnable_weapon_spawns, struct::get_array( "buildable_wallbuy", "targetname" ), true, false );
   
    ...
   
}

//zm_weapons.csc
function init()
{
    zm_swap_weapons::swap_wall_weapon();

    //pre-existing code, only copy above
    spawn_list = ;
    spawnable_weapon_spawns = struct::get_array( "weapon_upgrade", "targetname" );
    spawnable_weapon_spawns = ArrayCombine( spawnable_weapon_spawns, struct::get_array( "bowie_upgrade", "targetname" ), true, false );
    spawnable_weapon_spawns = ArrayCombine( spawnable_weapon_spawns, struct::get_array( "sickle_upgrade", "targetname" ), true, false );
    spawnable_weapon_spawns = ArrayCombine( spawnable_weapon_spawns, struct::get_array( "tazer_upgrade", "targetname" ), true, false );
    spawnable_weapon_spawns = ArrayCombine( spawnable_weapon_spawns, struct::get_array( "buildable_wallbuy", "targetname" ), true, false );
   
    ...
   
}

Now to figure out how to change the position of the weapon model pop-up...
Last Edit: December 08, 2023, 11:22:05 pm by marinescdude
broken avatar :(
×
broken avatar :(
Location: gb
Date Registered: 1 January 2016
Last active: 2 hours ago
Posts
12
Respect
Forum Rank
Legless Crawler
Primary Group
Member
My Contact & Social Links
More
Trying to implement JBird632's Custom Claymores to replace Trip Mines needs some specific ordering: first add a new wallbuy .gsc-side while you still have location info then delete the previous ones both server- and client-side.
Code Snippet
cpp
//_zm_weapons.gsc

function init_spawnable_weapon_upgrade()
{
    zm_swap_weapons::swap_claymores();
    zm_swap_weapons::swap_wall_weapon();

Evidently trigger_radius_use did not work on its own so time to use unitriggers and then execute zm_claymore::init at the end of the function...
Code Snippet
cpp
//zm_swap_weapons.gsc

#using scripts\zm\zm_claymore;
#using scripts\zm\_zm_unitrigger;

...

function swap_claymores()
{
    foreach(ent in struct::get_array("claymore_purchase", "targetname"))
    {
        VAL = ent.zombie_weapon_upgrade;
        if(!isdefined(VAL))
        {
            continue;
        }
        spawn_loc = struct::get(ent.target, "targetname");
        claymore = Spawn("trigger_radius_use", spawn_loc.origin, 0, 84, 72);
        claymore.targetname = "claymore_trigger";
        claymore zm_unitrigger::create_unitrigger( "Hold ^3&&1^7 to buy Claymores [Cost: 1000]" , 20, &visibility_and_update_prompt);
        if(isdefined(claymore))
            claymore.spawnmodel = util::spawn_model("wallbuy_claymore", spawn_loc.origin + VectorScale((0, -0.5, 0), 1), spawn_loc.angles);
    }
    thread zm_claymore::init();
}

function visibility_and_update_prompt( player )
{
    if(isdefined(self.hint_string))
    {
        self SetHintString( self.hint_string );
    }
    return true;
}

 
change the waittill from trigger to trigger_activated:
Code Snippet
cpp
//zm_claymore.gsc

function purchaseClaymores()
{
    trigger = GetEnt("claymore_trigger", "targetname");
    trigger.zombie_cost = 1000;    
    trigger SetHintString( "Hold ^3&&1^7 to buy Claymores [Cost: 1000]" );    
    trigger SetCursorHint( "HINT_NOICON" );
    trigger.claymore_triggered = false;
   
    thread give_claymores_after_rounds();

    while(1)
    {
        trigger waittill("trigger_activated", player);
   
        ...
       
    }
   
    ...
   
}
(apparently also needed to change a PlaySoundAtPosition to use zmb_cha_ching instead of purchase)
 
 
and delete the Trip Mine structs:
Code Snippet
cpp
//zm_swap_weapons.gsc, zm_swap_weapons.csc

function swap_wall_weapon()
{

    ...

    foreach(ent in struct::get_array("claymore_purchase", "targetname"))
    {
        VAL = ent.zombie_weapon_upgrade;
        if(!isdefined(VAL))
        {
            continue;
        }
        ent struct::delete();
    }
}

 
And I suppose to find out how to make the claymore weaponmodel pop out of the wallbuy...?
Last Edit: July 09, 2023, 04:53:31 pm by marinescdude
broken avatar :(
×
broken avatar :(
Location: gb
Date Registered: 1 January 2016
Last active: 2 hours ago
Posts
12
Respect
Forum Rank
Legless Crawler
Primary Group
Member
My Contact & Social Links
More
Now to figure out how to change the position of the weapon model pop-up...
Either relative movement:
Code Snippet
cpp
case "pistol_burst": //RK5
{
    ent.zombie_weapon_upgrade = "t5_olympia";
    ent.origin += (0, 10, 0);
    spawn_loc = struct::get(ent.target, "targetname");
    spawn_loc.origin += (0, 10, 0);
    break;
}
or repositioning altogether
Code Snippet
cpp
case "smg_fastfire": //Vesper
{
    ent.zombie_weapon_upgrade = "t5_aug";
    ent.origin = (3, 926, -30);
    ent.angles = (0, 180, 0);
    spawn_loc = struct::get(ent.target, "targetname");
    spawn_loc.origin = (3, 926, -30);
    spawn_loc.angles = (0, 180, 0);
    break;
}

broken avatar :(
×
broken avatar :(
Location: usBoston, MA
Date Registered: 7 April 2022
Last active: 5 months ago
Posts
6
Respect
Forum Rank
Legless Crawler
Primary Group
Member
×
Cosmo Wishbone's Contact & Social Links
Hey, so im trying to follow your findings and I have  a question...do I have to edit the _zm_weapons.gsc file and create a zm_swap_weapons.gsc and .csc?
Last Edit: October 11, 2023, 08:49:57 pm by Cosmo Wishbone
broken avatar :(
×
broken avatar :(
Location: gb
Date Registered: 1 January 2016
Last active: 2 hours ago
Posts
12
Respect
Forum Rank
Legless Crawler
Primary Group
Member
My Contact & Social Links
More
To change the train wallbuy on Shadows of Evil, use this:
 
Code Snippet
gamescript
foreach(ent in GetEntArray("train_buyable_weapon", "script_noteworthy"))
    ent.zombie_weapon_upgrade = "s2_sten";

I've yet to figure out how to change the spawned weapon model, currently returning an error indicating that the .model property of the usual ent.target entity is read-only.

 
Loading ...