Skip to content

Commit

Permalink
feat: rework water as terrain type
Browse files Browse the repository at this point in the history
  • Loading branch information
kiedtl committed Jun 21, 2024
1 parent 901f98f commit b5b73c9
Show file tree
Hide file tree
Showing 9 changed files with 63 additions and 7 deletions.
7 changes: 5 additions & 2 deletions data/des/des-main.des
Original file line number Diff line number Diff line change
Expand Up @@ -389,8 +389,11 @@ this, you share electricity damage with nearby monsters.
Wooden boards. Creaky and flammable, but makes you resistant to electricity.

% t_water
Someone spilled a lot of water here. It's difficult to sneak through, and will
make you very vulnerable to electricity. You are very resistant to fire though.
Deep water. It would be wise to avoid.

% t_water_shallow
It's difficult to sneak through, and will make you very vulnerable to
electricity. You are very resistant to fire though.

% t_f_lumi
Some kind of bluish fungi, glowing serenely in the dim light of the Dungeon.
Expand Down
6 changes: 6 additions & 0 deletions data/des/des-statuses-nonplayer.des
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ This is supposed to be a player-only status, and is probably a bug.
% nonplayer_Status.RingObscuration
This is supposed to be a player-only status, and is probably a bug.

% nonplayer_Status.RingDeceleration
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 Expand Up @@ -162,6 +165,9 @@ It doesn't seem to be awake...
% nonplayer_Status.Slow
It is moving 2x more slowly.

% nonplayer_Status.Water
It is in water.

% nonplayer_Status.DayBlindness
(Bug) Seems the sun burnt it when it went outside.

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

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

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

Expand Down Expand Up @@ -164,6 +167,9 @@ sounds.
% player_Status.Slow
You are moving 2x more slowly.

% player_Status.Water
You are in deep water, and are suitably affected.

% player_Status.DayBlindness
[BUG] So the sun burnt you when you went outside huh?

Expand Down
1 change: 1 addition & 0 deletions data/status_help.tsv
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,6 @@
.RingingEars "ringing ears" "[bug] singing" "ringing"
.Sleeping "sleeping" "dormant" "sleep"
.Slow "slowed" - "slow"
.Water "water" - "water"
.DayBlindness "day-blinded" - -
.NightBlindness "night-blinded" - -
6 changes: 5 additions & 1 deletion src/astar.zig
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ pub fn basePenaltyFunc(coord: Coord, opts: state.IsWalkableOptions) usize {
else => {},
};

if (state.dungeon.terrainAt(coord).is_path_penalized) {
c += 50;
}

if (opts.mob) |mob| {
if (mob.ai.flag(.FearsDarkness)) {
if (!state.dungeon.lightAt(coord).*)
Expand All @@ -94,7 +98,7 @@ pub fn basePenaltyFunc(coord: Coord, opts: state.IsWalkableOptions) usize {
}

if (!fire.fireIsSafeFor(mob, state.dungeon.fireAt(coord).*))
c += 49;
c += 50;
}

return c;
Expand Down
5 changes: 5 additions & 0 deletions src/combat.zig
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ pub const CHANCE_FOR_DIP_EFFECT = 33;
const ATTACKER_ENRAGED_BONUS: isize = 20;
const ATTACKER_INVIGORATED_BONUS: isize = 10;
const ATTACKER_CORRUPT_BONUS: isize = 10;
const ATTACKER_WATER_NBONUS: isize = 10;
const ATTACKER_FEAR_NBONUS: isize = 10;
const ATTACKER_HELD_NBONUS: isize = 20;
const ATTACKER_STUN_NBONUS: isize = 15;
Expand All @@ -35,6 +36,7 @@ const DEFENDER_UNLIT_BONUS: isize = 5;
const DEFENDER_ESHIELD_BONUS: isize = 7; // (per wall, so +7..49)
const DEFENDER_INVIGORATED_BONUS: isize = 10;
const DEFENDER_OPEN_SPACE_BONUS: isize = 10;
const DEFENDER_WATER_NBONUS: isize = 10;
const DEFENDER_ENRAGED_NBONUS: isize = 10;
const DEFENDER_RECUPERATE_NBONUS: isize = 10;
const DEFENDER_HELD_NBONUS: isize = 10;
Expand Down Expand Up @@ -96,6 +98,7 @@ pub fn chanceOfMissileLanding(attacker: *const Mob) usize {
var chance: isize = attacker.stat(.Missile);

chance -= if (attacker.isUnderStatus(.Debil)) |_| ATTACKER_STUN_NBONUS else 0;
chance -= if (attacker.isUnderStatus(.Water)) |_| ATTACKER_WATER_NBONUS else 0;

return @intCast(usize, math.clamp(chance, 0, 100));
}
Expand All @@ -121,6 +124,7 @@ pub fn chanceOfMeleeLanding(attacker: *const Mob, defender: ?*const Mob) usize {
chance -= if (attacker.hasStatus(.Fear)) ATTACKER_FEAR_NBONUS else 0;
chance -= if (attacker.hasStatus(.Held)) ATTACKER_HELD_NBONUS else 0;
chance -= if (attacker.hasStatus(.Debil)) ATTACKER_STUN_NBONUS else 0;
chance -= if (attacker.hasStatus(.Water)) ATTACKER_WATER_NBONUS else 0;
chance -= if (attacker.hasStatus(.RingConcentration)) ATTACKER_CONCENTRATE_NBONUS else 0;

return @intCast(usize, math.clamp(chance, 0, 100));
Expand All @@ -139,6 +143,7 @@ pub fn chanceOfAttackEvaded(defender: *const Mob, attacker: ?*const Mob) usize {

chance -= if (defender.hasStatus(.Held)) DEFENDER_HELD_NBONUS else 0;
chance -= if (defender.hasStatus(.Debil)) DEFENDER_STUN_NBONUS else 0;
chance -= if (defender.hasStatus(.Water)) DEFENDER_WATER_NBONUS else 0;
chance -= if (defender.hasStatus(.Recuperate)) DEFENDER_RECUPERATE_NBONUS else 0;
chance -= if (defender.hasStatus(.Enraged)) DEFENDER_ENRAGED_NBONUS else 0;
chance -= if (defender.hasStatus(.RingConcentration)) DEFENDER_CONCENTRATE_NBONUS else 0;
Expand Down
8 changes: 6 additions & 2 deletions src/mapgen.zig
Original file line number Diff line number Diff line change
Expand Up @@ -751,7 +751,9 @@ pub fn isRoomInvalid(
while (x < room.rect.end().x) : (x += 1) {
const coord = Coord.new2(room.rect.start.z, x, y);
if (state.dungeon.at(coord).type == .Lava or
state.dungeon.at(coord).type == .Water)
state.dungeon.at(coord).type == .Water or
state.dungeon.terrainAt(coord) == &surfaces.ShallowWaterTerrain or
state.dungeon.terrainAt(coord) == &surfaces.WaterTerrain)
{
return true;
}
Expand Down Expand Up @@ -813,6 +815,7 @@ pub fn excavatePrefab(
const tt: ?TileType = switch (fab.content[y][x]) {
.Any, .Connection => null,
.Window, .Wall => .Wall,
.Water,
.LevelFeature,
.Feature,
.LockedDoor,
Expand All @@ -827,7 +830,7 @@ pub fn excavatePrefab(
.Corpse,
.Ring,
=> .Floor,
.Water => .Water,
//.Water => .Water,
.Lava => .Lava,
};
if (tt) |_tt| state.dungeon.at(rc).type = _tt;
Expand Down Expand Up @@ -918,6 +921,7 @@ pub fn excavatePrefab(
.Door => placeDoor(rc, false),
.Brazier => _place_machine(rc, Configs[room.rect.start.z].light),
.ShallowWater => state.dungeon.at(rc).terrain = &surfaces.ShallowWaterTerrain,
.Water => state.dungeon.at(rc).terrain = &surfaces.WaterTerrain,
.Bars => {
const p_ind = utils.findById(surfaces.props.items, Configs[room.rect.start.z].bars);
_ = placeProp(rc, &surfaces.props.items[p_ind.?]);
Expand Down
26 changes: 24 additions & 2 deletions src/surfaces.zig
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ pub const Terrain = struct {
effects: []const StatusDataInfo = &[_]StatusDataInfo{},
flammability: usize = 0,
fire_retardant: bool = false,
is_path_penalized: bool = false,
repairable: bool = true,
luminescence: usize = 0,
opacity: usize = 0,
Expand Down Expand Up @@ -196,11 +197,11 @@ pub const WoodTerrain = Terrain{
};

pub const ShallowWaterTerrain = Terrain{
.id = "t_water",
.id = "t_water_shallow",
.name = "shallow water",
.color = 0x3c73b1, // medium blue
.tile = '≈',
.resists = .{ .rFire = 50, .rElec = -50 },
.resists = .{ .rFire = 25, .rElec = -25 },
.effects = &[_]StatusDataInfo{
.{ .status = .Conductive, .duration = .{ .Ctx = null } },
},
Expand All @@ -211,6 +212,25 @@ pub const ShallowWaterTerrain = Terrain{
.weight = 3,
};

pub const WaterTerrain = Terrain{
.id = "t_water",
.name = "deep water",
.color = 0x104381, // medium blue
.tile = '≈',
.resists = .{ .rFire = 50, .rElec = -50 },
.effects = &[_]StatusDataInfo{
.{ .status = .Conductive, .duration = .{ .Ctx = null } },
.{ .status = .Noisy, .duration = .{ .Ctx = null } },
.{ .status = .Water, .duration = .{ .Ctx = null } },
},
.fire_retardant = true,
.is_path_penalized = true,

.for_levels = &[_][]const u8{},
.placement = .RoomBlob,
.weight = 0,
};

pub const DeadFungiTerrain = Terrain{
.id = "t_f_dead",
.name = "dead fungi",
Expand Down Expand Up @@ -261,6 +281,8 @@ pub const TERRAIN = [_]*const Terrain{
&MetalTerrain,
&CopperTerrain,
&WoodTerrain,
&ShallowWaterTerrain,
&WaterTerrain,
&DeadFungiTerrain,
&TallFungiTerrain,
&PillarTerrain,
Expand Down
5 changes: 5 additions & 0 deletions src/types.zig
Original file line number Diff line number Diff line change
Expand Up @@ -1394,6 +1394,11 @@ pub const Status = enum {
// Doesn't have a power field.
Lifespan,

// Just combat debufs for now.
//
// Doesn't have a power field.
Water,

// }}}

pub const TOTAL = @typeInfo(@This()).Enum.fields.len;
Expand Down

0 comments on commit b5b73c9

Please sign in to comment.