diff --git a/README.md b/README.md index d6303953..be3b4e0a 100644 --- a/README.md +++ b/README.md @@ -424,6 +424,7 @@ ### Tranzit * Any door that requires a Turbine to open is automatically open whenever the power is on * Increased bus speed by 100% +* Powerups dropped within the bus are linked to the bus * Players can sprint and go prone on the bus * Lava in starting area activates after the power is on * Lava destroys grenades instantly diff --git a/scripts/zm/zm_transit/zm_transit_reimagined.gsc b/scripts/zm/zm_transit/zm_transit_reimagined.gsc index d4b6b810..442375cd 100644 --- a/scripts/zm/zm_transit/zm_transit_reimagined.gsc +++ b/scripts/zm/zm_transit/zm_transit_reimagined.gsc @@ -67,6 +67,7 @@ init() level thread power_local_electric_doors_globally(); level thread b23r_hint_string_fix(); level thread power_station_vision_change(); + level thread attach_powerups_to_bus(); } grief_include_weapons() @@ -390,6 +391,43 @@ change_dvar_over_time(dvar, val, time, increment) self setClientDvar(dvar, val); } +attach_powerups_to_bus() +{ + if (!isDefined(level.the_bus)) + { + return; + } + + while (1) + { + level waittill("powerup_dropped", powerup); + + attachpoweruptobus(powerup); + } +} + +attachpoweruptobus( powerup ) +{ + if ( !isdefined( powerup ) || !isdefined( level.the_bus ) ) + return; + + distanceoutsideofbus = 50.0; + pos = powerup.origin; + posinbus = pointonsegmentnearesttopoint( level.the_bus.frontworld, level.the_bus.backworld, pos ); + posdist2 = distance2dsquared( pos, posinbus ); + + if ( posdist2 > level.the_bus.radius * level.the_bus.radius ) + { + radiusplus = level.the_bus.radius + distanceoutsideofbus; + + if ( posdist2 > radiusplus * radiusplus ) + return; + } + + powerup enablelinkto(); + powerup linkto( level.the_bus ); +} + manage_zones( initial_zone ) { level.zone_manager_init_func = ::transit_zone_init;