GTAMP.com

Grand Theft Auto Multiplayer
It is currently Mon Jan 21, 2019 3:53 am

All times are UTC




Post new topic Reply to topic  [ 148 posts ]  Go to page Previous  1 ... 4, 5, 6, 7, 8  Next
Author Message
 Post subject: Re: SCR decompiler
PostPosted: Tue Dec 20, 2011 1:47 pm 
Offline
User avatar

Joined: Wed Mar 17, 2010 4:07 am
Posts: 414
Location: Wales, UK
I know it's a bit lengthy to do a gang car but it isn't that bad all in all. Two (three if you include the gang info which you need anyway) lines is all that's needed so not really fussed over changing it.

Syntax: [ Download ] [ Hide ]
Using GTA2 Script Syntax Highlighting
CAR_DATA zaib_car
...
SET_GANG_INFO (zaibgang,8,PISTOL,SILENCED_MACHINE_GUN,ROCKET_LAUNCHER,3, 68.3,27.5, 2.0,1,VTYPE,2)
...
LEVELSTART
...
zaib_car = CREATE_GANG_CAR (96.5,40.5,2.0) 2 315 VTYPE END
Parsed in 0.014 seconds, using GeSHi 1.0.8.10


Simples ;-)

PS - TM, any luck with getting true variable names decompiled from, say, map zones correctly? One would guess they were in order in the script anyway (like m01, m02, ,m03... m27 in order) so not too much of a worry overall.

_________________


Top
 Profile  
 
 Post subject: Re: SCR decompiler
PostPosted: Tue Dec 20, 2011 2:48 pm 
Offline
User avatar

Joined: Sat Dec 26, 2009 11:53 pm
Posts: 1101
i know it's possible to create them on runtime but if you have too many of them gta2 acts weirdly and randomly deletes cars, even if the player is inside it sometimes and thus causing a crash.

too bad, but if it are only 2 separate single commands there is nothing you can do.

_________________
yur sa'nok ngeyä


Top
 Profile  
 
 Post subject: Re: SCR decompiler
PostPosted: Tue Dec 20, 2011 3:01 pm 
Offline
User avatar

Joined: Fri Jan 29, 2010 3:00 pm
Posts: 953
Location: F21B3EED
@Pyro, Map zones are already fixed in the decompiler i released with my map editor. It was never about getting "true variable names", that is still impossible, but SCR does store the zone names separately in the file, which i do read now, correctly.

_________________
My GTA2 related projects:


Top
 Profile  
 
 Post subject: Re: SCR decompiler
PostPosted: Fri Jan 20, 2012 2:14 pm 
Offline
User avatar

Joined: Fri Jan 29, 2010 3:00 pm
Posts: 953
Location: F21B3EED
Full source code now available!

(added into the first post: http://gtamp.com/forum/viewtopic.php?f=4&t=447)

_________________
My GTA2 related projects:


Top
 Profile  
 
 Post subject: Re: SCR decompiler
PostPosted: Fri Jan 20, 2012 10:27 pm 
Offline
Hitman
User avatar

Joined: Sun Feb 28, 2010 10:34 pm
Posts: 144
Thanks TM!


Top
 Profile  
 
 Post subject: Re: SCR decompiler
PostPosted: Tue Jan 24, 2012 6:34 pm 
Offline
Mugger

Joined: Mon Jan 23, 2012 11:08 pm
Posts: 10
T.M. wrote:
Pyro wrote:
Just messed about with trailers on cars, and your right about it only working with CAR_DATA (was using PARKED_CAR_DATA previously which doesn't work). Maybe another one to add to list of weirdness. ;-)
Nice, didnt know that! Guess what? I hacked the SCR file again... AND IT WORKS :D LOL so i can make the trailer for those! gta2 supports it but compiler doesnt! damn... who wants me to make the compiler already..? :lol: i do! i start to understand why you guys always use 3d coords btw: because compiler is buggy, some commands works only for cars that have 3d coords etc. :shock: i think i need to find out which commands do that and work around it in my decompiler: atm i just convert 3d to 2d whenever possible, but that might break the scripts after recompile with the bugged compiler. edit: i changed my decompiler to always output 3d coords! too much trouble with all the checks to avoid compiler crashes!


Do create the custom compiler, another step away from half-assed tools from DMA is all good! And write it in a style that you can be confident in releasing, if done it would be a step further into creating a GTA2 clone even if you personally loose interest.

Best regards!


Top
 Profile  
 
 Post subject: Re: SCR decompiler
PostPosted: Mon Feb 06, 2012 7:56 pm 
Offline
User avatar

Joined: Fri Jan 29, 2010 3:00 pm
Posts: 953
Location: F21B3EED
I found out that some official maps use EXEC and ENDEXEC script commands! i wonder what they do, but i think i have an idea: maybe they makes all commands between those 2 commands to execute in one frame, like the WHILE_EXEC loop does? so it could ensure that generators all switch on at the same time. or cars would spawn at same time etc. havent tested yet.

This is from downtown SCR decompiled:
Syntax: [ Download ] [ Hide ]
Using GTA2 Script Syntax Highlighting
DECLARE_CRANE_POWERUP (crane2, gen2, 181, 12, 3)
DECLARE_CRANE_POWERUP (crane4, gen1, 239, 249, 3)
LEVELSTART
EXEC
SET_AMBIENT_LEVEL (0.40, 0)
SWITCH_GENERATOR (gen3, ON)
SWITCH_GENERATOR (gen4, ON)
SWITCH_GENERATOR (gen5, ON)
SWITCH_GENERATOR (gen6, ON)
SWITCH_GENERATOR (gen7, ON)
SWITCH_GENERATOR (gen8, ON)
SWITCH_GENERATOR (gen9, ON)
SWITCH_GENERATOR (gen10, ON)
SWITCH_GENERATOR (gen11, ON)
SWITCH_GENERATOR (gen12, ON)
SWITCH_GENERATOR (gen13, ON)
SWITCH_GENERATOR (gen14, ON)
SWITCH_GENERATOR (gen15, ON)
SWITCH_GENERATOR (gen16, ON)
SWITCH_GENERATOR (gen17, ON)
SWITCH_GENERATOR (gen18, ON)
SWITCH_GENERATOR (gen19, ON)
SWITCH_GENERATOR (gen20, ON)
SWITCH_GENERATOR (gen21, ON)
SWITCH_GENERATOR (gen23, ON)
SWITCH_GENERATOR (gen25, ON)
SWITCH_GENERATOR (gen27, ON)
SWITCH_GENERATOR (gen29, ON)
SWITCH_GENERATOR (gen22, ON)
SWITCH_GENERATOR (gen24, ON)
SWITCH_GENERATOR (gen26, ON)
SWITCH_GENERATOR (gen28, ON)
SWITCH_GENERATOR (gen30, ON)
SWITCH_GENERATOR (gen31, ON)
SWITCH_GENERATOR (gen32, ON)
SWITCH_GENERATOR (gen36, ON)
SWITCH_GENERATOR (gen37, ON)
SWITCH_GENERATOR (gen38, ON)
SWITCH_GENERATOR (gen39, ON)
SWITCH_GENERATOR (gen40, ON)
SWITCH_GENERATOR (gen41, ON)
SWITCH_GENERATOR (gen33, ON)
SWITCH_GENERATOR (gen34, ON)
SWITCH_GENERATOR (gen35, ON)
SWITCH_GENERATOR (gen42, ON)
SWITCH_GENERATOR (gen43, ON)
SWITCH_GENERATOR (gen44, ON)
SWITCH_GENERATOR (gen45, ON)
SWITCH_GENERATOR (gen46, ON)
SWITCH_GENERATOR (gen47, ON)
SWITCH_GENERATOR (gen48, ON)
SWITCH_GENERATOR (gen49, ON)
SWITCH_GENERATOR (gen50, ON)
SWITCH_GENERATOR (gen51, ON)
SWITCH_GENERATOR (gen52, ON)
SWITCH_GENERATOR (gen53, ON)
SWITCH_GENERATOR (gen54, ON)
SWITCH_GENERATOR (gen55, ON)
SWITCH_GENERATOR (gen56, ON)
SWITCH_GENERATOR (gen57, ON)
SWITCH_GENERATOR (gen58, ON)
SWITCH_GENERATOR (gen59, ON)
SWITCH_GENERATOR (gen60, ON)
SWITCH_GENERATOR (gen61, ON)
SWITCH_GENERATOR (gen62, ON)
SWITCH_GENERATOR (gen63, ON)
SWITCH_GENERATOR (gen64, ON)
SWITCH_GENERATOR (gen65, ON)
SWITCH_GENERATOR (gen66, ON)
SWITCH_GENERATOR (gen67, ON)
SWITCH_GENERATOR (gen68, ON)
SWITCH_GENERATOR (gen69, ON)
SWITCH_GENERATOR (gen70, ON)
SWITCH_GENERATOR (gen71, ON)
SWITCH_GENERATOR (gen72, ON)
SWITCH_GENERATOR (gen73, ON)
SWITCH_GENERATOR (gen74, ON)
SWITCH_GENERATOR (gen75, ON)
SWITCH_GENERATOR (gen76, ON)
SWITCH_GENERATOR (gen77, ON)
SWITCH_GENERATOR (gen78, ON)
SWITCH_GENERATOR (gen79, ON)
SWITCH_GENERATOR (gen80, ON)
SWITCH_GENERATOR (gen81, ON)
SWITCH_GENERATOR (gen82, ON)
SWITCH_GENERATOR (gen83, ON)
SWITCH_GENERATOR (gen84, ON)
SWITCH_GENERATOR (gen85, ON)
SWITCH_GENERATOR (gen86, ON)
SWITCH_GENERATOR (gen87, ON)
SWITCH_GENERATOR (gen88, ON)
SWITCH_GENERATOR (gen89, ON)
SWITCH_GENERATOR (gen90, ON)
SWITCH_GENERATOR (gen91, ON)
SWITCH_GENERATOR (gen92, ON)
SWITCH_GENERATOR (gen93, ON)
SWITCH_GENERATOR (gen94, ON)
SWITCH_GENERATOR (gen95, ON)
SWITCH_GENERATOR (gen96, ON)
SWITCH_GENERATOR (gen97, ON)
SWITCH_GENERATOR (gen98, ON)
SWITCH_GENERATOR (gen99, ON)
SWITCH_GENERATOR (gen100, ON)
SWITCH_GENERATOR (gen101, ON)
SWITCH_GENERATOR (gen102, ON)
SWITCH_GENERATOR (gen103, ON)
SWITCH_GENERATOR (gen104, ON)
SWITCH_GENERATOR (gen105, ON)
SWITCH_GENERATOR (gen106, ON)
SWITCH_GENERATOR (gen107, ON)
SWITCH_GENERATOR (gen108, ON)
SWITCH_GENERATOR (gen109, ON)
SWITCH_GENERATOR (gen110, ON)
SWITCH_GENERATOR (gen111, ON)
SWITCH_GENERATOR (gen112, ON)
SET_DIR_OF_TV_VANS (159.00, 137.00)
GIVE_CAR_ALARM (auto1)
GIVE_CAR_ALARM (auto2)
GIVE_CAR_ALARM (auto3)
GIVE_CAR_ALARM (auto4)
GIVE_CAR_ALARM (auto5)
GIVE_CAR_ALARM (auto6)
GIVE_CAR_ALARM (auto7)
GIVE_CAR_ALARM (auto8)
GIVE_CAR_ALARM (auto9)
GIVE_CAR_ALARM (auto10)
GIVE_CAR_ALARM (auto11)
GIVE_CAR_ALARM (auto12)
GIVE_CAR_ALARM (auto15)
GIVE_CAR_ALARM (auto20)
GIVE_CAR_ALARM (auto24)
GIVE_CAR_ALARM (auto30)
GIVE_CAR_ALARM (auto29)
GIVE_CAR_ALARM (auto34)
GIVE_CAR_ALARM (auto40)
GIVE_CAR_ALARM (auto17)
GIVE_CAR_ALARM (auto19)
GIVE_CAR_ALARM (auto21)
GIVE_CAR_ALARM (auto41)
GIVE_CAR_ALARM (auto42)
GIVE_CAR_ALARM (auto22)
GIVE_CAR_ALARM (auto25)
GIVE_CAR_ALARM (auto38)
GIVE_CAR_ALARM (auto28)
ENDEXEC
LEVELEND
 
Parsed in 0.033 seconds, using GeSHi 1.0.8.10

_________________
My GTA2 related projects:


Top
 Profile  
 
 Post subject: Re: SCR decompiler
PostPosted: Mon Feb 06, 2012 11:02 pm 
Offline
User avatar

Joined: Sat Dec 26, 2009 11:53 pm
Posts: 1101
thats what i thought in the beginning already but i didnt test anythign yet

_________________
yur sa'nok ngeyä


Top
 Profile  
 
 Post subject: Re: SCR decompiler
PostPosted: Mon Feb 06, 2012 11:06 pm 
Offline
Psycho
User avatar

Joined: Tue Apr 14, 2009 8:20 am
Posts: 71
Location: The Netherlands
EXEC lets GENERATORs create a weapon in singleplayer right after the game starts, in stead of after the minimum delay. In multiplayer, GENERATORs do this by default. I always wondered why weapon respawns behave differently in single- and multiplayer, and whether there would be a clean workaround. Turns out there is, thanks for finding!


Top
 Profile  
 
 Post subject: Re: SCR decompiler
PostPosted: Thu May 10, 2012 1:27 pm 
Offline
User avatar

Joined: Fri Jan 29, 2010 3:00 pm
Posts: 953
Location: F21B3EED
Has anyone tried to make the if/while structures yet, now when i gave all the code? Where is that T.B. guy anyways? He seemed to be interested in this.

I was thinking this decompiling for if/while structures again, and i got creeps from thinking that it might be impossible, because if the compiler is bugged (which it is), it would produce code that doesnt have any meaningful structure, for example a code such as:
Syntax: [ Download ] [ Hide ]
Using GTA2 Script Syntax Highlighting
if(lol = 5)
    if(wtf = 6)
        do_nowt
    endif
else
    do_nowt
    do_nowt
endif
 
Parsed in 0.014 seconds, using GeSHi 1.0.8.10

Might be compiled & decompiled back to:
Syntax: [ Download ] [ Hide ]
Using GTA2 Script Syntax Highlighting
if(lol = 5)
    do_nowt
    if(wtf = 6)
        do_nowt
        do_nowt
endif
 
Parsed in 0.013 seconds, using GeSHi 1.0.8.10

Which then again is not valid mis code. At least this is the impression i got last time when i looked at the compiled scripts bytecode, there seemed to be some illogicalities with the structures such as that, some else's were missing completely or endif's, or something like that.

I dont have time for this myself, maybe some of you have? I have some thoughts/finds about this decompiling in the last lines of scr_functions.h file if someone wants to take a look.

_________________
My GTA2 related projects:


Top
 Profile  
 
 Post subject: Re: SCR decompiler
PostPosted: Thu May 10, 2012 2:12 pm 
Offline
User avatar

Joined: Sat Dec 26, 2009 11:53 pm
Posts: 1101
i dont think it is a problem if code that doesnt work as scr because the compiler is bugged cannot be decompiled correctly

_________________
yur sa'nok ngeyä


Top
 Profile  
 
 Post subject: Re: SCR decompiler
PostPosted: Thu May 10, 2012 2:20 pm 
Offline
User avatar

Joined: Fri Jan 29, 2010 3:00 pm
Posts: 953
Location: F21B3EED
elypter wrote:
i dont think it is a problem if code that doesnt work as scr because the compiler is bugged cannot be decompiled correctly

God knows how many scripts there are which works, correctly, but when decompiled, doesnt. Because GTA2 allows these bugs to be there, they might not be found yet, until decompiling. So im not sure how useful the decompiler will be, if there is a lot of scripts like that, if not all :lol:

_________________
My GTA2 related projects:


Top
 Profile  
 
 Post subject: Re: SCR decompiler
PostPosted: Thu May 10, 2012 2:33 pm 
Offline
User avatar

Joined: Sat Dec 26, 2009 11:53 pm
Posts: 1101
that bugged else structure doesnt work in game. i avoid "else" most of the time because of that. there is no working map that uses this structure. so at least you dont have to worry about this one

_________________
yur sa'nok ngeyä


Top
 Profile  
 
 Post subject: Re: SCR decompiler
PostPosted: Thu May 10, 2012 2:39 pm 
Offline
User avatar

Joined: Fri Jan 29, 2010 3:00 pm
Posts: 953
Location: F21B3EED
elypter wrote:
that bugged else structure doesnt work in game. i avoid "else" most of the time because of that. there is no working map that uses this structure. so at least you dont have to worry about this one

What i meant was that GTA2 doesnt whine about it, it lets it "work", but the way it works is something different than the code says, for example you might code something and test the map and notice it works just fine, because you actually made mistake in the code, and the result was what you were looking for, by just your luckyness.

For example the else bug, i dont think i noticed it immediately, but after deep testing, i saw there wasnt all right. Sometimes you might code something so complex that it requires a lot of testing to actually notice such a bug.

_________________
My GTA2 related projects:


Top
 Profile  
 
 Post subject: Re: SCR decompiler
PostPosted: Thu May 10, 2012 2:59 pm 
Offline
User avatar

Joined: Sat Dec 26, 2009 11:53 pm
Posts: 1101
oh, ok, these cases cannot be handled correctly then. but fortunately those are very very rare. i cant think of any existing map.

_________________
yur sa'nok ngeyä


Top
 Profile  
 
 Post subject: Re: SCR decompiler
PostPosted: Tue Jun 26, 2012 2:16 pm 
Offline
User avatar

Joined: Fri Jan 29, 2010 3:00 pm
Posts: 953
Location: F21B3EED
I will be doing a full documenation on the SCR file format in here:
http://gtamp.com/forum/viewtopic.php?f=4&t=560&p=6750

_________________
My GTA2 related projects:


Top
 Profile  
 
 Post subject: Re: SCR decompiler
PostPosted: Wed Aug 15, 2012 1:20 pm 
Offline
Psycho

Joined: Wed Aug 08, 2012 9:25 pm
Posts: 51
I think there is an error in src_commands.h:
Code:
#define SCRCMD_SET_GANG_INFO1 223 // DF00
#define SCRCMD_SET_CHAR_MOM_FAT 448 // DF00
...
#define SCRCMD_MAX_COMMANDS 447 // in case needed.

Forgotten test code or easter egg? :lol:


Top
 Profile  
 
 Post subject: Re: SCR decompiler
PostPosted: Wed Aug 15, 2012 2:46 pm 
Offline
User avatar

Joined: Fri Jan 29, 2010 3:00 pm
Posts: 953
Location: F21B3EED
:mrgreen: shh.

How did you find it? Anyways, you won the free invisible teddy bear. Congratulations!

To be honest, I didnt expect anyone to find it ever. ;-)

_________________
My GTA2 related projects:


Top
 Profile  
 
 Post subject: Re: SCR decompiler
PostPosted: Wed Aug 15, 2012 7:14 pm 
Offline
Psycho

Joined: Wed Aug 08, 2012 9:25 pm
Posts: 51
I was curious how the gang (zone) variables got compiled, because the value of the gang name/reference itself (first parameter of SET_GANG_INFO) is without meaning. First I looked into hex dumps of the src and used your command list, but afterwards I found your documentation about strings more helpful. So I searched for the hex value of SET_GANG_INFO in your list and found your joke in doing so. Though needed some time to grasp my finding :D


Top
 Profile  
 
PostPosted: Fri Aug 23, 2013 1:44 pm 
Offline
User avatar

Joined: Fri Jan 29, 2010 3:00 pm
Posts: 953
Location: F21B3EED
Hmm... Its been a whole year from last post? WTF. Time is a bastard. Also, seems like the title has changed magically.

Nobody still got into the if/while things?

I have been doing some silent changes meanwhile, basically thinking how the structures should be represented; one struct per command, or shared structs? I have opened some of the union's into separate structs to make it easier to interpret the structs via another program, which i was also making few months ago, but stopped its development currently; it was supposed to ease up the analyzing and editing of SCR files in binary format.

I dont think i will release my current sources since the changes are minor. I have also renamed some of the "SCRCMD_" enums, and i probably will rename them better in the future (a lot of confusion in the names, 2d name used for 3d commands etc weirdness! (not my fault, lol)).

Oh, and i found "goto" command and its structure was missing from the sources. although, it should not be printed since it is internal command for the loops. Anyways, best to put everything in the sources (at least commented out) if there is some information we have about the SCR format.

Syntax: [ Download ] [ Hide ]
Using GTA2 Script Syntax Highlighting
//TWO_PARAMS_LAYOUT(GOTO, sprintf_str("GOTO"); // correct struct, but format not figured out yet;
Parsed in 0.013 seconds, using GeSHi 1.0.8.10


BTW, what the hell were the code tags for C++ ?

_________________
My GTA2 related projects:


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 148 posts ]  Go to page Previous  1 ... 4, 5, 6, 7, 8  Next

All times are UTC


Who is online

Users browsing this forum: No registered users and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group