Results 1 to 1 of 1
  1. #1
    bhfff's Avatar
    Join Date
    Nov 2012
    Gender
    male
    Posts
    162
    Reputation
    34
    Thanks
    619
    My Mood
    Amused

    Calculate the distance of an entity relative to your location (ASM)

    Cheat engine is your friend.

    This code will calculate the distance of an enemy or more, relative to your player coordinates and store it into a variable.

    It is useful for teleportation methods, for example you want to teleport to your nearest ally or on top of an enemy.

    Maybe there's an object on the ground and you want to make a teleport skill so the player can collect objects tha are in a certain range.

    There's more that you can do with this!

    Code:
    fld [PlayerX]
    fsub [OtherEntityX]
    fmul ST(0)
    fstp [distanceX] //dx^2
    
    fld [PlayerY]
    fsub [OtherEntityY]
    fmul ST(0)
    fstp [distanceY] //dy^2
    
    fld [PlayerZ]
    fsub [OtherEntityZ]
    fmul ST(0)
    fstp [distanceZ] //dz^2
    
    fld [distanceX]
    fadd [distanceY]
    fadd [distanceZ]
    fsqrt
    fstp [distanceTotal]// sqrt(dx^2 + dz^2 + dy^2) = distance
    [distanceTotal] Contains the distance of that player/entity.
    Last edited by bhfff; 11-24-2019 at 04:57 PM.

Similar Threads

  1. Does the address of an entity change once that entity has died?
    By phoenix8383 in forum Counter-Strike 2 Coding & Resources
    Replies: 5
    Last Post: 11-21-2015, 01:51 AM
  2. [Help] c++ VS 2012 calculate the FPS in the game
    By VDV777 in forum C++/C Programming
    Replies: 6
    Last Post: 05-19-2013, 01:47 PM
  3. [Source Code] Calculate vector distance
    By master131 in forum Call of Duty Modern Warfare 2 Coding / Programming / Source Code
    Replies: 6
    Last Post: 05-23-2011, 10:43 AM
  4. Replies: 26
    Last Post: 05-05-2011, 03:00 PM
  5. Replies: 10
    Last Post: 10-15-2009, 03:22 PM