Coding

 Reply to this postStart new topic

Is car target entity?

Sweet
post Dec 17 2010, 03:00 PM
Post #1


Ameteur Member

Posts: 48
Joined: 19-August 10



Here's the deal:
CODE
0A8D: 40@ = read_memory 0xB6F028 size 4 virtual_protect 0 // Read CCamera base address
40@ += 0x958 // Target Entity Pointer
0A8D: 40@ = read_memory 40@ size 4 virtual_protect 0 // Read target entity pointer
0A97: 41@ = car 20@ struct // get car's struct
0AEB: 41@ = car_struct 41@ handle // get handle of car by it's struct
if
003B:  40@ == 41@ // (int) // check, is car handle is target entity
jf @CR_3

I know, there's a mistake in code so help me out with it. Game just crashes, im now trying some different variants to get working it. Halp.
Go to the top of the page
 
+Quote Post
Silent
post Dec 17 2010, 03:12 PM
Post #2


The master of cut retort

Group Icon

Posts: 239
From: Warsaw, PL
Joined: 21-July 10



SANNY
0A8D: 40@ = read_memory 40@ size 4 virtual_protect 0 // Read target entity pointer
0A97: 41@ = car 20@ struct // get car's struct
0AEB: 41@ = car_struct 41@ handle // get handle of car by it's struct
if
003B:  40@ == 41@ // (int) // check, is car handle is target entity
jf @CR_3


You're comparing car struct pointer (40@) with car handle (41@ + it is weird - you're getting car struct, and car handle from struct, so in theory 41@ == 20@). I think that you can try to remove 0AEB - car struct will be compared with car struct then:

SANNY
0A8D: 40@ = read_memory 40@ size 4 virtual_protect 0 // Read target entity pointer (pointer to struct)
0A97: 41@ = car 20@ struct // get car's struct
003B:  40@ == 41@ // (int) // check, is car handle is target entity
jf @CR_3


Edit:
QUOTE
[2010-12-08]
(18:22:47) Silent: It is pointer to struct, yep?
(18:22:54) Silent: So we have to use 'struct X handle' opcode?
(18:23:00) Deji: Yeah


This post has been edited by Silent: Dec 17 2010, 03:23 PM
Go to the top of the page
 
+Quote Post
Sweet
post Dec 17 2010, 06:43 PM
Post #3


Ameteur Member

Posts: 48
Joined: 19-August 10



As far as i understand, its like this:
CODE
0A8D: 40@ = read_memory 0xB6F028 size 4 virtual_protect 0
40@ += 0x958 // Target Entity Pointer
0A8D: 40@ = read_memory 40@ size 4 virtual_protect 0 // Read target entity pointer (pointer to struct)
0A97: 41@ = car 20@ struct // get car's struct
if
003B:  40@ == 41@ // (int)
jf @CR_3

Its crash the game when i see a car near.
Go to the top of the page
 
+Quote Post
Deji
post Dec 17 2010, 08:23 PM
Post #4


Coding like a Rockstar!

Group Icon

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



0xB6F028 is the address of the CCamera structure, not a pointer to it.

SANNY
0A8E: 40@ = 0xB6F028 + 0x958  // 0xB6F980 is the direct address.
0A8D: 40@ = read_memory 40@ size 4 virtual_protect 0 // Read target entity pointer (pointer to struct)
0A97: 41@ = car 20@ struct // get car's struct
if
003B:  40@ == 41@ // (int)
jf @CR_3


That should work.


--------------------
Go to the top of the page
 
+Quote Post
Sweet
post Dec 18 2010, 02:28 PM
Post #5


Ameteur Member

Posts: 48
Joined: 19-August 10



Nope, not working.
Go to the top of the page
 
+Quote Post
Deji
post Dec 19 2010, 01:40 AM
Post #6


Coding like a Rockstar!

Group Icon

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



SANNY
{$CLEO}
0000: cam_test
repeat
    wait 0
until 0ADC:   test_cheat "CAM"
0247: load_model #ADMIRAL
while 8248:   not model #ADMIRAL available
    wait 0
end
04C4: store_coords_to 0@ 1@ 2@ from_actor $PLAYER_ACTOR with_offset 0 3.0 0
00A5: 3@ = create_car #ADMIRAL at 0@ 1@ 2@
000B: 2@ += 3.0
000B: 1@ += 2.0
0A97: 4@ = car 3@ struct
while true
    wait 0
    0A8D: 5@ = read_memory 0xB6F980 size 4 virtual_protect 0
    if
        003B:   5@ == 4@
    then
        0ACD: show_text_highpriority "Car targetted" time 1
    end
    if
        0ADC:   test_cheat "G"
    then
        0158: camera_on_car 3@ 18 2
    end
