Raised This Month: $ Target: $400
 0% 

[TF2] Couple of urgent questions


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
GoRRageBoy
BANNED
Join Date: Jul 2011
Old 09-05-2011 , 17:37   [TF2] Couple of urgent questions
Reply With Quote #1

Seeing as nobody responded to this thread for quite a number of hours, I've decided to revamp it and also give you guys more information on this "secret project" of mine.

The secret project in question actually consists of 2 plugins (at the moment), which I'm calling "[TF2] Bill the Soldier" and "[TF2] Ellis the Scout".

The plugins will basically change the voice clips that are played during/after certain events, from the default Soldier/Scout voice clips to voice clips from Bill/Ellis from L4D/L4D2.

The requirements for a player to have his voice clips changed are as follows:

- As a Soldier, wear Bill's Hat
- As a Scout, wear Ellis' Cap

I really don't have any questions about events, because I'm using this lovely wiki article about TF2 events which has REALLY helped me out in learning about all the events in TF2.

Onto the questions...(Questions are bolded, additional info pertaining to the questions will be in italics)


1. Is there any way to check if a player is wearing a specific hat? I already know how to check a player's class, but the hat-checking part, I don't know.


2. Am I using the proper sound-emitting function? I'm currently using EmitSoundToAll to emit the voice clips, but I'm not sure if using EmitSoundToAll will enable the lip-syncing function of the player models, and cause them to move their moves to the Bill/Ellis voice clips.

