diff --git a/README.md b/README.md index 08b17270..a5859442 100644 --- a/README.md +++ b/README.md @@ -137,6 +137,7 @@ * Removed ## Buildables +* Added purchase cost * Parts automatically picked up * Zombies no longer attack buildables (except Zombie Shield) diff --git a/_zm_reimagined.gsc b/_zm_reimagined.gsc index efba5d14..16d02d7c 100644 --- a/_zm_reimagined.gsc +++ b/_zm_reimagined.gsc @@ -2190,6 +2190,7 @@ buildbuildables() flag_wait( "initial_blackscreen_passed" ); // wait for buildables to be built wait 1; + updatebuildables(); removebuildable( "turbine", 1 ); } } @@ -2209,6 +2210,11 @@ buildbuildable( buildable, craft ) { if ( isDefined( buildable ) || stub.persistent != 3 ) { + equipname = stub get_equipname(); + stub.cost = 1000; + stub.trigger_hintstring = "Hold ^3[{+activate}]^7 for " + equipname + " [Cost: " + stub.cost + "]"; + stub.trigger_func = ::buildable_place_think; + if (craft) { stub maps/mp/zombies/_zm_buildables::buildablestub_finish_build( player ); @@ -2218,7 +2224,6 @@ buildbuildable( buildable, craft ) } else { - equipname = stub get_equipname(); level.zombie_buildables[stub.equipname].hint = "Hold ^3[{+activate}]^7 to craft " + equipname; stub.prompt_and_visibility_func = ::buildabletrigger_update_prompt; } @@ -2280,6 +2285,234 @@ get_equipname() } } +buildable_place_think() +{ + self endon( "kill_trigger" ); + player_built = undefined; + while ( isDefined( self.stub.built ) && !self.stub.built ) + { + self waittill( "trigger", player ); + if ( player != self.parent_player ) + { + continue; + } + if ( isDefined( player.screecher_weapon ) ) + { + continue; + } + if ( !is_player_valid( player ) ) + { + player thread ignore_triggers( 0.5 ); + } + status = player maps/mp/zombies/_zm_buildables::player_can_build( self.stub.buildablezone ); + if ( !status ) + { + self.stub.hint_string = ""; + self sethintstring( self.stub.hint_string ); + if ( isDefined( self.stub.oncantuse ) ) + { + self.stub [[ self.stub.oncantuse ]]( player ); + } + continue; + } + else + { + if ( isDefined( self.stub.onbeginuse ) ) + { + self.stub [[ self.stub.onbeginuse ]]( player ); + } + result = self maps/mp/zombies/_zm_buildables::buildable_use_hold_think( player ); + team = player.pers[ "team" ]; + if ( isDefined( self.stub.onenduse ) ) + { + self.stub [[ self.stub.onenduse ]]( team, player, result ); + } + if ( !result ) + { + continue; + } + if ( isDefined( self.stub.onuse ) ) + { + self.stub [[ self.stub.onuse ]]( player ); + } + prompt = player maps/mp/zombies/_zm_buildables::player_build( self.stub.buildablezone ); + player_built = player; + self.stub.hint_string = prompt; + self sethintstring( self.stub.hint_string ); + } + } + if ( isDefined( player_built ) ) + { + } + if ( self.stub.persistent == 0 ) + { + self.stub maps/mp/zombies/_zm_buildables::buildablestub_remove(); + thread maps/mp/zombies/_zm_unitrigger::unregister_unitrigger( self.stub ); + return; + } + if ( self.stub.persistent == 3 ) + { + maps/mp/zombies/_zm_buildables::stub_unbuild_buildable( self.stub, 1 ); + return; + } + if ( self.stub.persistent == 2 ) + { + if ( isDefined( player_built ) ) + { + self buildabletrigger_update_prompt( player_built ); + } + if ( !maps/mp/zombies/_zm_weapons::limited_weapon_below_quota( self.stub.weaponname, undefined ) ) + { + self.stub.hint_string = &"ZOMBIE_GO_TO_THE_BOX_LIMITED"; + self sethintstring( self.stub.hint_string ); + return; + } + if ( isDefined( self.stub.bought ) && self.stub.bought ) + { + self.stub.hint_string = &"ZOMBIE_GO_TO_THE_BOX"; + self sethintstring( self.stub.hint_string ); + return; + } + if ( isDefined( self.stub.model ) ) + { + self.stub.model notsolid(); + self.stub.model show(); + } + while ( self.stub.persistent == 2 ) + { + self waittill( "trigger", player ); + if ( isDefined( player.screecher_weapon ) ) + { + continue; + } + if ( !maps/mp/zombies/_zm_weapons::limited_weapon_below_quota( self.stub.weaponname, undefined ) ) + { + self.stub.hint_string = &"ZOMBIE_GO_TO_THE_BOX_LIMITED"; + self sethintstring( self.stub.hint_string ); + return; + } + if ( isDefined( self.stub.built ) && !self.stub.built ) + { + self.stub.hint_string = ""; + self sethintstring( self.stub.hint_string ); + return; + } + if ( player != self.parent_player ) + { + continue; + } + if ( !is_player_valid( player ) ) + { + player thread ignore_triggers( 0.5 ); + } + + if (player.score < self.stub.cost) + { + self play_sound_on_ent( "no_purchase" ); + player maps/mp/zombies/_zm_audio::create_and_play_dialog( "general", "no_money_weapon" ); + continue; + } + + player maps/mp/zombies/_zm_score::minus_to_player_score( self.stub.cost ); + self play_sound_on_ent( "purchase" ); + + self.stub.bought = 1; + if ( isDefined( self.stub.model ) ) + { + self.stub.model thread maps/mp/zombies/_zm_buildables::model_fly_away(); + } + player maps/mp/zombies/_zm_weapons::weapon_give( self.stub.weaponname ); + if ( isDefined( level.zombie_include_buildables[ self.stub.equipname ].onbuyweapon ) ) + { + self [[ level.zombie_include_buildables[ self.stub.equipname ].onbuyweapon ]]( player ); + } + if ( !maps/mp/zombies/_zm_weapons::limited_weapon_below_quota( self.stub.weaponname, undefined ) ) + { + self.stub.hint_string = &"ZOMBIE_GO_TO_THE_BOX_LIMITED"; + } + else + { + self.stub.hint_string = &"ZOMBIE_GO_TO_THE_BOX"; + } + self sethintstring( self.stub.hint_string ); + player maps/mp/zombies/_zm_buildables::track_buildables_pickedup( self.stub.weaponname ); + } + } + else while ( !isDefined( player_built ) || self buildabletrigger_update_prompt( player_built ) ) + { + if ( isDefined( self.stub.model ) ) + { + self.stub.model notsolid(); + self.stub.model show(); + } + while ( self.stub.persistent == 1 ) + { + self waittill( "trigger", player ); + if ( isDefined( player.screecher_weapon ) ) + { + continue; + } + if ( isDefined( self.stub.built ) && !self.stub.built ) + { + self.stub.hint_string = ""; + self sethintstring( self.stub.hint_string ); + return; + } + if ( player != self.parent_player ) + { + continue; + } + if ( !is_player_valid( player ) ) + { + player thread ignore_triggers( 0.5 ); + } + if ( player has_player_equipment( self.stub.weaponname ) ) + { + continue; + } + if (player.score < self.stub.cost) + { + self play_sound_on_ent( "no_purchase" ); + player maps/mp/zombies/_zm_audio::create_and_play_dialog( "general", "no_money_weapon" ); + continue; + } + if ( !maps/mp/zombies/_zm_equipment::is_limited_equipment( self.stub.weaponname ) || !maps/mp/zombies/_zm_equipment::limited_equipment_in_use( self.stub.weaponname ) ) + { + player maps/mp/zombies/_zm_score::minus_to_player_score( self.stub.cost ); + self play_sound_on_ent( "purchase" ); + + player maps/mp/zombies/_zm_equipment::equipment_buy( self.stub.weaponname ); + player giveweapon( self.stub.weaponname ); + player setweaponammoclip( self.stub.weaponname, 1 ); + if ( isDefined( level.zombie_include_buildables[ self.stub.equipname ].onbuyweapon ) ) + { + self [[ level.zombie_include_buildables[ self.stub.equipname ].onbuyweapon ]]( player ); + } + if ( self.stub.weaponname != "keys_zm" ) + { + player setactionslot( 1, "weapon", self.stub.weaponname ); + } + if ( isDefined( level.zombie_buildables[ self.stub.equipname ].bought ) ) + { + self.stub.hint_string = level.zombie_buildables[ self.stub.equipname ].bought; + } + else + { + self.stub.hint_string = ""; + } + self sethintstring( self.stub.hint_string ); + player maps/mp/zombies/_zm_buildables::track_buildables_pickedup( self.stub.weaponname ); + continue; + } + else + { + self.stub.hint_string = ""; + self sethintstring( self.stub.hint_string ); + } + } + } +} + buildabletrigger_update_prompt( player ) { can_use = 0; @@ -2689,6 +2922,21 @@ buildablestub_build_succeed() } } +// adds updated hintstring and functionality +updatebuildables() +{ + foreach (stub in level._unitriggers.trigger_stubs) + { + if(IsDefined(stub.equipname)) + { + equipname = stub get_equipname(); + stub.cost = 1000; + stub.trigger_hintstring = "Hold ^3[{+activate}]^7 for " + equipname + " [Cost: " + stub.cost + "]"; + stub.trigger_func = ::buildable_place_think; + } + } +} + removebuildable( buildable, after_built ) { if (!isDefined(after_built))