Server: Gone over info_tfgoal and item_tfgoal's speak and broadcast
code. It gets really confusing as to why non-owner messages get played on 2fort but I think those are just fallback cases. This is very much undocumented territory we're entering here.
This commit is contained in:
parent
a0a65b9843
commit
b7dab86f17
2 changed files with 234 additions and 49 deletions
|
@ -81,7 +81,8 @@ class info_tfgoal:CBaseTrigger
|
|||
float m_dTeamYellowGain;
|
||||
float m_dTeamGreenGain;
|
||||
float m_dScore; /* score to be added to the activators' team score */
|
||||
int m_iTeam; /* which team this belongs to */
|
||||
int m_iTeamUses; /* who can use it */
|
||||
int m_iTeamOwner; /* owner of the item */
|
||||
|
||||
int m_iHealth;
|
||||
int m_iArmor;
|
||||
|
@ -92,6 +93,21 @@ class info_tfgoal:CBaseTrigger
|
|||
int m_iRockets;
|
||||
int m_iDetpack;
|
||||
|
||||
/* visual fluff */
|
||||
string m_msgAll; /* global */
|
||||
string m_msgActivator; /* AP */
|
||||
string m_msgActTeam; /* AP team */
|
||||
string m_msgNonActTeam; /* non-AP team */
|
||||
string m_msgOwnerTeam; /* owner team */
|
||||
string m_msgNonOwnerTeams; /* non-owner team */
|
||||
|
||||
string m_voxAll; /* global */
|
||||
string m_voxActivator; /* AP */
|
||||
string m_voxActTeam; /* AP team */
|
||||
string m_voxNonActTeam; /* non-AP team */
|
||||
string m_voxOwnerTeam; /* owner team */
|
||||
string m_voxNonOwnerTeams; /* non-owner team */
|
||||
|
||||
void(void) info_tfgoal;
|
||||
virtual void(void) touch;
|
||||
virtual void(void) Respawn;
|
||||
|
@ -113,14 +129,12 @@ info_tfgoal::touch(void)
|
|||
return;
|
||||
|
||||
/* check for team eligibility */
|
||||
if (m_iTeam)
|
||||
if (other.team != m_iTeam)
|
||||
if (m_iTeamUses)
|
||||
if (other.team != m_iTeamUses)
|
||||
return;
|
||||
|
||||
/* check for the must-have carry */
|
||||
if (m_dMustCarry) {
|
||||
item_tfgoal findme = __NULL__;
|
||||
|
||||
/* find the needle in the haystack */
|
||||
for (entity e = world; (e = find(e, ::classname, "item_tfgoal"));) {
|
||||
item_tfgoal a = (item_tfgoal)e;
|
||||
|
@ -173,7 +187,7 @@ info_tfgoal::touch(void)
|
|||
|
||||
string ts;
|
||||
if (m_dScore) {
|
||||
ts = sprintf("teamscore_%i", m_iTeam);
|
||||
ts = sprintf("teamscore_%i", m_iTeamUses);
|
||||
forceinfokey(world, ts, sprintf("%d", serverkeyfloat(ts) + m_dScore));
|
||||
}
|
||||
if (m_dTeamBlueGain) {
|
||||
|
@ -193,6 +207,50 @@ info_tfgoal::touch(void)
|
|||
forceinfokey(world, ts, sprintf("%d", serverkeyfloat(ts) + m_dTeamGreenGain));
|
||||
}
|
||||
|
||||
/* message broadcaster */
|
||||
if (m_msgAll) {
|
||||
env_message_broadcast(m_msgAll);
|
||||
} else {
|
||||
for (entity e = world; (e = find(e, ::classname, "player")); ) {
|
||||
if (e == pl) {
|
||||
env_message_single(e, m_msgActivator);
|
||||
} else if (e.team == pl.team ) {
|
||||
env_message_single(e, m_msgActTeam);
|
||||
} else if (e.team != pl.team) {
|
||||
if (e.team == m_iTeamOwner && m_msgOwnerTeam)
|
||||
env_message_single(e, m_msgOwnerTeam);
|
||||
else {
|
||||
if (m_msgNonOwnerTeams)
|
||||
env_message_single(e, m_msgNonOwnerTeams);
|
||||
else
|
||||
env_message_single(e, m_msgNonActTeam);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* vox speaker */
|
||||
if (m_voxAll) {
|
||||
Vox_Sentence_Broadcast(m_voxAll);
|
||||
} else {
|
||||
for (entity e = world; (e = find(e, ::classname, "player")); ) {
|
||||
if (e == pl) {
|
||||
Vox_Sentence_Single(e, m_voxActivator);
|
||||
} else if (e.team == pl.team ) {
|
||||
Vox_Sentence_Single(e, m_voxActTeam);
|
||||
} else if (e.team != pl.team) {
|
||||
if (e.team == m_iTeamOwner && m_voxOwnerTeam)
|
||||
Vox_Sentence_Single(e, m_voxOwnerTeam);
|
||||
else {
|
||||
if (m_voxNonOwnerTeams)
|
||||
Vox_Sentence_Single(e, m_voxNonOwnerTeams);
|
||||
else
|
||||
Vox_Sentence_Single(e, m_voxNonActTeam);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* remove? */
|
||||
if (m_tfgResult & TFRESULT_REMOVE) {
|
||||
Hide();
|
||||
|
@ -242,7 +300,10 @@ info_tfgoal::SpawnKey(string strKey, string strValue)
|
|||
m_dMustCarry = stof(strValue);
|
||||
break;
|
||||
case "team_no":
|
||||
m_iTeam = stoi(strValue);
|
||||
m_iTeamUses = stoi(strValue);
|
||||
break;
|
||||
case "owned_by":
|
||||
m_iTeamOwner = stoi(strValue);
|
||||
break;
|
||||
case "count":
|
||||
m_dScore = stof(strValue);
|
||||
|
@ -262,6 +323,47 @@ info_tfgoal::SpawnKey(string strKey, string strValue)
|
|||
case "increase_team4":
|
||||
m_dTeamGreenGain = stof(strValue);
|
||||
break;
|
||||
/* messages that get sent */
|
||||
case "b_b":
|
||||
m_msgAll = strValue; /* global */
|
||||
break;
|
||||
case "message":
|
||||
m_msgActivator = strValue; /* AP */
|
||||
break;
|
||||
case "b_t":
|
||||
case "team_broadcast":
|
||||
m_msgActTeam = strValue; /* AP team */
|
||||
break;
|
||||
case "b_n":
|
||||
case "netname_non_team_broadcast":
|
||||
m_msgNonActTeam = strValue; /* non-AP team */
|
||||
break;
|
||||
case "b_o":
|
||||
case "owners_team_broadcast":
|
||||
m_msgOwnerTeam = strValue; /* owner team */
|
||||
break;
|
||||
case "non_owners_team_broadcast":
|
||||
m_msgNonOwnerTeams = strValue; /* non-owner team */
|
||||
break;
|
||||
/* sentences that get played */
|
||||
case "speak":
|
||||
m_voxAll = strValue; /* global */
|
||||
break;
|
||||
case "AP_speak":
|
||||
m_voxActivator = strValue; /* AP */
|
||||
break;
|
||||
case "team_speak":
|
||||
m_voxActTeam = strValue; /* AP team */
|
||||
break;
|
||||
case "non_team_speak":
|
||||
m_voxNonActTeam = strValue; /* non-AP team */
|
||||
break;
|
||||
case "owners_team_speak":
|
||||
m_voxOwnerTeam = strValue; /* owner team */
|
||||
break;
|
||||
case "non_owners_team_speak":
|
||||
m_voxNonOwnerTeams = strValue; /* non-owner team */
|
||||
break;
|
||||
/* AP manipulators */
|
||||
case "health":
|
||||
m_iHealth = stoi(strValue);
|
||||
|
@ -306,6 +408,7 @@ info_tfgoal::info_tfgoal(void)
|
|||
info_tfgoal::Respawn();
|
||||
}
|
||||
|
||||
/* the brush based version of tfgoal */
|
||||
class i_t_g:info_tfgoal
|
||||
{
|
||||
void(void) i_t_g;
|
||||
|
|
|
@ -19,15 +19,30 @@ class item_tfgoal:CBaseTrigger
|
|||
float m_dItemID;
|
||||
|
||||
int m_iTeamUses;
|
||||
int m_iTeamOwner;
|
||||
|
||||
string m_strSound;
|
||||
string m_voxTeam;
|
||||
string m_voxOtherTeam;
|
||||
string m_voxActivator;
|
||||
player m_eActivator;
|
||||
|
||||
/* visual fluff */
|
||||
string m_msgAll; /* global */
|
||||
string m_msgActivator; /* AP */
|
||||
string m_msgActTeam; /* AP team */
|
||||
string m_msgNonActTeam; /* non-AP team */
|
||||
string m_msgOwnerTeam; /* owner team */
|
||||
string m_msgNonOwnerTeams; /* non-owner team */
|
||||
|
||||
string m_voxAll; /* global */
|
||||
string m_voxActivator; /* AP */
|
||||
string m_voxActTeam; /* AP team */
|
||||
string m_voxNonActTeam; /* non-AP team */
|
||||
string m_voxOwnerTeam; /* owner team */
|
||||
string m_voxNonOwnerTeams; /* non-owner team */
|
||||
|
||||
void(void) item_tfgoal;
|
||||
virtual void(void) touch;
|
||||
virtual void(void) Respawn;
|
||||
virtual void(string, string) SpawnKey;
|
||||
};
|
||||
|
||||
void
|
||||
|
@ -49,23 +64,49 @@ item_tfgoal::touch(void)
|
|||
m_eActivator = pl;
|
||||
|
||||
sound(this, CHAN_ITEM, m_strSound, 1.0f, ATTN_NONE);
|
||||
|
||||
/* broadcast via VOX that this was taken from us */
|
||||
for (entity e = world; (e = find(e, ::classname, "player")); ) {
|
||||
WriteByte(MSG_MULTICAST, SVC_CGAMEPACKET);
|
||||
WriteByte(MSG_MULTICAST, EV_CHAT_VOX);
|
||||
|
||||
if (e.team != m_iTeamUses) {
|
||||
WriteString(MSG_MULTICAST, m_voxOtherTeam);
|
||||
} else {
|
||||
if (e == pl)
|
||||
WriteString(MSG_MULTICAST, m_voxActivator);
|
||||
else
|
||||
WriteString(MSG_MULTICAST, m_voxTeam);
|
||||
/* message broadcaster */
|
||||
if (m_msgAll) {
|
||||
env_message_broadcast(m_msgAll);
|
||||
} else {
|
||||
for (entity e = world; (e = find(e, ::classname, "player")); ) {
|
||||
if (e == pl) {
|
||||
env_message_single(e, m_msgActivator);
|
||||
} else if (e.team == pl.team ) {
|
||||
env_message_single(e, m_msgActTeam);
|
||||
} else if (e.team != pl.team) {
|
||||
if (e.team == m_iTeamOwner && m_msgOwnerTeam)
|
||||
env_message_single(e, m_msgOwnerTeam);
|
||||
else {
|
||||
if (m_msgNonOwnerTeams)
|
||||
env_message_single(e, m_msgNonOwnerTeams);
|
||||
else
|
||||
env_message_single(e, m_msgNonActTeam);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
msg_entity = e;
|
||||
multicast([0,0,0], MULTICAST_ONE);
|
||||
/* vox speaker */
|
||||
if (m_voxAll) {
|
||||
Vox_Sentence_Broadcast(m_voxAll);
|
||||
} else {
|
||||
for (entity e = world; (e = find(e, ::classname, "player")); ) {
|
||||
if (e == pl) {
|
||||
Vox_Sentence_Single(e, m_voxActivator);
|
||||
} else if (e.team == pl.team ) {
|
||||
Vox_Sentence_Single(e, m_voxActTeam);
|
||||
} else if (e.team != pl.team) {
|
||||
if (e.team == m_iTeamOwner && m_voxOwnerTeam)
|
||||
Vox_Sentence_Single(e, m_voxOwnerTeam);
|
||||
else {
|
||||
if (m_voxNonOwnerTeams)
|
||||
Vox_Sentence_Single(e, m_voxNonOwnerTeams);
|
||||
else
|
||||
Vox_Sentence_Single(e, m_voxNonActTeam);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -80,35 +121,76 @@ item_tfgoal::Respawn(void)
|
|||
m_eActivator = __NULL__;
|
||||
}
|
||||
|
||||
void
|
||||
item_tfgoal::SpawnKey(string strKey, string strValue)
|
||||
{
|
||||
switch (strKey) {
|
||||
case "noise":
|
||||
m_strSound = strValue;
|
||||
break;
|
||||
case "mdl":
|
||||
model = strValue;
|
||||
break;
|
||||
case "goal_no":
|
||||
m_dItemID = stof(strValue);
|
||||
break;
|
||||
case "team_no":
|
||||
m_iTeamUses = stoi(strValue);
|
||||
break;
|
||||
case "owned_by":
|
||||
m_iTeamOwner = stoi(strValue);
|
||||
break;
|
||||
/* messages that get sent */
|
||||
case "b_b":
|
||||
m_msgAll = strValue; /* global */
|
||||
break;
|
||||
case "message":
|
||||
m_msgActivator = strValue; /* AP */
|
||||
break;
|
||||
case "b_t":
|
||||
case "team_broadcast":
|
||||
m_msgActTeam = strValue; /* AP team */
|
||||
break;
|
||||
case "b_n":
|
||||
case "netname_non_team_broadcast":
|
||||
m_msgNonActTeam = strValue; /* non-AP team */
|
||||
break;
|
||||
case "b_o":
|
||||
case "owners_team_broadcast":
|
||||
m_msgOwnerTeam = strValue; /* owner team */
|
||||
break;
|
||||
case "non_owners_team_broadcast":
|
||||
m_msgNonOwnerTeams = strValue; /* non-owner team */
|
||||
break;
|
||||
/* sentences that get played */
|
||||
case "speak":
|
||||
m_voxAll = strValue; /* global */
|
||||
break;
|
||||
case "AP_speak":
|
||||
m_voxActivator = strValue; /* AP */
|
||||
break;
|
||||
case "team_speak":
|
||||
m_voxActTeam = strValue; /* AP team */
|
||||
break;
|
||||
case "non_team_speak":
|
||||
m_voxNonActTeam = strValue; /* non-AP team */
|
||||
break;
|
||||
case "owners_team_speak":
|
||||
m_voxOwnerTeam = strValue; /* owner team */
|
||||
break;
|
||||
case "non_owners_team_speak":
|
||||
m_voxNonOwnerTeams = strValue; /* non-owner team */
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
item_tfgoal::item_tfgoal(void)
|
||||
{
|
||||
for (int i = 1; i < (tokenize(__fullspawndata) - 1); i += 2) {
|
||||
switch (argv(i)) {
|
||||
case "noise":
|
||||
m_strSound = argv(i+1);
|
||||
break;
|
||||
case "mdl":
|
||||
model = argv(i+1);
|
||||
break;
|
||||
case "goal_no":
|
||||
m_dItemID = stof(argv(i+1));
|
||||
break;
|
||||
case "team_no":
|
||||
m_iTeamUses = stoi(argv(i+1));
|
||||
break;
|
||||
case "AP_speak":
|
||||
m_voxActivator = argv(i+1);
|
||||
break;
|
||||
case "team_speak":
|
||||
m_voxTeam = argv(i+1);
|
||||
break;
|
||||
case "non_team_speak":
|
||||
m_voxOtherTeam = argv(i+1);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
SpawnKey(argv(i), argv(i+1));
|
||||
}
|
||||
precache_sound(m_strSound);
|
||||
|
||||
|
|
Loading…
Reference in a new issue