Carnage3D - [yet another] GTA1 remake project

Talk about any other games here
User avatar
jericho
Car Jacker
Car Jacker
Posts: 23
Joined: 09 Sep 2019, 20:03

Carnage3D - [yet another] GTA1 remake project

Post by jericho »

Hi!

I've started this project some time ago from scratch, just for fun, and working on it now in my spare time.
Here first progress, nothing special - walking (no physics now), simple collisions with map, debug ui:


My goal is to mimic original game (to some degree), single-player only. No multiplayer is planned for now - its too complicated.

Tools and technologies used - C++11, Visual Studio 2015, GLFW, OpenGL3.2, Dear ImGUI and some other helper librarires.

Current task - adding physics and collision detections. I think Box2D physics library will fit perfectly.
Source code is closed for now, but I hope it will be released some day :)
User avatar
Sektor
Boss
Boss
Posts: 1423
Joined: 04 Mar 2008, 06:51
GH nick: Sektor
Location: GTAMP.com
Contact:

Re: Carnage3D - [yet another] GTA1 remake project

Post by Sektor »

Good luck with your project. I hope it gets passed the alpha/beta stage!
User avatar
jericho
Car Jacker
Car Jacker
Posts: 23
Joined: 09 Sep 2019, 20:03

Re: Carnage3D - [yet another] GTA1 remake project

Post by jericho »

Thanks!
Here little demonstration of how the box2d collision works, exe:
carnage3d_test01.zip
carnage3d test01
(482.88 KiB) Downloaded 644 times
To run this you will need:
1) Microsoft Visual C++ 2015 Redistributable, https://www.microsoft.com/en-us/downloa ... x?id=52685
2) Full version of GTA1 game for windows
3) Hardware that support opengl 3.2
4) Windows 7 preferred

Before launch, edit settings file in gamedata/config/sys_config.json and specify gta1 data location (gta_gamedata_location) and screen params.

I cannot guarantee that this demo will work, but if it does, please let me know.

Btw, press 'C' key for debug panel :)
User avatar
jericho
Car Jacker
Car Jacker
Posts: 23
Joined: 09 Sep 2019, 20:03

Re: Carnage3D - [yet another] GTA1 remake project

Post by jericho »

Now it open source on github: https://github.com/codenamecpp/carnage3d
User avatar
JernejL
Hitman
Hitman
Posts: 141
Joined: 21 Feb 2010, 22:03
GH nick: RedShirt

Re: Carnage3D - [yet another] GTA1 remake project

Post by JernejL »

I checked the code and had good nostalgia moment of my gta1 and gta2 reverse engineering, the code looks good, you did your homework with the file formats, i congratulate you that! Let me know if you have any questions regarding the rest of gta1 file formats (fonts, cmp, g24..) i had my own set of errata on dma documents, so i might be able to help :) Overall this looks like a good start.

As for opengta2 project, you could load gta2 data and gta1 data into a "similar engine", gta1 file formats except for palette weirdness fit into gta2 format well (including car deltas). Even the map slope blocks are identical, just file structure is changed (to clumps).
User avatar
jericho
Car Jacker
Car Jacker
Posts: 23
Joined: 09 Sep 2019, 20:03

Re: Carnage3D - [yet another] GTA1 remake project

Post by jericho »

Thanks, JernejL!
It would be really great if you share that info! I would add it to project repository if you don't mind :)

I'm afraid that GTA2 is too much for me to handle - even both GTA1 and GTA2 has similarities - but it much more complex task to mix them into one. Maybe some day I'll get to this too :)
User avatar
JernejL
Hitman
Hitman
Posts: 141
Joined: 21 Feb 2010, 22:03
GH nick: RedShirt

Re: Carnage3D - [yet another] GTA1 remake project

Post by JernejL »

