Skip to content

Commit

Permalink
feat: HLD: deceleration ring
Browse files Browse the repository at this point in the history
  • Loading branch information
kiedtl committed Jun 5, 2024
1 parent 94e69b4 commit e267e41
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 1 deletion.
7 changes: 7 additions & 0 deletions data/des/des-main.des
Original file line number Diff line number Diff line change
Expand Up @@ -753,3 +753,10 @@ glowing.


$cDuration:$. This effect lasts for $bwillpower$. turns.

% deceleration
$cEffect:$. Erects an invisible shield around you, causing attacks against you
to take twice as long.


$cDuration:$. This effect lasts for $bwillpower * 2$. turns.
27 changes: 27 additions & 0 deletions data/prefabs/HLD_s_deceleration.fab
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
:g_subroom
:priority 50
:notraps
% Allow stairs, guards, items

% TODO: which Leqhyebundib? My notebook isn't with me right now, I can't recall
% the first name of the steward one (or was that not a Leqhyebundib?)

@p P
Another strange relic found locked in Leqhyebundib's vaults. As it bears some
superficial similarities to the Earthen Shield's ring, it's being kept here for
eventual examination by the High Priest as well.

$g-- Zilodothrod Hubsel, Captain of the Guard$.
END POSTER

@0 p gold_c_wall_pltfrm
@1 p gold_c_wall_left
@2 p gold_c_wall_upper
@3 p gold_c_wall_lower
@4 p gold_c_wall_right
@5 p gold_c_wall_block
@r i =deceleration

.p.
0r0
124
17 changes: 17 additions & 0 deletions src/items.zig
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@ pub const ALL_ITEMS = [_]ItemTemplate{
.{ .w = 0, .i = .{ .X = &Earthen1ShieldAux } },
.{ .w = 0, .i = .{ .X = &Earthen2ShieldAux } },
.{ .w = 0, .i = .{ .r = DisintegrationRing } },
.{ .w = 0, .i = .{ .r = DecelerationRing } },
};

pub const Key = struct {
Expand Down Expand Up @@ -1157,6 +1158,22 @@ pub const ObscurationRing = Ring{ // {{{
}.f,
}; // }}}

pub const DecelerationRing = Ring{ // {{{
.name = "deceleration",
.required_MP = 2,
.effect = struct {
pub fn f() bool {
const will = @intCast(usize, state.player.stat(.Willpower));
const duration = math.max(1, will) * 2;
state.player.addStatus(.RingDeceleration, 0, .{ .Tmp = duration });

state.message(.Info, "An invisible shield begins to surround you.", .{});

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

pub const ExcisionRing = Ring{ // {{{
.name = "excision",
.required_MP = 5,
Expand Down
7 changes: 6 additions & 1 deletion src/types.zig
Original file line number Diff line number Diff line change
Expand Up @@ -1175,6 +1175,7 @@ pub const Status = enum {
RingDeception, // No power field
RingConcentration, // No power field
RingObscuration,
RingDeceleration,

// Item-specific effects.
DetectHeat, // Doesn't have a power field.
Expand Down Expand Up @@ -3249,7 +3250,8 @@ pub const Mob = struct { // {{{
if (weapon.reach < attacker.distance(recipient))
continue;

if (weapon.delay > longest_delay) longest_delay = weapon.delay;
if (weapon.delay > longest_delay)
longest_delay = weapon.delay;
_fightWithWeapon(attacker, recipient, weapon, opts, if (weapon.martial) martial else 0);
}

Expand All @@ -3258,6 +3260,9 @@ pub const Mob = struct { // {{{

if (!opts.free_attack) {
const d = attacker.coordMT(recipient.coord).closestDirectionTo(recipient.coord, state.mapgeometry);
if (recipient.hasStatus(.RingDeceleration)) {
longest_delay *= 2;
}
attacker.declareAction(.{ .Attack = .{ .who = recipient, .coord = recipient.coord, .direction = d, .delay = longest_delay } });
}

Expand Down

0 comments on commit e267e41

Please sign in to comment.