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

[TF2] Pets


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
arthurdead
Senior Member
Join Date: Jul 2013
Old 01-02-2014 , 17:42   [TF2] Pets
Reply With Quote #1

original code made by noodleboy347 kinda fixed by me and fixes/improvements by abrandnewday

Public Commands:
sm_givepet <petindex> - Gives Yourself A Pet
sm_killpet - Slay Your Pet

Admin Commands Requires Cheats Flag
sm_spawnpet <client> <pet index> - Allows an admin to spawn a pet for a player.
sm_slaypet <client> - Allows an admin to slay a player's pet.

Public Commands If you Have An Pet
sm_petwait - makes your pet stop following you
sm_petfollow - makes your pet follow you

Instructions
1. Download playerpets.smx, put that into addons/sourcemod/plugins
2. Download playerpets.phrases.txt, put that into addons/sourcemod/translations
3. Load it up ingame via "rcon sm plugins load playerpets"

If you want to make your own custom pets:
1. Click "Get Source" below to download playerpets.sp
2. Download playerpets.inc as well, this is where you code in custom pets.
3. Put playerpets.inc into your "includes" folder, wherever you store your coding resources
4. Put playerpets.sp into the "scripting" folder.
5. Edit playerpets.inc and create your own custom pets.
6. Complie playerpets.sp.

Note: to not remove the first pet on the list (it counts as pet index 0)
Attached Files
File Type: sp Get Plugin or Get Source (playerpets.sp - 602 views - 18.7 KB)
File Type: inc playerpets.inc (7.1 KB, 711 views)
File Type: txt playerpets.phrases.txt (467 Bytes, 475 views)

Last edited by arthurdead; 01-21-2014 at 15:26.
arthurdead is offline
Oshizu
Veteran Member
Join Date: Nov 2012
Location: Warsaw
Old 01-02-2014 , 18:49   Re: [delete pls]
Reply With Quote #2

Here lies fixed 'Golden Machine Gun' pets plugin

Notice: if it's public for more than one hour publisher gonna have seizure out of reason RQWERQRQEDRESARAEREQRAR
__________________
...

Last edited by Oshizu; 01-02-2014 at 18:49.
Oshizu is offline
arthurdead
Senior Member
Join Date: Jul 2013
Old 01-03-2014 , 10:48   Re: [delete pls]
Reply With Quote #3

Quote:
Originally Posted by Oshizu View Post
Here lies fixed 'Golden Machine Gun' pets plugin

Notice: if it's public for more than one hour publisher gonna have seizure out of reason RQWERQRQEDRESARAEREQRAR
actually i am gonna release later just gonna tweak more

Last edited by arthurdead; 01-03-2014 at 12:52.
arthurdead is offline
Sreaper
髪を用心
Join Date: Nov 2009
Old 01-03-2014 , 12:06   Re: [delete pls]
Reply With Quote #4

What is this pet mod and how does it work? I know gmg has a pet plugin up for download but I've never actually looked at the source code.

Last edited by Sreaper; 01-03-2014 at 12:07.
Sreaper is offline
psychonic

BAFFLED
Join Date: May 2008
Old 01-03-2014 , 12:48   Re: [delete pls]
Reply With Quote #5

Quote:
Originally Posted by arthurdead View Post
[TF2] Pets
this was made by noodleboy i just edited a bit requires smlib

to spawn a pet just

petType[client] = petnumber in the inc file;
SpawnPet(client);

example
petType[client] = 1;
SpawnPet(client);

this will spawn Mrs.Skelly

pets.sp
Code:
new pet[MAXPLAYERS+1];
new petType[MAXPLAYERS+1];
new petState[MAXPLAYERS+1];
new Handle:soundTimer[MAXPLAYERS+1] = INVALID_HANDLE;

