Compare commits

...

4 Commits

9 changed files with 142 additions and 70 deletions

View File

@ -148,6 +148,8 @@
[func_tankmortar](@ref func_tankmortar)
[func_trackchange](@ref func_trackchange)
[func_tracktrain](@ref func_tracktrain)
[func_train](@ref func_train)

View File

@ -15,8 +15,8 @@ printf -- "" > "/tmp/def_model"
do
SEG1=$(echo "$LINE" | awk '{ print $1 }')
SEG2=$(echo "$LINE" | awk '{ print $2 }')
KEY=$(echo "$LINE" | awk -F"\"" '{ print $2 }')
VAL=$(echo "$LINE" | awk -F"\"" '{ print $4 }')
KEY="$(echo "$LINE" | awk -F"\"" '{ print $2 }')"
VAL="$(echo "$LINE" | awk -F"\"" '{ print $4 }')"
if [ "$KEY" = "entityDef" ]
then
@ -45,7 +45,7 @@ do
if [ "$KEY" = "mins" ]
then
if [ -z $(cat "/tmp/def_mins") ]
if [ -z "$(cat /tmp/def_mins)" ]
then
printf -- "$VAL" > "/tmp/def_mins"
fi
@ -53,7 +53,7 @@ do
if [ "$KEY" = "maxs" ]
then
if [ -z $(cat "/tmp/def_maxs") ]
if [ -z "$(cat /tmp/def_maxs)" ]
then
printf -- "$VAL" > "/tmp/def_maxs"
fi
@ -66,7 +66,7 @@ do
if [ "$KEY" = "netname" ]
then
if [ -z "$(cat "/tmp/def_usage")" ]
if [ -z "$(cat /tmp/def_usage)" ]
then
printf -- "$VAL" > "/tmp/def_usage"
fi
@ -79,7 +79,7 @@ do
if [ "$KEY" = "model" ]
then
if [ -z $(cat "/tmp/def_model") ]
if [ -z "$(cat /tmp/def_model)" ]
then
printf -- "$VAL" > "/tmp/def_model"
fi
@ -87,12 +87,12 @@ do
if [ "$SEG1" = "}" ]
then
KEY_NAME=$(cat "/tmp/def_name")
KEY_COLOR=$(cat "/tmp/def_color")
KEY_MINS=$(cat "/tmp/def_mins")
KEY_MAXS=$(cat "/tmp/def_maxs")
KEY_USAGE=$(cat "/tmp/def_usage")
KEY_MODEL=$(cat "/tmp/def_model")
KEY_NAME="$(cat /tmp/def_name)"
KEY_COLOR="$(cat /tmp/def_color)"
KEY_MINS="$(cat /tmp/def_mins)"
KEY_MAXS="$(cat /tmp/def_maxs)"
KEY_USAGE="$(cat /tmp/def_usage)"
KEY_MODEL="$(cat /tmp/def_model)"
printf -- "" > "/tmp/def_name"
printf -- "" > "/tmp/def_color"
printf -- "" > "/tmp/def_mins"

View File

