Page 1 of 2

Grand Theft Loco

Posted: 05 Apr 2013, 15:55
by Sektor

Re: Grand Theft Loco

Posted: 05 Apr 2013, 16:22
by elypter
wow
how is that done scriptwise?
can that be done by store car command and remote control?

Re: Grand Theft Loco

Posted: 05 Apr 2013, 16:28
by Sektor
Here's the map: http://gtamp.com/maps/loco.7z

It should support 1-6 players but I only tested 1 and 2. Start it in network mode since it uses a custom gxt.

store and remote control commands are used but the important command is SET since that allows adding of 188 to the last carriage and that is the pointer for the engine! It doesn't have any doors, so ordering peds into there does nothing but at least remote works.

You tap arrows a few times to set speed and direction instead of holding down like you do with cars.

SET is powerful since with the help of other commands, it can be used to manipulate GTA2 memory that isn't normally accessible. Thanks to Jones for his findings on that command.

Re: Grand Theft Loco

Posted: 05 Apr 2013, 17:05
by Sektor
Weirdly, IS_CHAR_PRESSING_HORN is triggered when driving the train backwards, so I used it to detect reverse. The horn button does nothing.

Re: Grand Theft Loco

Posted: 05 Apr 2013, 17:17
by Cuban-Pete
Is it the naked gun 2 and half?

Nice hacking by the way.

Re: Grand Theft Loco

Posted: 05 Apr 2013, 17:25
by Sektor
That's a good name. I thought of calling it The Nudinator and I was going to have a weapon that killed every ped around called The Terminator but it crashed after a short time in multiplayer. Some commands Vike can fix so they don't crash when given invalid addresses, several are already patched in 11.43.

I thought of replacing the N weapon sprite with x-ray glasses, it doesn't have to be a gun :)

Thanks to SET, you can use any command on random/onscreen peds but exploding them or giving them orders crashes after a while, most likely when it gets to a bad address. There are some commands that might be able to check if an address is valid before writing to it.

Re: Grand Theft Loco

Posted: 05 Apr 2013, 17:44
by elypter
have you tried to add a door with stytool yet? then it could work to order a player into the engine

Re: Grand Theft Loco

Posted: 05 Apr 2013, 17:54
by Sektor
It already has 2 doors according to stytool but they don't work and adding more doesn't help. I tried the unlock door command but it didn't help or it crashed.

ORDER_CHAR_TO_DRIVE_CAR makes the player or ped chase the train but once he catches it, he just stops and never tries to get in.

Re: Grand Theft Loco

Posted: 05 Apr 2013, 18:10
by CarThief
That's probaly the craziest thing i've seen all day, any chance you could at some point create a guide on how to (ab)use the SET commands for these kinds of purposes reliabily? Would make for some crazy new missions if these can be used, hehe...
Or atleast makes it quite handy to do stuff with the trains. Perhaps to make em invincible or put 'turrets' on top of them(mini tanks)! Or for the sake of detail simply put a car on the trailer-area of the trains, if they have any (hm, perhaps it could even be taken off, too).

Edit: And with guide i suppose any reliable way to get ahold of a certain otherwise unreachable thing in the game memory, aka if a specific number where to always refer to this or that part of a train. Though i take its far from that easy to do so?

Re: Grand Theft Loco

Posted: 05 Apr 2013, 18:17
by Sektor
I will try to write a guide or at least put comments in my code. I did make a Super Train script before I found out about the SET command by putting tanks on the carriages (that I could get in and STORE) and messing with the GCI strengh settings. I got bored of Super Train since it wasn't nearly as cool as Super Tank.

The gta2manager debug setting, show car/ped IDs helps, since when I got in the last carriage, it said the ID for the engine was 1 higher than the last carriage (it was like 17 and 18). From previous tests (displaying vehicle memory location with ADD_SCORE), I had figured out that each car uses 188 bytes, so I needed to add 188 to the last carriage to get the ID for the engine.

IF you STORE a car or CREATE a car then you can add to it to get the next car.

CAR_DATA car01 (pretend I had some data here)
SET nextcar = ( car01 + 188 )
EXPLODE ( nextcar )

That would explode car02, if you created car02 but if you didn't create car02 then a dummy/AI car would explode.

Re: Grand Theft Loco

Posted: 06 Apr 2013, 01:00
by BenMillard
Want to turn this into a re-usable code which could be copy-pasted into any level via THREAD_TRIGGER and publish it on my site. (With credit to all who help, naturally.)

Does the offset change if the train has more/less carriages?

Re: Grand Theft Loco

Posted: 06 Apr 2013, 01:12
by Sektor
The number of carriages doesn't matter.

Re: Grand Theft Loco

Posted: 06 Apr 2013, 10:10
by Jones
[mis]IF (wait=0)
SET wait=1
STORE_CAR_CHARACTER_IS_IN ( p , carriage )

WHILE_EXEC(NOT(CHECK_CAR_MODEL( carriage,TRAINCAB)))
SET carriage = ( carriage + 188 ) // 188 is the size of vehicle struct
ENDWHILE
SET toot = ( carriage +0 )
TAKE_REMOTE_CONTROL_OF_CAR ( p, toot )
ENDIF[/mis]
Seems to work well, you can enter any carriage and it will loop till the last one and gives you control over it.

edit: changed WHILE_EXEC(CHECK_CAR_MODEL( carriage, TRAIN )) to WHILE_EXEC(NOT(CHECK_CAR_MODEL( carriage,TRAINCAB)))

Re: Grand Theft Loco

Posted: 06 Apr 2013, 10:41
by Sektor
Nice. Works great.

Re: Grand Theft Loco

Posted: 06 Apr 2013, 15:12
by Sektor
I updated Loco so that you can get in any carriage to control the train instead of just the last one. I removed the subroutines and improved the display_message/brief timing. I changed the name of the bonus you get for driving the train backwards. I made it so all peds that you punch die from electrocution and all drivers are aggressive.

Re: Grand Theft Loco

Posted: 07 Apr 2013, 09:34
by Galactic Boy
Game crashes when started. :(

Re: Grand Theft Loco

Posted: 07 Apr 2013, 18:07
by elypter
this would make a map idea of mine even more fun.
i thought about one team having to protect a train until it reaches its target and another team that tries to blow it up.

Re: Grand Theft Loco

Posted: 07 Apr 2013, 18:11
by Sektor
Galactic Boy wrote:Game crashes when started. :(
You have to start it in network mode since it uses a custom GXT or you can copy loco.gxt over e.gxt. It's also possible you downloaded a test version. I updated it about 4 times today just trying different functions on dummy peds. In the current version, all peds get in player 1's car and get out when he does but for reasons I currently don't understand, it seems to stop doing that if you get in a tank or change car.

Re: Grand Theft Loco

Posted: 07 Apr 2013, 20:01
by BenMillard
The sample from Jones doesn't declare all its variables and wait is never used?

Is a control structure around this missing?

Re: Grand Theft Loco

Posted: 07 Apr 2013, 20:05
by Jones
It only works in conjunciton with Sektor's code and wait is indeed used to prevent multpile execution of the code.