Skip to content

Commit

Permalink
Weapon element limiting
Browse files Browse the repository at this point in the history
  • Loading branch information
ToxicFrog committed Jul 2, 2022
1 parent 5d19c39 commit bd4138f
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 16 deletions.
6 changes: 4 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@
- Acid Spray causes surplus acid to splash onto nearby enemies
- Embrittlement makes acid stacks increase damage taken by enemies
- Explosive Reaction turns acid stacks into an explosion on death
- Fix: Infinite recursion with some upgrade combinations
- Fix: Weakness upgrade could sometimes give enemies damage resistance.
- New: weapons are limited to 2 elements, and must master the first before adding the second.
- Change: 2 basic levels are now required to unlock intermediate (and likewise for intermediate->master).
- Change: Documentation tweaks.
- Change: Redesign of damage-over-time API to support fractional stacks/durations.
- Change: Fire now applies stacks based on attack damage.
- Fix: Infinite recursion with some upgrade combinations
- Fix: Weakness upgrade could sometimes give enemies damage resistance.
- WIP: Beam upgrade for hitscan weapons
- currently disabled due to bad interactions with other weapons

Expand Down
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -163,10 +163,15 @@ Killing an enemy gives you a brief moment of time freeze (and some brief slow-mo

# Elemental Upgrades

Elemental upgrades work a bit differently from general upgrades. Each element has four associated upgrades:
Elemental upgrades add powerful debuffs and damage-over-time effects to your attacks. They work a bit differently from other upgrades. Each element has four associated upgrades:

- a basic upgrade that activates that elemental status effect on the weapon
- an intermediate upgrade that improves the status effect in a different way than just leveling up the base upgrade
- two master upgrades that add a powerful new effect, only one of which can be chosen on each weapon
- two *mastery upgrades* that add a powerful new effect, only one of which can be chosen on each weapon; one is designed for AoE combat, the other for tackling individual hard targets.

Lower-rank skills are required to have more levels than higher-rank ones, so to learn the intermediate upgrade you need at least two levels in the basic upgrade, and to (e.g.) upgrade a mastery to level 2, you need 3 ranks in the intermediate upgrade (and thus 4 in the basic upgrade). While each tree has two masteries, you can only choose one; doing so permanently locks out the other on that weapon.

Each weapon can only have two different elements on it. When you choose your first elemental upgrade, that element is "locked in" until you choose a mastery upgrade for it. At that point you can (if you wish) choose a second element next time it levels up.

## Fire

Expand Down
8 changes: 4 additions & 4 deletions ca.ancilla.laevis/upgrades/Acid.zs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class ::CorrosiveShots : ::BaseUpgrade {
}

override bool IsSuitableForWeapon(TFLV::WeaponInfo info) {
return true;
return ::ElementalUpgrade.CanAcceptElement(info, "Acid");
}
}

Expand All @@ -41,7 +41,7 @@ class ::AcidSpray : ::DotModifier {
}

override bool IsSuitableForWeapon(TFLV::WeaponInfo info) {
return info.upgrades.Level("::CorrosiveShots") > info.upgrades.Level("::AcidSpray");
return info.upgrades.Level("::CorrosiveShots") > info.upgrades.Level("::AcidSpray")+1;
}
}

Expand All @@ -53,7 +53,7 @@ class ::Embrittlement : ::DotModifier {
}

override bool IsSuitableForWeapon(TFLV::WeaponInfo info) {
return info.upgrades.Level("::AcidSpray") > info.upgrades.Level("::Embrittlement")
return info.upgrades.Level("::AcidSpray") > info.upgrades.Level("::Embrittlement")+1
&& info.upgrades.Level("::ExplosiveReaction") == 0;
}
}
Expand All @@ -71,7 +71,7 @@ class ::ExplosiveReaction : ::BaseUpgrade {
}

override bool IsSuitableForWeapon(TFLV::WeaponInfo info) {
return info.upgrades.Level("::AcidSpray") > info.upgrades.Level("::ExplosiveReaction")
return info.upgrades.Level("::AcidSpray") > info.upgrades.Level("::ExplosiveReaction")+1
&& info.upgrades.Level("::Embrittlement") == 0;
}
}
Expand Down
33 changes: 33 additions & 0 deletions ca.ancilla.laevis/upgrades/BaseUpgrade.zs
Original file line number Diff line number Diff line change
Expand Up @@ -99,3 +99,36 @@ class ::BaseUpgrade : Object play {
return StringTable.Localize("$"..self.GetClassName().."_Desc");
}
}

// TODO: this is pretty gross. It should be generalized so that elemental upgrades
// can answer questions about themselves.
class ::ElementalUpgrade : ::BaseUpgrade {
static bool CanAcceptElement(TFLV::WeaponInfo info, string element) {
string inprogress = GetElementInProgress(info.upgrades);
return inprogress == element
|| (inprogress == "" && GetElementCount(info.upgrades) < 2);
}

static uint GetElementCount(::UpgradeBag upgrades) {
uint count = 0;
if (upgrades.Level("::IncendiaryShots") > 0) ++count;
if (upgrades.Level("::PoisonShots") > 0) ++count;
if (upgrades.Level("::CorrosiveShots") > 0) ++count;
return count;
}

// A weapon should only ever have one element in progress, so we just return the
// first one we find.
static string GetElementInProgress(::UpgradeBag upgrades) {
if (upgrades.Level("::IncendiaryShots") > 0
&& (upgrades.Level("::Conflagration") + upgrades.Level("::InfernalKiln")) == 0)
return "Fire";
if (upgrades.Level("::PoisonShots") > 0
&& (upgrades.Level("::Putrefaction") + upgrades.Level("::Hallucinogens")) == 0)
return "Poison";
if (upgrades.Level("::CorrosiveShots") > 0
&& (upgrades.Level("::Embrittlement") + upgrades.Level("::ExplosiveReaction")) == 0)
return "Acid";
return "";
}
}
8 changes: 4 additions & 4 deletions ca.ancilla.laevis/upgrades/Fire.zs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class ::IncendiaryShots : ::BaseUpgrade {
}

override bool IsSuitableForWeapon(TFLV::WeaponInfo info) {
return true;
return ::ElementalUpgrade.CanAcceptElement(info, "Fire");
}
}

Expand All @@ -40,7 +40,7 @@ class ::SearingHeat : ::DotModifier {
}

override bool IsSuitableForWeapon(TFLV::WeaponInfo info) {
return info.upgrades.Level("::IncendiaryShots") > info.upgrades.Level("::SearingHeat");
return info.upgrades.Level("::IncendiaryShots") > info.upgrades.Level("::SearingHeat")+1;
}
}

Expand All @@ -52,7 +52,7 @@ class ::Conflagration : ::DotModifier {
}

override bool IsSuitableForWeapon(TFLV::WeaponInfo info) {
return info.upgrades.Level("::SearingHeat") > info.upgrades.Level("::Conflagration")
return info.upgrades.Level("::SearingHeat") > info.upgrades.Level("::Conflagration")+1
&& info.upgrades.Level("::InfernalKiln") == 0;
}
}
Expand Down Expand Up @@ -91,7 +91,7 @@ class ::InfernalKiln : ::BaseUpgrade {
}

override bool IsSuitableForWeapon(TFLV::WeaponInfo info) {
return info.upgrades.Level("::SearingHeat") > info.upgrades.Level("::InfernalKiln")
return info.upgrades.Level("::SearingHeat") > info.upgrades.Level("::InfernalKiln")+1
&& info.upgrades.Level("::Conflagration") == 0;
}
}
Expand Down
8 changes: 4 additions & 4 deletions ca.ancilla.laevis/upgrades/Poison.zs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class ::PoisonShots : ::BaseUpgrade {
}

override bool IsSuitableForWeapon(TFLV::WeaponInfo info) {
return true;
return ::ElementalUpgrade.CanAcceptElement(info, "Poison");
}
}

Expand All @@ -37,7 +37,7 @@ class ::Weakness : ::DotModifier {
}

override bool IsSuitableForWeapon(TFLV::WeaponInfo info) {
return info.upgrades.Level("::PoisonShots") > info.upgrades.Level("::Weakness");
return info.upgrades.Level("::PoisonShots") > info.upgrades.Level("::Weakness")+1;
}
}

Expand All @@ -50,7 +50,7 @@ class ::Hallucinogens : ::DotModifier {
}

override bool IsSuitableForWeapon(TFLV::WeaponInfo info) {
return info.upgrades.Level("::Weakness") > info.upgrades.Level("::Hallucinogens")
return info.upgrades.Level("::Weakness") > info.upgrades.Level("::Hallucinogens")+1
&& info.upgrades.Level("::Putrefaction") == 0;
}
}
Expand Down Expand Up @@ -125,7 +125,7 @@ class ::Putrefaction : ::BaseUpgrade {
}

override bool IsSuitableForWeapon(TFLV::WeaponInfo info) {
return info.upgrades.Level("::Weakness") > info.upgrades.Level("::Putrefaction")
return info.upgrades.Level("::Weakness") > info.upgrades.Level("::Putrefaction")+1
&& info.upgrades.Level("::Hallucinogens") == 0;
}
}
Expand Down

0 comments on commit bd4138f

Please sign in to comment.