I did make a plugin quite a number of months ago that allowed me to play sound clips using a command, and when I played a sound using the command, the player models mouth moved along with the speech line (Barney's "Head humpers!" line from "source sounds.gcf"). I've since lost the source code of that plugin I made, so I can't refer back to it.


3. Will just using the proper EmitSound function stop the default Soldier/Scout voice lines from playing, or do I have to code in another function to manually stop these voice lines from playing?Any help would be greatly appreciated, and if/when I finish these plugins and publicly release them here, massive credit will be given to anyone who has provided me with help in this thread.


4. Regarding that wiki article about TF2 Events that I linked to above; Is that article up-to-date, or are there any new events I should know about?

Last edited by GoRRageBoy; 09-06-2011 at 12:18. Reason: Repurposing the thread.
GoRRageBoy is offline
GoRRageBoy
BANNED
Join Date: Jul 2011
Old 09-06-2011 , 12:18   Re: [TF2] Couple of urgent questions
Reply With Quote #2

Repurposed the thread. Still in need of help
GoRRageBoy is offline
ajr1234
Senior Member
Join Date: Mar 2011
Location: Chicago, IL, U.S.A.
Old 09-06-2011 , 16:47   Re: [TF2] Couple of urgent questions
Reply With Quote #3

For #3, I don't think the default voice lines will stop playing. You should hook a NormalSHook and try to cancel out commentary.

Or what you could do is a NormalSHook and see which file is playing. Set that file's volume to 0 and EmitSound a similar dialog. Maybe that will work?

Then again, I'm a noob so I might be totally wrong.
ajr1234 is offline
asherkin
SourceMod Developer
Join Date: Aug 2009
Location: OnGameFrame()
Old 09-06-2011 , 20:34   Re: [TF2] Couple of urgent questions
Reply With Quote #4

Quote:
Originally Posted by GoRRageBoy View Post
1. Is there any way to check if a player is wearing a specific hat? I already know how to check a player's class, but the hat-checking part, I don't know.
Loop through all tf_wearable entities, check that m_hOwner == the client, then check m_iItemDefintionIndex matches those hat's item def indexes.

Quote:
Originally Posted by GoRRageBoy View Post
2. Am I using the proper sound-emitting function? I'm currently using EmitSoundToAll to emit the voice clips, but I'm not sure if using EmitSoundToAll will enable the lip-syncing function of the player models, and cause them to move their moves to the Bill/Ellis voice clips.
Should do as far as I can tell, there aren't that many others too chose from anyway! (See next point though.)

Quote:
Originally Posted by GoRRageBoy View Post
3. Will just using the proper EmitSound function stop the default Soldier/Scout voice lines from playing, or do I have to code in another function to manually stop these voice lines from playing?
No, as was said above you'll need to use a sound hook (which you should be using anyway to replace the sounds instead of emitting them manually).

Quote:
Originally Posted by GoRRageBoy View Post
4. Regarding that wiki article about TF2 Events that I linked to above; Is that article up-to-date, or are there any new events I should know about?
modevents.res in tf/resources will always be completely up-to-date, the community is pretty good at keeping the wiki updated though.
__________________
asherkin is offline
GoRRageBoy
BANNED
Join Date: Jul 2011
Old 09-06-2011 , 21:34   Re: [TF2] Couple of urgent questions
Reply With Quote #5

Sound hooks, eh? Not exactly sure what those are.

I just got off work and I'm dead tired, so I'll post the coding of the plugin that I've done so far, and if you could, could you do an example of the sound hook change in my coding and post the example for me?

I'm dead tired and just about to head to bed because I have to go back in to work in about 12 hours and I need sleeeeep.

NOTE: The defined sounds in OnPluginStart are just example sound lines. I haven't changed the defines to use the Bill voice clips that I'll be using. And the defined Gman "Rise and Shine" voice clips were part of a test I ran to see if the hooking worked properly. I also probably won't be using 5 sounds per event. That depends on how many voice clips I think I can use per event, that sound good.

I also haven't added in the Soldier class checks, or the Bill's Hat check, due to not knowing how to check which hat a player has equipped, and because I didn't want to add in the Soldier checks until I found out how to check a player's hat.

PHP Code:
/* ----- Global Includes ----- */
#include <sourcemod>
#include <sdktools>
#include <tf2_stocks>
#include <sdkhooks>

/* ----- Enable Strict Semicolon Mode ----- */
#pragma semicolon 1

/* ----- Voice Strings ----- */
new String:VOICE_PLAYERSPAWNED[5][64];
new 
String:VOICE_PLAYERDIED[5][64];
new 
String:VOICE_TOUCHED_LOCKER[5][64];
new 
String:VOICE_DESTROYED_OBJECT[5][64];
new 
String:VOICE_ROCKETJUMP[5][64];
new 
String:VOICE_ROCKETJUMP_LANDED[5][64];
new 
String:VOICE_ACHIEVEMENT_EARNED[5][64];
new 
String:VOICE_HITBYARROW[5][64];
new 
String:VOICE_HHHSPAWNED[5][64];
new 
String:VOICE_HHHKILLED[5][64];

/* ----- Plugin Information ----- */
public Plugin:myinfo =
{
    
name "Talk Like Bill",
    
author "[GoR] Rage Boy",
    
description "Spout off at the mouth like Bill from L4D",
    
version "0.1",
    
url ""
}

/* ----- Plugin has started ----- */
public OnPluginStart()
{
    
//Hook Events
    
HookEvent("player_spawn"Event_PlayerSpawn);
    
HookEvent("player_death"Event_PlayerDeath);
    
HookEvent("post_inventory_application"Event_LockerTouch);
    
HookEvent("rocket_jump"Event_RocketJump);
    
HookEvent("rocket_jump_landed"Event_RocketJumpLand);
    
HookEvent("object_destroyed"Event_ObjectDestroyed);
    
HookEvent("achievement_earned"Event_AchievementEarned);
    
HookEvent("arrow_impact"Event_HitByArrow);
    
HookEvent("pumpkin_lord_summoned"Event_HorsemannSpawned);
    
HookEvent("pumpkin_lord_killed"Event_HorsemannKilled);
    
    
//Define sounds to play on spawning
    
VOICE_PLAYERSPAWNED[0] = "vo/gman_misc/gman_riseshine.wav";
    
VOICE_PLAYERSPAWNED[1] = "vo/gman_misc/gman_riseshine.wav";
    
VOICE_PLAYERSPAWNED[2] = "vo/gman_misc/gman_riseshine.wav";
    
VOICE_PLAYERSPAWNED[3] = "vo/gman_misc/gman_riseshine.wav";
    
VOICE_PLAYERSPAWNED[4] = "vo/gman_misc/gman_riseshine.wav";
    
    
//Define sounds to play on dying
    
VOICE_PLAYERDIED[0] = "vo/pyro_laughevil02.wav";
    
VOICE_PLAYERDIED[1] = "vo/pyro_autoonfire02.wav";
    
VOICE_PLAYERDIED[2] = "vo/pyro_laughevil04.wav";
    
VOICE_PLAYERDIED[3] = "vo/pyro_goodjob01.wav";
    
VOICE_PLAYERDIED[4] = "vo/pyro_laughevil03.wav";
    
    
//Define sounds to play on touching a resupply locker
    
VOICE_TOUCHED_LOCKER[0] = "vo/pyro_laughevil02.wav";
    
VOICE_TOUCHED_LOCKER[1] = "vo/pyro_autoonfire02.wav";
    
VOICE_TOUCHED_LOCKER[2] = "vo/pyro_laughevil04.wav";
    
VOICE_TOUCHED_LOCKER[3] = "vo/pyro_goodjob01.wav";
    
VOICE_TOUCHED_LOCKER[4] = "vo/pyro_laughevil03.wav";
    
    
//Define sounds to play on destroying an object
    
VOICE_DESTROYED_OBJECT[0] = "vo/pyro_laughevil02.wav";
    
VOICE_DESTROYED_OBJECT[1] = "vo/pyro_autoonfire02.wav";
    
VOICE_DESTROYED_OBJECT[2] = "vo/pyro_laughevil04.wav";
    
VOICE_DESTROYED_OBJECT[3] = "vo/pyro_goodjob01.wav";
    
VOICE_DESTROYED_OBJECT[4] = "vo/pyro_laughevil03.wav";
    
    
//Define sounds to play on rocket jumping
    
VOICE_ROCKETJUMP[0] = "vo/pyro_laughevil02.wav";
    
VOICE_ROCKETJUMP[1] = "vo/pyro_autoonfire02.wav";
    
VOICE_ROCKETJUMP[2] = "vo/pyro_laughevil04.wav";
    
VOICE_ROCKETJUMP[3] = "vo/pyro_goodjob01.wav";
    
VOICE_ROCKETJUMP[4] = "vo/pyro_laughevil03.wav";
    
    
//Define sounds to play on landing after rocket jumping
    
VOICE_ROCKETJUMP_LANDED[0] = "vo/pyro_laughevil02.wav";
    
VOICE_ROCKETJUMP_LANDED[1] = "vo/pyro_autoonfire02.wav";
    
VOICE_ROCKETJUMP_LANDED[2] = "vo/pyro_laughevil04.wav";
    
VOICE_ROCKETJUMP_LANDED[3] = "vo/pyro_goodjob01.wav";
    
VOICE_ROCKETJUMP_LANDED[4] = "vo/pyro_laughevil03.wav";
    
    
//Define sounds to play on earning an achievement
    
VOICE_ACHIEVEMENT_EARNED[0] = "vo/pyro_laughevil02.wav";
    
VOICE_ACHIEVEMENT_EARNED[1] = "vo/pyro_autoonfire02.wav";
    
VOICE_ACHIEVEMENT_EARNED[2] = "vo/pyro_laughevil04.wav";
    
VOICE_ACHIEVEMENT_EARNED[3] = "vo/pyro_goodjob01.wav";
    
VOICE_ACHIEVEMENT_EARNED[4] = "vo/pyro_laughevil03.wav";
    
    
//Define sounds to play on being hit by a Huntsman arrow
    
VOICE_HITBYARROW[0] = "vo/pyro_laughevil02.wav";
    
VOICE_HITBYARROW[1] = "vo/pyro_autoonfire02.wav";
    
VOICE_HITBYARROW[2] = "vo/pyro_laughevil04.wav";
    
VOICE_HITBYARROW[3] = "vo/pyro_goodjob01.wav";
    
VOICE_HITBYARROW[4] = "vo/pyro_laughevil03.wav";
    
    
//Define sounds to play when the Horsemann spawns
    
VOICE_HHHSPAWNED[0] = "vo/pyro_laughevil02.wav";
    
VOICE_HHHSPAWNED[1] = "vo/pyro_autoonfire02.wav";
    
VOICE_HHHSPAWNED[2] = "vo/pyro_laughevil04.wav";
    
VOICE_HHHSPAWNED[3] = "vo/pyro_goodjob01.wav";
    
VOICE_HHHSPAWNED[4] = "vo/pyro_laughevil03.wav";
    
    
//Define sounds to play when the Horsemann is killed
    
VOICE_HHHKILLED[0] = "vo/pyro_laughevil02.wav";
    
VOICE_HHHKILLED[1] = "vo/pyro_autoonfire02.wav";
    
VOICE_HHHKILLED[2] = "vo/pyro_laughevil04.wav";
    
VOICE_HHHKILLED[3] = "vo/pyro_goodjob01.wav";
    
VOICE_HHHKILLED[4] = "vo/pyro_laughevil03.wav";
}

/* ----- Map has started ----- */
public OnMapStart()
{
    for( new 
05i++)
    {
        
PrecacheSound(VOICE_PLAYERSPAWNED[i], true);
        
PrecacheSound(VOICE_PLAYERDIED[i], true);
        
PrecacheSound(VOICE_TOUCHED_LOCKER[i], true);
        
PrecacheSound(VOICE_ROCKETJUMP[i], true);
        
PrecacheSound(VOICE_ROCKETJUMP_LANDED[i], true);
        
PrecacheSound(VOICE_DESTROYED_OBJECT[i], true);
        
PrecacheSound(VOICE_ACHIEVEMENT_EARNED[i], true);
        
PrecacheSound(VOICE_HITBYARROW[i], true);
        
PrecacheSound(VOICE_HHHSPAWNED[i], true);
        
PrecacheSound(VOICE_HHHKILLED[i], true);
    }
}

/* ----- Event: Player has spawned ----- */
public Action:Event_PlayerSpawn(Handle:event, const String:name[], bool:dontBroadcast)
{
    
//Define what "client" is, since this is an event, and "client" isn't naturally defined
    
new client GetClientOfUserId(GetEventInt(event"userid"));
    
//Choose one of the defined VOICE_PLAYERSPAWNED clips at random, then play it
    
EmitSoundToAll(VOICE_PLAYERSPAWNED[GetRandomInt(04)], client___1.0);
}

/* ----- Event: Player has died ----- */
public Action:Event_PlayerDeath(Handle:eventString:strName[], bool:bDontBroadcast)
{
    
//Define what "client" is, since this is an event, and "client" isn't naturally defined
    
new client GetClientOfUserId(GetEventInt(event"userid"));
    
//Choose one of the defined VOICE_PLAYERDIED clips at random, then play it
    
EmitSoundToAll(VOICE_PLAYERDIED[GetRandomInt(04)], client___1.0);
}

/* ----- Event: Player has touched a resupply locker, or changed their equipped items ----- */
public Action:Event_LockerTouch(Handle:event, const String:name[], bool:dontBroadcast)
{
    
//Define what "client" is, since this is an event, and "client" isn't naturally defined
    
new client GetClientOfUserId(GetEventInt(event"userid"));
    
//Choose one of the defined VOICE_TOUCHED_LOCKER clips at random, then play it
    
EmitSoundToAll(VOICE_TOUCHED_LOCKER[GetRandomInt(04)], client___1.0);
}

/* ----- Event: Player has rocket-jumped ----- */
public Action:Event_RocketJump(Handle:eventString:strName[], bool:dontBroadcast)
{
    
//Define what "client" is, since this is an event, and "client" isn't naturally defined
    
new client GetClientOfUserId(GetEventInt(event"userid"));
    
//Choose one of the defined VOICE_ROCKETJUMP clips at random, then play it
    
EmitSoundToAll(VOICE_ROCKETJUMP[GetRandomInt(04)], client___1.0);
}

/* ----- Event: Player has successfully landed and survived a rocket-jump ----- */
public Action:Event_RocketJumpLand(Handle:eventString:strName[], bool:dontBroadcast)
{
    
//Define what "client" is, since this is an event, and "client" isn't naturally defined
    
new client GetClientOfUserId(GetEventInt(event"userid"));
    
//Choose one of the defined VOICE_ROCKETJUMP_LANDED clips at random, then play it
    
EmitSoundToAll(VOICE_ROCKETJUMP_LANDED[GetRandomInt(04)], client___1.0);
}

/* ----- Event: Player has destroyed an object ----- */
public Action:Event_ObjectDestroyed(Handle:eventString:strName[], bool:bDontBroadcast)
{
    
//Define what "client" is, since this is an event, and "client" isn't naturally defined
    
new client GetClientOfUserId(GetEventInt(event"userid"));
    
//Choose one of the defined VOICE_DESTROYED_OBJECT clips at random, then play it
    
EmitSoundToAll(VOICE_DESTROYED_OBJECT[GetRandomInt(04)], client___1.0);
}

/* ----- Event: Player has earned an achievement ----- */
public Action:Event_AchievementEarned(Handle:event, const String:name[], bool:dontBroadcast)
{
    
//Define what "client" is, since this is an event, and "client" isn't naturally defined
    
new client GetClientOfUserId(GetEventInt(event"userid"));
    
//Choose one of the defined VOICE_ACHIEVEMENT_EARNED clips at random, then play it
    
EmitSoundToAll(VOICE_ACHIEVEMENT_EARNED[GetRandomInt(04)], client___1.0);
}

/* ----- Event: Player has been hit by a Huntsman arrow ----- */
public Action:Event_HitByArrow(Handle:event, const String:name[], bool:dontBroadcast)
{
    
//Define what "client" is, since this is an event, and "client" isn't naturally defined
    
new client GetClientOfUserId(GetEventInt(event"userid"));
    
//Choose one of the defined VOICE_HITBYARROW clips at random, then play it
    
EmitSoundToAll(VOICE_HITBYARROW[GetRandomInt(04)], client___1.0);
}

/* ----- Event: Player has been hit by a Huntsman arrow ----- */
public Action:Event_HorsemannSpawned(Handle:event, const String:name[], bool:dontBroadcast)
{
    
//Define what "client" is, since this is an event, and "client" isn't naturally defined
    
new client GetClientOfUserId(GetEventInt(event"userid"));
    
//Choose one of the defined VOICE_HHHSPAWNED clips at random, then play it
    
EmitSoundToAll(VOICE_HHHSPAWNED[GetRandomInt(04)], client___1.0);
}

/* ----- Event: Player has been hit by a Huntsman arrow ----- */
public Action:Event_HorsemannKilled(Handle:event, const String:name[], bool:dontBroadcast)
{
    
//Define what "client" is, since this is an event, and "client" isn't naturally defined
    
new client GetClientOfUserId(GetEventInt(event"userid"));
    
//Choose one of the defined VOICE_HHHKILLED clips at random, then play it
    
EmitSoundToAll(VOICE_HHHKILLED[GetRandomInt(04)], client___1.0);
}

/* ----- Stock: Valid Client Check ----- */
stock bool:IsValidClient(clientbool:nobots true)

    if (
client <= || client MaxClients || !IsClientConnected(client) || (nobots && IsFakeClient(client)))
    {
        return 
false
    }
    return 
IsClientInGame(client); 


Quote:
Originally Posted by asherkin View Post
Loop through all tf_wearable entities, check that m_hOwner == the client, then check m_iItemDefintionIndex matches those hat's item def indexes.
I understood the item definition index part....nothing else. Care to type up a quick example of this in action? My brain isn't functioning at full power right now due to sleepiness.

Last edited by GoRRageBoy; 09-06-2011 at 21:40.
GoRRageBoy is offline
Tylerst
Veteran Member
Join Date: Oct 2010
Old 09-07-2011 , 07:57   Re: [TF2] Couple of urgent questions
Reply With Quote #6

Quote:
Originally Posted by GoRRageBoy View Post
Quote:
Originally Posted by asherkin View Post
Loop through all tf_wearable entities, check that m_hOwner == the client, then check m_iItemDefintionIndex matches those hat's item def indexes.
I understood the item definition index part....nothing else. Care to type up a quick example of this in action? My brain isn't functioning at full power right now due to sleepiness.
PHP Code:
new hat = -1
while((
hat=FindEntityByClassname(hat"tf_wearable"))!=INVALID_ENT_REFERENCE)
{
     if(
GetEntPropEnt(hatProp_Send"m_hOwner")==client&&GetEntProp(hatProp_Send"m_iItemDefinitionIndex")==InsertHatIndexHere)
     {
           
//Dostuff
     
}


Last edited by Tylerst; 09-07-2011 at 08:05.
Tylerst is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 09-07-2011 , 10:13   Re: [TF2] Couple of urgent questions
Reply With Quote #7

Quote:
Originally Posted by GoRRageBoy View Post
4. Regarding that wiki article about TF2 Events that I linked to above; Is that article up-to-date, or are there any new events I should know about?
It should be reasonably up to date, as I went through the entire thing a few weeks ago to sync it with the newest modevents.res.

Quote:
Originally Posted by GoRRageBoy View Post
I understood the item definition index part....nothing else. Care to type up a quick example of this in action? My brain isn't functioning at full power right now due to sleepiness.
I can only assume asherkin is referring to the item numbers in scripts/items/items_game.txt
__________________
Not currently working on SourceMod plugin development.

Last edited by Powerlord; 09-07-2011 at 10:16.
Powerlord is offline
GoRRageBoy
BANNED
Join Date: Jul 2011
Old 09-07-2011 , 20:50   Re: [TF2] Couple of urgent questions
Reply With Quote #8

Quote:
Originally Posted by Tylerst View Post
PHP Code:
new hat = -1
while((
hat=FindEntityByClassname(hat"tf_wearable"))!=INVALID_ENT_REFERENCE)
{
     if(
GetEntPropEnt(hatProp_Send,  "m_hOwner")==client&&GetEntProp(hatProp_Send,  "m_iItemDefinitionIndex")==InsertHatIndexHere)
     {
           
//Dostuff
     
}

Thank you very much for clarifying that for me.


Also, I'm stuck at a new obstacle now. Sound hooks! Yay!

I've found this but it confuses me. Must...google...."alliedmods soundhook"....to find....example!
GoRRageBoy is offline
Tylerst
Veteran Member
Join Date: Oct 2010
Old 09-07-2011 , 21:55   Re: [TF2] Couple of urgent questions
Reply With Quote #9

I've never done sound hooks, but I believe you would use NormalSHook or AmbientSHook with the particular sound file and return Plugin_Stop to stop them from playing, or Plugin_Changed to change the sound.

Also, TF2_AddCondition has to do with gameplay conditions(Uber, bonk, kritz, taunts, cloaking, etc), none of it has to do with sounds

Last edited by Tylerst; 09-07-2011 at 22:01.
Tylerst is offline
GoRRageBoy
BANNED
Join Date: Jul 2011
Old 09-08-2011 , 08:00   Re: [TF2] Couple of urgent questions
Reply With Quote #10

Quote:
Originally Posted by Tylerst View Post
Also, TF2_AddCondition has to do with gameplay conditions(Uber, bonk, kritz, taunts, cloaking, etc), none of it has to do with sounds

Son of a bitch, I must've gotten the wrong API URL.

The thing I linked to was for the "sdktools_sound" section.
GoRRageBoy 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 19:42.


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