public SpawnPet(client)
{
    decl Float:pos[3];
    GetClientAbsOrigin(client, pos);
     OffsetLocation(pos);
     if(!(pet[client] = CreateEntityByName("prop_dynamic_override")))
     {
         return;
     }
     PrecacheModel(petInfo[petType[client]][iModel]);
     SetEntityModel(pet[client], petInfo[petType[client]][iModel]);
     DispatchSpawn(pet[client]);
     TeleportEntity(pet[client], pos, NULL_VECTOR, NULL_VECTOR);
     SetEntPropFloat(pet[client], Prop_Send, "m_flModelScale", petInfo[petType[client]][iModelSize]);
     SetPetState(client, STATE_SPAWNING);
     CreateParticle(petInfo[petType[client]][iSpawnParticle], pos);
     EmitAmbientSound(petInfo[petType[client]][iSoundGeneric], pos, pet[client]);
     EmitAmbientSound(petInfo[petType[client]][iSoundSpawn], pos);
     SetEntProp(client, Prop_Data, "m_CollisionGroup", COLLISION_GROUP_NPC);
     SetEntityRenderMode(pet[client], RENDER_TRANSADD);
     SafeKillTimer(soundTimer[client]);
     soundTimer[client] = CreateTimer(10.0, Timer_GenericSound, client);
     SDKHook(client, SDKHook_PreThink, PetThink);
}

public PetThink(client)
{
     if(!IsValidEntity(pet[client]))
     {
         SDKUnhook(client, SDKHook_PreThink, PetThink);
         return;
     }
     decl Float:pos[3], Float:ang[3], Float:clientPos[3];
    GetEntPropVector(pet[client], Prop_Data, "m_vecOrigin", pos);
     GetEntPropVector(pet[client], Prop_Data, "m_angRotation", ang);
     GetClientAbsOrigin(client, clientPos);
     new Float:dist = GetVectorDistance(clientPos, pos);
     new Float:distX = clientPos[0] - pos[0];
    new Float:distY = clientPos[1] - pos[1];
     new Float:speed = (dist - 64.0) / 54;
     Math_Clamp(speed, -4.0, 4.0);
     if(FloatAbs(speed) < 0.3)
     speed *= 0.1;
     if(dist > 1024.0)
     {
         decl Float:posTmp[3];
         GetClientAbsOrigin(client, posTmp);
         OffsetLocation(posTmp);
         TeleportEntity(pet[client], posTmp, NULL_VECTOR, NULL_VECTOR);
         GetEntPropVector(pet[client], Prop_Data, "m_vecOrigin", pos);
     }
     if(pos[0] < clientPos[0]) pos[0] += speed;
     if(pos[0] > clientPos[0]) pos[0] -= speed;
     if(pos[1] < clientPos[1]) pos[1] += speed;
     if(pos[1] > clientPos[1]) pos[1] -= speed;
     switch(petInfo[petType[client]][iHeight])
     {
        case HEIGHT_GROUND: pos[2] = clientPos[2];
         case HEIGHT_HOVER: pos[2] = clientPos[2] + 32.0;
         case HEIGHT_FLY: pos[2] = clientPos[2] + 96.0;
     }
     if(!(GetEntityFlags(client) & FL_ONGROUND))
         SetPetState(client, STATE_JUMPING);
     else if(FloatAbs(speed) > 0.2)
         SetPetState(client, STATE_WALKING);
     else if(TF2_IsPlayerInCondition(client, TFCond_Taunting))
         SetPetState(client, STATE_TAUNTING);
     else if(GetClientButtons(client) & IN_DUCK)
         SetPetState(client, STATE_DUCKING);
     else
         SetPetState(client, STATE_IDLE);
     ang[1] = (ArcTangent2(distY, distX) * 180) / 3.14;
     TeleportEntity(pet[client], pos, ang, NULL_VECTOR);
}

public Action:Timer_GenericSound(Handle:timer, any:client)
{
    if(pet[client] == 0 || !IsValidEntity(pet[client]))
     {
         KillTimer(timer);
     }
     decl Float:pos[3];
     GetEntPropVector(pet[client], Prop_Data, "m_vecOrigin", pos);
     EmitAmbientSound(petInfo[petType[client]][iSoundGeneric], pos, pet[client], _, _, _, petInfo[petType[client]][iPitch]);
     soundTimer[client] = CreateTimer(GetRandomFloat(20.0, 60.0), Timer_GenericSound, client);
}

