Skip to content

Conversation

@vinci6k
Copy link
Contributor

@vinci6k vinci6k commented Apr 22, 2020

No description provided.

@jordanbriere
Copy link
Contributor

Thanks! However I don't think it would be wise to add an extra signature to maintain for that function. I proposed an alternative in the thread that encouraged this PR, and if that function was specifically needed to be hooked, I think it would be overall more robust and maintainable to dynamically grab it through m_pfnTouch that is available in the crossbow_bolt's datamap which would eliminate the need to keep data up-to-date for it (even if I doubt that game will be updated anytime soon 😄).

@Ayuto
Copy link
Member

Ayuto commented Apr 22, 2020

I agree. That function is a very special case and I would like to keep the number of signatures and offsets as less as possible.

@vinci6k
Copy link
Contributor Author

vinci6k commented Apr 22, 2020

Understandable. Guess I jumped the gun on this one.

I think it would be overall more robust and maintainable to dynamically grab it through m_pfnTouch that is available in the crossbow_bolt's datamap which would eliminate the need to keep data up-to-date for it (even if I doubt that game will be updated anytime soon 😄).

If it's not too much of a hassle, could you give me an example on how to do that?

@jordanbriere
Copy link
Contributor

If it's not too much of a hassle, could you give me an example on how to do that?

Sure, here is a basic example:

# Create a bolt
bolt = Entity.create('crossbow_bolt')

# The touch function is bound when the bolt is spawned
bolt.spawn()

# Grab the touch function
bolt_touch = bolt.get_datamap_property_pointer('m_pfnTouch').make_function(
    Convention.THISCALL,
    (DataType.POINTER, DataType.POINTER),
    DataType.VOID
)

# Do whatever with it
print('CCrossbowBolt::Touch\'s address is:', bolt_touch.address)

@vinci6k
Copy link
Contributor Author

vinci6k commented Apr 22, 2020

Awesome, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants