Skip to content

Commit

Permalink
a really early version of race mode. this took all day.
Browse files Browse the repository at this point in the history
  • Loading branch information
yellowberryHN committed Sep 16, 2023
1 parent ac52546 commit 9494362
Show file tree
Hide file tree
Showing 18 changed files with 246 additions and 56 deletions.
10 changes: 9 additions & 1 deletion data/maps.cfg
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
_currentmaps = "cosmic duabo flux fz_burn illusion indust1 neo_falls neo_noir precipice realm retrograde ruins"
_shadowmaps = "color"
_parkourmaps = "ftdeluxe secondevermap"
_racemaps = "race_test"
_ctfmaps = "hr retrograde zigguraut"

_allmaps = (concat $_currentmaps $_shadowmaps $_ctfmaps $_parkourmaps)
_allmaps = (concat $_currentmaps $_shadowmaps $_ctfmaps $_parkourmaps $_racemaps)

_genmapitems = [
looplist curmap $arg1 [
Expand Down Expand Up @@ -63,6 +64,13 @@ newgui maps [
guilist [ guistrut 15 1; _genmapitems $_parkourmaps ]
guilist [ guistrut 15 1 ]
_showmapshot
]
guitab "t:gui.map.race"
guilist [
guistrut 17 1
guilist [ guistrut 15 1; _genmapitems $_racemaps ]
guilist [ guistrut 15 1 ]
_showmapshot
]
guitab "t:gui.map.custom"
guilist [
Expand Down
8 changes: 6 additions & 2 deletions data/menus.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -310,8 +310,9 @@ newgui gamemode [
guibutton "Insta-Tactics" "mode 18; showgui maps"
guibutton "Team Instagib Tactics" "mode 19; showgui maps"
guibutton "Grenade Battle" "mode 20; showgui maps"
guibutton "Last Man Standing (WIP)" "mode 22; showgui maps"
guibutton "Explosive CTF (WIP)" "mode 23; showgui maps"
guibutton "Last Man Standing (WIP)" "mode 21; showgui maps"
guibutton "Explosive CTF (WIP)" "mode 22; showgui maps"
guibutton "Race Mode (^fs^f6DEV^fr)" "mode 25; showgui maps"
]
]
] "t:gui.gamemode"
Expand Down Expand Up @@ -1692,6 +1693,9 @@ newentgui jumppad "Z Y X" "0 200 0 200 0 200"
newentgui sound "Type Radius Size" "0 20 0 500 0 500"
newentgui particles "Type" "0 13"
newentgui flag "Direction Team" "0 360 0 2"
newentgui start "Direction" "0 360"
newentgui checkpoint "Direction ID" "0 360 0 50"
newentgui finish "Direction" "0 360"
contexteditgui = [
if $hmapedit [showgui brushes] [
Expand Down
33 changes: 25 additions & 8 deletions data/stdedit.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ enttypelist = [
base
spotlight
flag
start checkpoint finish
]

enttypeselect = [
Expand All @@ -85,6 +86,9 @@ ent_action_particles = [ entproperty 0 ( * $arg1 1 ) ]
ent_action_sound = [ entproperty 0 ( * $arg1 1 ) ]
ent_action_cycle = [ entset ( if ( > $arg1 -1 ) [ result $arg2 ] [ result $arg3 ] ) ]
ent_action_flag = [ entproperty 0 ( * $arg1 1 ) ]
ent_action_start = [ entproperty 0 ( * $arg1 15 ) ]
ent_action_checkpoint = [ entproperty 0 ( * $arg1 15 ) ]
ent_action_finish = [ entproperty 0 ( * $arg1 15 ) ]

//////// Copy and Paste //////////////

Expand Down Expand Up @@ -266,31 +270,31 @@ genenthudmapmodel = [

genenthudplayerstart = [
if (= (ea 1) 0) [
format "yaw: %1; team: %2 (neutral)" (ea 0) (ea 1) // general
format "direction: %1; team: %2 (neutral)" (ea 0) (ea 1) // general
] [
if (= (ea 1) 1) [
format "yaw: %1; team: ^f3%2 (red)" (ea 0) (ea 1) // red
format "direction: %1; team: ^f3%2 (red)" (ea 0) (ea 1) // red
] [
if (= (ea 1) 2) [
format "yaw: %1; team: ^f1%2 (blue)" (ea 0) (ea 1) // blue
format "direction: %1; team: ^f1%2 (blue)" (ea 0) (ea 1) // blue
] [
format "yaw: %1; team: %2" (ea 0) (ea 1) // invalid team
format "direction: %1; team: %2" (ea 0) (ea 1) // invalid team
]
]
]
]

genenthudflag = [
if (= (ea 1) 0) [
format "yaw: %1; team: %2 (neutral)" (ea 0) (ea 1) // general
format "direction: %1; team: %2 (neutral)" (ea 0) (ea 1) // general
] [
if (= (ea 1) 1) [
format "yaw: %1; team: ^f3%2 (red)" (ea 0) (ea 1) // red
format "direction: %1; team: ^f3%2 (red)" (ea 0) (ea 1) // red
] [
if (= (ea 1) 2) [
format "yaw: %1; team: ^f1%2 (blue)" (ea 0) (ea 1) // blue
format "direction: %1; team: ^f1%2 (blue)" (ea 0) (ea 1) // blue
] [
format "yaw: %1; team: %2" (ea 0) (ea 1) // invalid team
format "direction: %1; team: %2" (ea 0) (ea 1) // invalid team
]
]
]
Expand Down Expand Up @@ -335,6 +339,18 @@ genenthudenvmap = [
format "radius: %1" $radius
]

genenthudstart = [
format "direction: %1" (ea 0)
]

genenthudcheckpoint = [
format "direction: %1; id: ^f2%2" (ea 0) (ea 1)
]

genenthudfinish = [
format "direction: %1" (ea 0)
]

genenthud = [
if (strcmp (getalias (concatword "genenthud" (et))) "") [
result "No Information"
Expand Down Expand Up @@ -439,6 +455,7 @@ echovshaderparam = [echo ***vshaderparam (getvshaderparamnames $getseltex) (
// echovshaderparamspecscale = [echo ***shaderparam specscale (getvshaderparam $getseltex specscale)]

findpickupents = [entfind ammo;entfind health;]
findraceents = [entfind start;entfind checkpoint;entfind finish;]

prettysky = [
skybox "skyboxes/remus/sky01"
Expand Down
1 change: 1 addition & 0 deletions packages/lang/en_US.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ ds "en_US" [
"gui.map.shadow" "Shadow"
"gui.map.ctf" "CTF"
"gui.map.parkour" "Parkour"
"gui.map.race" "Race"
"gui.map.custom" "Custom maps"
"gui.texgui.textures" "Textures"
Expand Down
34 changes: 34 additions & 0 deletions packages/models/race/gem/gem.obj
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Blender 3.3.1
# www.blender.org
o Gem
v -1.000000 0.000000 1.000000
v 1.000000 0.000000 1.000000
v -1.000000 0.000000 -1.000000
v 1.000000 0.000000 -1.000000
v 0.000000 1.500000 0.000000
v 0.000000 -1.500000 0.000000
vn -0.0000 -0.5547 -0.8321
vn -0.0000 0.5547 -0.8321
vn -0.0000 0.5547 0.8321
vn 0.8321 0.5547 -0.0000
vn -0.8321 0.5547 -0.0000
vn -0.0000 -0.5547 0.8321
vn 0.8321 -0.5547 -0.0000
vn -0.8321 -0.5547 -0.0000
vt 0.166667 0.500000
vt 0.833333 0.500000
vt 0.166667 0.500000
vt 0.166667 0.500000
vt 0.833333 0.500000
vt 0.833333 0.500000
vt 0.500000 1.000000
vt 0.500000 0.000000
s 0
f 3/4/1 4/6/1 6/8/1
f 4/6/2 3/4/2 5/7/2
f 1/1/3 2/2/3 5/7/3
f 2/3/4 4/6/4 5/7/4
f 3/5/5 1/1/5 5/7/5
f 2/2/6 1/1/6 6/8/6
f 4/6/7 2/3/7 6/8/7
f 1/1/8 3/5/8 6/8/8
Binary file added packages/models/race/gem/gem.pdn
Binary file not shown.
Binary file added packages/models/race/gem/gem.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added packages/models/race/gem/gem_mask.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions packages/models/race/gem/obj.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
objload gem.obj
objskin * gem.png gem_mask.png
mdlscale 1000
2 changes: 1 addition & 1 deletion src/engine/physics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -675,7 +675,7 @@ static inline bool plcollide(physent *d, const vec &dir, physent *o)

bool plcollide(physent *d, const vec &dir, bool insideplayercol) // collide with player
{
if(d->type==ENT_CAMERA || d->state!=CS_ALIVE) return false;
if(d->type==ENT_CAMERA || d->state!=CS_ALIVE || d->racing) return false;
int lastinside = collideinside;
physent *insideplayer = NULL;
loopdynentcache(x, y, d->o, d->radius)
Expand Down
39 changes: 30 additions & 9 deletions src/fpsgame/entities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,13 @@ namespace entities
static const char * const entmdlnames[] =
{
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, // health, ammo
NULL, NULL, "race/gem", // race start, finish, checkpoint
NULL, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL,
NULL, NULL,
NULL,
NULL, NULL,
NULL,
NULL, NULL,
NULL, NULL,
NULL
NULL, NULL, // teleport, teledest
NULL, // base
NULL, NULL, NULL, NULL, NULL,
NULL // flag
};
return entmdlnames[type];
}
Expand All @@ -79,7 +77,7 @@ namespace entities
case I_AMMO: case I_HEALTH:
break;
case RACE_START: case RACE_FINISH: case RACE_CHECKPOINT:
if (!m_race) continue;
if (!m_race || !m_edit) continue;
break;
}
const char *mdl = entmdlname(i);
Expand Down Expand Up @@ -111,6 +109,8 @@ namespace entities
case TELEPORT:
if(e.attr2 < 0) continue;
break;
case RACE_CHECKPOINT:
break;
default:
if(!e.spawned() || e.type < I_AMMO || e.type > I_HEALTH) continue;
}
Expand Down Expand Up @@ -594,6 +594,14 @@ namespace entities
}
}

void raceyaw(extentity& e)
{
gle::colorf(0, 1, 1);
vec dir;
vecfromyawpitch(e.attr1, 0, 1, 0, dir);
renderentarrow(e, dir, 4);
}

void entradius(extentity &e, bool color)
{
int maxcheckpoints = 0;
Expand All @@ -613,19 +621,24 @@ namespace entities
break;

case RACE_START:
gle::colorf(1, 0, 0);
loopv(ents) {
// successor
if(ents[i]->type == RACE_CHECKPOINT && ents[i]->attr2 == 1) {
renderentarrow(e, vec(ents[i]->o).sub(e.o).normalize(), e.o.dist(ents[i]->o));
}
// precessor
/*
if(ents[i]->type == RACE_FINISH) {
renderentarrow(*ents[i], vec(e.o).sub(ents[i]->o).normalize(), ents[i]->o.dist(e.o));
}
*/
}
raceyaw(e);
break;

case RACE_CHECKPOINT:
gle::colorf(1, 0, 0);
loopv(ents) {
// successor
if(ents[i]->type == RACE_CHECKPOINT && (e.attr2+1) == ents[i]->attr2) {
Expand All @@ -635,21 +648,29 @@ namespace entities
if(ents[i]->type == RACE_CHECKPOINT && (e.attr2-1) == ents[i]->attr2) {
renderentarrow(*ents[i], vec(e.o).sub(ents[i]->o).normalize(), ents[i]->o.dist(e.o));
}
else if (ents[i]->type == RACE_START && e.attr2 == 1) {
renderentarrow(*ents[i], vec(e.o).sub(ents[i]->o).normalize(), ents[i]->o.dist(e.o));
}
}
raceyaw(e);
break;

case RACE_FINISH:
gle::colorf(1, 0, 0);
loopv(ents) if(ents[i]->type == RACE_CHECKPOINT && ents[i]->attr2 > maxcheckpoints) {
maxcheckpoints = ents[i]->attr2;
}
// successor
/*
loopv(ents) if(ents[i]->type == RACE_START) {
renderentarrow(e, vec(ents[i]->o).sub(e.o).normalize(), e.o.dist(ents[i]->o));
}
*/
// precessor
loopv(ents) if(ents[i]->type == RACE_CHECKPOINT && ents[i]->attr2 == maxcheckpoints) {
renderentarrow(*ents[i], vec(e.o).sub(ents[i]->o).normalize(), ents[i]->o.dist(e.o));
}
raceyaw(e);
break;

case FLAG:
Expand Down
1 change: 1 addition & 0 deletions src/fpsgame/fps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,7 @@ namespace game
{
int tag = cmode ? cmode->getspawngroup(d) : 0;
if(m_teammode && !cmode) tag = (!strcmp(d->team, "red") ? 1 : (!strcmp(d->team, "blue") ? 2 : 0));
else if (m_race && cmode) { cmode->pickspawn(d); return; }
//conoutf("spawn tag: %d, team: %s, cmode: %s", tag, d->team, cmode ? "true" : "false");
findplayerspawn(d, -1, tag);
}
Expand Down
3 changes: 2 additions & 1 deletion src/fpsgame/game.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ static struct gamemodeinfo
{ "Explosive CTF", M_INSTA | M_BOTTOMLESS | M_TEAM | M_CTF | M_NOITEMS | M_ECTF, "Rockets! Grenades! Instagib! CTF! Exciting!"}, // 22
{ "Test Mode", M_TEST, "It might be something stupid, or it might be cool. It also might crash your game."}, // 23
{ "Reverse One Flag CTF", M_CTF | M_TEAM | M_R1CTF, "Capture the center flag and return it to the enemy base to score points!"}, // 24
{ "Race Mode", M_RACE | M_BOTTOMLESS | M_PARKOUR, "Race: Be the first who completes 3 laps. Kill people to repulse them." }, // 25
{ "Race Mode", M_RACE | M_BOTTOMLESS | M_PARKOUR, "Get to the finish as fast as you can!" }, // 25
};

#define STARTGAMEMODE (-1)
Expand Down Expand Up @@ -776,6 +776,7 @@ namespace game
virtual void setup() {}
virtual void checkitems(fpsent *d) {}
virtual int respawnwait(fpsent *d, int delay = 0) { return 0; }
virtual void pickspawn(fpsent* d) { findplayerspawn(d); }
virtual int getspawngroup(fpsent *d) { return 0; }
virtual float ratespawn(fpsent *d, const extentity &e) { return 1.0f; }
virtual void senditems(packetbuf &p) {}
Expand Down
Loading

0 comments on commit 9494362

Please sign in to comment.