@ -84,10 +84,9 @@ trigger_changetarget::Trigger(entity act, triggermode_t state)
{
NSEntity f;
f = (NSEntity)find(world, ::targetname, target);
for (f = __NULL__; (f = (NSEntity)find(f, ::targetname, target));) {
if (f) {
dprint("^2trigger_changetarget::^3Trigger^7: " \
NSLog("^2trigger_changetarget::^3Trigger^7: " \
"Changing %s (%s) target from '%s' to '%s'\n", \
target, f.classname, f.target, target);

View File

@ -131,8 +131,8 @@ GameLibrary_FindInGameDir(string filename, string gamedirname)
static void
GameLibrary_LibListParse(int id, string strKey, string strValue)
{
if (id == 0)
print(sprintf("%i %S %S\n", id, strKey, strValue));
//if (id == 0)
//print(sprintf("%i %S %S\n", id, strKey, strValue));
switch(strKey) {
case "game":

View File

@ -23,11 +23,6 @@
/** This class represents active gamerules. */
class NSGameRules:NSIO
{
private:
int m_iIntermission;
float m_flIntermissionTime;
float m_flIntermissionCycle;
public:
void NSGameRules(void);
@ -94,12 +89,14 @@ public:
virtual void DamageRadius(vector,entity,float,float,bool,int);
/* end of a game */
/** Called when intermission starts. */
/** Called when intermission starts. Will send all current players to the intermission screen. */
virtual void IntermissionStart(void);
/** Called when intermission calls a new map. */
/** Called when the intermission system calls a new map. */
virtual void IntermissionCycle(void);
/** Called when intermission ents. */
/** Called when intermission ends. */
virtual void IntermissionEnd(void);
/** Run to send a specific player to an intermission. Like when joining late. */
virtual void IntermissionToPlayer(NSClientPlayer);
/** Returns if the gamerules find themselves in an intermission. */
virtual bool InIntermission(void);
@ -126,7 +123,11 @@ public:
virtual void SpectatorDisconnect(NSClientPlayer);
virtual void SpectatorThink(NSClientPlayer);
*/
private:
int m_iIntermission;
float m_flIntermissionTime;
float m_flIntermissionCycle;
entity m_eIntermissionPoint;
};
/* our currently running mode */

View File

@ -192,7 +192,6 @@ NSGameRules::IntermissionStart(void)
void
NSGameRules::IntermissionCycle(void)
{
static NSEntity cam;
NSEntity targ;
if (!m_iIntermission)
@ -205,34 +204,28 @@ NSGameRules::IntermissionCycle(void)
WriteByte(MSG_MULTICAST, SVC_CGAMEPACKET);
WriteByte(MSG_MULTICAST, EV_INTERMISSION);
cam = (NSEntity)find(cam, ::classname, "info_intermission");
m_eIntermissionPoint = (NSEntity)find(m_eIntermissionPoint, ::classname, "info_intermission");
if (cam) {
targ = (NSEntity)find(world, ::targetname, cam.target);
/* if we have an intermission point, send it to all players. */
if (m_eIntermissionPoint) {
targ = (NSEntity)find(world, ::targetname, m_eIntermissionPoint.target);
if (targ) {
vector foo;
foo = vectoangles(targ.origin - cam.origin);
WriteByte(MSG_MULTICAST, 1);
WriteFloat(MSG_MULTICAST, foo[0]);
WriteFloat(MSG_MULTICAST, foo[1]);
WriteFloat(MSG_MULTICAST, foo[2]);
WriteCoord(MSG_MULTICAST, cam.origin[0]);
WriteCoord(MSG_MULTICAST, cam.origin[1]);
WriteCoord(MSG_MULTICAST, cam.origin[2]);
} else {
WriteByte(MSG_MULTICAST, 1);
WriteFloat(MSG_MULTICAST, cam.angles[0]);
WriteFloat(MSG_MULTICAST, cam.angles[1]);
WriteFloat(MSG_MULTICAST, cam.angles[2]);
WriteCoord(MSG_MULTICAST, cam.origin[0]);
WriteCoord(MSG_MULTICAST, cam.origin[1]);
WriteCoord(MSG_MULTICAST, cam.origin[2]);
foo = vectoangles(targ.origin - m_eIntermissionPoint.origin);
m_eIntermissionPoint.angles = foo;
}
WriteByte(MSG_MULTICAST, 1);
WriteFloat(MSG_MULTICAST, m_eIntermissionPoint.angles[0]);
WriteFloat(MSG_MULTICAST, m_eIntermissionPoint.angles[1]);
WriteFloat(MSG_MULTICAST, m_eIntermissionPoint.angles[2]);
WriteCoord(MSG_MULTICAST, m_eIntermissionPoint.origin[0]);
WriteCoord(MSG_MULTICAST, m_eIntermissionPoint.origin[1]);
WriteCoord(MSG_MULTICAST, m_eIntermissionPoint.origin[2]);
for (entity pl = world; (pl = find(pl, ::classname, "player"));) {
setorigin(pl, cam.origin);
setorigin(pl, m_eIntermissionPoint.origin);
}
} else {
WriteByte(MSG_MULTICAST, 0);
@ -241,11 +234,33 @@ NSGameRules::IntermissionCycle(void)
msg_entity = world;
multicast([0,0,0], MULTICAST_ALL);
if (!cam)
if (!m_eIntermissionPoint)
m_flIntermissionCycle = 0.0f;
else
m_flIntermissionCycle = time + 5.0f;
}
void
NSGameRules::IntermissionToPlayer(NSClientPlayer targetPlayer)
{
WriteByte(MSG_MULTICAST, SVC_CGAMEPACKET);
WriteByte(MSG_MULTICAST, EV_INTERMISSION);
/* we're in an intermission already, so this should be set. */
if (g_grMode.m_eIntermissionPoint) {
WriteByte(MSG_MULTICAST, 1);
WriteFloat(MSG_MULTICAST, g_grMode.m_eIntermissionPoint.angles[0]);
WriteFloat(MSG_MULTICAST, g_grMode.m_eIntermissionPoint.angles[1]);
WriteFloat(MSG_MULTICAST, g_grMode.m_eIntermissionPoint.angles[2]);
WriteCoord(MSG_MULTICAST, g_grMode.m_eIntermissionPoint.origin[0]);
WriteCoord(MSG_MULTICAST, g_grMode.m_eIntermissionPoint.origin[1]);
WriteCoord(MSG_MULTICAST, g_grMode.m_eIntermissionPoint.origin[2]);
} else {
WriteByte(MSG_MULTICAST, 0);
}
msg_entity = targetPlayer;
multicast([0,0,0], MULTICAST_ONE_R);
}
bool

View File

@ -162,6 +162,10 @@ PutClientInServer(void)
/* the game and its triggers start when the player is ready to see it */
trigger_auto_trigger();
if (g_grMode.InIntermission() == true) {
g_grMode.IntermissionToPlayer((NSClientPlayer)self);
}
}
/** Run before game physics have taken place.

View File

@ -361,6 +361,8 @@ NSRenderableEntity::RenderFXPass(void)
break;
case RM_GLOW:
colormod = [1,1,1];
alpha = m_flRenderAmt == 0.0 ? 0.0f : 1.0f;
case RM_WORLDGLOW: /* TODO: Figure out what this does differently */
if (checkpvs(vecPlayer, this) == FALSE)
alpha -= clframetime;
@ -900,22 +902,12 @@ NSRenderableEntity::GetRenderFX(void)
float
NSRenderableEntity::GetRenderAmt(void)
{
if (m_iRenderMode == RM_NORMAL)
return 1.0f;
else if (m_iRenderMode == RM_GLOW && m_flRenderAmt == 0.0)
return 1.0f;
return m_flRenderAmt;
}
vector
NSRenderableEntity::GetRenderColor(void)
{
if (m_iRenderMode == RM_NORMAL)
return [1.0, 1.0, 1.0];
else if (m_iRenderMode == RM_GLOW)
return [1.0, 1.0, 1.0];
return m_vecRenderColor;
}

View File

@ -14,6 +14,8 @@
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
static bool g_spDefaultSet;
static void
SurfData_ParseField(int i, int a)
{
@ -99,6 +101,7 @@ SurfData_Parse(string line)
static string t_name;
static int braced = 0;
static int i;
static bool isDefault = false;
c = tokenize_console(line);
key = argv(0);
@ -109,8 +112,34 @@ SurfData_Parse(string line)
break;
case "}":
/* increase counter when done */
if (t_name)
if (t_name) {
/* we now apply our values to everything else. */
if (isDefault) {
for (int m = 1i; m < g_surfdata_count; m++) {
g_surfdata[m].m_flMaterial = g_surfdata[0].m_flMaterial;
g_surfdata[m].m_flThickness = g_surfdata[0].m_flThickness;
g_surfdata[m].m_flDensity = g_surfdata[0].m_flDensity;
g_surfdata[m].m_flElasticity = g_surfdata[0].m_flElasticity;
g_surfdata[m].m_flFriction = g_surfdata[0].m_flFriction;
g_surfdata[m].m_flDampening = g_surfdata[0].m_flDampening;
g_surfdata[m].m_flJumpFactor = g_surfdata[0].m_flJumpFactor;
g_surfdata[m].m_flMaxSpeedFactor = g_surfdata[0].m_flMaxSpeedFactor;
g_surfdata[m].m_sndStepLeft = g_surfdata[0].m_sndStepLeft;
g_surfdata[m].m_sndStepRight = g_surfdata[0].m_sndStepRight;
g_surfdata[m].m_sndBulletImpact = g_surfdata[0].m_sndBulletImpact;
g_surfdata[m].m_sndScrapeRough = g_surfdata[0].m_sndScrapeRough;
g_surfdata[m].m_sndScrapeSoft = g_surfdata[0].m_sndScrapeSoft;
g_surfdata[m].m_sndImpactHard = g_surfdata[0].m_sndImpactHard;
g_surfdata[m].m_sndImpactSoft = g_surfdata[0].m_sndImpactSoft;
g_surfdata[m].m_sndShake = g_surfdata[0].m_sndShake;
g_surfdata[m].m_sndStrain = g_surfdata[0].m_sndStrain;
g_surfdata[m].m_sndRoll = g_surfdata[0].m_sndRoll;
g_surfdata[m].m_sndBreak = g_surfdata[0].m_sndBreak;
}
}
i++;
}
braced--;
t_name = "";
@ -120,6 +149,13 @@ SurfData_Parse(string line)
SurfData_ParseField(i, c);
} else if (braced == 0) {
t_name = strtolower(line);
if (t_name == "default") {
isDefault = true;
} else {
isDefault = false;
}
hash_add(g_hashsurfdata, t_name, (int)i);
}
}
@ -153,7 +189,8 @@ SurfData_CountLine(string line)
int c;
string key;
static string t_name;
static int braced = 0;
static int braced = 0i;
static int surfdataCount = 0i;
c = tokenize_console(line);
key = argv(0);
@ -164,6 +201,7 @@ SurfData_CountLine(string line)
break;
case "}":
braced--;
surfdataCount++;
t_name = "";
break;
default:
@ -173,6 +211,10 @@ SurfData_CountLine(string line)
if (t_name)
g_surfdata_count++;
/* sanity test */
if (t_name == "default" && surfdataCount == 0i)
g_spDefaultSet = true;
}
}
return;
@ -258,8 +300,9 @@ SurfData_Shutdown(void)
if (g_surfdata) {
memfree(g_surfdata);
}
g_surfdata_count = 0;
g_surfdata_count = 0i;
g_hashsurfdata = 0;
g_spDefaultSet = false;
}
void
@ -276,27 +319,36 @@ SurfData_Init(void)
index = g_surfdata_count;
/* create the hash-table if it doesn't exist */
if (!g_hashsurfdata) {
g_hashsurfdata = hash_createtab(2, HASH_ADD);
/* if it already exists, detroy it first */
if (g_hashsurfdata) {
hash_destroytab(g_hashsurfdata);
}
fh = fopen("scripts/surfaceproperties.txt", FILE_READ);
/* it's OK for one to not exist... */
if (fh < 0) {
print("^1[SURFDATA] Can't find surfaceproperties.txt\n");
return;
}
/* count content */
/* count surfaceproperty definitions */
while ((line = fgets(fh))) {
SurfData_CountLine(line);
}
/* we did not find 'default' as the first entry. */
if (g_spDefaultSet == false) {
error("^1no 'default' defined at the top of scripts/surfaceproperties.txt");
return;
}
/* alocate our stuff */
g_surfdata = (surfaceData_t *)memalloc(sizeof(surfaceData_t) * g_surfdata_count);
g_hashsurfdata = hash_createtab(2, HASH_ADD);
/* Defaults */
for (int i = 0; i < g_surfdata_count; i++) {
/* Internal, defaults. Most of them get overriden by the first entry ('default') */
for (int i = 0i; i < g_surfdata_count; i++) {
g_surfdata[i].m_strBase = "";
g_surfdata[i].m_flMaterial = -1;
g_surfdata[i].m_flThickness = 1.0f;
@ -328,10 +380,17 @@ SurfData_Init(void)
}
fclose(fh);
for (int i = 0; i < g_surfdata_count; i++) {
for (int i = 0i; i < g_surfdata_count; i++) {
Sound_Precache(g_surfdata[i].m_sndStepLeft);
Sound_Precache(g_surfdata[i].m_sndStepRight);
Sound_Precache(g_surfdata[i].m_sndBulletImpact);
Sound_Precache(g_surfdata[i].m_sndScrapeRough);
Sound_Precache(g_surfdata[i].m_sndScrapeSoft);
Sound_Precache(g_surfdata[i].m_sndImpactHard);
Sound_Precache(g_surfdata[i].m_sndImpactSoft);
Sound_Precache(g_surfdata[i].m_sndShake);
Sound_Precache(g_surfdata[i].m_sndStrain);
Sound_Precache(g_surfdata[i].m_sndRoll);
Sound_Precache(g_surfdata[i].m_sndBreak);
}