Skip to content

Commit

Permalink
Progression: Add Weapon Drop Control
Browse files Browse the repository at this point in the history
Natural drop-like behavior for Heretic and Hexen classes as weapons are not dropped in those games - without impeding gameplay in DOOM.

If a weapon drops for a flagged class it'll check for ammo types and drop one of those instead.
  • Loading branch information
Lemon-King committed Jun 22, 2024
1 parent 413a876 commit d1bff87
Show file tree
Hide file tree
Showing 11 changed files with 68 additions and 3 deletions.
1 change: 1 addition & 0 deletions resources/assets/playersheets/clericplayer.playersheet
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@
"misc/p_pkup": "hexen/misc/p_pkup",
"misc/w_pkup": "hexen/misc/w_pkup"
},
"only_drop_unowned_weapons": true,
"xp_bonus_stat": "wisdom",
"use_max_health_scaler": false,
"skill_modifier": [],
Expand Down
1 change: 1 addition & 0 deletions resources/assets/playersheets/doomplayer.playersheet
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@
"misc/p_pkup": "doom/misc/p_pkup",
"misc/w_pkup": "doom/misc/w_pkup"
},
"soundclass": "marine",
"xp_bonus_stat": "rage",
"use_max_health_scaler": false,
"skill_modifier": [],
Expand Down
1 change: 1 addition & 0 deletions resources/assets/playersheets/fighterplayer.playersheet
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@
"misc/p_pkup": "hexen/misc/p_pkup",
"misc/w_pkup": "hexen/misc/w_pkup"
},
"only_drop_unowned_weapons": true,
"xp_bonus_stat": "wisdom",
"use_max_health_scaler": false,
"skill_modifier": [],
Expand Down
1 change: 1 addition & 0 deletions resources/assets/playersheets/hereticplayer.playersheet
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@
"misc/p_pkup": "corvus/misc/p_pkup",
"misc/w_pkup": "corvus/misc/w_pkup"
},
"only_drop_unowned_weapons": true,
"soundclass": "corvus",
"xp_bonus_stat": "wisdom",
"use_max_health_scaler": false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@
"misc/p_pkup": "hexen/misc/p_pkup",
"misc/w_pkup": "hexen/misc/w_pkup"
},
"only_drop_unowned_weapons": true,
"xp_bonus_stat": "wisdom",
"use_max_health_scaler": false,
"skill_modifier": [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@
"misc/p_pkup": "hexen/misc/p_pkup",
"misc/w_pkup": "hexen/misc/w_pkup"
},
"only_drop_unowned_weapons": true,
"xp_bonus_stat": "wisdom",
"use_max_health_scaler": false,
"skill_modifier": [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@
"misc/p_pkup": "hexen/misc/p_pkup",
"misc/w_pkup": "hexen/misc/w_pkup"
},
"only_drop_unowned_weapons": true,
"xp_bonus_stat": "wisdom",
"use_max_health_scaler": false,
"skill_modifier": [],
Expand Down
1 change: 1 addition & 0 deletions resources/assets/playersheets/hx2paladinplayer.playersheet
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@
"misc/p_pkup": "hexen/misc/p_pkup",
"misc/w_pkup": "hexen/misc/w_pkup"
},
"only_drop_unowned_weapons": true,
"xp_bonus_stat": "wisdom",
"use_max_health_scaler": false,
"skill_modifier": [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@
"misc/p_pkup": "hexen/misc/p_pkup",
"misc/w_pkup": "hexen/misc/w_pkup"
},
"only_drop_unowned_weapons": true,
"xp_bonus_stat": "wisdom",
"use_max_health_scaler": false,
"skill_modifier": [],
Expand Down
1 change: 1 addition & 0 deletions resources/assets/playersheets/mageplayer.playersheet
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@
"misc/p_pkup": "hexen/misc/p_pkup",
"misc/w_pkup": "hexen/misc/w_pkup"
},
"only_drop_unowned_weapons": true,
"xp_bonus_stat": "wisdom",
"use_max_health_scaler": false,
"skill_modifier": [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,61 @@ class PlayerSheetEventHandler: EventHandler {
if (prog != NULL) {
exp = prog.AwardExperience(e.thing);
}

if (prog.handler) {
prog.handler.OnKill(pt, e.thing, exp);
}
}
}
}
}

