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

[TF2 MvM] Destroy/Edit The Tank via SM


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Potato Uno
Veteran Member
Join Date: Jan 2014
Location: Atlanta, Georgia
Old 08-28-2015 , 11:06   [TF2 MvM] Destroy/Edit The Tank via SM
Reply With Quote #1

So I want an admin command called "sm_destroy_tank" that will scan the map for all active tank entities and either:

(A) Force the tank that the admin wants destroyed to explode
(B) Change the health of the tank (raise it, lower it, etc)

So this code would find all the active tanks on the map:

PHP Code:
int iEntity = -1;
while ((
iEntity FindEntityByClassname(iEntity"tank_boss")) != -1)
{
    
// Something goes here?

What commands (like AcceptEntityInput) do I need to call to make the tank explode? What netprop (SetEntProp) do I need to call to change the tank's health?

Datamaps:

Spoiler


Netprops:

Spoiler


Thanks for any and all help!

EDIT: I do see this on the datamaps dump:

PHP Code:
InputSetSpeed (Input)(0 Bytes) - SetSpeed
InputSetHealth (Input)(0 Bytes) - SetHealth
InputSetMaxHealth (Input)(0 Bytes) - SetMaxHealth
InputAddHealth (Input)(0 Bytes) - AddHealth
InputRemoveHealth (Input)(0 Bytes) - RemoveHealth 
I have no idea how to trigger them or use them. I also still cannot find the tank explosion trigger either.

The sv_cheats 1 command tf_mvm_tank_kill will force a tank on the map to explode, so that's something I want to write an SM command alias of (but with more options).

Last edited by Potato Uno; 08-28-2015 at 11:09.
Potato Uno is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 08-28-2015 , 11:07   Re: [TF2 MvM] Destroy/Edit The Tank via SM
Reply With Quote #2

Have you tried using SDKHooks_TakeDamage on the tank entity to deal it damage?

As for changing health, it has AddHealth and RemoveHealth inputs...
__________________
Not currently working on SourceMod plugin development.

Last edited by Powerlord; 08-28-2015 at 11:09.
Powerlord is offline
Potato Uno
Veteran Member
Join Date: Jan 2014
Location: Atlanta, Georgia
Old 08-28-2015 , 11:15   Re: [TF2 MvM] Destroy/Edit The Tank via SM
Reply With Quote #3

Quote:
Originally Posted by Powerlord View Post
Have you tried using SDKHooks_TakeDamage on the tank entity to deal it damage?
I'm going to look into that right now. It looks like that will do the trick.

Quote:
Originally Posted by Powerlord View Post
As for changing health, it has AddHealth and RemoveHealth inputs...
I never have played with datamaps inputs. Can you provide one example of how to use them?

Thanks for the help Ross!
Potato Uno is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 08-28-2015 , 11:52   Re: [TF2 MvM] Destroy/Edit The Tank via SM
Reply With Quote #4

The SDKTools extension has commands for triggering inputs.

Assuming AddHealth takes an int number...

PHP Code:
#include <sdktools>

// Add 200 health to the tank
SetVariantInt(200);
AcceptEntityInput(iEntity"AddHealth"); 
It may take a float instead... there are a bunch of SetVariant functions for different types.
__________________
Not currently working on SourceMod plugin development.
Powerlord is offline
Potato Uno
Veteran Member
Join Date: Jan 2014
Location: Atlanta, Georgia
Old 08-28-2015 , 13:51   Re: [TF2 MvM] Destroy/Edit The Tank via SM
Reply With Quote #5

SDKHooks_TakeDamage did the job perfectly well:

PHP Code:
        // Otherwise, kill it:
        
else
        {
            
SDKHooks_TakeDamage(EntityIndex0010000000000000.0DMG_CRIT);
            
ReplyToCommand(iClient"[SM] Successfully destroyed tank entity #%d."EntityIndex);
        } 
I'm still investigating tank health modifying. For one, it doesn't update the tank health bar unless someone manually hurts it with something.
Potato Uno is offline
Potato Uno
Veteran Member
Join Date: Jan 2014
Location: Atlanta, Georgia
Old 08-28-2015 , 14:39   Re: [TF2 MvM] Destroy/Edit The Tank via SM
Reply With Quote #6

Untested solution to the problem.

PHP Code:
        SetEntProp(EntityIndexProp_Data"m_iHealth"NewHealth);        
        
SetEntProp(EntityIndexProp_Data"m_iMaxHealth"NewMaxHealth);
        
SetEntPropFloat(EntityIndexProp_Send"m_lastHealthPercentage"NewHealth*1.0/NewMaxHealth); 
The first changes the tank's health, the second changes the tank's max health cap (the game uses this number to force-recalculate m_lastHealthPercentage so this is important), and the third adjusts the HUD health bar.

When someone whacks the tank again the game will re-calculate m_lastHealthPercentage, so I think it should be set correctly, but if not, it will be adjusted anyway.

Again, not tested, but this should do the trick. I'll have to test it later.
Potato Uno is offline
Benoist3012
Veteran Member
Join Date: Mar 2014
Location: CWave::ForceFinish()
Old 08-29-2015 , 05:33   Re: [TF2 MvM] Destroy/Edit The Tank via SM
Reply With Quote #7

PHP Code:
SetVariantInt(999999);
AcceptEntityInput(tank,"RemoveHealth"); 
__________________
Benoist3012 is offline
SoulSharD
Member
Join Date: Oct 2013
Location: United Kingdom
Old 08-29-2015 , 06:05   Re: [TF2 MvM] Destroy/Edit The Tank via SM
Reply With Quote #8

I wonder if setting SDKHooks_TakeDamage to a negative value would actually add health...
__________________

SoulSharD is offline
Benoist3012
Veteran Member
Join Date: Mar 2014
Location: CWave::ForceFinish()
Old 08-29-2015 , 13:41   Re: [TF2 MvM] Destroy/Edit The Tank via SM
Reply With Quote #9

Quote:
Originally Posted by SoulSharD View Post
I wonder if setting SDKHooks_TakeDamage to a negative value would actually add health...
Weapon with negative dmg overheal the hurted player.

The command hurtme -99 overheal too.

I guess it work too with SDKHooks_TakeDamage
__________________
Benoist3012 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 11:30.


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