Skip to content

Commit

Permalink
Optional barrel overheating and duration #712
Browse files Browse the repository at this point in the history
  • Loading branch information
cxong committed Aug 17, 2024
1 parent 38a4e93 commit d8f77f9
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 11 deletions.
12 changes: 8 additions & 4 deletions data/.wolf3d/N3Ddata.cdogscpn/guns.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
"Sound": "small_launcher",
"SwitchSound": "bow_draw0",
"Recoil": 0.1,
"Ammo": "Feed"
"Ammo": "Feed",
"OverheatTicks": -1
},
{
"Pic": "large_launcher",
Expand All @@ -40,7 +41,8 @@
"Sound": "large_launcher",
"SwitchSound": "bow_draw1",
"Recoil": 0.17,
"Ammo": "Feed"
"Ammo": "Feed",
"OverheatTicks": -1
},
{
"Pic": "super_feeder",
Expand All @@ -54,7 +56,8 @@
"Sound": "super_feeder",
"SwitchSound": "bow_draw2",
"Recoil": 0.23,
"Ammo": "Feed"
"Ammo": "Feed",
"OverheatTicks": -1
},
{
"Pic": "blaster_yellow",
Expand All @@ -67,7 +70,8 @@
"Sound": "cantaloupe_feeder",
"SwitchSound": "package_r",
"Elevation": 18,
"Ammo": "Cantaloupe"
"Ammo": "Cantaloupe",
"OverheatTicks": -1
},
{
"Pic": "",
Expand Down
8 changes: 4 additions & 4 deletions src/cdogs/weapon.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
This file incorporates work covered by the following copyright and
permission notice:
Copyright (c) 2013-2019, 2021 Cong Xu
Copyright (c) 2013-2019, 2021, 2024 Cong Xu
All rights reserved.
Redistribution and use in source and binary forms, with or without
Expand Down Expand Up @@ -171,10 +171,10 @@ void WeaponBarrelOnFire(Weapon *w, const int barrel)

bool WeaponBarrelIsOverheating(const Weapon *w, const int idx)
{
if (!WeaponClassHasMuzzle(w->Gun))
if (!WeaponClassHasMuzzle(w->Gun) || w->Gun->OverheatTicks < 0)
{
return false;
}
// Overheat after 1 second of continuous firing
return w->barrels[idx].heatCounter > FPS_FRAMELIMIT;
// Overheat after some duration of continuous firing
return w->barrels[idx].heatCounter > w->Gun->OverheatTicks;
}
6 changes: 4 additions & 2 deletions src/cdogs/weapon_class.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
C-Dogs SDL
A port of the legendary (and fun) action/arcade cdogs.
Copyright (c) 2013-2023 Cong Xu
Copyright (c) 2013-2024 Cong Xu
All rights reserved.
Redistribution and use in source and binary forms, with or without
Expand Down Expand Up @@ -357,6 +357,8 @@ static void LoadWeaponClass(WeaponClass *wc, json_t *node, const int version)
}

LoadInt(&wc->Price, node, "Price");
wc->OverheatTicks = FPS_FRAMELIMIT; // default 1 second overheating
LoadInt(&wc->OverheatTicks, node, "OverheatTicks");

LOG(LM_MAP, LL_DEBUG, "loaded %s name(%s) lock(%d)...",
GunTypeStr(wc->Type), wc->name, wc->Lock);
Expand Down Expand Up @@ -400,7 +402,7 @@ static void LoadWeaponClass(WeaponClass *wc, json_t *node, const int version)
wc->u.Normal.Auto ? "true" : "false");
}

LOG(LM_MAP, LL_DEBUG, "price(%d)", wc->Price);
LOG(LM_MAP, LL_DEBUG, "price(%d) overheatTicks(%d)", wc->Price, wc->OverheatTicks);
}
void WeaponClassesTerminate(WeaponClasses *wcs)
{
Expand Down
3 changes: 2 additions & 1 deletion src/cdogs/weapon_class.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
C-Dogs SDL
A port of the legendary (and fun) action/arcade cdogs.
Copyright (c) 2013-2019, 2021-2023 Cong Xu
Copyright (c) 2013-2019, 2021-2024 Cong Xu
All rights reserved.
Redistribution and use in source and binary forms, with or without
Expand Down Expand Up @@ -119,6 +119,7 @@ typedef struct
char *DropGun; // Gun to drop if an actor with this gun dies
bool IsRealGun; // whether this gun can be used as is by players
int Price; // Price to purchase gun
int OverheatTicks; // Number of ticks required to overheat the barrel and start smoking
} WeaponClass;
typedef struct
{
Expand Down

0 comments on commit d8f77f9

Please sign in to comment.