override void WorldThingSpawned(WorldEvent e) {
if (e.thing is "Weapon" && level.MapTime > 0) {
let onlyDropUnownedWeapons = false;
PlayerPawn pp = PlayerPawn(players[0].mo);
if (pp.FindInventory("Progression")) {
Progression prog = Progression(pp.FindInventory("Progression"));
onlyDropUnownedWeapons = prog.OnlyDropUnownedWeapons;
}

if (onlyDropUnownedWeapons) {
Weapon weap = Weapon(e.thing);
if (weap.Owner || (weap.SisterWeapon && (Weapon)(pp.FindInventory(weap.SisterWeapon.GetClassName())).Owner)) {
// Player owns these weapons, skip, and allow it to drop.
return;
}

if (pp.CountInv(weap.GetClassName()) > 0) {
let ammo1 = GetDefaultByType(weap.GetClass()).AmmoType1;
let ammo2 = GetDefaultByType(weap.GetClass()).AmmoType2;

let selectedAmmo = ammo1;
if (ammo1 && ammo2) {
int select = random[rngWeapDrop](0,1);
if (select == 0) {
selectedAmmo = ammo1;
} else if (select == 1) {
selectedAmmo = ammo2;
}
} else if (ammo2) {
selectedAmmo = ammo2;
} else if (!ammo1 && !ammo2) {
weap.Destroy();
return;
}

Ammo newAmmo = Ammo(weap.Spawn(selectedAmmo, weap.pos));
if (newAmmo) {
newAmmo.angle = weap.angle;
newAmmo.vel = weap.vel;

weap.Destroy();
}
}
}
}
}
}

class PlayerSheetStatBase {
Expand All @@ -73,7 +120,7 @@ class PlayerSheetStatGain {
class PlayerSheetStatParams {
int maximum; // Maximum Stat Value
PlayerSheetStatBase base;
PlayerSheetStatGain gain;
PlayerSheetStatGain gain;
}

class PlayerSheetStat {
Expand Down Expand Up @@ -222,6 +269,7 @@ class PlayerSheetJSON {
bool UseMaxHealthScaler;
bool HalveXPBeforeLevel4;
bool UsesEventHandler;
bool OnlyDropUnownedWeapons;

double experienceModifier;

Expand Down Expand Up @@ -316,6 +364,7 @@ class PlayerSheetJSON {
let valSkillModifier = FileJSON.GetArray(jsonObject, "skill_modifier");
double valXPModifier = FileJSON.GetDouble(jsonObject, "xp_modifier");
bool valHalveXPBeforeLevel4 = FileJSON.GetBool(jsonObject, "halve_xp_before_level_4");
bool valOnlyDropUnownedWeapons = FileJSON.GetBool(jsonObject, "only_drop_unowned_weapons");
let valExperienceTable = FileJSON.GetArray(jsonObject, "experience");
let valHPTable = FileJSON.GetArray(jsonObject, "health");
if (!valHPTable) {
Expand Down Expand Up @@ -470,6 +519,8 @@ class PlayerSheetJSON {
self.soundLevelUp = valSoundLevelUp;
self.soundClass = valSoundClass;

self.OnlyDropUnownedWeapons = valOnlyDropUnownedWeapons;

if (valSkillModifier) {
if (defaultSkillMod.Size() < valSkillModifier.arr.Size()) {
self.skillmodifier.Resize(valSkillModifier.arr.Size());
Expand Down Expand Up @@ -536,6 +587,8 @@ class Progression: Inventory {
bool HalveXPBeforeLevel4;
bool UsesEventHandler;

bool OnlyDropUnownedWeapons;

// Class Tables
Array<int> experienceTable;
Array<int> hitpointTable;
Expand Down Expand Up @@ -702,6 +755,8 @@ class Progression: Inventory {
}
}

self.OnlyDropUnownedWeapons = PlayerSheet.OnlyDropUnownedWeapons;

self.soundLevelUp = PlayerSheet.soundLevelUp;

self.HalveXPBeforeLevel4 = PlayerSheet.HalveXPBeforeLevel4;
Expand All @@ -711,7 +766,7 @@ class Progression: Inventory {

self.xp_bonus_stat = PlayerSheet.xp_bonus_stat;

self.soundClass = PLayerSheet.soundClass;
self.soundClass = PlayerSheet.soundClass;

self.skillmodifier.Copy(PlayerSheet.skillmodifier);

Expand Down

0 comments on commit d1bff87

Please sign in to comment.