AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   [TF2 MvM] Destroy/Edit The Tank via SM (https://forums.alliedmods.net/showthread.php?t=270744)

Potato Uno 08-28-2015 11:06

[TF2 MvM] Destroy/Edit The Tank via SM
 
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).

Powerlord 08-28-2015 11:07

Re: [TF2 MvM] Destroy/Edit The Tank via SM
 
Have you tried using SDKHooks_TakeDamage on the tank entity to deal it damage?

As for changing health, it has AddHealth and RemoveHealth inputs...

Potato Uno 08-28-2015 11:15

Re: [TF2 MvM] Destroy/Edit The Tank via SM
 
Quote:

Originally Posted by Powerlord (Post 2337710)
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 (Post 2337710)
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!

Powerlord 08-28-2015 11:52

Re: [TF2 MvM] Destroy/Edit The Tank via SM
 
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.

Potato Uno 08-28-2015 13:51

Re: [TF2 MvM] Destroy/Edit The Tank via SM
 
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 08-28-2015 14:39

Re: [TF2 MvM] Destroy/Edit The Tank via SM
 
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.

Benoist3012 08-29-2015 05:33

Re: [TF2 MvM] Destroy/Edit The Tank via SM
 
PHP Code:

SetVariantInt(999999);
AcceptEntityInput(tank,"RemoveHealth"); 


SoulSharD 08-29-2015 06:05

Re: [TF2 MvM] Destroy/Edit The Tank via SM
 
I wonder if setting SDKHooks_TakeDamage to a negative value would actually add health...

Benoist3012 08-29-2015 13:41

Re: [TF2 MvM] Destroy/Edit The Tank via SM
 
Quote:

Originally Posted by SoulSharD (Post 2337925)
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


All times are GMT -4. The time now is 19:02.

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