Raised This Month: $51 Target: $400
 12% 

Solved [L4D2] Defibrillate survivor death model?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Shadowysn
Senior Member
Join Date: Sep 2015
Location: Location:
Old 04-24-2019 , 07:24   [L4D2] Defibrillate survivor death model?
Reply With Quote #1

I'm still new with many of these advanced topics of Sourcemod.

Long story short, I'm creating a simple plugin to defib a death model like in Rayman's Admin System, with the effects of defibrillating. (get-up animation, vocalization, etc.)
Unfortunately, I ran into a roadblock in that I have no idea how to do the actual defib part.

I attempted to do the unknown-to-me and used the vtable dumper for signatures but I definitely could not find anything related to defibrillating a dead body successfully.

Last edited by Shadowysn; 06-05-2019 at 23:55.
Shadowysn is offline
Lux
Veteran Member
Join Date: Jan 2015
Location: Cat
Old 04-24-2019 , 11:18   Re: [L4D2] Defibrillate survivor death model?
Reply With Quote #2

You can call this script function with an entity.
ReviveByDefib()

Here is a stock from timocop
PHP Code:
static L4D2_RunScript(const String:sCode[], any:...)
{
    static 
iScriptLogic INVALID_ENT_REFERENCE;
    if(
iScriptLogic == INVALID_ENT_REFERENCE || !IsValidEntity(iScriptLogic)) {
        
iScriptLogic EntIndexToEntRef(CreateEntityByName("logic_script"));
        if(
iScriptLogic == INVALID_ENT_REFERENCE || !IsValidEntity(iScriptLogic))
            
SetFailState("Could not create 'logic_script'");

        
DispatchSpawn(iScriptLogic);
    }

    static 
String:sBuffer[512];
    
VFormat(sBuffersizeof(sBuffer), sCode2);

    
SetVariantString(sBuffer);
    
AcceptEntityInput(iScriptLogic"RunScriptCode");


ReviveByDefib is one of many vscript functions that can be called with sorcemod from using an entity.
https://developer.valvesoftware.com/...ript_Functions



If you want the proper signature for the defib revive here.
Code:
"CTerrorPlayer::OnRevivedByDefibrillator"
{
				/* RevivedByDefibrillatorDelayed <- Search for this string */
				/* Pass (CTerrorPlayer *DeadClient, CTerrorPlayer *Reviver, CSurvivorDeathModel *DeathModel) you should beable to pass the dead client ptr as the reviver*/
	"library"		"server"
	"linux"			"@_ZN13CTerrorPlayer24OnRevivedByDefibrillatorEPS_P19CSurvivorDeathModel"
	"windows"		"\x55\x8B\xEC\x83\xEC\x34\x53\x56\x8B\xF1\x8A\x86\x01\x40\x00\x00"
								/* 55 8B EC 83 EC 34 53 56 8B F1 8A 86 01 40 00 00 */
	
}
__________________
Connect
My Plugins: KlickME
[My GitHub]

Commission me for L4D

Last edited by Lux; 04-24-2019 at 11:26.
Lux is offline
Shadowysn
Senior Member
Join Date: Sep 2015
Location: Location:
Old 04-24-2019 , 23:29   Re: [L4D2] Defibrillate survivor death model?
Reply With Quote #3

Quote:
Originally Posted by Lux View Post
You can call this script function with an entity.
ReviveByDefib()

Here is a stock from timocop
PHP Code:
static L4D2_RunScript(const String:sCode[], any:...)
{
    static 
iScriptLogic INVALID_ENT_REFERENCE;
    if(
iScriptLogic == INVALID_ENT_REFERENCE || !IsValidEntity(iScriptLogic)) {
        
iScriptLogic EntIndexToEntRef(CreateEntityByName("logic_script"));
        if(
iScriptLogic == INVALID_ENT_REFERENCE || !IsValidEntity(iScriptLogic))
            
SetFailState("Could not create 'logic_script'");

        
DispatchSpawn(iScriptLogic);
    }

    static 
String:sBuffer[512];
    
VFormat(sBuffersizeof(sBuffer), sCode2);

    
SetVariantString(sBuffer);
    
AcceptEntityInput(iScriptLogic"RunScriptCode");


ReviveByDefib is one of many vscript functions that can be called with sorcemod from using an entity.
https://developer.valvesoftware.com/...ript_Functions



If you want the proper signature for the defib revive here.
Code:
"CTerrorPlayer::OnRevivedByDefibrillator"
{
				/* RevivedByDefibrillatorDelayed <- Search for this string */
				/* Pass (CTerrorPlayer *DeadClient, CTerrorPlayer *Reviver, CSurvivorDeathModel *DeathModel) you should beable to pass the dead client ptr as the reviver*/
	"library"		"server"
	"linux"			"@_ZN13CTerrorPlayer24OnRevivedByDefibrillatorEPS_P19CSurvivorDeathModel"
	"windows"		"\x55\x8B\xEC\x83\xEC\x34\x53\x56\x8B\xF1\x8A\x86\x01\x40\x00\x00"
								/* 55 8B EC 83 EC 34 53 56 8B F1 8A 86 01 40 00 00 */
	
}
Thanks lux. I think I'm gonna go with the vscript method...

And, uhh...
PHP Code:
InputRunScript line = (1column = (15) : error end of statement expected (; or lf
I didn't really use vscript so I don't have any idea about this error. I put a ; in the end of the string
Code:
("%i.ReviveByDefib();", client)
as requested, but that error still pops up.

Last edited by Shadowysn; 04-24-2019 at 23:31.
Shadowysn is offline
Lux
Veteran Member
Join Date: Jan 2015
Location: Cat
Old 04-25-2019 , 00:52   Re: [L4D2] Defibrillate survivor death model?
Reply With Quote #4

PHP Code:
void L4D2_ReviveByDefib(int iClient)
{
    
L4D2_RunScript("GetPlayerFromUserID(%d).ReviveByDefib()"GetClientUserId(iClient));

__________________
Connect
My Plugins: KlickME
[My GitHub]

Commission me for L4D

Last edited by Lux; 04-25-2019 at 00:55.
Lux is offline
Shadowysn
Senior Member
Join Date: Sep 2015
Location: Location:
Old 04-26-2019 , 05:45   Re: [L4D2] Defibrillate survivor death model?
Reply With Quote #5

Quote:
Originally Posted by Lux View Post
PHP Code:
void L4D2_ReviveByDefib(int iClient)
{
    
L4D2_RunScript("GetPlayerFromUserID(%d).ReviveByDefib()"GetClientUserId(iClient));

Works good! Almost...

If there's a clone of a character and they both die, only one can get resurrected. The other won't be revived (when defibfix ext enabled?) or if I take the defibfix extension off it most likely will resurrect the already revived person. (I'm not really going to turn off an extension that's supposed to fix bugs)

But eh, maybe when I learn more about signatures I could use the different method.
Shadowysn is offline
Lux
Veteran Member
Join Date: Jan 2015
Location: Cat
Old 04-26-2019 , 06:43   Re: [L4D2] Defibrillate survivor death model?
Reply With Quote #6

I don't think the ext would fix it,

This is the script function in psudocode
PHP Code:
void __cdecl CTerrorPlayer::ScriptReviveByDefibrillator(CTerrorPlayer *this)
{
  
int v1// ebx
  
signed int *v2// esi

  
if ( dword_FBA2CC )
  {
    
v1 0;
    while ( 
)
    {
      
v2 = *(signed int **)(g_DeadSurvivors v1);
      if ( 
v2 )
      {
        if ( 
this == (CTerrorPlayer *)CTerrorPlayer::GetPlayerByCharacter(v2[1526]) )
          break;
      }
      if ( 
dword_FBA2CC <= ++v1 )
        return;
    }
    
CTerrorPlayer::OnRevivedByDefibrillator(thisthis, (CSurvivorDeathModel *)v2);
  }

By the look of it you would need to change the survivor char prop on the deathmodel to revive more people or create more of them.
__________________
Connect
My Plugins: KlickME
[My GitHub]

Commission me for L4D
Lux is offline
Shadowysn
Senior Member
Join Date: Sep 2015
Location: Location:
Old 05-30-2019 , 06:10   Re: [L4D2] Defibrillate survivor death model?
Reply With Quote #7

Quote:
Originally Posted by Lux View Post
I don't think the ext would fix it,

This is the script function in psudocode
PHP Code:
void __cdecl CTerrorPlayer::ScriptReviveByDefibrillator(CTerrorPlayer *this)
{
  
int v1// ebx
  
signed int *v2// esi

  
if ( dword_FBA2CC )
  {
    
v1 0;
    while ( 
)
    {
      
v2 = *(signed int **)(g_DeadSurvivors v1);
      if ( 
v2 )
      {
        if ( 
this == (CTerrorPlayer *)CTerrorPlayer::GetPlayerByCharacter(v2[1526]) )
          break;
      }
      if ( 
dword_FBA2CC <= ++v1 )
        return;
    }
    
CTerrorPlayer::OnRevivedByDefibrillator(thisthis, (CSurvivorDeathModel *)v2);
  }

By the look of it you would need to change the survivor char prop on the deathmodel to revive more people or create more of them.
So after a break from Sourcemod, I did give this a think but...

m_nCharacterType is screwed up.

It won't let me set it's value at all. It just roadblocked the code with an error, saying that the property could not be found...
Shadowysn is offline
Lux
Veteran Member
Join Date: Jan 2015
Location: Cat
Old 05-31-2019 , 11:12   Re: [L4D2] Defibrillate survivor death model?
Reply With Quote #8

m_nCharacterType entprop is for the survivor_death_model only.
For survivors entprop is m_survivorCharacter
__________________
Connect
My Plugins: KlickME
[My GitHub]

Commission me for L4D
Lux is offline
Shadowysn
Senior Member
Join Date: Sep 2015
Location: Location:
Old 05-31-2019 , 23:55   Re: [L4D2] Defibrillate survivor death model?
Reply With Quote #9

Quote:
Originally Posted by Lux View Post
m_nCharacterType entprop is for the survivor_death_model only.
For survivors entprop is m_survivorCharacter
Ah whoops, should've been more clear with what entity I was using on.

int entdata = GetEntProp(survivor, Prop_Send, "m_survivorCharacter");
SetEntProp(body, Prop_Data, "m_nCharacterType", entdata);


It causes the error.

There's also a weird thing I forgot to mention... there was similar code in another scripting file that also sets m_nCharacterType to the survivor's character, and it perfectly functions.
The previous code and the code in the other scripting file were essentially called upon the creation of a new survivor_death_model, yet only the other scripting file's code works.

Last edited by Shadowysn; 06-01-2019 at 00:00.
Shadowysn is offline
Lux
Veteran Member
Join Date: Jan 2015
Location: Cat
Old 06-01-2019 , 00:41   Re: [L4D2] Defibrillate survivor death model?
Reply With Quote #10

SetEntProp(body, Prop_Data, "m_nCharacterType", entdata);
to
SetEntProp(body, Prop_Send, "m_nCharacterType", entdata);
__________________
Connect
My Plugins: KlickME
[My GitHub]

Commission me for L4D
Lux 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 15:28.


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