Skip to content

Conversation

@vinci6k
Copy link
Contributor

@vinci6k vinci6k commented Feb 25, 2019

When working with armor (CSS, CSGO) or critical hits (TF2), CBaseEntity::OnTakeDamage gives incorrect values. I found out that CBaseCombatCharacter::OnTakeDamage_Alive gives the correct values, so I've added the data for all supported games.

# ../damage_comparison/damage_comparison.py

# Source.Python
from entities import TakeDamageInfo
from entities.entity import BaseEntity
from entities.hooks import EntityCondition, EntityPreHook


@EntityPreHook(EntityCondition.is_player, 'on_take_damage')
def on_take_damage_pre(stack_data):
    base_entity = BaseEntity._obj(stack_data[0])
    info = TakeDamageInfo._obj(stack_data[1])

    print(f'otd:   player({base_entity.index}) took {info.damage} damage')


@EntityPreHook(EntityCondition.is_player, 'on_take_damage_alive')
def on_take_damage_alive_pre(stack_data):
    base_entity = BaseEntity._obj(stack_data[0])
    info = TakeDamageInfo._obj(stack_data[1])

    print(f'otd_a: player({base_entity.index}) took {info.damage} damage')

Output (from CSGO):

otd:   player(5) took 28.294065475463867 damage
otd_a: player(5) took 13.0 damage

I wasn't sure where to add the data for Blade Symphony, but it does have the same offset as Left 4 Dead 2, are these two games on the same Source engine branch?

@jordanbriere
Copy link
Contributor

Thanks!

I wasn't sure where to add the data for Blade Symphony, but it does have the same offset as Left 4 Dead 2, are these two games on the same Source engine branch?

The data is parsed using the GameConfigObj class which merge and overwrite the data using the shared → engine → game tree. Since Blade Symphony is defining SOURCE_ENGINE to "blade" in the blade.cmake file, the data for the CBaseCombatCharacter class for that engine would go into ../blade/CBaseCombatCharacter.ini. We don't have any data specific to that engine, and I honestly don't think anyone even play that game anymore. Mainly explained for future reference to how it internally works.

@jordanbriere jordanbriere reopened this Mar 1, 2019
@jordanbriere jordanbriere merged commit 0e2fb1d into Source-Python-Dev-Team:master Mar 1, 2019
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.

2 participants