Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


[C]Get float from game function

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine
View previous topic :: View next topic  
Author Message
Frouk
Grandmaster Cheater
Reputation: 5

Joined: 22 Jun 2021
Posts: 510

PostPosted: Tue Mar 22, 2022 12:20 pm    Post subject: [C]Get float from game function Reply with quote

i wanted to make a teleporter to waypoint but the problem is that i need get z ground so player won't fall off from the map or die when player coords is higher than ground one
Back to top
View user's profile Send private message
Frouk
Grandmaster Cheater
Reputation: 5

Joined: 22 Jun 2021
Posts: 510

PostPosted: Wed Mar 23, 2022 12:00 pm    Post subject: Reply with quote

anyone ?
._.
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 152

Joined: 06 Jul 2014
Posts: 4697

PostPosted: Wed Mar 23, 2022 12:17 pm    Post subject: Reply with quote

Easiest way is to disable fall damage and just teleport the player high up.

Maybe the waypoint also has a z-coordinate you can use?

I guess you could do a scanline going down from high up and detect when it hits the ground. This would involve reverse engineering the game's floor collision detection system- a process that would take a large amount of effort on your part and can't be explained in a forum post or two.
Maybe the game has a function that returns the height of the ground at a certain point, but good luck finding it.

_________________
I don't know where I'm going, but I'll figure it out when I get there.
Back to top
View user's profile Send private message
Frouk
Grandmaster Cheater
Reputation: 5

Joined: 22 Jun 2021
Posts: 510

PostPosted: Wed Mar 23, 2022 1:31 pm    Post subject: Reply with quote

ParkourPenguin wrote:
Easiest way is to disable fall damage and just teleport the player high up.

Maybe the waypoint also has a z-coordinate you can use?

I guess you could do a scanline going down from high up and detect when it hits the ground. This would involve reverse engineering the game's floor collision detection system- a process that would take a large amount of effort on your part and can't be explained in a forum post or two.
Maybe the game has a function that returns the height of the ground at a certain point, but good luck finding it.

well i'm want to call one:
Code:
CWorld::FindGroundZForCoords(CVector2D pos)
{
//bla bla bla
}//taken from IDA
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8585
Location: 127.0.0.1

PostPosted: Wed Mar 23, 2022 8:59 pm    Post subject: Reply with quote

You're missing half of that output if you took that from IDA. What's the return value? Is the function static as well or is it a __thiscall?

Look for references to that function as well to see how it is being called in the actual disassembly. Since it is taking a CVector2D, that could be simplified to just two float/doubles being pushed or moved into the floating point registers or it may be a pointer to an object of that type.

Hard for us to really go off just part of the prototype.

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
Frouk
Grandmaster Cheater
Reputation: 5

Joined: 22 Jun 2021
Posts: 510

PostPosted: Thu Mar 24, 2022 12:35 am    Post subject: Reply with quote

atom0s wrote:
You're missing half of that output if you took that from IDA. What's the return value? Is the function static as well or is it a __thiscall?

Look for references to that function as well to see how it is being called in the actual disassembly. Since it is taking a CVector2D, that could be simplified to just two float/doubles being pushed or moved into the floating point registers or it may be a pointer to an object of that type.

Hard for us to really go off just part of the prototype.

i just given an example, full function:
Code:
float __cdecl CWorld::FindGroundZForCoord(CVector2D posn)
{
  double result; // st7
  CVector v2[4]; // [esp+0h] [ebp-38h] BYREF

  v2[0].x = posn.x;
  v2[0].y = posn.y;
  v2[0].z = 1000.0;
  if ( CWorld::ProcessVerticalLine(v2, -1000.0, &v2[1], &posn, 1, 0, 0, 0, 1, 0, 0) )
    result = v2[1].z;
  else
    result = 20.0;
  return result;
}

there's another but it needs CVector (x,y,z)
Back to top
View user's profile Send private message
TsTg
Master Cheater
Reputation: 5

Joined: 12 Dec 2012
Posts: 340
Location: Somewhere....

PostPosted: Thu Mar 24, 2022 2:42 pm    Post subject: Reply with quote

so in that code it takes the 2D co-ordinate, then assume later the Z axis is 1000....

have you tried using that on the CVector(x,y,z) function tho ?

i agree with ParkourPenguin about disabling the fall damage during the teleport (then maybe disable that after), but as atom0s said, more digging is required into the code and how the methods are called in game.
Back to top
View user's profile Send private message
Frouk
Grandmaster Cheater
Reputation: 5

Joined: 22 Jun 2021
Posts: 510

PostPosted: Thu Mar 24, 2022 2:57 pm    Post subject: Reply with quote

Z is automatically becomes 1000.0 to get the highest coord like, if there's bridge in the game but you want to teleport exactly on the bridge it will give the exact z coord, and in game functions are using more arguments like:
Code:
float __cdecl blabla::bla(CVector pos, CVector retstr)
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8585
Location: 127.0.0.1

PostPosted: Thu Mar 24, 2022 11:29 pm    Post subject: Reply with quote

Frouk wrote:
atom0s wrote:
You're missing half of that output if you took that from IDA. What's the return value? Is the function static as well or is it a __thiscall?

Look for references to that function as well to see how it is being called in the actual disassembly. Since it is taking a CVector2D, that could be simplified to just two float/doubles being pushed or moved into the floating point registers or it may be a pointer to an object of that type.

Hard for us to really go off just part of the prototype.

i just given an example, full function:
Code:
float __cdecl CWorld::FindGroundZForCoord(CVector2D posn)
{
  double result; // st7
  CVector v2[4]; // [esp+0h] [ebp-38h] BYREF

  v2[0].x = posn.x;
  v2[0].y = posn.y;
  v2[0].z = 1000.0;
  if ( CWorld::ProcessVerticalLine(v2, -1000.0, &v2[1], &posn, 1, 0, 0, 0, 1, 0, 0) )
    result = v2[1].z;
  else
    result = 20.0;
  return result;
}

there's another but it needs CVector (x,y,z)


Find references to that call and look at the actual disassembly to see how the parameters are handled and how the call is being made. Then just replicate that in your own code. Given that it is using objects (ie. CVector2D) it's hard to give you a straight answer that will absolutely work since there are countless ways that object could be constructed, or where it stores the actual X/Y/Z coords and so on in it.

But as is that looks very simple to implement once you look at a reference that already is calling it or making use of the same/similar objects and do similar.

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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 vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites