Raised This Month: $ Target: $400
 0% 

[L4D2] Manipulating Defib Penalty?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
JackieChan
AlliedModders Donor
Join Date: Nov 2009
Old 10-23-2011 , 17:51   [L4D2] Manipulating Defib Penalty?
Reply With Quote #1

(Err, sorry if I posted this in the wrong area)

Tried searching around, but have been unsuccessful at finding anything, but here is what I was wanting to do.

I want to be able to find how many defibs have been used in the round and be able to manipulate that number into the scoreboard at the end of each round (like adding or subtracting to that number).

Is such a thing even possible?

*edit (4/22/12)
Found out the answer to this. In case anyone ends up stumbling upon this, it lies in the "m_iVersusDefibsUsed" netprop. You have to manipulate it by using this:

Code:
GameRules_SetProp("m_iVersusDefibsUsed", <value>, 4, 0);
In order to change both teams, set the value to an array, then when adjusting the array, check if the teams are flipped by using this:

Code:
...

if(GameRules_GetProp("m_bAreTeamsFlipped", 4, 0))
{
      <code> (This will be for the team going 2nd)
}
else
{
       <code> (This will be for the team going 1st)
}
...
*edit 9/11/12
I figured I would elaborate on how to do this properly.

Include Left4Downtown:
PHP Code:
#include <left4downtown> 
Next index a defib counter and a respawn counter:
PHP Code:
new DefibCounter[2]; //This is used to make sure the correct number of defibs show up on the RoundEnd scoreboard
new RespawnCounter;  //Just to count how many respawns there were 
Next, make that number increase for every defib/respawn a player does. Hook events "round_end", "defibrillator_used" and whatever function you use for respawning.

Wipe both numbers on map start:
PHP Code:
public OnMapStart()
{
     
ReviveCounter[0] = 0;
     
ReviveCounter[1] = 0;

On the defib event/respawn function:
PHP Code:
if(GameRules_GetProp("m_bAreTeamsFlipped"40))
{
     
ReviveCounter[1] +=1;
}
else
{
     
ReviveCounter[0] +=1;

On the RoundEnd event:
PHP Code:
new score[2];
new 
Handle:defibpenalty FindConVar("vs_defib_penalty");

GameRules_GetProp("m_iVersusDefibsUsed"40);
GameRules_GetProp("m_iVersusDefibsUsed"41);

L4D2_GetVersusCampaignScores(score);

if(
GameRules_GetProp("m_bAreTeamsFlipped"40))
{
    
score[1] -= RespawnCount*GetConVarInt(defibpenalty);
}
else
{
    
score[0] -= RespawnCount*GetConVarInt(defibpenalty);
}

L4D2_SetVersusCampaignScores(score);

GameRules_SetProp("m_iVersusDefibsUsed"ReviveCounter[0], 40);
GameRules_SetProp("m_iVersusDefibsUsed"ReviveCounter[1], 41);

GameRules_SetProp("m_iCampaignScore"score[0], 40);
GameRules_SetProp("m_iCampaignScore"score[1], 41); 
That should do it. Without the 9/11/12 edit, it would subtract the defibs, but won't mirror it on the scoreboard when you hold down TAB which is what you want to reflect to.
__________________

Last edited by JackieChan; 09-11-2012 at 20:13.
JackieChan is offline
Mr. Zero
Veteran Member
Join Date: Jun 2009
Location: Denmark
Old 10-25-2011 , 06:07   Re: [L4D2] Manipulating Defib Penalty?
Reply With Quote #2

To count how many defibs was used would be pretty easy.
Just setup a counter to the defib_used event and reset it on round_start.

As for altering the score, easy too. Use the L4D_OnSetCampaignScores forward and subtract the points from the score.

However there would be no way to "show it" for the players.
You would have to print it to chat that "Survivors is getting 25 points subtract per defib used" or something along those lines.

Edit: Unless you mean the defib penalty on the score board itself. Been a while since I played versus, but doesn't the game already subtract amount of defib used?
If you just want to edit the amount of points subtracted per defib used, use the cvar: vs_defib_penalty.

Last edited by Mr. Zero; 10-25-2011 at 06:10.
Mr. Zero is offline
JackieChan
AlliedModders Donor
Join Date: Nov 2009
Old 10-25-2011 , 19:02   Re: [L4D2] Manipulating Defib Penalty?
Reply With Quote #3

Yeah, I was looking for either adding or subtracting the number of defibs used on the scoreboard itself.
__________________
JackieChan is offline
Mr. Zero
Veteran Member
Join Date: Jun 2009
Location: Denmark
Old 10-26-2011 , 02:06   Re: [L4D2] Manipulating Defib Penalty?
Reply With Quote #4

In that case you would probably have to detour the following function: CTerrorGameRules:GetVersusDefibsUsed(int)

Maybe if you ask really nicely, the l4downtown team might help you out unless you know yourself how to detour.

PHP Code:
.text:002DAA86 ; =============== S U B R O U T I N E =======================================
.
text:002DAA86
.text:002DAA86 Attributesbp-based frame
.text:002DAA86
.text:002DAA86 CTerrorGameRules::GetVersusDefibsUsed(int)const
.
text:002DAA86 _ZNK16CTerrorGameRules19GetVersusDefibsUsedEi proc near
.text:002DAA86                                         CODE XREFCDirectorVersusMode::EndVersusModeRound(bool)+31Cp
.text:002DAA86                                         CDirectorVersusMode::EndVersusModeRound(bool)+331p
.text:002DAA86
.text:002DAA86 arg_0           dword ptr  8
.text:002DAA86 arg_4           dword ptr  0Ch
.text:002DAA86
.text:002DAA86                 push    ebp
.text:002DAA87                 mov     ebpesp
.text:002DAA89                 push    edi
.text:002DAA8A                 push    esi
.text:002DAA8B                 push    ebx
.text:002DAA8C                 sub     esp1Ch
.text:002DAA8F                 call    __i686_get_pc_thunk_bx
.text:002DAA94                 add     ebx0AD6560h
.text:002DAA9A                 mov     esi, [ebp+arg_4]
.
text:002DAA9D                 mov     eaxds:(g_pMatchExtL4D_ptr 0DB0FF4h)[ebx]
.
text:002DAAA3                 mov     edx, [eax]
.
text:002DAAA5                 mov     eax, [edx]
.
text:002DAAA7                 mov     ecx, [eax+0Ch]
.
text:002DAAAA                 lea     eax, (aFcvar_never_as 0DB0FF4h)[ebx] ; "FCVAR_NEVER_AS_STRING"
.text:002DAAB0                 test    ds:(mp_gamemode+15h 0DB0FF4h)[ebx], 10h
.text:002DAAB7                 jnz     short loc_2DAACD
.text:002DAAB9                 mov     eaxdword ptr ds:(mp_gamemode+1Ch 0DB0FF4h)[ebx]
.
text:002DAABF                 mov     eax, [eax+24h]
.
text:002DAAC2                 test    eaxeax
.text:002DAAC4                 lea     edi, (asc_B90B66+0DB0FF4h)[ebx]
.
text:002DAACA                 cmovz   eaxedi
.text:002DAACD
.text:002DAACD loc_2DAACD:                             ; CODE XREFCTerrorGameRules::GetVersusDefibsUsed(int)+31j
.text:002DAACD                 mov     [esp+4], eax
.text:002DAAD1                 mov     [esp], edx
.text:002DAAD4                 call    ecx
.text:002DAAD6                 test    eaxeax
.text:002DAAD8                 jz      short loc_2DAB26
.text:002DAADA                 mov     dword ptr [esp+8], int
.text:002DAAE2                 lea     edx, (unk_B2218E 0DB0FF4h)[ebx]
.
text:002DAAE8                 mov     [esp+4], edx    s
.text:002DAAEC                 mov     [esp], eax      int
.text:002DAAEF                 call    _ZN9KeyValues6GetIntEPKci KeyValues::GetInt(char  const*,int)
.
text:002DAAF4                 test    eaxeax
.text:002DAAF6                 jle     short loc_2DAB26
.text:002DAAF8                 mov     eaxds:(TheDirector_ptr 0DB0FF4h)[ebx]
.
text:002DAAFE                 mov     eax, [eax]
.
text:002DAB00                 mov     [esp], eax
.text:002DAB03                 call    _ZNK9CDirector15AreTeamsFlippedEv CDirector::AreTeamsFlipped(void)
.
text:002DAB08                 cmp     esi2
.text:002DAB0B                 jz      short loc_2DAB22
.text:002DAB0D                 mov     edx0FFFFFFFFh
.text:002DAB12                 cmp     esi3
.text:002DAB15                 jnz     short loc_2DAB28
.text:002DAB17                 test    alal
.text:002DAB19                 jnz     short loc_2DAB26
.text:002DAB1B
.text:002DAB1B loc_2DAB1B:                             ; CODE XREFCTerrorGameRules::GetVersusDefibsUsed(int)+9Ej
.text:002DAB1B                 mov     edx1
.text:002DAB20                 jmp     short loc_2DAB28
.text:002DAB22 ; ---------------------------------------------------------------------------
.
text:002DAB22
.text:002DAB22 loc_2DAB22:                             ; CODE XREFCTerrorGameRules::GetVersusDefibsUsed(int)+85j
.text:002DAB22                 test    alal
.text:002DAB24                 jnz     short loc_2DAB1B
.text:002DAB26
.text:002DAB26 loc_2DAB26:                             ; CODE XREFCTerrorGameRules::GetVersusDefibsUsed(int)+52j
.text:002DAB26                                         CTerrorGameRules::GetVersusDefibsUsed(int)+70j ...
.
text:002DAB26                 xor     edxedx
.text:002DAB28
.text:002DAB28 loc_2DAB28:                             ; CODE XREFCTerrorGameRules::GetVersusDefibsUsed(int)+8Fj
.text:002DAB28                                         CTerrorGameRules::GetVersusDefibsUsed(int)+9Aj
.text:002DAB28                 mov     eax, [ebp+arg_0]
.
text:002DAB2B                 mov     eax, [eax+edx*4+420h]
.
text:002DAB32                 add     esp1Ch
.text:002DAB35                 pop     ebx
.text:002DAB36                 pop     esi
.text:002DAB37                 pop     edi
.text:002DAB38                 pop     ebp
.text:002DAB39                 retn
.text:002DAB39 _ZNK16CTerrorGameRules19GetVersusDefibsUsedEi endp 
Mr. Zero is offline
Reply



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 01:38.


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