Welcome to Open Carnage

A resource for Halo 1 modding and tech, with unique means of rewarding individual content creation and support. Have a wander to see why we're worth the time! EST. 2012

Sign in to follow this  
Followers 0
aLTis

How to detect if object is upside down?

I've spent too much time trying to see if a vehicle is upside down based on its rotations (pitch, yaw and roll). Can anyone write me a function that would check if a vehicle is upside down based on rotations or something?

WaeV likes this

08f9474ede.jpg

Share this post


Link to post
Share on other sites

Members of Open Carnage never see off-site ads.

function is_vehicle_flipped(ObjectID)
     local object = get_object_memory(ObjectID)
     if(object ~= 0) then
         if(read_bit(object + 0x8B, 7) == 1) then return true end
     end
     return false
end

 

If you want slightly less code, you could use

return (read_bit(object + 0x8B, 7) == 1)

for that if(read_bit... statement. It won't make a difference in performance; it just looks somewhat nicer. Otherwise, very good!

aLTis likes this

Share this post


Link to post
Share on other sites
function is_vehicle_flipped(ObjectID)
     local object = get_object_memory(ObjectID)
     if(object ~= 0) then
         if(read_bit(object + 0x8B, 7) == 1) then return true end
     end
     return false
end

This always returns false for me, I've tried flipping over several vehicles on different maps.


08f9474ede.jpg

Share this post


Link to post
Share on other sites

This always returns false for me, I've tried flipping over several vehicles on different maps.

I've tested it on Bloodgulch for both Halo CE and PC, as well as on Bigass for CE. Perhaps you are using the object's memory address as the parameter, rather than the object's ID.
aLTis, Kavawuvi and WaeV like this

dynamic.png

Share this post


Link to post
Share on other sites

I can confirm that giraffe's function works as expected. Do make sure that you are passing a vehicle object ID, and you're using an object ID.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0
  • Recently Browsing   0 members

    No registered users viewing this page.