public SetPetState(client, status)
{
     decl Float:pos[3];
     GetEntPropVector(pet[client], Prop_Data, "m_vecOrigin", pos);
    if(petState[client] == status)
     {
         return;
     }
     switch(status)
     {
         case STATE_IDLE: SetPetAnim(client, petInfo[petType[client]][iAnimIdle]);
         case STATE_WALKING: SetPetAnim(client, petInfo[petType[client]][iAnimWalk]);
         case STATE_JUMPING:
         {
             SetPetAnim(client, petInfo[petType[client]][iAnimJump]);
             EmitAmbientSound(petInfo[petType[client]][iSoundJump], pos, pet[client], _, _, _, petInfo[petType[client]][iPitch]);
        }
         case STATE_TAUNTING:
         {
             SetPetAnim(client, petInfo[petType[client]][iAnimTaunt]);
             EmitAmbientSound(petInfo[petType[client]][iSoundTaunt], pos, pet[client], _, _, _, petInfo[petType[client]][iPitch]);
        }
         case STATE_SPAWNING:
         {
             SetPetAnim(client, petInfo[petType[client]][iAnimSpawn]);
             EmitAmbientSound(petInfo[petType[client]][iSoundSpawn], pos, pet[client], _, _, _, petInfo[petType[client]][iPitch]);
        }
         case STATE_DUCKING:
         {
             SetPetAnim(client, petInfo[petType[client]][iAnimDuck]);
             EmitAmbientSound(petInfo[petType[client]][iSoundDuck], pos, pet[client], _, _, _, petInfo[petType[client]][iPitch]);
        }
     }
     petState[client] = status;
}

public SetPetAnim(client, const String:anim[])
{
    SetVariantString(anim);
     AcceptEntityInput(pet[client], "SetAnimation");
}

public OffsetLocation(Float:pos[3])
{
     pos[0] += GetRandomFloat(-128.0, 128.0);
     pos[1] += GetRandomFloat(-128.0, 128.0);
}


public KillPet(client)
{
    if(pet[client] == 0)
     {
         return;
     }
     decl Float:pos[3];
     Entity_GetAbsOrigin(pet[client], pos);
     SDKUnhook(client, SDKHook_PreThink, PetThink);
     AcceptEntityInput(pet[client], "Kill");
     CreateParticle(petInfo[petType[client]][iDeathParticle], pos);
     pet[client] = 0;
}
pets.inc
Code:
#define STATE_IDLE 1
#define STATE_WALKING 2
#define STATE_JUMPING 3
#define STATE_SPAWNING 4
#define STATE_TAUNTING 5
#define STATE_DUCKING 6

#define HEIGHT_GROUND 1
#define HEIGHT_HOVER 2
#define HEIGHT_FLY 3

enum petContent
{
     String:iModel[PLATFORM_MAX_PATH],
     String:iSoundGeneric[PLATFORM_MAX_PATH],
     String:iSoundJump[PLATFORM_MAX_PATH],
     String:iSoundTaunt[PLATFORM_MAX_PATH],
     String:iSoundSpawn[PLATFORM_MAX_PATH],
     String:iSoundDuck[PLATFORM_MAX_PATH],
     String:iAnimIdle[PLATFORM_MAX_PATH],
     String:iAnimWalk[PLATFORM_MAX_PATH],
     String:iAnimJump[PLATFORM_MAX_PATH],
     String:iAnimTaunt[PLATFORM_MAX_PATH],
     String:iAnimSpawn[PLATFORM_MAX_PATH],
     String:iAnimDuck[PLATFORM_MAX_PATH],
     String:iDeathParticle[PLATFORM_MAX_PATH],
     String:iSpawnParticle[PLATFORM_MAX_PATH],
     Float:iModelSize,
     iPitch,
     iHeight,
};

stock petInfo[][petContent] =
{
     {
         "models/empty.mdl",
         "misc/null.wav",
         "misc/null.wav",
         "misc/null.wav",
         "misc/null.wav",
         "misc/null.wav",
        "idle", "idle", "idle", "idle", "idle", "idle",
         "unknown",
         "unknown",
         0.0,
         0,
         0,
     },
     {
         "models/bots/skeleton_sniper/skeleton_sniper.mdl",
         "misc/halloween/skeletons/skelly_small_21.wav",
         "misc/halloween/skeletons/skelly_small_06.wav",
         "misc/halloween/skeletons/skelly_small_20.wav",
         "misc/halloween/spell_skeleton_horde_rise.wav",
         "misc/halloween/skeletons/skelly_small_11.wav",
         "stand_LOSER", "s_swimAlign_LOSER", "a_jumpstart_LOSER", "taunt06", "spawn06", "crouch_LOSER",
         "ghost_appearation",
         "ghost_appearation",
         0.5,
         100,
         HEIGHT_GROUND,
     }
};
Code:
stock SafeKillTimer(&Handle:timer)
{
     if(timer != INVALID_HANDLE)
     {
         KillTimer(timer);
         timer = INVALID_HANDLE;
     }
}
Code:
stock CreateParticle(String:particle[], Float:pos[3])
{
    new tblidx = FindStringTable("ParticleEffectNames");
     new String:tmp[256];
     new count = GetStringTableNumStrings(tblidx);
     new stridx = INVALID_STRING_INDEX;
     for(new i=0; i<count; i++)
     {
         ReadStringTable(tblidx, i, tmp, sizeof(tmp));
         if(StrEqual(tmp, particle, false))
         {
             stridx = i;
             break;
         }
     }
     for(new i=1; i<=GetMaxClients(); i++)
    {
         if(!IsValidEntity(i)) continue;
         if(!IsClientInGame(i)) continue;
         TE_Start("TFParticleEffect");
         TE_WriteFloat("m_vecOrigin[0]", pos[0]);
         TE_WriteFloat("m_vecOrigin[1]", pos[1]);
         TE_WriteFloat("m_vecOrigin[2]", pos[2]);
         TE_WriteNum("m_iParticleSystemIndex", stridx);
         TE_SendToClient(i, 0.0);
     }
}
https://forums.alliedmods.net/misc.php?do=showrules
Quote:
Do not blank out posts - if you solve your problem post the solution for others to find.
psychonic is offline
arthurdead
Senior Member
Join Date: Jul 2013
Old 01-03-2014 , 13:05   Re: [delete pls]
Reply With Quote #6

Quote:
Originally Posted by psychonic View Post
i was just going to make a new version
arthurdead is offline
Mr. Man
Veteran Member
Join Date: Mar 2011
Location: Huh?
Old 01-03-2014 , 13:11   Re: [TF2] Pets
Reply With Quote #7

W-wha? I am confused about what this plugin does...
Mr. Man is offline
404UserNotFound
BANNED
Join Date: Dec 2011
Old 01-09-2014 , 02:03   Re: [TF2] Pets
Reply With Quote #8

So after looking at the code and trying to compile it, a few things:

1. You're probably going to want to change "<gmg/pets>" to just "<pets>" and pop the pets.inc contents into your "include" folder
2. You're gonna want to add this to the top of pets.sp:
PHP Code:
#include <sourcemod>
#include <sdktools>
#include <tf2>
#include <tf2_stocks>
#include <sdkhooks> 
Otherwise you'll have huge error spam when you try to compile
3. Once you've done 1 and 2, the only error left will be the lack of a TraceEntityFilterPlayer function which you can find in many plugins.

I haven't fully compiled this or added in a command to spawn a pet and test it, but it looks promising.
404UserNotFound is offline
arthurdead
Senior Member
Join Date: Jul 2013
Old 01-09-2014 , 02:23   Re: [TF2] Pets
Reply With Quote #9

Quote:
Originally Posted by abrandnewday View Post
So after looking at the code and trying to compile it, a few things:

1. You're probably going to want to change "<gmg/pets>" to just "<pets>" and pop the pets.inc contents into your "include" folder
2. You're gonna want to add this to the top of pets.sp:
PHP Code:
#include <sourcemod>
#include <sdktools>
#include <tf2>
#include <tf2_stocks>
#include <sdkhooks> 
Otherwise you'll have huge error spam when you try to compile
3. Once you've done 1 and 2, the only error left will be the lack of a TraceEntityFilterPlayer function which you can find in many plugins.

I haven't fully compiled this or added in a command to spawn a pet and test it, but it looks promising.
fixed and added command to spawn/kill pet
arthurdead is offline
404UserNotFound
BANNED
Join Date: Dec 2011
Old 01-09-2014 , 21:08   Re: [TF2] Pets
Reply With Quote #10

Code:
L 01/09/2014 - 21:06:40: [SM] Native "GetClientAbsOrigin" reported: Client 1 is not in game
L 01/09/2014 - 21:06:40: [SM] Displaying call stack trace for plugin "pets.smx":
L 01/09/2014 - 21:06:40: [SM]   [0]  Line 146, C:\Users\User\Desktop\Work\Coding\addons\sourcemod\scripting\pets.sp::SpawnPet()
L 01/09/2014 - 21:06:40: [SM]   [1]  Line 139, C:\Users\User\Desktop\Work\Coding\addons\sourcemod\scripting\pets.sp::Command_EasyPet()
Another bug is that no matter what playerfilter (i.e. if I choose myself) you use, it seems to always get "attached" to a specific player.

Last edited by 404UserNotFound; 01-09-2014 at 21:17.
404UserNotFound 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 22:15.


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