Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Radiant/neverball.game/data/entities.ent
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,8 @@ Used for most static level geometry.
<string key="author" name="Author">Name of the author.</string>
<boolean key="bonus" name="Bonus level">Marks this level as a bonus level.</boolean>
<real key="idle" name="Idling time-out (Neverputt)">Neverputt: time to wait after the ball has stopped before starting the next shot. Useful to ensure that moving objects won't hit the ball while the player is making the shot.</real>
<real key="can_forfeit_after" name="Can forfeit time-out (Neverputt)">Neverputt: time to wait for the ball to stop before the player can forfeit their turn for a penalty. -1.0 means never. 0.0 means always. The default is 30.0.</real>
<real key="auto_timeout" name="Automatic time-out (Neverputt)">Neverputt: time to wait for the ball to stop before the player automatically forfeits their turn for a penalty. -1.0 means never. The default is -1.0.</real>
<integer key="par" name="Par (Neverputt)">Neverputt: the number of strokes required to complete the hole.</integer>
</group>
</classes>
2 changes: 2 additions & 0 deletions TrenchBroom/entities.ent
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,8 @@ Used for most static level geometry.
<string key="author" name="Author">Name of the author.</string>
<boolean key="bonus" name="Bonus level">Marks this level as a bonus level.</boolean>
<real key="idle" name="Idling time-out (Neverputt)">Neverputt: time to wait after the ball has stopped before starting the next shot. Useful to ensure that moving objects won't hit the ball while the player is making the shot.</real>
<real key="can_forfeit_after" name="Can forfeit time-out (Neverputt)">Neverputt: time to wait for the ball to stop before the player can forfeit their turn for a penalty. -1.0 means never. 0.0 means always. The default is 30.0.</real>
<real key="auto_timeout" name="Automatic time-out (Neverputt)">Neverputt: time to wait for the ball to stop before the player automatically forfeits their turn for a penalty. -1.0 means never. The default is -1.0.</real>
<integer key="par" name="Par (Neverputt)">Neverputt: the number of strokes required to complete the hole.</integer>
</group>
</classes>
1 change: 1 addition & 0 deletions data/map-ckk/17.map
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// entity 0
{
"classname" "worldspawn"
"can_forfeit_after" "60"
// brush 0
{
( 72 640 264 ) ( 72 640 240 ) ( 72 656 264 ) mtrl/invisible 128 128 0 0.5 0.5 0 0 0
Expand Down
2 changes: 1 addition & 1 deletion data/map-ckk/18.map
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@

// entity 0
{
"classname" "worldspawn"
"grad" "back/space.png"
"back" "map-back/jupitor.sol"
"can_forfeit_after" "60"
// brush 0
{
( -384 6016 -160 ) ( -400 6032 -160 ) ( -384 6016 -184 ) mtrl/invisible 128 128 0 0.5 0.5 0 0 0
Expand Down
2 changes: 1 addition & 1 deletion data/map-iCourse/iPutt14.map
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

// entity 0
{
"classname" "worldspawn"
"can_forfeit_after" "60"
// brush 0
{
( -66 -328 -128 ) ( -128 -352 -128 ) ( -70 -326 -128 ) mtrl/turf-green-small 0 0 0 0.5 0.5 0 0 0
Expand Down
2 changes: 1 addition & 1 deletion data/map-iCourse/iPutt15.map
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

// entity 0
{
"classname" "worldspawn"
"can_forfeit_after" "60"
// brush 0
{
( -352 288 104 ) ( -326 314 80 ) ( -322 312 80 ) mtrl/turf-green-dark 0 0 0 0.5 0.5 0 0 0
Expand Down
2 changes: 1 addition & 1 deletion data/map-iCourse/iPutt16.map
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

// entity 0
{
"classname" "worldspawn"
"can_forfeit_after" "60"
// brush 0
{
( -256 -288 -152 ) ( -230 -314 -152 ) ( -232 -318 -152 ) mtrl/invisible 0 0 0 0.5 0.5 0 0 0
Expand Down
2 changes: 1 addition & 1 deletion data/map-iCourse/iPutt18.map
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

// entity 0
{
"classname" "worldspawn"
"can_forfeit_after" "60"
// brush 0
{
( 128 768 -328 ) ( 128 768 -336 ) ( 186 826 -336 ) mtrl/invisible 0 0 0 0.5 0.5 0 0 0
Expand Down
1 change: 1 addition & 0 deletions data/map-paxed3/ovalli.map
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// entity 0
{
"classname" "worldspawn"
"can_forfeit_after" "60"
// brush 0
{
( -64 64 8 ) ( -64 64 -8 ) ( -64 128 -8 ) mtrl/invisible 0 0 0 0.5 0.5 134217728 0 0
Expand Down
2 changes: 1 addition & 1 deletion data/map-vidski/bigpipe.map
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

// entity 0
{
"classname" "worldspawn"
"can_forfeit_after" "60"
// brush 0
{
( 0 -2304 296 ) ( 0 -2432 296 ) ( -96 -2304 296 ) mtrl/arrow-green-light 0 0 0 0.5 0.5 134217728 0 0
Expand Down
20 changes: 8 additions & 12 deletions data/map-vidski/clovertop.map
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// entity 0
{
"classname" "worldspawn"
"can_forfeit_after" "60"
// brush 0
{
( 64 -176 -8 ) ( 64 -304 -8 ) ( -32 -176 -8 ) mtrl/arrow-green-light 128 160 0 0.5 0.5 134217728 0 0
Expand Down Expand Up @@ -4043,8 +4044,9 @@
}
// entity 1
{
"classname" "func_train"
"target" "t2"
"classname" "info_player_start"
"origin" "0.000000 16.000000 16.000000"
"radius" "0.0625"
}
// entity 2
{
Expand Down Expand Up @@ -4072,37 +4074,31 @@
}
// entity 6
{
"classname" "info_player_start"
"origin" "0.000000 16.000000 16.000000"
"radius" "0.0625"
}
// entity 7
{
"classname" "target_position"
"origin" "-392.000000 376.000000 528.000000"
"targetname" "target_position1"
"angle" "-179.999985"
}
// entity 8
// entity 7
{
"classname" "info_player_intermission"
"origin" "1424.000000 -960.000000 1504.000000"
"target" "target_position1"
"angle" "-179.999985"
}
// entity 9
// entity 8
{
"classname" "info_player_deathmatch"
"origin" "0.000000 64.000000 1312.000000"
"radius" "0.1375"
}
// entity 10
// entity 9
{
"classname" "target_position"
"origin" "272.000000 -152.000000 288.000000"
"targetname" "target_position2"
}
// entity 11
// entity 10
{
"classname" "info_player_intermission"
"origin" "-2072.000000 1344.000000 2272.000000"
Expand Down
2 changes: 1 addition & 1 deletion data/map-vidski/hourglass.map
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

// entity 0
{
"classname" "worldspawn"
"can_forfeit_after" "60"
// brush 0
{
( -568 0 1066 ) ( -567 -18 1066 ) ( -568 0 1082 ) mtrl/edge-green-dark 240 4 0 -0.5 0.5 0 0 0
Expand Down
2 changes: 1 addition & 1 deletion data/map-vidski/voodoo.map
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

// entity 0
{
"classname" "worldspawn"
"can_forfeit_after" "60"
// brush 0
{
( 0 -1312 16 ) ( 49 -1307 16 ) ( 0 -1312 32 ) mtrl/edge-green-dark 12 0 0 0.5 0.5 0 0 0
Expand Down
87 changes: 86 additions & 1 deletion putt/game.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ static float jump_dt; /* Jump duration */
static float jump_p[3]; /* Jump destination */

static float idle_t; /* Idling timeout */
static float forf_t; /* Can forfeit timeout */
static float auto_t; /* Automatic timeout */

static float putt_t; /* Current player putt time elapsed */
static int has_forfeited; /* Has the current player forfeited? */
static int has_auto_forf; /* Was there an auto-forfeiture? */

/*---------------------------------------------------------------------------*/

Expand Down Expand Up @@ -93,7 +99,11 @@ int game_init(const char *s)
jump_e = 1;
jump_b = 0;

idle_t = 1.0f;
idle_t = 1.0f;
forf_t = 30.0f;
auto_t = -1.0f;

putt_t = 0.0f;

view_init();

Expand All @@ -114,6 +124,10 @@ int game_init(const char *s)
if (idle_t < 1.0f)
idle_t = 1.0f;
}
else if (strcmp(k, "can_forfeit_after") == 0)
sscanf(v, "%f", &forf_t);
else if (strcmp(k, "auto_timeout") == 0)
sscanf(v, "%f", &auto_t);
}
return 1;
}
Expand Down Expand Up @@ -476,6 +490,18 @@ static int game_update_state(float dt)
return GAME_STOP;
}

/* Test for automatic forfeit time-outs. */

if (auto_t >= 0.f)
{
if (putt_t >= auto_t)
{
t = 0.f;
has_auto_forf = 1;
return GAME_TIME;
}
}

return GAME_NONE;
}

Expand Down Expand Up @@ -545,6 +571,8 @@ int game_step(const float g[3], float dt)
b = d;
if (m)
st += t;

putt_t += t;
}

/* Mix the sound of a ball bounce. */
Expand All @@ -570,6 +598,13 @@ void game_putt(void)
file.vary.uv[ball].v[2] = -4.f * view_e[2][2] * view_m;

view_m = 0.f;

/* Start forfeit timers. */

putt_t = 0.f;

has_forfeited = 0;
has_auto_forf = 0;
}

/*---------------------------------------------------------------------------*/
Expand Down Expand Up @@ -708,5 +743,55 @@ void game_set_pos(float p[3], float e[3][3])
v_cpy(file.vary.uv[ball].e[2], e[2]);
}

int game_can_forfeit(void)
{
if (forf_t < 0.f)
return 0;

if (has_forfeited)
return 0;

if (putt_t >= forf_t)
return 1;

return 0;
}

int game_has_forced(void)
{
return has_auto_forf;
}

/*
* The ball is forfeited. If not already forfeited, call ‘hole_time’.
*
* The reason this isn't a direct wrapper around ‘hole_time’ is that once a
* forfeit is reached, the player can pause again, and then press escape to go
* back to the forfeiture screen, which upon entry re-executes this function.
*
* For st_fall, the logic is that if ‘hole_all’ is only called if the game
* is not currently paused, thus preventing multiple calls to ‘hole_fall’
* for a single fall, giving multiple penalties for a single event.
*
* This trick doesn't work for manual forfeits, since they are entered from
* a paused state, not from an unpaused state, so we need to track separate
* instances differently, so that pausing from a forfeit penalty and then
* pressing escape doesn't apply another forfeiture.
*/
void game_forfeit(void)
{
if (!has_forfeited)
{
/* Reset timers. */

has_forfeited = 1;
putt_t = 0;

/* Forfeit the ball. */

hole_time();
}
}

/*---------------------------------------------------------------------------*/

5 changes: 5 additions & 0 deletions putt/game.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#define GAME_STOP 1
#define GAME_GOAL 2
#define GAME_FALL 3
#define GAME_TIME 4

/*---------------------------------------------------------------------------*/

Expand All @@ -52,6 +53,10 @@ void game_ball(int);
void game_set_pos(float[3], float[3][3]);
void game_get_pos(float[3], float[3][3]);

int game_can_forfeit(void);
int game_has_forced(void);
void game_forfeit(void);

/*---------------------------------------------------------------------------*/

#endif
6 changes: 6 additions & 0 deletions putt/hole.c
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,12 @@ void hole_fall(void)
}
}

void hole_time(void)
{
/* Just use the same logic as hole_fall. */
hole_fall();
}

/*---------------------------------------------------------------------------*/

void hole_song(void)
Expand Down
1 change: 1 addition & 0 deletions putt/hole.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ int hole_move(void);
void hole_goal(void);
void hole_stop(void);
void hole_fall(void);
void hole_time(void);

void hole_song(void);

Expand Down
2 changes: 1 addition & 1 deletion putt/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ static int loop(void)
{
case SDL_WINDOWEVENT_FOCUS_LOST:
if (video_get_grab())
goto_pause(&st_over);
goto_pause(&st_over, &st_time);
break;

case SDL_WINDOWEVENT_MOVED:
Expand Down
Loading