AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Approved Plugins (https://forums.alliedmods.net/forumdisplay.php?f=8)
-   -   [Condition Zero] Career Tasks Fix (https://forums.alliedmods.net/showthread.php?t=331591)

LunaTheReborn 03-27-2021 23:09

[Condition Zero] Career Tasks Fix
 
2 Attachment(s)
Background & Mechanism
Recently, I noticed that Condition Zero has a special game mode in which you need to achieve certain tasks, decide who your teammates are... Quite fascinating. However, after I looking into the mission pack system, I noticed that there're some task codes that just won't work. Since all of these tasks are used to create a T mission pack, whereas the built-in mission pack is a CT pack, I wonder whether that is the reason why nobody has notice and Valve doesn't even care to have it fixed.

These three unusable vanilla tasks are:
Code:

killdefuser - Kill a CT when he is defusing.
killvip - Kill a VIP.
stoprescue - Kill a CT to whom hostages are following.

These unusable goal codes can hurt a custom T mission pack fatally, since the task codes left for modders are boring regular tasks, like "Kill X enemies with Y weapon. Oh, remember to headshot. And don't get killed. And keep it that way until you win." Therefore I decided to dig into it a bit and try my best to have it fixed.

This is the call chain I built by refering to ReGameDLL-CS:
Code:

CBasePlayer::Killed()
TheCareerTasks->HandleEnemyKill()
CCareerTaskManager::HandleEvent()
CCareerTask::OnEvent()

Strangely, in the CCareerTask::OnEvent() function, it was the attacker's m_bIsVIP and m_bIsDefusing is being checked. But things just getting weirder: I noticed that when CCareerTaskManager::HandleEvent() is iterating through all tasks by calling their corresponding CCareerTask::OnEvent() function, it SWAP the pAttacker and pVictim.
In CCareerTaskManager::HandleEvent() we have:
Code:

for (auto task : m_tasks)
{
        task->OnEvent(event, pAttacker, pVictim);
}

But CCareerTask::OnEvent() was declared like this:
Code:

void CCareerTask::OnEvent(GameEventType event, CBasePlayer *pVictim, CBasePlayer *pAttacker)
{
        ...
}

What is going on here? A double flip? Hence I investigate the entire call chain.
The result is:
Code:

CBasePlayer::Killed()
↓ Flipped.
TheCareerTasks->HandleEnemyKill()
↓ Retained.
CCareerTaskManager::HandleEvent()
↓ Flipped.
CCareerTask::OnEvent()
↓ Flipped.
Result: Check flags and identify the victim to complete tasks.

It's genuine an UBISOFT-ish result instead of Valve-ish.
So the simplest fix I can purpose is to flip the param of HandleEnemyKill() via Orpheu module.

But after this patch, one task remains unfixed, which is "Kill a CT whom hostages are following."
Then I go straight into CCareerTask::OnEvent() and as excepted, this code is used to determine whether a player is followed by hostages.
Code:

if (pHostage->m_target == pAttacker)
        hostagesCount++;

The problem is, CHostage::m_target is an unused pointer. In Condition Zero, a class named CHostageImprov is de facto taken over the control of all hostage behavior. The mystery offset 490 in CHostage.

While making a hook in function HostageFollowState::OnUpdate(), I noticed a fatal bug in Orpheu module. It interpreted CHostageImprov as an alias of CBaseEntity by a superfluous configuration file. It is wrong and can cause a serious of CTD.

By hooking HostageFollowState::OnUpdate(), CHostage::m_target can now nicely syncing with HostageFollowState::m_leader and CCareerTask::OnEvent() can now properly handle everything rest. At last, it is all fixed.


Requirement
- Orpheu
- AMX Mod X start from 1.8.1
Tested & Works on
Counter-Strike: Condition Zero EXCLUSIVELY
Installation
After regular Orpheu installation steps, you have to delete
czero\addons\amxmodx\configs\orpheu\types\CBa seEntity\aliases\CHostageImprov
This is a must-step or you will have a guaranteed CTD since this is a misinterpretation in Orpheu.

The other zip is a custom mission pack for you to test these fixed tasks. Install it just like any other Condition-Zero mission packs.
You can also confirm the bugs by disabling this plugin then try to finish the tasks.
Reference Book
ReGameDLL-CS
Credits
Arkshine's plugin Infinite Round. From which I learned how to modify a member of a non-CBaseEntity class.

Matoliet 04-03-2021 05:40

Re: [Condition Zero] Career Tasks Fix
 
:)233333这又是什么模式插件?

HamletEagle 04-03-2021 06:19

Re: [Condition Zero] Career Tasks Fix
 
You should either add all your custom includes inside the archive(offset.inc) or link to a thread from this forum where people can download them(for orpheu includes for example).
Usually I would have checked to confirm your findings, but I quickly read your analysis and it looks reasonable.
Also remove the commented code, your source files shouldn't contain any commented/dead code.

If someone can confirm this works, I'll approve.

LunaTheReborn 04-03-2021 07:56

Re: [Condition Zero] Career Tasks Fix
 
Quote:

Originally Posted by HamletEagle (Post 2742830)
You should either add all your custom includes inside the archive(offset.inc) or link to a thread from this forum where people can download them(for orpheu includes for example).
Usually I would have checked to confirm your findings, but I quickly read your analysis and it looks reasonable.
Also remove the commented code, your source files shouldn't contain any commented/dead code.

If someone can confirm this works, I'll approve.

Thanks for your correction! I must be too exciting to properly pack all stuff in... Sorry for that, I re-uploaded the package with offset.inc and have the debug code removed.

DJEarthQuake 04-03-2021 08:38

Re: [Condition Zero] Career Tasks Fix
 
All I can confirm is a double-standard. Why not put this on Github and have Valve fix it?

HamletEagle 04-04-2021 07:41

Re: [Condition Zero] Career Tasks Fix
 
Luna, I went ahead and approved your plugin. If someone finds any problems, please let me know.

Edit: I changed modification from ALL to CZ.

Napoleon_be 04-08-2021 20:10

Re: [Condition Zero] Career Tasks Fix
 
Quote:

Originally Posted by DJEarthQuake (Post 2742838)
All I can confirm is a double-standard. Why not put this on Github and have Valve fix it?

No point in upgrading an oldtimer

DJEarthQuake 04-09-2021 09:25

Re: [Condition Zero] Career Tasks Fix
 
Quote:

Originally Posted by Napoleon_be (Post 2743473)
No point in upgrading an oldtimer

It's not entirely hopeless. HL got a 20 year patch last year. There's not a month that goes by where there isn't a client update. One of the less known plugins here I helped fix shows 'teammates money' is now on the 'Cstrike scoreboard'.

Back to the plugin itself here specifically. I've had CZERO since the beginning. Does anybody know when these 'Career Tasks' were made into 'working left-ins'?

meTaLiCroSS 05-29-2023 17:00

Re: [Condition Zero] Career Tasks Fix
 
https://github.com/s1lentq/ReGameDLL_CS/pull/836

zinjar 07-06-2023 02:57

Re: [Condition Zero] Career Tasks Fix
 
The German Shepherd Malamute mix, also known as the Alaskan Shepherd is a very good-looking and loyal dog that has been sought after malamute german shepherd mix


All times are GMT -4. The time now is 04:38.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.