Page 1 of 2

[HL2:DM] Infinite aux power for sprinting OR breathing

Posted: Mon Apr 11, 2016 1:28 pm
by Painkiller
Could someone please make for SourcePython?


https://forums.alliedmods.net/showthread.php?t=73097

Posted: Wed Apr 13, 2016 6:05 am
by satoon101
We don't currently have the CBasePlayer::PlayerRunCommand virtual function for HL2:MP in our data. So, the following uses a tick listener instead:

Syntax: Select all

from filters.players import PlayerIter
from listeners import OnTick


SPRINTING = 1
BREATHING = 4


@OnTick
def _tick():
for player in PlayerIter('alive'):

active_devices = player.active_devices

if active_devices & SPRINTING:
player.active_devices = active_devices & ~SPRINTING
player.suit_power_load = 0

if active_devices & BREATHING:
player.active_devices = active_devices & ~BREATHING
player.suit_power_load = 0


If need be, I can add ConVars for sprinting and breathing to allow one to be active instead of always both.

*Note that this requires the newest version of Source.Python (version 305) as it uses 2 properties I just added to the data.


*Edit: I have added CBasePlayer.run_command for hl2mp, so now the following works, as well (as of SP version 306):

Syntax: Select all

from entities.hooks import EntityCondition
from entities.hooks import EntityPreHook
from memory import make_object
from players.entity import Player

SPRINTING = 1
BREATHING = 4


@EntityPreHook(EntityCondition.is_player, 'run_command')
def pre_run_command(stackdata):
player = make_object(Player, stackdata[0])
if player.dead:
return

active_devices = player.active_devices

if active_devices & SPRINTING:
player.active_devices = active_devices & ~SPRINTING
player.suit_power_load = 0

if active_devices & BREATHING:
player.active_devices = active_devices & ~BREATHING
player.suit_power_load = 0

Posted: Wed Apr 13, 2016 4:49 pm
by Painkiller
Hi Satoon i have problems.

Syntax: Select all

18:48:20 [SP] Unloading plugin 'auxpower'... 

[SP] Caught an Exception:
Traceback (most recent call last):
File '../addons/source-python/packages/source-python/plugins/command.py', line 204, in call_command
self[sub_command](*args)
File '../addons/source-python/packages/source-python/plugins/command.py', line 342, in reload_plugin
self.unload_plugin(plugin_name)
File '../addons/source-python/packages/source-python/plugins/command.py', line 320, in unload_plugin
del self.manager[plugin_name]
File '../addons/source-python/packages/source-python/plugins/manager.py', line 149, in __delitem__
self._remove_modules(plugin_name)
File '../addons/source-python/packages/source-python/plugins/manager.py', line 197, in _remove_modules
instance._unload_instance()
File '../addons/source-python/packages/source-python/entities/hooks.py', line 143, in _unload_instance
_waiting_entity_hooks.remove(self)

ValueError: list.remove(x): x not in list

Posted: Wed Apr 13, 2016 5:12 pm
by satoon101
I am really not sure why that would happen, but that error seems to be happening when you unload the script. Does it work fine when it's loaded?

Posted: Wed Apr 13, 2016 5:43 pm
by Painkiller

Syntax: Select all

9:41:53 sp load auxpower
19:41:53 [SP] Loading plugin 'auxpower'...

[SP] Caught an Exception:
Traceback (most recent call last):
File '../addons/source-python/packages/source-python/plugins/manager.py', line 71, in __missing__
instance = self.instance(plugin_name, self.base_import)
File '../addons/source-python/packages/source-python/plugins/instance.py', line 82, in __init__
self._plugin = import_module(import_name)
File '../addons/source-python/plugins/auxpower/auxpower.py', line 10, in <module>
@EntityPreHook(EntityCondition.is_player, 'run_command')
File '../addons/source-python/packages/source-python/entities/hooks.py', line 103, in __call__
if self.initialize(entity):
File '../addons/source-python/packages/source-python/entities/hooks.py', line 131, in initialize
self.hooked_function = getattr(entity, self.function)
File '../addons/source-python/packages/source-python/entities/entity.py', line 98, in __getattr__
raise AttributeError('Attribute '{0}' not found'.format(attr))

AttributeError: Attribute 'run_command' not found


[SP] Plugin 'auxpower' was unable to be loaded.

