Coding

 Reply to this postStart new topic

random liveries

Jeremie21
post Mar 22 2014, 09:31 PM
Post #1


The New Guy!

Posts: 10
Joined: 22-March 14



Hi all,

I used this mods :
http://gtapolicemods.com/showthread.php?12...ht=change+paint

I use the same script for several vehicle. I wanted to know how to modify the script in order to have a single script with all vehicles involved.
I currently use this script about ten vehicle, and I wanted to reduce my list of mods cleo ...


I think the solution lies in these lines :

0A12: get_car 26@ tertiary_color_to 33@ quaternary_color_to 7@
if and
Car.Model(26@) == #TAXI
not 7@ == 255
else_jump @F14WRPJ_443

I tried to add more models after #TAXI, but it doesn't work ...
Go to the top of the page
 
+Quote Post
uokka
post Mar 23 2014, 12:35 PM
Post #2


Actually living entity

Posts: 143
From: Earth
Joined: 15-January 11



CODE
if
  not 7@ == 255
then
  if OR
    Car.Model(26@) == #TAXI
    Car.Model(26@) == #ADMIRAL
    Car.Model(26@) == #ALPHA
  then
    jump @some_where
  end
else
  jump @F14WRPJ_443
end


--------------------
My english is just perfekt. I am only not sure, whether I it rightly utilize..
. . .
Go to the top of the page
 
+Quote Post
Jeremie21
post Mar 23 2014, 01:19 PM
Post #3


The New Guy!

Posts: 10
Joined: 22-March 14



thank you for the answer, but an error message starts :

Label "some_where" non trouvé.

I sent you the entire script by mp (in red the part I posted)
Go to the top of the page
 
+Quote Post
uokka
post Mar 23 2014, 01:33 PM
Post #4


Actually living entity

Posts: 143
From: Earth
Joined: 15-January 11



Doesn't surprise me. q:

Try this:

NOTE: For some reason, the site puts an additional "{" in the code.
Deji, you need to fix this!
{$CLEO .cs}

//-------------MAIN---------------
thread 'F14WRPJ'

:F14WRPJ_11
wait 0
if
Player.Defined($PLAYER_CHAR)
else_jump @F14WRPJ_11
0A8D: 27@ = read_memory 12010644 size 4 virtual_protect 0
27@ += 4
0A8D: 27@ = read_memory 27@ size 4 virtual_protect 0
28@ = 0
jump @F14WRPJ_78

:F14WRPJ_78
0A8D: 26@ = read_memory 27@ size 1 virtual_protect 0
27@ += 1
if and
26@ >= 0
128 > 26@
else_jump @F14WRPJ_443
005A: 26@ += 28@ // (int)
0A12: get_car 26@ tertiary_color_to 33@ quaternary_color_to 7@

// --------------------------------------------

//if and
//Car.Model(26@) == #TAXI
//not 7@ == 255
//else_jump @F14WRPJ_443

if
7@ == 255
jump @F14WRPJ_443

if OR
Car.Model(26@) == #TAXI
Car.Model(26@) == #ADMIRAL
Car.Model(26@) == #ALPHA
else_jump @F14WRPJ_443

// --------------------------------------------

0209: 20@ = random_int_in_ranges 0 6
if
not 20@ == 0
else_jump @F14WRPJ_293
if
not 20@ == 1
else_jump @F14WRPJ_318
if
not 20@ == 2
else_jump @F14WRPJ_343
if
not 20@ == 3
else_jump @F14WRPJ_368
if
not 20@ == 4
else_jump @F14WRPJ_393
if
not 20@ == 5
else_jump @F14WRPJ_418
jump @F14WRPJ_443

:F14WRPJ_293
06ED: set_car 26@ paintjob 0
0A11: set_car 26@ tertiary_color_to 33@ quaternary_color_to 255
jump @F14WRPJ_443

:F14WRPJ_318
06ED: set_car 26@ paintjob 1
0A11: set_car 26@ tertiary_color_to 33@ quaternary_color_to 255
jump @F14WRPJ_443

:F14WRPJ_343
06ED: set_car 26@ paintjob 2
0A11: set_car 26@ tertiary_color_to 33@ quaternary_color_to 255
jump @F14WRPJ_443

:F14WRPJ_368
06ED: set_car 26@ paintjob 3
0A11: set_car 26@ tertiary_color_to 33@ quaternary_color_to 255
jump @F14WRPJ_443

