0.3 Style vehicle damage

Started by Gulk2, Mar 30, 2020, 04:06 PM

Previous topic - Next topic

Gulk2

Bulletproof unoccupied vehicles for the Java server but it's really simple if you want to use it in non-java server I think.

MainController

    @Override
    public void onPlayerEnterVehicle(Player player, Vehicle vehicle, int slot) {
        Vehicle v = vehicle;
        VehicleImmunity none = new VehicleImmunity();
        v.setImmunities(none);
    }

    @Override
    public void onPlayerExitVehicle(Player player, Vehicle vehicle) {
        Vehicle v = vehicle;
        //System.out.println(vehicle.getSyncReasonOrdinal());
        //server.sendClientMessage((null), new Colour(255, 0, 255), player.getName() + "VEHSYNC: " +v.getSyncReasonOrdinal() );
        if (v.getSyncReasonOrdinal() == 4) { //4 seems to mean empty
            // so we set bulletproof only when vehcile is empty.
            VehicleImmunity bp = new VehicleImmunity(VehicleImmunity.Flag.BulletProof, VehicleImmunity.Flag.Tyres);
            v.setImmunities(bp);
        }
    }

    @Override
    public void onVehicleRespawn(Vehicle vehicle) {
        Vehicle v = vehicle;
        VehicleImmunity bp = new VehicleImmunity(VehicleImmunity.Flag.BulletProof, VehicleImmunity.Flag.Tyres);
        v.setImmunities(bp);
    }

Then make sure to spawn your vehicles with the immunities, this includes an idle vehicle timeout for respawning.

So, create a new class


public class ServerConfig {

    public static class Setup {
       
    public static void mainVeh(int modelId, int worldId, Vector position, float angle, VehicleColours colours) {
            Vehicle v = server.createVehicle(modelId, worldId, position, angle, colours);
            v.setIdleRespawnTimeout(210000);
            VehicleImmunity bp = new VehicleImmunity(VehicleImmunity.Flag.BulletProof, VehicleImmunity.Flag.Tyres);
        }

 public static void loadVehicles() {
            mainVeh(163, 1, new Vector(-1743.0f, -211.8f, 15.0f), (4.71239f), new VehicleColours(43, 0)); //barracks@Armybase
        }
    }

}

spawn it in MainController

    @Override
    public boolean onServerInitialise() {
        System.out.println("[" + LocalTime.now() + "][SERVER]INITIALIZED");
        Setup.loadVehicles();
       
        return true;

    }

Edit: forgot to add respawn too. added.

Sebastian

This is fun to play around with, sometimes, when players dm alot around vehicles.
"but..but... the car didn't explode T_T"

@Murdock was telling me about Sky-City server where DriverOnWater was enabled, and he was just playing around sometimes by turning it off, and players were wrecked xD

Gulk2

#2
Quote from: Sebastian on Mar 31, 2020, 03:32 PMThis is fun to play around with, sometimes, when players dm alot around vehicles.
"but..but... the car didn't explode T_T"

@Murdock was telling me about Sky-City server where DriverOnWater was enabled, and he was just playing around sometimes by turning it off, and players were wrecked xD
As much as i enjoy the new gameplay with vehicles as a danger of instant explosion, i also enjoyed being able to use them as cover in 0.3 and now with this new sync players cant abuse desynced vehicles (fuck you NubKillerUK) for cover so it's nice!

Oh and this stuff works well for the Rhino tank(make it invincible), which has low hp in vcmp for whatever reason. You can also do stuff like give police vehicles more hp than regular vehicles.

I use this for creating unique groups of vehicles, with unique traits or powers, some with respawn timers, some that dont respawn at idle and just sit wherever players leave them.