Posted: Wed Apr 13, 2016 6:24 pm
by satoon101
I think you missed this part:
satoon101 wrote:*Edit: I have added CBasePlayer.run_command for hl2mp, so now the following works, as well (as of SP version 306):

Posted: Wed Apr 13, 2016 7:13 pm
by Painkiller
I can not use this version.

Re: [HL2:DM] Infinite aux power for sprinting OR breathing

Posted: Wed Apr 20, 2016 4:50 pm
by Painkiller
Ok i have updated SP and works fine.

Re: [HL2:DM] Infinite aux power for sprinting OR breathing

Posted: Wed May 08, 2019 3:18 pm
by Painkiller
Since the SP update it does not work anymore as it should.

There is no boost.
You can only walk

Syntax: Select all

from entities.hooks import EntityCondition
from entities.hooks import EntityPreHook
from memory import make_object
from players.entity import Player

SPRINTING = 1
BREATHING = 4


@EntityPreHook(EntityCondition.is_player, 'run_command')
def pre_run_command(stackdata):
player = make_object(Player, stackdata[0])
if player.dead:
return

active_devices = player.active_devices

if active_devices & SPRINTING:
player.active_devices = active_devices & ~SPRINTING
player.suit_power_load = 0

if active_devices & BREATHING:
player.active_devices = active_devices & ~BREATHING
player.suit_power_load = 0

Re: [HL2:DM] Infinite aux power for sprinting OR breathing

Posted: Wed May 08, 2019 7:21 pm
by Ayuto
Oh, I think I know where the problem is. A week ago we improved the speed of many player properties by using a different implementation. However, the new implementation is probably reading the address of "active_devices" using the wrong data type. It's probably unsinged int/short instead of just int. I will investigate this next week.

Re: [HL2:DM] Infinite aux power for sprinting OR breathing

Posted: Thu May 09, 2019 8:43 am
by Painkiller
ok,
thanks in advance.

Re: [HL2:DM] Infinite aux power for sprinting OR breathing

Posted: Sat May 11, 2019 8:55 am
by Ayuto

Re: [HL2:DM] Infinite aux power for sprinting OR breathing

Posted: Mon May 13, 2019 10:15 am
by Painkiller
Thank you works fine.

Re: [HL2:DM] Infinite aux power for sprinting OR breathing

Posted: Wed May 15, 2019 6:29 pm
by Painkiller
After a long test, I noticed that the same error always appears at the end of the map.

Re: [HL2:DM] Infinite aux power for sprinting OR breathing

Posted: Wed May 15, 2019 8:18 pm
by Baster1985
It will be time to learn python

Re: [HL2:DM] Infinite aux power for sprinting OR breathing

Posted: Thu May 16, 2019 9:01 pm
by Painkiller
Baster1985 wrote:It will be time to learn python


Yes, if you have time for it?

I would be glad.

Re: [HL2:DM] Infinite aux power for sprinting OR breathing

Posted: Thu May 16, 2019 10:17 pm
by Baster1985
I rather meant you. Then you do not have to ask others about every little thing

Re: [HL2:DM] Infinite aux power for sprinting OR breathing

Posted: Fri May 17, 2019 2:16 pm
by Painkiller
There are scripters and craftsmen

I am a craftsperson.

I'm so sorry for something I did not create. I am very happy about the support of the community.

As I said, I also like to pay money.
viewtopic.php?f=9&t=2009

Re: [HL2:DM] Infinite aux power for sprinting OR breathing

Posted: Sun Jun 02, 2019 6:56 am
by Painkiller
There's still spending that mistake.

It works in the beginning but after a certain time, not anymore.

Code: Select all

2019-06-02 08:47:29 - sp   -   EXCEPTION   
[SP] Caught an Exception:
Traceback (most recent call last):
  File "../addons/source-python/plugins/auxpower/auxpower.py", line 20, in pre_run_command
    player.suit_power_load = 0
  File "../addons/source-python/packages/source-python/entities/_base.py", line 125, in __setattr__
    object.__setattr__(self, attr, value)

ValueError: Unable to find property 'm_flSuitPowerLoad'.

Re: [HL2:DM] Infinite aux power for sprinting OR breathing

Posted: Sun Jun 02, 2019 7:18 am
by Ayuto
Just commited a fix:
https://github.com/Source-Python-Dev-Te ... b201fd0b2a

I will publish a new release today (version 690).