Author Topic: Chrisbot6's Support_Trains (BETA!)  (Read 16911 times)

Tilting you say?
Yes. If I use the same tilt node that the player uses I can make the bot tilt too.

You ever get ontrainspawn to work correctly?
I scrapped it because onVehicleSpawn does the same thing and works better.

Yes. If I use the same tilt node that the player uses I can make the bot tilt too.

So trains could tilt upwards/downwards when going on slopes?

2 days and only 2 replies.

Obviously everyone's too busy with go-karts and weapon packs to care about trains.
Are you kidding? I've always awaited the day when I would see trains in Blockland.

Are you kidding? I've always awaited the day when I would see trains in Blockland.

A bit tardy to the party, aren't we?

A bit tardy to the party, aren't we?

Really doesn't matter - this topic deserves all the activity it can get.

Really doesn't matter - this topic deserves all the activity it can get.

I didn't want to type "bump", wasn't buried enough, so by replying to his post, I managed to bump it up and keep it relevant.

Going to finish up some of the current features and upload Alpha 7, then I'll put this on the backburner for a bit to work on Moorshank and other stuff.

Sorry about that, but I can't really do anything else until I get a properly rigged train model to mess with. Maybe I should learn blender.
« Last Edit: September 09, 2013, 12:38:15 PM by chrisbot6 »

I can easily model the train, I just can't do any of the other necessary stuff for blockland to process the model as a bot or vehicle.

I can easily model the train, I just can't do any of the other necessary stuff for blockland to process the model as a bot or vehicle.
Can you possibly send me the .obj of what you had before you realized you'd done goof'd?

I'll explain: If you export the .obj file, I can import it into Milkshape. Which can then export it as a .dts file after I rig it properly.

In other news, ALPHA 7 is uploading soon:
Code: [Select]
- Fixed turning events, perfect corners now possible with a bit of hard work
- Messed with the TrainLoop, made it EVEN MORE frequent which means it should be EVEN MORE reliable.
- Added trainLoopTurn
- Added a MUCH BETTER train registering system
- Added a proper train sound system
- Added Bushido's Hazard train as a test.

- Lots of bugfixes
  - Train braking sound should now play in reverse
  - Debug messages no longer appear in the console unless you set $trainsdebug to true
  - Fixed that horrible bug where trains stop working on servers that are up for a long time (Mainly RTB)
  - Removed a lot of the console spam
  - And other things
« Last Edit: September 14, 2013, 09:38:33 AM by chrisbot6 »

To add a custom train to the mod (must be a bot vehicle) package:
Code: [Select]
function [DATABLOCKNAME]::onAdd(%this,%obj)
    {
        parent::onAdd(%this,%obj);
        PrimeTrainPhysics(%obj,[ENABLEENGINE],[DRAG],[ENGINEPOWER],[ENGINEMAX],[BRAKES],[STARTSOUND],[RUNSOUND],[STOPSOUND],[IDLESOUND],[HORNSOUND]);
    }
Replace "[DATABLOCKNAME]" with the name of your train's datablock. For the rest of the options:
- ENABLEENGINE determines whether or not the train has an engine that can be started/stopped via chat commands or keybinds.
- DRAG determines the slowdown force that acts on the train when it is coming to a stop.
- ENGINEPOWER determines how hard the train is being pushed forward, and plays a part in determining how fast it gets to full speed.
- ENGINEMAX determines how fast the engine is capable of going. Note that this is relitive to the max speed defined in your bot vehicle's datablock.
- BRAKES determines whether or not your train has brakes usable via keybind or chat commands.
- STARTSOUND, RUNSOUND and STOPSOUND, IDLESOUND and HORNSOUND are the sound datablocks that the train uses. Put "0" to not have sound.

Why not just Support_Trains automatically do that for all bot vehicles with isTrain set to true in the datablock? In addition to that, it'd determine all the above values from the datablock fields.

Something like this in a package:

function PlayerData::onAdd(%this, %obj) {
   parent::onAdd(%this, %obj);

   if (%this.isTrain) {
      PrimeTrainPhysics(%obj,
         %this.enableEngine,
         %this.drag,
         %this.enginePower,
         %this.engineMax,
         %this.brakes,
         %this.startSound,
         %this.runSound,
         %this.stopSound,
         %this.idleSound,
         %this.hornSound
      );
   }
}

Something like this in a package:

function PlayerData::onAdd(%this, %obj) {
   parent::onAdd(%this, %obj);

   if (%this.isTrain) {
      PrimeTrainPhysics(%obj,
         %this.enableEngine,
         %this.drag,
         %this.enginePower,
         %this.engineMax,
         %this.brakes,
         %this.startSound,
         %this.runSound,
         %this.stopSound,
         %this.idleSound,
         %this.hornSound
      );
   }
}


Thanks, but I literally just did this (:
Code: [Select]
// cart physics
    function Armor::onAdd(%this,%obj) {
        trainsdebug("Detected AIPlayer added!");
        parent::onAdd(%this,%obj);
       
        %data = %obj.getDatablock();
       
        if(%data.Trainmod_isTrain) {
            // new train init system!
            PrimeTrainPhysics(%obj, %data.Trainmod_engine,%data.Trainmod_drag, %data.Trainmod_enginePower,
            %data.Trainmod_engineMax, %data.Trainmod_brakes, %data.Trainmod_startData, %data.Trainmod_runData,
            %data.Trainmod_stopData, %data.Trainmod_idleData, %data.Trainmod_hornData,%data.Trainmod_soundTick);
        } else {
            trainsdebug("(Not a train)");
        }
    }
   
    function Armor::onRemove(%this,%obj) {
        trainsdebug("Detected AIPlayer removed!");
        %data = %obj.getDatablock();
       
        if(%data.Trainmod_isTrain) {
            StopTrainPhysics(%obj);
        } else {
            trainsdebug("(Not a train)");
        }
       
        // this has to come last this time
        parent::onRemove(%this,%obj);
    }
Shame I just got back, I could've copypasted your code; it's simpler than mine.

Anyway, the datablock vars are now as follows for future reference:
Trainmod_isTrain
Trainmod_engine
Trainmod_enginePower
Trainmod_engineMax
Trainmod_drag
Trainmod_brakes
Trainmod_startData
Trainmod_runData
Trainmod_idleData
Trainmod_hornData
Trainmod_stopData
Trainmod_soundTick
« Last Edit: September 14, 2013, 09:40:33 AM by chrisbot6 »

Can you possibly send me the .obj of what you had before you realized you'd done goof'd?

I'll explain: If you export the .obj file, I can import it into Milkshape. Which can then export it as a .dts file after I rig it properly.

I'll see if I can do that today.

Code: [Select]
    function Armor::onAdd(%this,%obj) {
        %data = %obj.getDatablock();
    }

What are you even doing? %data == %this, lol.

What are you even doing? %data == %this, lol.
I'm stupid.
« Last Edit: September 14, 2013, 05:33:40 PM by chrisbot6 »