:F14WRPJ_393
06ED: set_car 26@ paintjob 4
0A11: set_car 26@ tertiary_color_to 33@ quaternary_color_to 255
jump @F14WRPJ_443

:F14WRPJ_418
06ED: set_car 26@ paintjob -1
0A11: set_car 26@ tertiary_color_to 33@ quaternary_color_to 255
jump @F14WRPJ_443

:F14WRPJ_443
28@ += 256
28@ > 35584
else_jump @F14WRPJ_78
jump @F14WRPJ_475

:F14WRPJ_475
wait 0
if
Actor.DrivingVehicleType($PLAYER_ACTOR, #TAXI)
else_jump @F14WRPJ_11
03C0: 0@ = actor $PLAYER_ACTOR car
0A12: get_car 0@ tertiary_color_to 33@ quaternary_color_to 7@
if and
0AB0: key_pressed 80
0AB0: key_pressed 48
else_jump @F14WRPJ_589
06ED: set_car 0@ paintjob 0
0A11: set_car 0@ tertiary_color_to 33@ quaternary_color_to 255
wait 50
097A: play_audio_at 0.0 0.0 0.0 event 1138
wait 50
jump @F14WRPJ_11

:F14WRPJ_589
if and
0AB0: key_pressed 80
0AB0: key_pressed 57
else_jump @F14WRPJ_661
06ED: set_car 0@ paintjob 1
0A11: set_car 0@ tertiary_color_to 33@ quaternary_color_to 255
wait 50
097A: play_audio_at 0.0 0.0 0.0 event 1138
wait 50
jump @F14WRPJ_11

:F14WRPJ_661
if and
0AB0: key_pressed 80
0AB0: key_pressed 56
else_jump @F14WRPJ_733
06ED: set_car 0@ paintjob 2
0A11: set_car 0@ tertiary_color_to 33@ quaternary_color_to 255
wait 50
097A: play_audio_at 0.0 0.0 0.0 event 1138
wait 50
jump @F14WRPJ_11

:F14WRPJ_733
if and
0AB0: key_pressed 80
0AB0: key_pressed 55
else_jump @F14WRPJ_805
06ED: set_car 0@ paintjob 3
0A11: set_car 0@ tertiary_color_to 33@ quaternary_color_to 255
wait 50
097A: play_audio_at 0.0 0.0 0.0 event 1138
wait 50
jump @F14WRPJ_11

:F14WRPJ_805
if and
0AB0: key_pressed 80
0AB0: key_pressed 54
else_jump @F14WRPJ_877
06ED: set_car 0@ paintjob 4
0A11: set_car 0@ tertiary_color_to 33@ quaternary_color_to 255
wait 50
097A: play_audio_at 0.0 0.0 0.0 event 1138
wait 50
jump @F14WRPJ_11

:F14WRPJ_877
if and
0AB0: key_pressed 80
0AB0: key_pressed 53
else_jump @F14WRPJ_11
06ED: set_car 0@ paintjob -1
0A11: set_car 0@ tertiary_color_to 33@ quaternary_color_to 255
wait 50
097A: play_audio_at 0.0 0.0 0.0 event 1138
wait 50
jump @F14WRPJ_11


This post has been edited by Deji: Mar 23 2014, 08:39 PM
Reason for edit: Deji: Removed it easy...


--------------------
My english is just perfekt. I am only not sure, whether I it rightly utilize..
. . .
Go to the top of the page
 
+Quote Post
Jeremie21
post Mar 23 2014, 11:49 PM
Post #5


The New Guy!

Posts: 10
Joined: 22-March 14



no it doesn't work ...
Go to the top of the page
 
+Quote Post
uokka
post Mar 24 2014, 12:31 AM
Post #6


Actually living entity

Posts: 143
From: Earth
Joined: 15-January 11



Hey sorry I didn't test this. Didn't even check what the script does.
I simply took your assumption and added model checks.
I just followed the link right now.

If you only want to change the paintjobs of any vehicles, check this out:
http://gtagmodding.com/mods/86-quick-paintjob-changer/

Otherwise, I would have to check why the script looks in vehicle struct etc and thats boring.. tongue.gif

--

Thanks, Deji.

This post has been edited by uokka: Mar 24 2014, 12:32 AM


--------------------
My english is just perfekt. I am only not sure, whether I it rightly utilize..
. . .
Go to the top of the page
 
+Quote Post
Jeremie21
post Mar 24 2014, 09:15 PM
Post #7


The New Guy!

Posts: 10
Joined: 22-March 14



thank you for the link !!
The difference between the two scripts :
in the mine, the game randomly generates the liveries
in want, you must make the change manually

I'm interested in the second,but it would be nice if you found a way to make the game randomly generates the liveries
Go to the top of the page
 
+Quote Post
Jeremie21
post Mar 29 2014, 04:23 PM
Post #8


The New Guy!

Posts: 10
Joined: 22-March 14



I have find the solution for the emergency vehicles :

0A12: get_car 26@ tertiary_color_to 33@ quaternary_color_to 7@
if and
not Car.Wrecked(26@)
0975: car 26@ emergency_vehicle
not 7@ == 255

but for the "normal vehicle", I don't know ...
Go to the top of the page
 
+Quote Post
Jeremie21
post Apr 5 2014, 09:51 PM
Post #9


The New Guy!

Posts: 10
Joined: 22-March 14



I think the problem is the opcode.
opcode 0975 concerning emergency vehicles. Suddenly, I'm looking for similar opcode for standards vehicles.

someone has an idea, please ??...
Go to the top of the page
 
+Quote Post
Deji
post Apr 6 2014, 05:05 PM
Post #10


Coding like a Rockstar!

Group Icon

Posts: 1,468
From: ???
Joined: 28-May 09



QUOTE (Jeremie21 @ Apr 5 2014, 10:51 PM) *
I think the problem is the opcode.
opcode 0975 concerning emergency vehicles. Suddenly, I'm looking for similar opcode for standards vehicles.

someone has an idea, please ??...


I think I only just have an idea of what you want...

I've also discovered the following commands are named very wrongly in the default SB files and in the 'v1' files:
CODE
06EC: get_num_car_colours $CARMOD_CAR store_to $10446
097D: get_num_car_liveries $CARMOD_CAR store_to $10084


They are actually the inverse. 06EC is for paintjobs/liveries and 097D refers to the actual number of possible paintjobs applied to the vehicle.

No matter, though, the following should be compiled with v2 definitions or rewritten with v1 definitions (after which the code will make no sense tongue.gif) and should work mostly:
{$CLEO .cs}
WAIT 0
WHILE TRUE
    WAIT 0
    IF IS_PLAYER_PLAYING $PLAYER_CHAR
    THEN
        GET_CHAR_COORDINATES $PLAYER_ACTOR 0@ 1@ 2@
        
        // start search
        IF FIND_ALL_RANDOM_VEHICLES_IN_SPHERE 0@ 1@ 2@ 100.0 next FALSE skip_dead TRUE store_to 3@
        THEN
            REPEAT
                // check no paintjob has been applied already
                GET_CURRENT_VEHICLE_PAINTJOB 3@ 4@
                IF NOT 4@ > -1
                THEN
                    // check this car can have a paintjob
                    GET_NUM_AVAILABLE_PAINTJOBS 3@ store_to 4@
                    4@ += 1
                        
                    // randomize paintjob
                    GENERATE_RANDOM_INT_IN_RANGE 0 4@ store_to 5@
                    
                    // depending on whether the odds were met, apply the paintjob
                    IF 5@ < 0
                    THEN 5@ = -1
                    END
                    GIVE_VEHICLE_PAINTJOB 3@ 5@
                END
                // continue search
            UNTIL NOT FIND_ALL_RANDOM_VEHICLES_IN_SPHERE 0@ 1@ 2@ 100.0 next TRUE skip_dead TRUE store_to 3@
        END
    END
END


Problems: No easy way to tell if a specific car has already been processed in order to optionally not apply paintjobs to certain vehicles.
A fix for that would require some memory hackage or creating your own pool of data on vehicles (which is somewhat more complex). Both are practises I now like to avoid in CLEO, since it's really not built for it. Of course, you might be able think of something which works for you without creating an ASI.


--------------------
Go to the top of the page
 
+Quote Post
Jeremie21
post Apr 9 2014, 06:04 PM
Post #11


The New Guy!

Posts: 10
Joined: 22-March 14



I added the opcode (I think it is good ...)

CODE
{$CLEO .cs}
WAIT 0
WHILE TRUE
WAIT 0
IF 0256: IS_PLAYER_PLAYING $PLAYER_CHAR
THEN
00A0: GET_CHAR_COORDINATES $PLAYER_ACTOR 0@ 1@ 2@

// start search
IF 0AE2: FIND_ALL_RANDOM_VEHICLES_IN_SPHERE 0@ 1@ 2@ 100.0 next FALSE skip_dead TRUE store_to 3@
THEN
REPEAT
// check no paintjob has been applied already
0988: GET_CURRENT_VEHICLE_PAINTJOB 3@ 4@
IF NOT 4@ > -1
THEN
// check this car can have a paintjob
06EC: GET_NUM_AVAILABLE_PAINTJOBS 3@ store_to 4@
4@ += 1

// randomize paintjob
0209: GENERATE_RANDOM_INT_IN_RANGE 0 4@ store_to 5@

// depending on whether the odds were met, apply the paintjob
IF 5@ < 0
THEN 5@ = -1
END
06ED: GIVE_VEHICLE_PAINTJOB 3@ 5@
END
// continue search
UNTIL 0AE2: NOT FIND_ALL_RANDOM_VEHICLES_IN_SPHERE 0@ 1@ 2@ 100.0 next TRUE skip_dead TRUE store_to 3@
END
END
END


but nothing happens in game ...

Uoka mod allows the same, but manually (press the P key). May be we could ensure that the game does it automatically. No ?

Uoka mods :

CODE
{$CLEO .cs}
0000: NOP

while true
wait 0

if
80DF: not actor $PLAYER_ACTOR driving
then
wait 250
continue
end

if
0AB0: key_pressed 80 // 'P'
jf continue

if and
847A: not actor $PLAYER_ACTOR driving_bike
84A9: not actor $PLAYER_ACTOR driving_heli
84A7: not actor $PLAYER_ACTOR driving_boat
84AB: not actor $PLAYER_ACTOR driving_plane
84C8: not actor $PLAYER_ACTOR driving_flying_vehicle
then

// 03C0: 0@ = actor $PLAYER_ACTOR car
0811: 0@ = actor $PLAYER_ACTOR car // versionC

06EC: get_car 0@ number_of_possible_paintjobs_to 1@

if
1@ > 0
then
1@ -= 1
0988: get_car 0@ paintjob 2@
if
802D: not 2@ >= 1@
then
2@ += 1
06ED: set_car 0@ paintjob 2@
// 0AD1: show_formatted_text_highpriority "Paintjop #%d" time 250 2@
else
06ED: set_car 0@ paintjob -1
// 0AD1: show_formatted_text_highpriority "Paintjop OFF" time 250 2@
end
wait 250
end
end
end
Go to the top of the page
 
+Quote Post
Deji
post Apr 10 2014, 10:36 AM
Post #12


Coding like a Rockstar!

Group Icon

Posts: 1,468
From: ???
Joined: 28-May 09



QUOTE (Jeremie21 @ Apr 9 2014, 07:04 PM) *
but nothing happens in game ...


Only certain vehicles have paint jobs. You cannot apply a paint job to every vehicle, without appropriately adding textures specific for the vehicle.


--------------------
Go to the top of the page
 
+Quote Post
Jeremie21
post Apr 10 2014, 04:34 PM
Post #13


The New Guy!

Posts: 10
Joined: 22-March 14



Yes, I know that all vehicles are not affected. But I use the vehicles on which the script should work. But nothing happens in game. The script works for you ?
Go to the top of the page
 
+Quote Post
Deji
post Apr 10 2014, 05:29 PM
Post #14


Coding like a Rockstar!

Group Icon

Posts: 1,468
From: ???
Joined: 28-May 09



QUOTE (Jeremie21 @ Apr 10 2014, 05:34 PM) *
Yes, I know that all vehicles are not affected. But I use the vehicles on which the script should work. But nothing happens in game. The script works for you ?


Ah, there is an error in one of the opcodes:
CODE
UNTIL 0AE2: NOT FIND_ALL_RANDOM_VEHICLES_IN_SPHERE 0@ 1@ 2@ 100.0 next TRUE skip_dead TRUE store_to 3@


The opcode must begin with 8, e.g. 8XXX, to negate the opcode here. Not needed in my source, obviously, since SB allows NOT to be used when using keywords.


--------------------
Go to the top of the page
 
+Quote Post
Jeremie21
post Apr 10 2014, 05:51 PM
Post #15


The New Guy!

Posts: 10
Joined: 22-March 14



Sorry, I don't understand what you mean.
Can you post the complete correction of the script please ??...
Go to the top of the page
 
+Quote Post
Deji
post Apr 10 2014, 10:17 PM
Post #16


Coding like a Rockstar!

Group Icon

Posts: 1,468
From: ???
Joined: 28-May 09



QUOTE (Jeremie21 @ Apr 10 2014, 06:51 PM) *
Sorry, I don't understand what you mean.
Can you post the complete correction of the script please ??...


You only need to change the line I mentioned:
QUOTE
UNTIL 0AE2: NOT FIND_ALL_RANDOM_VEHICLES_IN_SPHERE 0@ 1@ 2@ 100.0 next TRUE skip_dead TRUE store_to 3@

to
QUOTE
UNTIL 8AE2: NOT FIND_ALL_RANDOM_VEHICLES_IN_SPHERE 0@ 1@ 2@ 100.0 next TRUE skip_dead TRUE store_to 3@



OR, compile the original script I posted using SCR for SB3: http://gtagmodding.com/opcode-database/generator/
Because writing opcodes is a huge time waster.


--------------------
Go to the top of the page
 
+Quote Post
Jeremie21
post Apr 12 2014, 10:27 PM
Post #17


The New Guy!

Posts: 10
Joined: 22-March 14



This doesn't work. The game crashes at launch ...
I tried something else. Starting from the script that I modified for emergency vehicles, I found this opcode 0137.
I tried with one vehicle and it works.
But when I want to put several vehicles in the same script the game crash

Script work

turned.gif
CODE
// This file was decompiled using SASCM.INI published by Seemann (http://sannybuilder.com/files/SASCM.rar) on 13.10.2007

{$VERSION 3.1.0027}
{$CLEO .cs}

//-------------MAIN---------------
thread 'F14WRPJ'

:F14WRPJ_11
wait 0
if
Player.Defined($PLAYER_CHAR)
jf @F14WRPJ_11
0A8D: 27@ = read_memory 12010644 size 4 virtual_protect 0
27@ += 4
0A8D: 27@ = read_memory 27@ size 4 virtual_protect 0
28@ = 0
jump @F14WRPJ_78

:F14WRPJ_78
0A8D: 26@ = read_memory 27@ size 1 virtual_protect 0
27@ += 1
if and
26@ >= 0
128 > 26@
jf @F14WRPJ_443
005A: 26@ += 28@ // (int)
0A12: get_car 26@ tertiary_color_to 33@ quaternary_color_to 7@
if and
0137: is_car_model 26@ model #ALPHA
not 7@ == 255

jf @F14WRPJ_443
0209: 20@ = random_int_in_ranges 0 6
if
not 20@ == 0
jf @F14WRPJ_293
if
not 20@ == 1
jf @F14WRPJ_318
if
not 20@ == 2
jf @F14WRPJ_343
if
not 20@ == 3
jf @F14WRPJ_368
if
not 20@ == 4
jf @F14WRPJ_393
if
not 20@ == 5
jf @F14WRPJ_418
jump @F14WRPJ_443

:F14WRPJ_293
06ED: set_car 26@ paintjob 0
0A11: set_car 26@ tertiary_color_to 33@ quaternary_color_to 255
jump @F14WRPJ_443

:F14WRPJ_318
06ED: set_car 26@ paintjob 1
0A11: set_car 26@ tertiary_color_to 33@ quaternary_color_to 255
jump @F14WRPJ_443

:F14WRPJ_343
06ED: set_car 26@ paintjob 2
0A11: set_car 26@ tertiary_color_to 33@ quaternary_color_to 255
jump @F14WRPJ_443

:F14WRPJ_368
06ED: set_car 26@ paintjob 3
0A11: set_car 26@ tertiary_color_to 33@ quaternary_color_to 255
jump @F14WRPJ_443

:F14WRPJ_393
06ED: set_car 26@ paintjob 4
0A11: set_car 26@ tertiary_color_to 33@ quaternary_color_to 255
jump @F14WRPJ_443

:F14WRPJ_418
06ED: set_car 26@ paintjob -1
0A11: set_car 26@ tertiary_color_to 33@ quaternary_color_to 255
jump @F14WRPJ_443

:F14WRPJ_443
28@ += 256
28@ > 35584
jf @F14WRPJ_78
jump @F14WRPJ_11


Script doesn't work (when I modify the red lines)

0A12: get_car 26@ tertiary_color_to 33@ quaternary_color_to 7@
if or
0137: car 0@ model == #ALPHA
0137: car 0@ model == #BANDITO
0137: car 0@ model == #TAXI
not 7@ == 255


I don't understand why ... Any idea?
Go to the top of the page
 
+Quote Post
Reply to this postStart new topic

5 User(s) are reading this topic (5 Guests and 0 Anonymous Users)
0 Members: