Skip to content

Commit

Permalink
feat: add ring of concentration
Browse files Browse the repository at this point in the history
  • Loading branch information
kiedtl committed Sep 4, 2023
1 parent 3f3e6e6 commit 98e5225
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 1 deletion.
6 changes: 5 additions & 1 deletion data/des/des-main.des
Original file line number Diff line number Diff line change
Expand Up @@ -708,4 +708,8 @@ $cDuration:$. Ring duration lasts for $bwillpower$. turns.

% condemnation
$cEffect:$. Destroys a single undead enemy, at the cost of $b20 - willpower$.
turns of Held.
turns of $aHeld$..

% concentration
$cEffect:$. Doubles your willpower for $bwillpower * 2$. turns, at the cost of
$aSlow$., $b-100 Melee%$., and $b-100 Evade%$. for the same duration.
3 changes: 3 additions & 0 deletions data/des/des-statuses-nonplayer.des
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ This is supposed to be a player-only status, and is probably a bug.
% nonplayer_Status.RingDeception
This is supposed to be a player-only status, and is probably a bug.

% nonplayer_Status.RingConcentration
This is supposed to be a player-only status, and is probably a bug.

% nonplayer_Status.DetectHeat
This is supposed to be a player-only status, and is probably a bug.

Expand Down
3 changes: 3 additions & 0 deletions data/des/des-statuses-player.des
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ Refer to the ring's description.
% player_Status.RingDeception
Refer to the ring's description.

% player_Status.RingConcentration
Refer to the ring's description.

% player_Status.DetectHeat
You are detecting sources of heat, as well as enemies attuned to fire.

Expand Down
1 change: 1 addition & 0 deletions data/status_help.tsv
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
.RingConjuration "ring: conjuration" "house of pain" -
.RingAcceleration "ring: acceleration" "is in effect" -
.RingDeception "ring: deception" "voting for trump" -
.RingConcentration "ring: concentration" "using the Force" -
.DetectHeat "detect heat" - -
.DetectElec "detect electricity" - -
.EtherealShield "ethereal shield" - -
Expand Down
20 changes: 20 additions & 0 deletions src/items.zig
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ pub const RINGS = [_]ItemTemplate{
.{ .w = 9, .i = .{ .r = DetonationRing } },
.{ .w = 9, .i = .{ .r = DeceptionRing } },
.{ .w = 9, .i = .{ .r = CondemnationRing } },
.{ .w = 9, .i = .{ .r = ConcentrationRing } },
};
pub const NIGHT_RINGS = [_]ItemTemplate{
.{ .w = 9, .i = .{ .r = ExcisionRing } },
Expand Down Expand Up @@ -1014,6 +1015,25 @@ pub const CondemnationRing = Ring{ // {{{
}.f,
}; // }}}

pub const ConcentrationRing = Ring{ // {{{
.name = "concentration",
.required_MP = 1,
.stats = .{ .Willpower = 1 },
.requires_nopain = true,
.effect = struct {
pub fn f() bool {
const will = @intCast(usize, state.player.stat(.Willpower));
const duration = math.max(1, will * 2);
state.player.addStatus(.RingConcentration, 0, .{ .Tmp = duration });
state.player.addStatus(.Slow, 0, .{ .Tmp = duration });

state.message(.Info, "Your consciousness begins withdrawing from your physical body.", .{});

return true;
}
}.f,
}; // }}}

pub const ExcisionRing = Ring{ // {{{
.name = "excision",
.required_MP = 5,
Expand Down
5 changes: 5 additions & 0 deletions src/player.zig
Original file line number Diff line number Diff line change
Expand Up @@ -937,12 +937,14 @@ pub const RingError = enum {
NotEnoughMP,
HatedByNight,
CannotBeCorrupted,
CannotBeInPain,

pub fn text1(self: @This()) []const u8 {
return switch (self) {
.NotEnoughMP => "low mana",
.HatedByNight => "hated by the Night",
.CannotBeCorrupted => "must be uncorrupted",
.CannotBeInPain => "must not be in pain",
};
}
};
Expand All @@ -958,6 +960,9 @@ pub fn checkRing(index: usize) ?RingError {
if (ring.requires_uncorrupt and state.player.hasStatus(.Corruption)) {
return .CannotBeCorrupted;
}
if (ring.requires_nopain and state.player.hasStatus(.Pain)) {
return .CannotBeInPain;
}
return null;
}

Expand Down
10 changes: 10 additions & 0 deletions src/types.zig
Original file line number Diff line number Diff line change
Expand Up @@ -1129,6 +1129,7 @@ pub const Status = enum {
RingConjuration, // No power field
RingAcceleration, // No power field
RingDeception, // No power field
RingConcentration, // No power field

// Item-specific effects.
DetectHeat, // Doesn't have a power field.
Expand Down Expand Up @@ -4090,6 +4091,14 @@ pub const Mob = struct { // {{{
val = @divTrunc(val * 50, 100);
};
},
.Melee => {
if (self.hasStatus(.RingConcentration))
val -= 100;
},
.Evade => {
if (self.hasStatus(.RingConcentration))
val -= 100;
},
else => {},
}

Expand Down Expand Up @@ -4705,6 +4714,7 @@ pub const Ring = struct {
stats: enums.EnumFieldStruct(Stat, isize, 0) = .{},
hated_by_nc: bool = false,
requires_uncorrupt: bool = false,
requires_nopain: bool = false,
effect: fn () bool,
};

Expand Down

0 comments on commit 98e5225

Please sign in to comment.