trigger_push, change push speed

Please post any questions about developing your plugin here. Please use the search function before posting!
User avatar
InvisibleSoldiers
Member
Posts: 91
Joined: Fri Mar 15, 2019 6:08 am
Location: Russian Federation
Contact:

trigger_push, change push speed

Postby InvisibleSoldiers » Wed Jan 29, 2020 4:47 am

I'm trying to change push speed of trigger_push entity, Fortunately, push direction of the trigger is declared as datamap property, so it easy to change but the pushspeed - no.
I found out offset from CBaseTrigger to the variable is 0x74. But nothing happen when I set myself pushspeed, it remains the same actually.

CTriggerPush::Touch: https://github.com/ValveSoftware/source ... .cpp#L2242

Syntax: Select all

trigger_push_touch = server_binary['_ZN12CTriggerPush5TouchEP11CBaseEntity'].make_function(
Convention.THISCALL,
(DataType.POINTER, DataType.POINTER),
DataType.VOID
)

@PreHook(trigger_push_touch)
def pre_hook(stack_data):
print(stack_data[0].get_float(0x74)) # Real m_flPushspeed
stack_data[0].set_float(512.0, 0x74) # Changed but it doesn't lead to anything.
User avatar
Sam
Member
Posts: 68
Joined: Tue Jul 03, 2018 3:00 pm
Location: Russian Federation
Contact:

Re: trigger_push, change push speed

Postby Sam » Wed Jan 29, 2020 7:17 am

Maybe?

Code: Select all

stack_data[0].set_float(0x74, 512.0)

http://wiki.sourcepython.com/developing ... .set_float
It's a trap!
User avatar
InvisibleSoldiers
Member
Posts: 91
Joined: Fri Mar 15, 2019 6:08 am
Location: Russian Federation
Contact:

Re: trigger_push, change push speed

Postby InvisibleSoldiers » Wed Jan 29, 2020 7:45 am

Sam wrote:Maybe?

Code: Select all

stack_data[0].set_float(0x74, 512.0

http://wiki.sourcepython.com/developing ... .set_float

set_float((Pointer)arg1, (float)arg2[, (Channel)offset=0]) → None
User avatar
L'In20Cible
Project Leader
Posts: 1236
Joined: Sat Jul 14, 2012 9:29 pm
Location: Québec

Re: trigger_push, change push speed

Postby L'In20Cible » Wed Jan 29, 2020 7:54 am

Your offset is definitely wrong. No way 0x74 is pointing to CTriggerPush::m_flPushSpeed. Hint:

Syntax: Select all

from entities.entity import Entity
from mathlib import Vector
from memory import get_size

entity = Entity.find_or_create('trigger_push')
print(
'm_flPushSpeed\'s offset is between ' +
f"{entity.datamap.find('m_vecPushDir').offset + get_size(Vector)} and " +
f"{entity.factory.size}."
)
User avatar
InvisibleSoldiers
Member
Posts: 91
Joined: Fri Mar 15, 2019 6:08 am
Location: Russian Federation
Contact:

Re: trigger_push, change push speed

Postby InvisibleSoldiers » Wed Jan 29, 2020 10:44 am

L'In20Cible wrote:Your offset is definitely wrong. No way 0x74 is pointing to CTriggerPush::m_flPushSpeed. Hint:

Syntax: Select all

from entities.entity import Entity
from mathlib import Vector
from memory import get_size

entity = Entity.find_or_create('trigger_push')
print(
'm_flPushSpeed\'s offset is between ' +
f"{entity.datamap.find('m_vecPushDir').offset + get_size(Vector)} and " +
f"{entity.factory.size}."
)

Thank you!

Syntax: Select all

@PreHook(trigger_push_touch)
def pre_hook(stack_data):
index = index_from_pointer(stack_data[1])

if 0 < index < 65:
player = playerdict[index]

if player.playing_style.trigger_push_scale >= 0:
default = stack_data[0].get_float(0x484)

stack_data[0].set_float(default * player.playing_style.trigger_push_scale, 0x484)
trigger_push_touch.skip_hooks(stack_data[0], stack_data[1])
stack_data[0].set_float(default, 0x484)

return False

Return to “Plugin Development Support”

Who is online

Users browsing this forum: No registered users and 3 guests