end


--------------------
Go to the top of the page
 
+Quote Post
Sweet
post Dec 19 2010, 11:48 AM
Post #7


Ameteur Member

Posts: 48
Joined: 19-August 10



It crashes anyway. I tired of this, maybe its exe problem?
Here's version and size in bytes:
ver 1.0us | 13,7 МБ (14 383 616 bytes)
Go to the top of the page
 
+Quote Post
Silent
post Dec 19 2010, 12:21 PM
Post #8


The master of cut retort

Group Icon

Posts: 239
From: Warsaw, PL
Joined: 21-July 10



I have the same EXE (I believe that Deji has it too), so it should work хорошо.

Maybe an error log could help.
Go to the top of the page
 
+Quote Post
Deji
post Dec 19 2010, 03:36 PM
Post #9


Coding like a Rockstar!

Group Icon

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



I can use this with both the compact and hoodlum .exe (1.0 US - same size as yours) with this script... The camera struct should be located at the same place for most 1.0 exe's.

When does that script actually crash?


--------------------
Go to the top of the page
 
+Quote Post
Sweet
post Dec 19 2010, 04:25 PM
Post #10


Ameteur Member

Posts: 48
Joined: 19-August 10



Er, it crashes when i enter test-code "CAM". Car is spawning and game freezes.
And yes, i use hoodlum exe's.

QUOTE
so it should work хорошо.

хорошо лол biggrin.gif
Go to the top of the page
 
+Quote Post
Deji
post Dec 19 2010, 05:02 PM
Post #11


Coding like a Rockstar!

Group Icon

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



It's weird... the only reason I can think of a crash occuring when reading a value is if the memory is part of a function, which it's not.

Try this:
SANNY
{$CLEO}
0000: cam_test
repeat
    wait 0
until 0ADC:   test_cheat "CAM"
0247: load_model #ADMIRAL
while 8248:   not model #ADMIRAL available
    wait 0
end
04C4: store_coords_to 0@ 1@ 2@ from_actor $PLAYER_ACTOR with_offset 0 3.0 0
00A5: 3@ = create_car #ADMIRAL at 0@ 1@ 2@
000B: 2@ += 3.0
000B: 1@ += 2.0
0A97: 4@ = car 3@ struct
0A8D: 5@ = read_memory 0x4054C7 size 4 virtual_protect 1
000A: 5@ += 0x958
while true
    wait 0
    0A8D: 6@ = read_memory 5@ size 4 virtual_protect 0
    if
        003B:   6@ == 4@
    then
        0ACD: show_text_highpriority "Car targetted" time 1
    end
    if
        0ADC:   test_cheat "G"
    then
        0158: camera_on_car 3@ 18 2
    end
end


--------------------
Go to the top of the page
 
+Quote Post
Sweet
post Dec 20 2010, 11:05 AM
Post #12


Ameteur Member

Posts: 48
Joined: 19-August 10



It's working, but i can't goddamn put it into script as is.
CODE
:CR_2
0407: store_coords_to 21@ 22@ 23@ from_car 20@ with_offset 0.0 0.0 0.0 // 21 22 23 - ?????????? ??????
04C4: store_coords_to 24@ 25@ 26@ from_actor $PLAYER_ACTOR with_offset 0.0 0.0 0.0
0509: 27@ = distance_between_XY 21@ 22@ and_XY 24@ 25@
if
  not 27@ >= 60.0
jf @CR_1
{
*******************
TODO: replace by new method including 'reading camera's entyty'
*******************

if
  02CA: car 20@ bounding_sphere_visible
jf @CR_3

*******************
ITS: new variant, awaitng for check
*******************
}
// here's the code have to be placed
03F0: enable_text_draw 1
0407: store_coords_to 1@ 2@ 3@ from_car 20@ with_offset 0.0 0.0 1.5
0227: 28@ = car 20@ health
0227: 32@ = car 20@ health
0A97: 33@ = car 20@ struct
33@ += 34 // car model

I've tried but its crashing, expect your code is ok.
Go to the top of the page
 
+Quote Post
Deji
post Dec 20 2010, 03:35 PM
Post #13


Coding like a Rockstar!

Group Icon

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



This is why I use constants tongue.gif Since I don't know which vars are free, I'll just guess..

Hope this is right
SANNY
:CR_2
0407: store_coords_to 21@ 22@ 23@ from_car 20@ with_offset 0.0 0.0 0.0 // 21 22 23 - ?????????? ??????
04C4: store_coords_to 24@ 25@ 26@ from_actor $PLAYER_ACTOR with_offset 0.0 0.0 0.0
0509: 27@ = distance_between_XY 21@ 22@ and_XY 24@ 25@
if
  not 27@ >= 60.0
jf @CR_1
0A97: 28@ = car 20@ struct
0A8D: 29@ = read_memory 0x4054C7 size 4 virtual_protect 1   // read pointer to CCamera
000A: 29@ += 0x958                                          // add offset to CCamera
0A8D: 29@ = read_memory 29@ size 4 virtual_protect 0
003B:   29@ == 28@
jf @CR_1
03F0: enable_text_draw 1
0407: store_coords_to 1@ 2@ 3@ from_car 20@ with_offset 0.0 0.0 1.5
0227: 28@ = car 20@ health
0227: 32@ = car 20@ health
0A97: 33@ = car 20@ struct
33@ += 34 // car model


--------------------
Go to the top of the page
 
+Quote Post
Sweet
post Dec 20 2010, 06:33 PM
Post #14


Ameteur Member

Posts: 48
Joined: 19-August 10



Huge progress! Game isn't crash but not showing what i need too.

Here's the code as is CODE!!!111111

This post has been edited by Sweet: Dec 20 2010, 06:40 PM
Go to the top of the page
 
+Quote Post
Silent
post Dec 20 2010, 08:47 PM
Post #15


The master of cut retort

Group Icon

Posts: 239
From: Warsaw, PL
Joined: 21-July 10



Umm, 32@ and 33@ are timers, so maybe that's why it shows wrong values?

SANNY
// 21 22 23 - ?????????? ??????


Some Русские литеры? tongue.gif

+

SANNY
0A97: 33@ = car 20@ struct
33@ += 34 // car model
0A8D: 33@ = read_memory 33@ size 2 virtual_protect 0


Why not just use

SANNY
0441: 33@ = car 20@ model

?

This post has been edited by Silent: Dec 20 2010, 08:48 PM
Go to the top of the page
 
+Quote Post
Sweet
post Dec 21 2010, 03:29 PM
Post #16


Ameteur Member

Posts: 48
Joined: 19-August 10



QUOTE
Umm, 32@ and 33@ are timers, so maybe that's why it shows wrong values?

It's great working even if i use them.

QUOTE
// 21 22 23 - ?????????? ??????
Some Русские литеры?

Nah, its wrong code pasted from browser. All the comments i've writing in english only.

QUOTE
Why not just use
CODE
0441: 33@ = car 20@ model

In time when i making it i didn't know about this tongue.gif
So problem is still have no solve.
Go to the top of the page
 
+Quote Post
Deji
post Dec 22 2010, 02:47 PM
Post #17


Coding like a Rockstar!

Group Icon

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



The getLocalVarOffset function seemed to be returning offsets for mission variables or something... Oddly, removing the variables above 33@ seemed to help some things.. Perhaps use of a mission variable sets a mission flag in the thread..


Anyway, I fixed it (couldn't help making some optimisations, but this could still be optimised much more)..

Source


--------------------
Go to the top of the page
 
+Quote Post
Sweet
post Dec 24 2010, 12:47 PM
Post #18


Ameteur Member

Posts: 48
Joined: 19-August 10



Why you remove GetFullScreenXY function? It's not works without it, even if i paste it by my own.
Go to the top of the page
 
+Quote Post
Deji
post Dec 24 2010, 01:18 PM
Post #19


Coding like a Rockstar!

Group Icon

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



Heh, remove this line:
CODE
0AB1: call_scm_func @getFullScreenXY 2 coords_XY 3@ 4@ store_to 3@ 4@


Forgot to remove it. A function call like that isn't really needed.


--------------------
Go to the top of the page
 
+Quote Post
Sweet
post Dec 24 2010, 05:14 PM
Post #20


Ameteur Member

Posts: 48
Joined: 19-August 10



I get it by my own, its NOT working again. Game is not crashing, but not showing the line above cars. Only if i sit into the car, it shows, but in wrong place (somewhere near left bottom of screen)
Go to the top of the page
 
+Quote Post
Reply to this postStart new topic

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