Actually i'll say that gta2 is easier - the sty files are nearly identical to g24 (same layout of sprites and tiles, better animation support) and file format is better documented - i built a sty tool and it's source code is availible (even tho it's written in pascal - https://gtamp.com/GTA2/gta1-gta2-tool-source-code.7z ).

Map format for gta2 is nearly same as gta1 except better organized into chunks (and files can contain compressed and uncompressed map, compressed map is identical to gta1 ( map grid, columns, blocks pointers ) and uncompressed is 3d array of blocks only ) - i've made converters to convert cmp files to gta2 gmp maps - see https://gtamp.com/GTA2/cmp2gmp.zip

gta2 has same block styles as gta1 with same indexes, plus additional diagonals and partial blocks with highier IDs.
User avatar
jericho
Car Jacker
Car Jacker
Posts: 23
Joined: 09 Sep 2019, 20:03

Re: Carnage3D - [yet another] GTA1 remake project

Post by jericho »

Formats that's one thing, but I mean that gta2 game is more complex in implementation and requires far more time and effort then I can put into...
User avatar
jericho
Car Jacker
Car Jacker
Posts: 23
Joined: 09 Sep 2019, 20:03

Re: Carnage3D - [yet another] GTA1 remake project

Post by jericho »

Current progress:
User avatar
JernejL
Hitman
Hitman
Posts: 141
Joined: 21 Feb 2010, 22:03
GH nick: RedShirt

Re: Carnage3D - [yet another] GTA1 remake project

Post by JernejL »

Like i wrote on youtube, you are doing good progress :) maybe next step is to add some pedestrians? :)
User avatar
jericho
Car Jacker
Car Jacker
Posts: 23
Joined: 09 Sep 2019, 20:03

Re: Carnage3D - [yet another] GTA1 remake project

Post by jericho »

Thanks, JernejL !
Pedestrians and cars traffic are on todo list of current milestone (Tier1). It is one of many thing to implement for the next test build.
User avatar
jericho
Car Jacker
Car Jacker
Posts: 23
Joined: 09 Sep 2019, 20:03

Re: Carnage3D - [yet another] GTA1 remake project

Post by jericho »

It's been awhile since any significant progress, but project is still alive. Recent update - - implemented weapons and explosions.
User avatar
JernejL
Hitman
Hitman
Posts: 141
Joined: 21 Feb 2010, 22:03
GH nick: RedShirt

Re: Carnage3D - [yet another] GTA1 remake project

Post by JernejL »

The weapon behaviors look really good, feels like gta1 too!

Are you intending physics as similar to original or just an reimplementation? gta1 ran 2 physicsal models (dummy car drivers) and live cars, player car always used live cars more exact model, and police also use that under some conditions. dummy car drivers use the live model only when they encounter collisions (until they find path back to road - if they ever can)
User avatar
Sektor
Boss
Boss
Posts: 1423
Joined: 04 Mar 2008, 06:51
GH nick: Sektor
Location: GTAMP.com
Contact:

Re: Carnage3D - [yet another] GTA1 remake project

Post by Sektor »

The physics look great but I guess it's hard to tell how it feels until you actually play it.
User avatar
jericho
Car Jacker
Car Jacker
Posts: 23
Joined: 09 Sep 2019, 20:03

Re: Carnage3D - [yet another] GTA1 remake project

Post by jericho »

JernejL wrote: 28 Aug 2020, 08:11
Are you intending physics as similar to original or just an reimplementation? gta1 ran 2 physicsal models (dummy car drivers) and live cars, player car always used live cars more exact model, and police also use that under some conditions. dummy car drivers use the live model only when they encounter collisions (until they find path back to road - if they ever can)
I'm not sure, but I think it would be more interesting if dummy drivers would behave as live :)
User avatar
jericho
Car Jacker
Car Jacker
Posts: 23
Joined: 09 Sep 2019, 20:03

Re: Carnage3D - [yet another] GTA1 remake project

Post by jericho »

If anyone knows how vehicles physics works in gta1, please share that information.
User avatar
JernejL
Hitman
Hitman
Posts: 141
Joined: 21 Feb 2010, 22:03
GH nick: RedShirt

Re: Carnage3D - [yet another] GTA1 remake project

Post by JernejL »

jericho wrote: 09 Sep 2020, 12:15 If anyone knows how vehicles physics works in gta1, please share that information.

I'll dig thru my memory of things i remember exist, so here's what i know:

They used a rather simple vehicle model, and as i mentioned they use 2 physics models (dummy driver cars & proper physics cars ).

If we take the original g24 file documents from dma, the description is following:

Code: Select all

weight is a weight descriptor for the car.
max_speed and min_speed are descriptors of the maximum and minimum possible speeds for the car.
acceleration, braking, grip, handling and turning are descriptors of these characteristics of the car.
damagable reflects how easily the car can sustain damage
cx, cy is the pixel co-ordinates of the centre of mass of the car, relative to the graphical centre.
moment is the moment of inertia of the car.
rbp_mass is the total mass of the car.
g1_thrust is the ratio for 1s gear ( only one gear now ).
handbrake_friction is the friction of the handbrake.
footbrake_friction is the friction of the footbrake.
front_brake_bias is the front bias of braking.
turn_ratio is the turn ratio of the car.
drive_wheel_offset, steering_wheel_offset, back_end_slide_value and handbrake_slide_value are more handling controls.

BTW, please check this out, this are some really old corrections to dma documents ( dated year 1998 :) ), and provide some corrections ( like x,y order of coords for doors is wrong):

http://web.archive.org/web/200807050822 ... topic.html

Some more details on physics are here, this is refering to setting tabs in gtacars program (if you need that program let me know):

http://web.archive.org/web/199902031206 ... ss/phy.htm
Specs Tab

A lot of this is for the "computer controlled" car
(eg: The cars that move around with other drivers in)
Weight - The weight of the car - doesn't seem to do anything.
Max. Speed - This sets the Top Speed at which the computer will drive the car
Min Speed - Same as above but for reverse.
Acceleration - How fast the computer controlled model accelerates
Braking - More computer controlled fields
Grip - How much grip the comptuer cars have.
Damagable - This is its hit points. Setting this to 255 will make one tough car! (This is not for bullet damage)
Value - This is how much it fetches, 10 = $12,000 (mint cond.)
Physics Tab

CG_X - Centre of Gravity on X axis: Setting this positive will make the car bear to the left when turning.
CG_Y - No effect.
Moment - The potentioal energy the car has. Setting this too low (eg: 1) will make the car spin insanly.
Mass - The weight of the car, setting this low will make it go faster but the brakes will also be more responsive (makes car go a bit strange) Setting this higher will do the reverse of the above.
Thust - This is the most important one. This is how much thrust is applied to the car model. A high thrust to low weight will result in a very fast car.
Tire Adhesion_X - Setting this higher will make the car go faster. Don't set it too high
Tire Adhesion_Y - Setting this to about 2 will make it feel like you are driving on glue. Setting it to 5 can cause GTA to blue screen!
Steer Tab

Handling - Seems to make no difference to the game.
Turning - No difference.
Turn Ratio - Setting this lower will make the steering less responsive and seting it higher will make it more responsive.
Drive Wheel Offset - Leave this as -25. Setting it to anything else will make the car spin insanly.
Steeringwheel offset - Leave this as 25. Like the drivewheel settings but only kicks in when you steer. Setting it to 0 will make steering very sluggish!
Brake Tab
Handbrake Friction - The amount of friction the handbrake produces against the tyres, if set high it makes a really strong brake, if set low, it means you can do cool powerslides. (0.9 is normal)
Footbrake Friction - Same as above but for the footbrake (down arrow key)
Front Brake Bias - No effect
Back End Slide - No effect
Handbrake Slide - No effect

So it looks like they say a lot of settings are not even used / important, but from what i see the main settings are:

Turn Ratio (responsivness of steering) - i suggest you list and sort all cars by turn ratio, and figure out which cars have high and low value
Drive Wheel Offset, Steeringwheel offset - probably referes to location of wheel points on the sprite - you can verify this by figuring out where car produces skidmarks (create a fully transparent car, see where skidmarks are produced in a screenshot, and then correlate and create similar system to figure out where tyres should be)
CG_X, CG_Y set mass centre on the car sprite, this can be usually fed into a physics engine of choice possibly directly.
Moment - https://en.wikipedia.org/wiki/Potential_energy - i assume this has some factor with mass in how hard the car is to get up to speed and how hard car will push when hitting things, the whole intention of this value seems a bit confusing.
Mass - this is probably again something that can be put in physics engine directly
Thust - this seems like acceleration factor engine produces
Tire Adhesion_X - This is tyre longtitudal adhesion factor (probably also used for rolling friction)
Tire Adhesion_Y - This is tyre lateral adhesion factor

I'd first suggest you put all the gta car values into some excel table, so you can see and sort the values to see what range things have and how they corelate to big, small vehicles and shitty vs sports vehicles.

Additionally i would suggest that you build your own physics model for cars instead of trying to produce same gta behavior code - then just use GTA values for "reference" on how your car model should drive, some values might need scaling (like mass, coordinate system for tyre coordinates.. ).

Usually cars in games are still implemented as raycast cars (basically 4 points on car) where they simulate spring ground contacts and control lateral / longtitudal friction.
This actually is a rather good vehicle model, i use a this in top down city (minus the ground spring thing which is not needed in a gta-ish game), each physics engine has its own way how you do this, but approach is same, this produces most car behaviors easily including handbrake turns, j-turns, etc..

I'm willing to share code i use in my game, i use newton physics engine in my game, maybe that can get you started, what physics engine do you use?
User avatar
jericho
Car Jacker
Car Jacker
Posts: 23
Joined: 09 Sep 2019, 20:03

Re: Carnage3D - [yet another] GTA1 remake project

Post by jericho »

JernejL, Thanks for reply!

I'm using box2d as physics engine, it is 2d only so I have to fake third dimension - though this is almost no problem. I have decided to try this approach instead of using true 3d physics engine because of simplicity.

I played around with gtacars tool a bit, but it produces unpredictable results every time I change physics values - car gets crazy or even game crashes. I found this video tutorial but it didn't really help, there it is advised not to touch anything.

Thanks for links, "After Sales Support" especially, i could not find this one even with wayback machine for some reason.
User avatar
JernejL
Hitman
Hitman
Posts: 141
Joined: 21 Feb 2010, 22:03
GH nick: RedShirt

Re: Carnage3D - [yet another] GTA1 remake project

Post by JernejL »

That video seems to explain some things, momentum seems to be "wind / wheel rolling friction resistance" - essentially how fast will car slow down when no controls are pressed.

I just realised - that channel is probably another gta "old skooler" - Faze from gouranga forums it seems ( http://forums.gtazz.com/profile.php?id=122 )

I think it's still a good idea to just put all these values into a table and see how they relate for each vehicle model.

does box2d have any kind of support for top down vehicles? can it get velocity at point on body and apply force on a point?
User avatar
jericho
Car Jacker
Car Jacker
Posts: 23
Joined: 09 Sep 2019, 20:03

Re: Carnage3D - [yet another] GTA1 remake project

Post by jericho »

JernejL wrote: 10 Sep 2020, 07:35 does box2d have any kind of support for top down vehicles? can it get velocity at point on body and apply force on a point?
Yep, disabling gravity force along Y axis gives "top down" mode.
What I am implemented at this point is: each vehicle is single rigid body with dimensions in meters (1 map unit equals 4 meters). Mass of the body I take directly from style data, I assume that value in kilograms. Applying forces, impulses and torque on it gives some driving-like mechanics.
Post Reply