AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Snippets and Tutorials (https://forums.alliedmods.net/forumdisplay.php?f=112)
-   -   [Snippet][TF2] Directly Spawning Mannpower Powerups and extra info... (https://forums.alliedmods.net/showthread.php?t=253874)

Oshizu 12-29-2014 20:09

[Snippet][TF2] Directly Spawning Mannpower Powerups and extra info...
 
Hi Guys

I'd like to share with you quite lazy snippet which allows you to spawn normally working powerups without mannpower mode on nor need to use info_target spawners. Directly thru 'CreateEntityByName' :bee:

Test Plugin:
PHP Code:

#include <sdktools>
#include <tf2_stocks>
 
public OnPluginStart()
{
    
RegConsoleCmd("sm_powerup_spawn_test"SpawnTest_Powerup);
}

public 
Action:SpawnTest_Powerup(clientargs)
{
    
decl String:argc[32]
    
GetCmdArg(1argcsizeof(argc))

    
decl Float:player_pos[3]
    
GetClientAbsOrigin(clientplayer_pos)

    new 
entity CreateEntityByName("item_powerup_rune")
    new 
Address:desu GetEntityAddress(entity) + Address:1256;

    new 
type StringToInt(argc)
    if(
type == 1)
    {
        
StoreToAddress(desu0x5ANumberType_Int8)
    }
    else if(
type == 2)
    {
        
StoreToAddress(desu0x5DNumberType_Int8)
    }
    else if(
type == 2)
    {
        
StoreToAddress(desu0x5CNumberType_Int8)
    }
    else if(
type == 3
    {
        
StoreToAddress(desu0x5CNumberType_Int8)
    }
    else if(
type == 4)
    {
        
StoreToAddress(desu0x5BNumberType_Int8)
    }
    else if(
type == 5)
    {
        
StoreToAddress(desu0x5ENumberType_Int8)
    }
    else if(
type == 6)
    {
        
StoreToAddress(desu0x5FNumberType_Int8)
    }
    else if(
type == 7)
    {
        
StoreToAddress(desu0x60NumberType_Int8)
    }
    else if(
type == 8)
    {
        
StoreToAddress(desu0x61NumberType_Int8)
    }
    
TeleportEntity(entityplayer_posNULL_VECTORNULL_VECTOR)
    
DispatchSpawn(entity)


IDs for Powerups
PHP Code:

 /*
 Table List:
0x5A: Strenght
0x5D: Resistance
0x5C: Regneration
0x5B: Haste
0x5E: Vampire
0x5F: Warlock
0x60: Precision
0x61: Agilty
 */ 

This is Windows version of plugin
For Linux you will probably need to change 'Address:1256' to linux equivalent of that address
It is either: 1276 or probably one of these:
PHP Code:

  *(_BYTE *)(v9 1260) = a3;
  *(
_DWORD *)(v9 1264) = a4;
  *(
_DWORD *)(v9 1268) = a5;
  *(
_DWORD *)(v9 1272) = a6

Found above informations in following things:
- CTFRune::CreateRune(Vector const&, int, bool, Vector) //Found in there offset for setting type of powerups\\ *You can find it on windows by searching string 'item_powerup_rune'.
- CTFRune::MyTouch(CBasePlayer *) //Found in there ids of powerups\\ *Can be found by searching 'You got the PRECISION power-up!' string*


- Enjoy. I'il probably update/refine/turn into plugin this snippet tommorow cause it's kinda messy at it's current state :bacon:

psychonic 12-29-2014 20:25

Re: [Snippet][TF2] Directly Spawning Mannpower Powerups and extra info...
 
Those IDs look like they're just the condition #'s of the player conds granted by the runes.

WildCard65 12-29-2014 20:26

Re: [Snippet][TF2] Directly Spawning Mannpower Powerups...
 
Quote:

Originally Posted by Oshizu (Post 2241688)
Hi Guys

I'd like to share with you quite lazy snippet which allows you to spawn normally working powerups without mannpower mode on nor need to use info_target spawners. Directly thru 'CreateEntityByName' :bee:

Test Plugin:
PHP Code:

#include <sdktools>
#include <tf2_stocks>
 
public OnPluginStart()
{
    
RegConsoleCmd("sm_powerup_spawn_test"SpawnTest_Powerup);
}

public 
Action:SpawnTest_Powerup(clientargs)
{
    
decl String:argc[32]
    
GetCmdArg(1argcsizeof(argc))

    
decl Float:player_pos[3]
    
GetClientAbsOrigin(clientplayer_pos)

    new 
entity CreateEntityByName("item_powerup_rune")
    new 
Address:desu GetEntityAddress(entity) + Address:1256;

    new 
type StringToInt(argc)
    if(
type == 1)
    {
        
StoreToAddress(desu0x5ANumberType_Int8)
    }
    else if(
type == 2)
    {
        
StoreToAddress(desu0x5DNumberType_Int8)
    }
    else if(
type == 2)
    {
        
StoreToAddress(desu0x5CNumberType_Int8)
    }
    else if(
type == 3
    {
        
StoreToAddress(desu0x5CNumberType_Int8)
    }
    else if(
type == 4)
    {
        
StoreToAddress(desu0x5BNumberType_Int8)
    }
    else if(
type == 5)
    {
        
StoreToAddress(desu0x5ENumberType_Int8)
    }
    else if(
type == 6)
    {
        
StoreToAddress(desu0x5FNumberType_Int8)
    }
    else if(
type == 7)
    {
        
StoreToAddress(desu0x60NumberType_Int8)
    }
    else if(
type == 8)
    {
        
StoreToAddress(desu0x61NumberType_Int8)
    }
    
TeleportEntity(entityplayer_posNULL_VECTORNULL_VECTOR)
    
DispatchSpawn(entity)


IDs for Powerups
PHP Code:

 /*
 Table List:
0x5A: Strenght
0x5D: Resistance
0x5C: Regneration
0x5B: Haste
0x5E: Vampire
0x5F: Warlock
0x60: Precision
0x61: Agilty
 */ 

This is Windows version of plugin
For Linux you will probably need to change 'Address:1256' to linux equivalent of that address
It is either: 1276 or probably one of these:
PHP Code:

  *(_BYTE *)(v9 1260) = a3;
  *(
_DWORD *)(v9 1264) = a4;
  *(
_DWORD *)(v9 1268) = a5;
  *(
_DWORD *)(v9 1272) = a6

- Enjoy. I'il probably update/refine/turn into plugin this snippet tommorow cause it's kinda messy at it's current state :bacon:

Here's a better version:
PHP Code:

#define WINDOWS
//#define LINUX //Uncomment this line and comment the above if your on linux.

#if defined WINDOWS
#define OFFSET Address:1256
#endif
#if defined LINUX
#define OFFSET Address:1256 //Anyone got the linux address?
#endif
new addresses[8] = {0x5A0x5D0x5C0x5B0x5E0x5F0x600x61};

stock CreatePowerup(typefloat:pos[3], float:rotation[3])
{
    new 
entity CreateEntityByName("item_powerup_rune")
    new 
Address:desu GetEntityAddress(entity) + OFFSET;
    
StoreToAddress(desuaddresses[type], NumberType_Int8);
    
TeleportEntity(entityposrotationNULL_VECTOR);
    
DispatchSpawn(entity);
    return 
entity;



psychonic 12-29-2014 20:44

Re: [Snippet][TF2] Directly Spawning Mannpower Powerups...
 
Quote:

Originally Posted by WildCard65 (Post 2241694)
Here's a better version:

It's not really better, just rearranging the original logic.

An improvement would be changing it to use gamedata with offsets relative to existing sendprops or datadesc vars (also named in gamedata), rather than hardcoding offsets relative to the entity base in the plugin. They be very likely to change on most updates like that.

Ex. offset of m_iszModel + 24.

friagram 12-30-2014 06:23

Re: [Snippet][TF2] Directly Spawning Mannpower Powerups and extra info...
 
This is beta, and early at that... The offsets are going to change for sure.

404UserNotFound 01-03-2015 22:07

Re: [Snippet][TF2] Directly Spawning Mannpower Powerups and extra info...
 
Throwin' my hat in the ring with something I made. Gives the powerup directly to the player and when you die the powerup drops. Only thing is they seem do a flashy thing after a while of not being picked up and they don't seem to disappear. They do respect team spawn rooms and that you can't bring a powerup into your own spawn. As well, you can only pick one up, but using these commands will grant you every powerup without losing any.

Very shitty code mind you, but still usable. And no, not clearing the individual rune type on the death event does not lead to "having the powerup effect without having the rune". It appears that the HasRune condition is the true controller of whether or not you have the rune's effect.

PHP Code:

public OnPluginStart()
{
    
RegAdminCmd("sm_rune1"Command_Rune1ADMFLAG_GENERIC"it's a command");
    
RegAdminCmd("sm_rune2"Command_Rune2ADMFLAG_GENERIC"it's a command");
    
RegAdminCmd("sm_rune3"Command_Rune3ADMFLAG_GENERIC"it's a command");
    
RegAdminCmd("sm_rune4"Command_Rune4ADMFLAG_GENERIC"it's a command");
    
RegAdminCmd("sm_rune5"Command_Rune5ADMFLAG_GENERIC"it's a command");
    
RegAdminCmd("sm_rune6"Command_Rune6ADMFLAG_GENERIC"it's a command");
    
RegAdminCmd("sm_rune7"Command_Rune7ADMFLAG_GENERIC"it's a command");
    
RegAdminCmd("sm_rune8"Command_Rune8ADMFLAG_GENERIC"it's a command");
    
    
HookEvent("player_death"Event_PlayerChanged);
}


public 
Action:Command_Rune1(clientargs)
{
    
TF2_AddCondition(clientTFCond_HasRuneTFCondDuration_Infinite);
    
TF2_AddCondition(clientTFCond_RuneStrengthTFCondDuration_Infinite);
}

public 
Action:Command_Rune2(clientargs)
{
    
TF2_AddCondition(clientTFCond_HasRuneTFCondDuration_Infinite);
    
TF2_AddCondition(clientTFCond_RuneHasteTFCondDuration_Infinite);
}

public 
Action:Command_Rune3(clientargs)
{
    
TF2_AddCondition(clientTFCond_HasRuneTFCondDuration_Infinite);
    
TF2_AddCondition(clientTFCond_RuneRegenTFCondDuration_Infinite);
}

public 
Action:Command_Rune4(clientargs)
{
    
TF2_AddCondition(clientTFCond_HasRuneTFCondDuration_Infinite);
    
TF2_AddCondition(clientTFCond_RuneResistTFCondDuration_Infinite);
}

public 
Action:Command_Rune5(clientargs)
{
    
TF2_AddCondition(clientTFCond_HasRuneTFCondDuration_Infinite);
    
TF2_AddCondition(clientTFCond_RuneVampireTFCondDuration_Infinite);
}

public 
Action:Command_Rune6(clientargs)
{
    
TF2_AddCondition(clientTFCond_HasRuneTFCondDuration_Infinite);
    
TF2_AddCondition(clientTFCond_RuneWarlockTFCondDuration_Infinite);
}

public 
Action:Command_Rune7(clientargs)
{
    
TF2_AddCondition(clientTFCond_HasRuneTFCondDuration_Infinite);
    
TF2_AddCondition(clientTFCond_RunePrecisionTFCondDuration_Infinite);
}

public 
Action:Command_Rune8(clientargs)
{
    
TF2_AddCondition(clientTFCond_HasRuneTFCondDuration_Infinite);
    
TF2_AddCondition(clientTFCond_RuneAgilityTFCondDuration_Infinite);
}

public 
Action:Event_PlayerChanged(Handle:event, const String:name[], bool:dontbroadcast)
{
    new 
client GetClientOfUserId(GetEventInt(event"userid"));
    
TF2_RemoveCondition(clientTFCond_HasRune);
    return 
Plugin_Continue;



Powerlord 01-05-2015 11:42

Re: [Snippet][TF2] Directly Spawning Mannpower Powerups and extra info...
 
I haven't tried it, but if you want to give players a particular rune directly, you can probably use TF2Items to spawn the inventory version of it on them.

Also, I have no idea why the weapon class is listed as saxxy in the schema, it just is.

WildCard65 01-05-2015 18:20

Re: [Snippet][TF2] Directly Spawning Mannpower Powerups and extra info...
 
Quote:

Originally Posted by Powerlord (Post 2245150)
I haven't tried it, but if you want to give players a particular rune directly, you can probably use TF2Items to spawn the inventory version of it on them.

Also, I have no idea why the weapon class is listed as saxxy in the schema, it just is.

I believe the pan is also a saxxy

404UserNotFound 01-06-2015 01:28

Re: [Snippet][TF2] Directly Spawning Mannpower Powerups and extra info...
 
Quando omni flunkus Saxxy (When all else fails, Saxxy)

Powerlord 01-06-2015 13:06

Re: [Snippet][TF2] Directly Spawning Mannpower Powerups and extra info...
 
Quote:

Originally Posted by WildCard65 (Post 2245298)
I believe the pan is also a saxxy

The pan is also a melee weapon.

The saxxy meta-class maps to these server classes, depending on the player class:
  • tf_weapon_bat
  • tf_weapon_shovel
  • tf_weapon_fireaxe
  • tf_weapon_bottle
  • tf_weapon_fists
  • tf_weapon_wrench
  • tf_weapon_bonesaw
  • tf_weapon_club
  • tf_weapon_knife


All times are GMT -4. The time now is 15:48.

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