Raptor007 / aq2-tng

Action Quake 2: The Next Generation. Raptor007's sandbox for testing changes. When verified stable, this code is pushed to the official aq2-tng repo:
https://github.com/aq2-tng/aq2-tng/tree/bots
4 stars 2 forks source link

Make sure environmental hazards work correctly. #27

Closed Raptor007 closed 7 years ago

Raptor007 commented 8 years ago

On map "rooftops" the streets below should kill you anytime after LCA. On map "tequila" the top of the cactus should hurt you but not throw you into the air.

Raptor007 commented 7 years ago

I have an idea about the cactus: See if any of Maniac's updates included changes to the way damage effects the entity's velocity. I suspect damage mods that didn't previously add velocity are doing so now. (This could be related to issue #12.)

Raptor007 commented 7 years ago

On tequila, g_trigger.c hurt_touch(...) calls g_combat.c T_Damage(... , damage=1, knockback=1, ... , mod=MOD_TRIGGER_HURT). This should create a tiny imperceptible knockback, but instead creates a large one.

This commit might be related: https://github.com/Raptor007/aq2-tng/commit/79011d6b63ef03aedec52d2e517f327b1c21b7d2#diff-94ad8854d8d0a819f2804696a3ac7028L877

Raptor007 commented 7 years ago

I fixed the tequila cactus knockback by reverting some of the vector math: https://github.com/Raptor007/aq2-tng/commit/a076dd29978f6ae0c77c545df0fbb213f587a682

Raptor007 commented 7 years ago

I think the rooftops damage-after-LCA issue is somehow related to hurt_touch(...) triggers, or maybe a mismatched use of level.time and level.frametime when dealing with timestamp.

Possibly relevant file history: https://github.com/Raptor007/aq2-tng/commits/master/source/g_trigger.c https://github.com/Raptor007/aq2-tng/commits/master/source/g_target.c

Side note, this line seems wrong for sv_fps: https://github.com/Raptor007/aq2-tng/blob/e28465e587b948c5c26f496b37b54ab4a656495e/source/g_trigger.c#L482

Raptor007 commented 7 years ago

For the rooftops issue, I threw some debug output into the 1.52 source and found that when the player is killed for being at the bottom of the map, it calls: p_client.c: ClientThink g_utils.c: G_TouchTriggers g_trigger.c: hurt_touch g_combat.c: T_Damage (mod=MOD_TRIGGER_HURT)

While running around at the bottom of the map in 1.52, G_TouchTriggers matches repeatedly with 1 hit, until eventually it has 2 hits and the hurt_touch happens.

I put debug output into TNG to see if hurt_touch ever gets called while at the bottom of rooftops, but it doesn't, and G_TouchTriggers just gets 1 hit repeatedly. This at least gives me some idea where to look.

The difference lies in the returned data from gi.BoxEdicts( ent->absmin, ent->absmax, touch, MAX_EDICTS, AREA_TRIGGERS ): https://github.com/Raptor007/aq2-tng/blob/e28465e587b948c5c26f496b37b54ab4a656495e/source/g_utils.c#L491

It's not yet clear if the problem in TNG is absmin/absmax or that the map damage trigger entity we're supposed to be touching isn't there when it should be. Probably the latter. Perhaps the touched entity at the ground is supposed to trigger the arrival of the hurting entity?

Raptor007 commented 7 years ago

The repeated touch at the bottom of rooftops is Touch_Multi, so the issue could be related to that and/or multi_trigger/multi_wait/G_UseTargets which is likely trying to trigger the activation of a different entity to kill the player(s) below.

Raptor007 commented 7 years ago

It looks like multi_trigger and multi_wait are functioning correctly, so I'm digging into whenG_UseTargets gets called for rooftops.

AQ2 1.52: G_UseTargets delay 0.00 target killers G_UseTargets delay 3.01 target hurting G_UseTargets delay 3.00 target hurting ...3 seconds later... G_UseTargets delay 0.00 target hurting hurt_use frame 71 solid=SOLID_TRIGGER G_TouchTriggers: hurt_touch G_UseTargets delay 0.00 target hurting hurt_use frame 72 solid=SOLID_NOT

AQ2-TNG: G_UseTargets delay 0.00 target killers G_UseTargets delay 3.01 target hurting G_UseTargets delay 3.00 target hurting ...3 seconds later... G_UseTargets delay 0.00 target hurting hurt_use frame 71 solid=SOLID_TRIGGER G_UseTargets delay 0.00 target hurting hurt_use frame 71 solid=SOLID_NOT

In 1.52 hurt_use gets called on two different frames which allows the hurt_touch to happen, but in TNG it gets called twice on the same frame. This is because nextthink is now an integer, so it truncates the result of 3.01 HZ to the same as 3.00 HZ.

Raptor007 commented 7 years ago

Fixed: https://github.com/Raptor007/aq2-tng/commit/e22c667ee8cf131e3ed73b20531b2fdbae47f40a

It also occurs to me that the reason this map developer would have done such a convoluted thing instead of doing a simple always-on hurt brush is because they wanted falling kills credited (see issue #30).