Raised This Month: $32 Target: $400
 8% 

[Condition Zero] Career Tasks Fix


Post New Thread Reply   
 
Thread Tools Display Modes
Plugin Info:     Modification:   Condition-Zero        Category:   Admin Commands        Approver:   HamletEagle (36)
LunaTheReborn
Junior Member
Join Date: Feb 2020
Old 03-27-2021 , 23:09   [Condition Zero] Career Tasks Fix
Reply With Quote #1

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.
Attached Files
File Type: zip CZ Test Missionpack.zip (4.1 KB, 352 views)
File Type: zip CareerTasksFix.zip (8.5 KB, 317 views)

Last edited by HamletEagle; 04-04-2021 at 07:53.
LunaTheReborn is offline
Matoliet
New Member
Join Date: Apr 2021
Old 04-03-2021 , 05:40   Re: [Condition Zero] Career Tasks Fix
Reply With Quote #2

233333这又是什么模式插件?
Matoliet is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 04-03-2021 , 06:19   Re: [Condition Zero] Career Tasks Fix
Reply With Quote #3

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.
__________________
HamletEagle is offline
LunaTheReborn
Junior Member
Join Date: Feb 2020
Old 04-03-2021 , 07:56   Re: [Condition Zero] Career Tasks Fix
Reply With Quote #4

Quote:
Originally Posted by HamletEagle View Post
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.

Last edited by LunaTheReborn; 04-03-2021 at 07:57. Reason: Grammer & usage of word.
LunaTheReborn is offline
DJEarthQuake
Veteran Member
Join Date: Jan 2014
Location: Astral planes
Old 04-03-2021 , 08:38   Re: [Condition Zero] Career Tasks Fix
Reply With Quote #5

All I can confirm is a double-standard. Why not put this on Github and have Valve fix it?
__________________

Last edited by DJEarthQuake; 04-05-2021 at 07:43. Reason: Had wrong URL.
DJEarthQuake is offline
Old 04-03-2021, 09:15
HamletEagle
This message has been deleted by HamletEagle.
Old 04-03-2021, 21:54
DJEarthQuake
This message has been deleted by HamletEagle.
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 04-04-2021 , 07:41   Re: [Condition Zero] Career Tasks Fix
Reply With Quote #6

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.
__________________

Last edited by HamletEagle; 04-05-2021 at 15:05.
HamletEagle is offline
Old 04-05-2021, 07:35
DJEarthQuake
This message has been deleted by HamletEagle.
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 04-08-2021 , 20:10   Re: [Condition Zero] Career Tasks Fix
Reply With Quote #7

Quote:
Originally Posted by DJEarthQuake View Post
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
__________________
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
DJEarthQuake
Veteran Member
Join Date: Jan 2014
Location: Astral planes
Old 04-09-2021 , 09:25   Re: [Condition Zero] Career Tasks Fix
Reply With Quote #8

Quote:
Originally Posted by Napoleon_be View Post
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'?
__________________
DJEarthQuake is offline
meTaLiCroSS
Gaze Upon My Hat
Join Date: Feb 2009
Location: Viņa del Mar, Chile
Old 05-29-2023 , 17:00   Re: [Condition Zero] Career Tasks Fix
Reply With Quote #9

https://github.com/s1lentq/ReGameDLL_CS/pull/836
__________________
Quote:
Originally Posted by joropito View Post
You're right Metalicross
meTaLiCroSS is offline
zinjar
New Member
Join Date: Jul 2023
Old 07-06-2023 , 02:57   Re: [Condition Zero] Career Tasks Fix
Reply With Quote #10

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
zinjar is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 00:58.


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