-
Notifications
You must be signed in to change notification settings - Fork 42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
added new hook, handler and dispatcher for any damage events happening #120
base: master
Are you sure you want to change the base?
Conversation
… in minqlx plugins
better filter potential players by the entity_id in range(0, 64) (MAX_PLAYERS = 64 in ql source). Otherwise you will get dmg events from stuff like crushers, lava, trigger_hurt trying to be converted into a player that obviously does not exist.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, Markus!
Please also take a look to this #124
That issue is the main reason, why I don't want to merge this PR.
hooks.c
Outdated
return; | ||
} | ||
|
||
target_id = target->client->ps.clientNum; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if target->client is spectating, ps.clientNum is the player who is being spectated.
hooks.c
Outdated
target_id = target->client->ps.clientNum; | ||
|
||
if (attacker && attacker->client) { | ||
attacker_id = attacker->client->ps.clientNum; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here
python/minqlx/_handlers.py
Outdated
target_player = minqlx.Player(target_id) if target_id in range(0, 64) else None | ||
inflictor_player = minqlx.Player(attacker_id) if attacker_id is not None and attacker_id in range(0, 64) else None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no need check validity of target_id and attacker_id. My_G_Damage is expected to pass valid ids
python_embed.c
Outdated
{"is_chatting", "Whether the player is currently chatting."}, | ||
{"is_frozen", "Whether the player is frozen(freezetag)."}, | ||
{NULL} | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is from other PR
python_embed.c
Outdated
PyStructSequence_SetItem(state, 12, PyBool_FromLong(g_entities[client_id].client->ps.eFlags & EF_TALK != 0)); | ||
PyStructSequence_SetItem(state, 13, PyBool_FromLong(g_entities[client_id].client->ps.pm_type == 4)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is from other PR
python_embed.c
Outdated
#if PY_VERSION_HEX < ((3 << 24) | (7 << 16)) | ||
char *entity_classname = NULL, *item_classname = NULL; | ||
#else | ||
const char *entity_classname = NULL, *item_classname = NULL; | ||
#endif | ||
gentity_t* ent; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is already merged
python_embed.c
Outdated
#if PY_VERSION_HEX < ((3 << 24) | (7 << 16)) | ||
PyEval_InitThreads(); | ||
#endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is already merged
I hooked into G_Damage and forwarded that towards python, so that python plugins now can self.add_hook("damage", self.handle_damage) in its own function. The plugin function gets
The events can't be stopped, and are delivered regardless of whether the target actually gets health/armor reduced, i.e. from rocket jumps with DAMAGE_NO_PROTECTION not set, or team damage in the DAMAGE_NO_TEAM_PROTECTION case. You can detect harmful team shots by this. Plugins would need to filter the events they are interested in on their own.