Skip to content

Commit

Permalink
feat: UI: show desc for weap ego when exam mob
Browse files Browse the repository at this point in the history
  • Loading branch information
kiedtl committed Jun 20, 2024
1 parent 9108816 commit 4337939
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 18 deletions.
36 changes: 34 additions & 2 deletions data/des/des-misc-ui.des
Original file line number Diff line number Diff line change
@@ -1,6 +1,38 @@
% ex_sp_dodgeable_missable

If a bolt is dodgeable, the target can evade it depending on their $bEvasion$. stat.
If a bolt is dodgeable, the target can evade it depending on their $bEvasion$.
stat.


If a bolt is missable, the caster can miss their target depending on their $bMissile$. stat.
If a bolt is missable, the caster can miss their target depending on their
$bMissile$. stat.

% ego_bone
More damage will be dealt to living enemies, and less to undead.

% ego_copper
When standing on copper ground, $b+3$. electric damage will be dealt.

% ego_nc_insane
When both attacker and defender are in an unlit area, there is a will-checked
chance for the defender to be driven insane.

% ego_nc_masspara
When the attacker is in an unlit area, there is a will-checked chance to
paralyse nearby foes if they are also standing in the dark. The duration of the
paralysis will always be less than the time needed for the attacker to reach
them.

% ego_nc_duplicate
When both attacker and defender are in an unlit area, there is a will-checked
chance to create a spectral copy of the defender. The spectral copy will
$calways$. be aligned with the Night Creatures, and will last for $bwillpower *
2$. turns.

% ego_swap
When a successful hit is landed, the attacker and defender will swap places.

% ego_drain
Attacking a $oWielder$. $g(see the creature's description)$. will drain them of
their MP, absorbing it and preventing them from channelling the Necromancer's
power.
27 changes: 14 additions & 13 deletions src/types.zig
Original file line number Diff line number Diff line change
Expand Up @@ -1430,6 +1430,7 @@ pub const Status = enum {
.Corruption,
.Blind,
=> mob.life_type != .Living,
.Insane => mob.life_type == .Spectral,
else => false,
};
}
Expand Down Expand Up @@ -4906,6 +4907,19 @@ pub const Weapon = struct {
Swap,
Drain,

pub fn id(self: Ego) ?[]const u8 {
return switch (self) {
.None => null,
.Bone => "ego_bone",
.Copper => "ego_copper",
.NC_Insane => "ego_nc_insanity",
.NC_MassPara => "ego_nc_mass_para",
.NC_Duplicate => "ego_nc_duplicate",
.Swap => "ego_swap",
.Drain => "ego_drain",
};
}

pub fn name(self: Ego) ?[]const u8 {
return switch (self) {
.None => null,
Expand All @@ -4918,19 +4932,6 @@ pub const Weapon = struct {
.Drain => "draining",
};
}

pub fn description(self: Ego) ?[]const u8 {
return switch (self) {
.None => null,
.Bone => "More damage will be dealt to living enemies, and less to undead.",
.Copper => "When standing on copper ground, you deal $b+3$. electric damage.",
.NC_Insane => "When both you and your foe are in an unlit area, you have a will-checked chance to send your foe insane with your attacks.",
.NC_MassPara => "When you are attacking from an unlit area, you have a will-checked chance to paralyse nearby foes if they are also standing in the dark. The duration of the paralysis will always be less than the time needed to reach them.",
.NC_Duplicate => "When both you and your foe are in an unlit area, you have a will-checked chance to create a spectral copy of your foe. The spectral copy will be aligned with the Night Creatures, and will last for $bwillpower * 2$. turns.",
.Swap => "When you land a successful hit, you have a chance to swap places with your foe.",
.Drain => "Attacking a $oWielder$. $g(see the enemy's description)$. will drain them of their MP, absorbing it and preventing them from channelling the Necromancer's power.",
};
}
};

pub fn createBoneWeapon(comptime weapon: *const Weapon, opts: struct {}) Weapon {
Expand Down
10 changes: 7 additions & 3 deletions src/ui.zig
Original file line number Diff line number Diff line change
Expand Up @@ -1003,8 +1003,11 @@ fn _getMonsSpellsDescription(self: *Console, starty: usize, mob: *Mob, _: usize)
y += self.drawTextAtf(0, y, "· $cdamage$.: {} $g<{s}>$.", .{
weapon.damage, weapon.damage_kind.stringLong(),
}, .{});
if (weapon.ego != .None)
y += self.drawTextAtf(0, y, "· $cego$.: {s}", .{weapon.ego.name().?}, .{});
if (weapon.ego != .None) {
const name = weapon.ego.name().?;
y += self.drawTextAtf(0, y, "· $cego$.: {s}", .{name}, .{});
self.addTooltipForText("{s} ego", .{name}, "{s}", .{weapon.ego.id().?});
}
if (weapon.martial != false)
y += self.drawTextAt(0, y, "· $cmartial$.: yes", .{});
if (weapon.delay != 100)
Expand Down Expand Up @@ -1231,7 +1234,8 @@ fn _getItemDescription(self: *Console, starty: usize, item: Item, linewidth: usi

y += _writerHeader(self, y, linewidth, "traits", .{});

const p_ego_desc = p.ego.description();
const p_ego_desc = if (p.ego.id()) |i| state.descriptions.get(i) else null;

if (p.martial) {
const stat = state.player.stat(.Martial);
const statfmt = utils.SignedFormatter{ .v = stat };
Expand Down

0 comments on commit 4337939

Please sign in to comment.