Trickster wtf?

Discussion in 'Coding' started by ViroMan, Feb 9, 2014.

  1. ViroMan

    ViroMan Black Hole (*sniff*) Bully

    Messages:
    8,382
    Likes Received:
    4
    Trophy Points:
    0
    So I decided to mess around with the vehicle scripts... just... wtf!?
    Changes to imp_jeep.txt

    Code:
    "horsepower"    "50"        // engine power
    changing it does work... why was it set so high? It seems to have no effect when climbing hills at all. Only in how fast it accelerates at all.
    Code:
    "maxrpm"        "500"        // max rounds per minute
    The bad/good... Jeep can't turn worth shit when driving faster then 20mph, still goes same speed as before, and RPM is not noticeably effected.

    How FUCK is maxrpm creating said effect!? WHY WHY WHY is maxrpm tied to the ability to turn when going fast AND NOTHING TO DO WITH RPM!?! The SCRIPTS ARE CURSED!

    edit:
    Setting maxrpm to 300 makes the jeep undrivable except in nearly strait line. It also allows the terrain to effect the vehicle more. Minor bumps can mess with steering significantly.

    Another thing discovered... when going in reverse I have crazy tight control over vehicle. Forward acceleration and reverse acceleration are calculated different somehow. Going in reverse is unaffected by horse power like going forward is. It still jumps to max reverse speed fast.


    Note to all:
    Don't fuck with "massoverride". I have no clue why we are overiding the mass of a vehicle but, if you set it to 0 as the script says is default... you get spinny vehicle of death.
     
    Last edited: Feb 9, 2014
  2. Candles

    Candles CAPTAIN CANDLES, DUN DUN DUN, DUN DUN DUN DUN.

    Messages:
    4,251
    Likes Received:
    10
    Trophy Points:
    0
    Oh no Viroman, that's not the most surprising part of it. The most surprising part is how value for maxRPM is never actually used in the code.
     
  3. ViroMan

    ViroMan Black Hole (*sniff*) Bully

    Messages:
    8,382
    Likes Received:
    4
    Trophy Points:
    0
    wait... what... HOW is it effecting the vehicles if its not in the code!? Is it uploaded strait to the HL engine and completely fucked there?
     
  4. ViroMan

    ViroMan Black Hole (*sniff*) Bully

    Messages:
    8,382
    Likes Received:
    4
    Trophy Points:
    0
    maxRPM is defiantly inversely tied to reverse aceleration. The lower the maxrpm the faster you accelerate backwards and have less control.

    even if empires code doesn't touch that value it is still effecting everything about vehicles.
     
  5. Lazybum

    Lazybum :D Staff Member Moderator

    Messages:
    4,827
    Likes Received:
    190
    Trophy Points:
    0
    That is neat. When you said maxrpm makes vehicles unable to turn I would have guessed it effected the how fast the wheels turned, if it was set so low it would mean the the side that should be spinning faster wasn't making enough of a difference to how fast the other side goes. It would also account for when you hit bumps because all of a sudden the wight of the vehicle would be on one side, enabling it to suddenly turn. Or rather no, that would just mean it would spin out faster if the rpm is higher.

    But anyways after you saying it affects reverse acceleration I don't know what to say, it really is some dark magic.
     
  6. Trickster

    Trickster Retired Developer

    Messages:
    16,576
    Likes Received:
    46
    Trophy Points:
    0
    A lot of the stuff I generally found out by doing what Drag used to do, which was messing about with the HL2 Jalopy within HL2. There are even some unused script lines in there which will activate when dumped into Empires scripts, which is why you can turn in the turbo-jeeps on EPIC.

    Honestly, what you're looking at right there is the tip of the iceberg. It's a tiny fraction of the insanity those scripts will produce. Start getting into serious handling properties and you'll just lose your mind. If it's of any use, here's a script file that Drag and I both extensively commented. It might give you some bits of information. I've cut out the latter half of the file which just contains the sound cues and whatnot, as well as the boost stuff, because I'm hitting max post size. The important info is there either way.

    Code:
    	// Brenodi Empire Medium Tank;  Script last changed January 6 2009
    
    "vehicle"
    {
    	"body"
    	{
    		"countertorquefactor"	"1.5"		// Drag: Script found in Episode 2 jalopy car script. Valve's vehicle movement code seems to accept it. It sometimes stabilizes vehicles, especially the ones with high torque/power. Useful for LT. Only minor affects on most other vehicles. If something messes up, set this to 0 or take it out of script again.
    		"massCenterOverride"	"0 0 -1.5"	// leave at vec3_origin for no override; Drag: First coordinate moves center left/right (don't change it), second : front, rear --> setting it <0 limits the turning ability of a tank "on spot" and a bit on the move, setting it > 0 makes turning slower in the beginning and way faster if you keep the keys pressed  ; third: up/down --> moving it up? (-) counters flipping but hinders hill climbing
    		"massoverride"			"2000"	// in kg, leave at 0 for no override (kg); Drag: This is the physical mass of the tank. Nothing gets added or substracted from this. Note for BE Med: Somehow a lot more driveable with +200 mass than the rest of the vehicles, I suspect its the small wheel size
    		"addgravity"			"0.33"	// keeps car down; Drag: Set it high (0.4+) = vehicles will do crazy things if they try to jump. Set it too low(<0.2), vehicles suspension system dies, no use changing this all too much unless you want to tune hill-climbing capability
    	}
    	"engine"
    	{
    		"horsepower"		"250"		// engine power ; Drag: Not used, vehicle_engines.txt value seems to override this
    		"maxrpm"		"1200"		// max rounds per minute
    		"maxspeed"		"35"		// forward mph ; Drag: Not used, vehicles_engine.txt value seems to override this; rumors say this value is used when a scout with vehicle speed upgrade enters a vehicle (2.24 bug)
    		"maxReverseSpeed"	"10"		// backward mph ; Drag: Not used, vehicles_engine.txt value seems to override this
    		"autotransmission"	"1"		// true for auto, false for manual
    		"axleratio"		"0.6"		// ratio of engine rev to axle rev; Drag: The higher this ratio the faster the engine will rev (--> faster gear changing); Rule of thumb: The smaller the wheels and the more axles there are, the lower this value should be as it multiplies? the torque (too much power on small wheels means instant spinout, see BE arty)
    		"gear"			"2.86"		// 1st gear (max 6 gears) Drag: Likely to be used as "the backwards gear" The higher the values the stronger the gear, the first gear needs to be powerful, else the vehicle can neither brake well nor start moving.
    		"gear"			"1.59"		// 2nd gear 
    		"gear"			"1.17"		// 3rd gear 
    		"gear"			"1.0"		// 4th gear
    		"gear"			"0.84"		// 5th gear
    		"shiftuprpm"		"600"		// max RPMs to switch to a higher gear; Drag: Unsure if this is used, probably overwritten in vehicle_engines.txt
    		"shiftdownrpm"		"300"		// min RPMs to switch to a lower gear; Drag: Unsure if this is used, probably overwritten in vehicle_engines.txt
    	}
    	
    "steering"
    	{
    		"degreesSlow"		"50"	// angle in degrees of steering; Drag: Usually affects steering the most. Going below 20 is bad, going above 60 is bad. Correlates with slowsteeringrate.
    		"degreesFast"		"20"	// angle in degrees of steering; Drag: Uncertain if this works correctly
    		"steeringExponent"	"1.0"	// steering function is linear, then raised to this power to be slower at the beginning of the curve, faster at the end; Having this over 1 makes driving unpleasant on a laggy server
    
    		"slowcarspeed"		"10"	// this is the max speed of "slow"
    		"fastcarspeed"		"20"	// this is the min speed of "fast"
    		"slowsteeringrate"	"1.25"	// this is the speed the wheels are steered when the vehicle is "slow" //Drag: The "softer" way to change steering, less radical than messing with the angles
    		"faststeeringrate"	"0.75"	// this is the speed the wheels are steered when the vehicle is "fast"
    
    		"steeringRestRateSlow"	"4.0"	// this is the speed at which the wheels move toward their resting state (straight ahead) ; Drag: Sometimes increasing this will keep the vehicle on track more, but it already is pretty high
    		"steeringRestRateFast"	"2.0"
    		"turnThrottleReduceSlow"		"0.25" //Drag: Stabilizes the vehicle in curves by making it slower; before you use high values here THINK, if the vehicle gets slower in curves it will shift down a gear and try to become faster again, can be unpleasant depending on your gear/shift settings
    		"turnThrottleReduceFast"		"0.25"
    		"brakeSteeringRateFactor"		"6"
    		"throttleSteeringRestRateFactor"	"2"
    
    		"skidallowed"	"1"	// true/false skid flag; Drag: Might have some influence on steering but nothing enlightening, keep at 1 to enable future use of skid sounds
    		"dustcloud"		"1"	// flag for creating a dustcloud behind vehicle
    	}
    	
    	"wheelsperaxle"	"2"	// wheels per axle
    	//Axle section: For every pair of model attachments (wheel_rx, wheel_lx, etc.) the engine creates an axle between them. These axles NEED an entry in this script else there will be a crash. However even tanks that have 16 (8x2) wheels the engine still only seems to want and use 4 axles. More than 4 entries didn't work in tests atleast. 
    	// front axle
    	"axle"
    	{
    		"torquefactor"	"0.25"	// normalized to 1 across all axles
    		"brakefactor"	"0.25"	// normalized to 1 across all axles
    			
    		"wheel"
    		{
    			"radius"	"15" 	//Drag: governed by the position of the wheel attachment in the MODEL, if you increase this the vehicle will float.
    			"mass"		"250"		// in kg - KrenzO edit: increase this to stop tank from lunging forward on braking
    			"inertia"	"0"		// steady the car (fixes the oscillation of the axles about z) Drag: A value of 0.5 steadies high powered vehicles, but no magical fix here
    			"damping"	"0"		// usually 0 - Duke edit: seems to slow the whole thing down and feels like the rubber is incredibly soft ; Drag: value of 0.5 is possible if you plan on having some kind of slow utility vehicle that shouldn't go anywhere fast
    			"rotdamping"	"0.0"		// usually 0
    			"material"	"jeeptire"	// tire surface properties; Drag: This value correlates with the entry in the surfaceproperties.txt and all files belonging to it (not included in 2.24 empires valves standard is used). This allows you to change the material properties of the wheels, especially the wheel friction. I've send my experimental scripts to trickster if someone needs them
    			"skidmaterial"	"slidingrubbertire"	// surface properties when sliding
    			"brakematerial" "brakingrubbertire"	// surface properties wen breaking
    		}
    		
    		"suspension" //Abandon all hope ye who enter here :(
    		{
    			"springConstant"		"20"		//Strength of spring, lower values will make spring weaker 
    			"springDamping"			"2"
    			"stabilizerConstant"		"20"
    			"springDampingCompression"	"4"
    			"maxBodyForce"			"20"
    		}
    
    		
    	}
    
    	"axle"
    	{
    		"torquefactor"	"0.25"	// normalized to 1 across all axles
    		"brakefactor"	"0.25"	// normalized to 1 across all axles
    			
    		"wheel"
    		{
    			"radius"	"15"
    			"mass"		"250"		// in kg
    			"inertia"	"0"		// steady the car (fixes the oscillation of the axles about z)
    			"damping"	"0"		// usually 0 - Duke edit: seems to slow the whole thing down and feels like the rubber is incredibly soft
    			"rotdamping"	"0.0"		// usually 0
    			"material"	"jeeptire"	// tire surface properties 
    			"skidmaterial"	"slidingrubbertire"	// surface properties when sliding
    			"brakematerial" "brakingrubbertire"	// surface properties wen breaking
    		}
    		
    		"suspension"
    		{
    			"springConstant"		"20"		//Strength of spring, lower values will make spring weaker 
    			"springDamping"			"2"
    			"stabilizerConstant"		"20"
    			"springDampingCompression"	"4"
    			"maxBodyForce"			"20"
    		}
    		
    	}
    
    	"axle"
    	{
    		"torquefactor"	"0.25"	// normalized to 1 across all axles
    		"brakefactor"	"0.25"	// normalized to 1 across all axles
    			
    		"wheel"
    		{
    			"radius"	"15"
    			"mass"		"250"	// in kg
    			"inertia"	"0"		// steady the car (fixes the oscillation of the axles about z)
    			"damping"	"0"		// usually 0 - Duke edit: seems to slow the whole thing down and feels like the rubber is incredibly soft
    			"rotdamping"	"0.0"		// usually 0
    			"material"	"jeeptire"	// tire surface properties 
    			"skidmaterial"	"slidingrubbertire"	// surface properties when sliding
    			"brakematerial" "brakingrubbertire"	// surface properties wen breaking
    		}
    		
    		"suspension"
    		{
    			"springConstant"		"20"		//Strength of spring, lower values will make spring weaker 
    			"springDamping"			"2"
    			"stabilizerConstant"		"20"
    			"springDampingCompression"	"4"
    			"maxBodyForce"			"20"
    		}
    		
    	}
    
    	// rear axle
    	"axle"
    	{
    		"torquefactor"	"0.25"
    		"brakefactor"	"0.25"
    		
    		"wheel"
    		{
    			"radius"	"16"
    			"mass"		"150"
    			"inertia"	"0"		// steady the car (fixes the oscillation of the axles about z)
    			"damping"	"0"
    			"rotdamping"	"0.0"
    			"material"	"jeeptire"
    			"skidmaterial"	"slidingrubbertire"
    			"brakematerial" "brakingrubbertire"
    		}
    		"suspension"
    		{
    			"springConstant"		"20"
    			"springDamping"			"2"
    			"stabilizerConstant"		"20"
    			"springDampingCompression"	"4"
    			"maxBodyForce"			"20"
    		}
    	}
    }
    
     
  7. ViroMan

    ViroMan Black Hole (*sniff*) Bully

    Messages:
    8,382
    Likes Received:
    4
    Trophy Points:
    0
    Thanks for the txt.

    trickster... your script says
    Code:
            "horsepower"        "250"        // engine power ; Drag: Not used, vehicle_engines.txt value seems to override this
    however it effects acceleration. At least for jeeps. I duno about others. Something that changed after change to orange box?
     
  8. Z100000M

    Z100000M Vithered Weteran

    Messages:
    9,120
    Likes Received:
    70
    Trophy Points:
    0
    Krenzo, what the actual fuck.
    Just tell me how one person is able to create chaos with logic.
     
  9. Beerdude26

    Beerdude26 OnThink(){ IsDownYet(); }

    Messages:
    7,243
    Likes Received:
    13
    Trophy Points:
    0
    Nah that wasn't Krenzo's doing, the vehicle code is mainly from Valve. Although Krenzo definitely did not help with making 3-axle vehicles.
     
  10. Trickster

    Trickster Retired Developer

    Messages:
    16,576
    Likes Received:
    46
    Trophy Points:
    0
    To be honest, I think most of the testing we did with this was after the Orangebox port. If that's affecting acceleration as well then it's obviously something we missed. This was done like 3-4 years ago to be fair.
     
  11. ViroMan

    ViroMan Black Hole (*sniff*) Bully

    Messages:
    8,382
    Likes Received:
    4
    Trophy Points:
    0
    Yes it effects acceleration and to a minor degree torque. I will start going through it all again and see what does what.
     
  12. ViroMan

    ViroMan Black Hole (*sniff*) Bully

    Messages:
    8,382
    Likes Received:
    4
    Trophy Points:
    0
    Candles... is vehicle speed hardcoded? No matter what I change I can't get jeep speed to change.

    Tried vehicle_engines.txt and imp_jeep.txt
     
  13. wealthysoup

    wealthysoup Lead Tester

    Messages:
    1,857
    Likes Received:
    0
    Trophy Points:
    0
    I thought it was always done by vehicle_engines.txt. Are you sure that you edited the entry for the right vehicle and engine?

    Im almost certain that it isnt hardcoded
     
  14. CyberKiller

    CyberKiller Nyooks!

    Messages:
    1,107
    Likes Received:
    8
    Trophy Points:
    0
    I remember playing with the vehicle scripts once to try and solve the tank spinning out problem.
    I gave it up as a bad job as the vehicle code is so bad that just creating new physical properties for the tyre/track materials would cause using the handbrake to crash the game.

    As a side note I messed around giving the BE med tank loads of torque and it rise up and pull wheelies all the time. :D
     
  15. ViroMan

    ViroMan Black Hole (*sniff*) Bully

    Messages:
    8,382
    Likes Received:
    4
    Trophy Points:
    0
    standard jeep engine is the first entry in vehicle_engines.txt.

    Here are the speed values:
    vehicle_engines.txt
    default is "Max Speed" "50"

    imp_jeep.txt
    "maxspeed" "65"

    so... ya... jeeps go 80 not 50 or 65.

    Side note: IF I set maxRPM to 5000 something breaks in the code. Engine HP drops to near nothing and max vehicle speed is 43~ ish
     
  16. Candles

    Candles CAPTAIN CANDLES, DUN DUN DUN, DUN DUN DUN DUN.

    Messages:
    4,251
    Likes Received:
    10
    Trophy Points:
    0
    Make sure you got your units set up right. Last time I checked, the game defaults to displaying km/h for speed, but the scripts are written in mph. I can check the code when I get home, though I know for a fact that the max speed isn't hardcoded because it's been changed before.
     
  17. ViroMan

    ViroMan Black Hole (*sniff*) Bully

    Messages:
    8,382
    Likes Received:
    4
    Trophy Points:
    0
    Does 80mph translate into 50 or 65 kph?

    </me googles it> ohh... 50mph = 80kph
    ohh, so it does work I just assumed it didn't. I had completely forgotten your coding predecessor wankers did that weird thing.
     
  18. wealthysoup

    wealthysoup Lead Tester

    Messages:
    1,857
    Likes Received:
    0
    Trophy Points:
    0
    Yeah thats what it was, scripts are measured in mph and vehicle speed display defaults to kph. I remember trickster commenting on this when the bug with the vehicle speed display was fixed.

    So yeah, im not sure if maxspeed is ever used (in the individual vehicle scripts), unless maybe its used to limit the maxspeed no matter which engine is used?
     
  19. McGyver

    McGyver Experimental Pedagogue

    Messages:
    6,533
    Likes Received:
    31
    Trophy Points:
    0
    This is hilarious. First Mars Climate Orbiter now Empires Mod. One day even coders from 'merica will learn that there is no place for Imperial units in computers.
     
  20. wealthysoup

    wealthysoup Lead Tester

    Messages:
    1,857
    Likes Received:
    0
    Trophy Points:
    0
    Top marks for the post as always mcgyver.

    Personally I think itd just simplify it massively to set the default speed to mph, or else mention specifically in scripts that speeds are measured in mph.

    As usual somethings done one way and then later the thing that adds confusion gets implemented without much thought. (In this instance it was vehicle scripts with maxspeed written as mph but assigned no variable. This was fine until the speedo was implemented ingame).

    I'm not making excuses its just interesting how easily these things happen
     

Share This Page