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

Solved [L4D2] Tank fire immunity


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
alcybery
Member
Join Date: Apr 2016
Old 05-25-2018 , 16:32   [L4D2] Tank fire immunity
Reply With Quote #1

I'm trying to make tank to only burn while being in a fire but not after leaving fire. I have this code, but it doesn't compile (undefined symbol "ExtinguishEntity")

PHP Code:
public OnPluginStart()
    
HookEvent("player_hurt"EventPlayerHurt)

public 
Action:EventPlayerHurt(Handle:h_EventString:s_Name[], bool:b_DontBroadcast)
{
    
decl i_UserIDi_ClientString:s_ModelName[64]
    
    
i_UserID GetEventInt(h_Event"userid")
    
i_Client GetClientOfUserId(i_UserID)
    
    
GetEntPropString(i_ClientProp_Data"m_ModelName"s_ModelNamesizeof(s_ModelName))

    if (
StrContains(s_ModelName"hulk") != -1)
    {
        
decl String:s_Weapon[16], i_Type
        
        i_Type 
GetEventInt(h_Event"type")
        
GetEventString(h_Event"weapon"s_Weaponsizeof(s_Weapon))

        if (
i_Type == 268435464)
        {
            
ExtinguishEntity(i_Client);
            
SetEntPropFloat(i_ClientProp_Send"m_burnPercent"1.0);
        }
    }


Last edited by alcybery; 06-26-2018 at 13:20.
alcybery is offline
Silvers
SourceMod Plugin Approver
Join Date: Aug 2010
Location: SpaceX
Old 05-25-2018 , 17:48   Re: [L4D2] Tank fire immunity
Reply With Quote #2

Code:
#include <sourcemod>
#include <sdktools>
at the top of plugin. But your code most likely won't work, damage and preventing death etc doesn't work on events. You need to use SDKHooks.. look at other plugins for example how to hook the entity when tank spawns (using events) and then SDKHooks OnTakeDamage to handle it correctly and make it work.
__________________
Silvers is offline
alcybery
Member
Join Date: Apr 2016
Old 05-25-2018 , 18:43   Re: [L4D2] Tank fire immunity
Reply With Quote #3

Thanks, it was silly to forget to add these lines Plugin seems to be working, tank stops burning after leaving the fire and doesn't die.
alcybery is offline
xerox8521
Senior Member
Join Date: Sep 2011
Old 05-25-2018 , 20:26   Re: [L4D2] Tank fire immunity
Reply With Quote #4

Instead of checking the model for hulk you should just retrieve the m_zombieClass prop and check if the value is 8 ( i believe).
Honestly I suggest forcing semicolons (#pragma semicolon 1 at the top of the plugin) as it is bad practice to not use them as alot of other languages require them to work.

Last edited by xerox8521; 05-25-2018 at 20:26.
xerox8521 is offline
Silvers
SourceMod Plugin Approver
Join Date: Aug 2010
Location: SpaceX
Old 05-25-2018 , 20:36   Re: [L4D2] Tank fire immunity
Reply With Quote #5

I was going to say, for what I call hackish-type solutions this would probably work, but if you want accurate health changing/stopping SDKHooks is the method. m_zombieClass is much better check, class number 8 or something. Check other plugins for various methods on doing stuff.
__________________

Last edited by Silvers; 05-25-2018 at 20:37. Reason: typo
Silvers is offline
alcybery
Member
Join Date: Apr 2016
Old 05-25-2018 , 20:48   Re: [L4D2] Tank fire immunity
Reply With Quote #6

Quote:
Originally Posted by xerox8521 View Post
Instead of checking the model for hulk you should just retrieve the m_zombieClass prop and check if the value is 8 ( i believe).
Honestly I suggest forcing semicolons (#pragma semicolon 1 at the top of the plugin) as it is bad practice to not use them as alot of other languages require them to work.
Something like this?

PHP Code:
#include <sourcemod>
#include <sdktools>
#pragma semicolon 1 

public OnPluginStart()
HookEvent("player_hurt"EventPlayerHurt);

public 
Action:EventPlayerHurt(Handle:h_EventString:s_Name[], bool:b_DontBroadcast)
{
    
decl i_UserIDi_Client;
    
    
i_UserID GetEventInt(h_Event"userid");
    
i_Client GetClientOfUserId(i_UserID);

    if(
GetEntProp(i_ClientProp_Send"m_zombieClass") == 8)
    {
        
decl String:s_Weapon[16], i_Type;
        
        
i_Type GetEventInt(h_Event"type");
        
GetEventString(h_Event"weapon"s_Weaponsizeof(s_Weapon));

        if (
i_Type == 268435464)
        {
            
ExtinguishEntity(i_Client);
            
SetEntPropFloat(i_ClientProp_Send"m_burnPercent"1.0);
        }
    }

Quote:
Originally Posted by Silvers View Post
I was going to say, for what I call hackish-type solutions this would probably work, but if you want accurate health changing/stopping SDKHooks is the method. m_zombieClass is much better check, class number 8 or something. Check other plugins for various methods on doing stuff.
Unfortunately that is above my level of knowledge. With the code that I posted I just combined two different plugins.

Last edited by alcybery; 05-25-2018 at 21:01.
alcybery is offline
Psyk0tik
Veteran Member
Join Date: May 2012
Location: Homeless
Old 05-25-2018 , 21:13   Re: [L4D2] Tank fire immunity
Reply With Quote #7

Super Tanks and Super Tanks+ show an example for how to give Tanks fire immunity.
__________________
Psyk0tik is offline
Silvers
SourceMod Plugin Approver
Join Date: Aug 2010
Location: SpaceX
Old 05-26-2018 , 08:36   Re: [L4D2] Tank fire immunity
Reply With Quote #8

Quote:
Originally Posted by alcybery View Post
Unfortunately that is above my level of knowledge.
Quote:
Originally Posted by Silvers View Post
look at other plugins for example
That's how I learnt by checking other plugins until I learnt the common mistakes and enough to write without references.
__________________
Silvers is offline
Psyk0tik
Veteran Member
Join Date: May 2012
Location: Homeless
Old 05-26-2018 , 09:07   Re: [L4D2] Tank fire immunity
Reply With Quote #9

Quote:
Originally Posted by Silvers View Post
That's how I learnt by checking other plugins until I learnt the common mistakes and enough to write without references.
That's how I learned to write plugins as well. By learning from your and other people's plugins, I went from not knowing what "#include <sourcemod>" was even for to being able to write a simple plugin that creates files in specific directories without using references. It all just comes down to whether someone is determined to learn, to just copy off of others, or to just request from others.

@OP, the wiki is a good start for beginners but if you really want to get into the more complex stuff, you need to have the motivation and patience to learn. You also have to get into the habit of sort of teaching yourself along the way, and asking help in the Scripting board (if you really can't find an old thread about the same topic already).
__________________
Psyk0tik is offline
Silvers
SourceMod Plugin Approver
Join Date: Aug 2010
Location: SpaceX
Old 05-26-2018 , 10:20   Re: [L4D2] Tank fire immunity
Reply With Quote #10

PHP Code:
#include <sourcemod>
#include <sdktools>
#include <sdkhooks>

#pragma semicolon 1
#pragma newdecls required

public void OnPluginStart()
{
    
// Nice and simple we have an event for tank spawning
    
HookEvent("tank_spawn"Event_TankSpawn);
}

public 
Action Event_TankSpawn(Handle eventchar[] namebool dontBroadcast)
{
    
int client GetEventInt(event"userid");
    
client GetClientOfUserId(client);

    if( 
client && IsClientInGame(client) )
    {
        
// We only need to hook when the tank spawns
        
SDKHook(clientSDKHook_OnTakeDamageOnTakeDamage);
    }
}  

public 
Action OnTakeDamage(int clientint &attackerint &inflictorfloat &damageint &damagetype)
{
    if( 
damagetype == 268435464 )
    {
        
ExtinguishEntity(client);
        
SetEntPropFloat(clientProp_Send"m_burnPercent"1.0);

        
// If you want to completely block damage caused by walking in the fire, these two lines do that:
        
damage 0.0;
        return 
Plugin_Changed;
    }
    return 
Plugin_Continue// No changes to damage.

You could remove the "return blah" and "damage = 0.0" lines if you don't want to change damage.

See Mutant Zombies plugin for more on dealing with fire and preventing the damage or you could reduce the damage etc.
__________________

Last edited by Silvers; 05-26-2018 at 10:20. Reason: missing semicolon
Silvers 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 02:42.


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