Skip to content

Commit

Permalink
feat: add moar prefabs!
Browse files Browse the repository at this point in the history
HLD_ember_beast

Also add the ember beast and its spells itself
  • Loading branch information
kiedtl committed May 21, 2024
1 parent 9c3f5fb commit 4ce156f
Show file tree
Hide file tree
Showing 5 changed files with 184 additions and 20 deletions.
49 changes: 49 additions & 0 deletions data/prefabs/HLD_ember_beast.fab
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
:g_tunneler
:g_restriction 1
:priority 100
:notraps
:noitems
:noguards
:nostairs

@@e M ember_beast

:tunneler_orientation north
:tunneler_orientation south
:tunneler_orientation east
:tunneler_orientation west


e.
..


\

:tunneler_orientation north

e.
..
..

\

:tunneler_orientation south

..
e.
..

\

:tunneler_orientation east

.e.
...

\

:tunneler_orientation west

e..
...
7 changes: 7 additions & 0 deletions src/items.zig
Original file line number Diff line number Diff line change
Expand Up @@ -1810,6 +1810,13 @@ pub const KICK_STRS = [_]DamageStr{
_dmgstr(81, "curbstomp", "curbstomps", ""),
};

pub const BURN_STRS = [_]DamageStr{
_dmgstr(8, "singe", "singes", ""),
_dmgstr(20, "scorch", "scorches", ""),
_dmgstr(40, "burn", "burns", ""),
_dmgstr(80, "burn", "burns", " horribly"),
_dmgstr(150, "incinerate", "incinerates", ""),
};
pub const SHOCK_STRS = [_]DamageStr{
_dmgstr(10, "zap", "zaps", ""),
_dmgstr(40, "shock", "shocks", ""),
Expand Down
54 changes: 50 additions & 4 deletions src/mobs.zig
Original file line number Diff line number Diff line change
Expand Up @@ -1577,7 +1577,7 @@ pub const EmberlingTemplate = MobTemplate{

.max_HP = 2,
.memory_duration = 4,
.innate_resists = .{ .rFume = 100, .rFire = RESIST_IMMUNE },
.innate_resists = .{ .rFume = 100, .rFire = 50 },
.stats = .{ .Willpower = 1, .Evade = 5, .Vision = 5, .Melee = 50 },
},
// XXX: Emberlings are never placed alone, this determines number of
Expand All @@ -1590,7 +1590,52 @@ pub const EmberlingTemplate = MobTemplate{
},
.statuses = &[_]StatusDataInfo{
.{ .status = .Sleeping, .duration = .Prm },
.{ .status = .Fire, .duration = .Prm },
.{ .status = .Noisy, .duration = .Prm },
},
};

pub const EmberBeastTemplate = MobTemplate{
.mob = .{
.id = "ember_beast",
.species = &Species{
.name = "ember beast",
.default_attack = &Weapon{
.name = "burning lance",
.damage = 2,
.damage_kind = .Fire,
.strs = &items.PIERCING_STRS,
.delay = 90,
},
},
.tile = 'E',
.ai = AI{
.profession_description = "watching",
.work_fn = ai.standStillAndGuardWork,
.fight_fn = ai.mageFight,
.is_curious = false,
.is_fearless = true,
.flags = &[_]AI.Flag{.DetectWithHeat},
},
.life_type = .Construct,

.spells = &[_]SpellOptions{
.{ .MP_cost = 3, .spell = &spells.BOLT_FIERY_JAVELIN, .power = 1 },
.{ .MP_cost = 20, .spell = &spells.CAST_ENGINE, .power = 10 },
},
.max_MP = 30,

.blood = null,
.blood_spray = gas.SmokeGas.id,
.corpse = .None,

.multitile = 2,
.max_HP = 7,
.memory_duration = 20,
.innate_resists = .{ .rFume = 100, .rAcid = 50, .rFire = 25, .rElec = -75, .Armor = 10 },
.stats = .{ .Willpower = 1, .Evade = 0, .Vision = 6, .Melee = 90 },
},
.statuses = &[_]StatusDataInfo{
.{ .status = .Sleeping, .duration = .Prm },
.{ .status = .Noisy, .duration = .Prm },
},
};
Expand Down Expand Up @@ -2190,12 +2235,12 @@ pub const BurningBruteTemplate = MobTemplate{

.faction = .Revgenunkim,
.multitile = 2,
.max_HP = 15,
.max_HP = 13,
.memory_duration = 10,
.blood = null,
.corpse = .None,

.innate_resists = .{ .rAcid = RESIST_IMMUNE, .rFire = RESIST_IMMUNE, .rElec = -25 },
.innate_resists = .{ .rAcid = RESIST_IMMUNE, .rFire = RESIST_IMMUNE, .rElec = -25, .Armor = 25 },
.stats = .{ .Willpower = 8, .Evade = 10, .Melee = 80 },
},
.statuses = &[_]StatusDataInfo{
Expand Down Expand Up @@ -2259,6 +2304,7 @@ pub const MOBS = [_]MobTemplate{
StalkerTemplate,
BoneRatTemplate,
EmberlingTemplate,
EmberBeastTemplate,
SparklingTemplate,
SkeletalBlademasterTemplate,
TorturerNecromancerTemplate,
Expand Down
10 changes: 9 additions & 1 deletion src/player.zig
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,15 @@ pub fn executeWizardFun(w: WizardFun) void {
// .waves = 3,
// .target = state.player,
// } });
@panic("nooooooooooooo");

mapgen.initLevel(5);
const c = for (&DIRECTIONS) |d| {
if (state.dungeon.entries[5].move(d, state.mapgeometry)) |n|
if (state.is_walkable(n, .{ .right_now = true }))
break n;
} else unreachable;
_ = state.player.teleportTo(c, null, false, false);
//@panic("nooooooooooooo");
},
.Particles => {
_ = janet.loadFile("scripts/particles.janet", state.gpa.allocator()) catch return;
Expand Down
84 changes: 69 additions & 15 deletions src/spells.zig
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,21 @@ pub const CAST_CALL_UNDEAD = Spell{
},
};

pub const CAST_ENGINE = Spell{
.id = "sp_sprint_engine",
.name = "overpowered engine",
.cast_type = .Smite,
.smite_target_type = .Self,
.check_has_effect = struct {
// Enemy must be far far away
fn f(caster: *Mob, opts: SpellOptions, _: Coord) bool {
return ai.closestEnemy(caster).mob.distance(caster) > opts.power;
}
}.f,
.noise = .Louder,
.effect_type = .{ .Status = .Fast },
};

// TODO: generalize into a healing spell?
pub const CAST_REGEN = Spell{
.id = "sp_regen",
Expand All @@ -267,20 +282,20 @@ pub const CAST_REGEN = Spell{

// Spells that give specific status to specific class of mobs. {{{

fn _createSpecificStatusSp(comptime id: []const u8, name: []const u8, anim: []const u8, s: Status) Spell {
fn _createSpecificStatusSp(comptime id: []const u8, name: []const u8, anim: []const u8, status_str: []const u8, s: Status) Spell {
return Spell{
.id = "sp_haste_" ++ id,
.name = "haste " ++ name,
.id = "sp_" ++ status_str ++ "_" ++ id,
.name = status_str ++ " " ++ name,
.animation = .{ .Particle = .{ .name = anim } },
.cast_type = .Smite,
.smite_target_type = .{ .SpecificAlly = id },
.effect_type = .{ .Status = s },
};
}

pub const CAST_ENRAGE_BONE_RAT = _createSpecificStatusSp("bone_rat", "bone rat", "glow-white-gray", .Enraged);
pub const CAST_FIREPROOF_DUSTLING = _createSpecificStatusSp("dustling", "dustling", "glow-cream", .Fireproof);
pub const CAST_ENRAGE_DUSTLING = _createSpecificStatusSp("dustling", "dustling", "glow-cream", .Enraged);
pub const CAST_ENRAGE_BONE_RAT = _createSpecificStatusSp("bone_rat", "bone rat", "glow-white-gray", "enrage", .Enraged);
pub const CAST_FIREPROOF_DUSTLING = _createSpecificStatusSp("dustling", "dustling", "glow-cream", "fireproof", .Fireproof);
pub const CAST_ENRAGE_DUSTLING = _createSpecificStatusSp("dustling", "dustling", "glow-cream", "enrage", .Enraged);

// }}}

Expand Down Expand Up @@ -353,6 +368,39 @@ pub const BOLT_AIRBLAST = Spell{
}.f },
};

pub const BOLT_FIERY_JAVELIN = Spell{
.id = "sp_javelin_fire",
.name = "fiery javelin",
.cast_type = .Bolt,
.bolt_dodgeable = true,
.bolt_missable = true,
.bolt_multitarget = false,
.animation = .{ .Particle = .{ .name = "zap-bolt" } },
.noise = .Loud,
.check_has_effect = struct {
fn f(caster: *Mob, _: SpellOptions, target: Coord) bool {
return caster.distance2(target) >= 3;
}
}.f,
.effect_type = .{ .Custom = struct {
fn f(caster_c: Coord, _: Spell, opts: SpellOptions, coord: Coord) void {
if (state.dungeon.at(coord).mob) |victim| {
victim.takeDamage(.{
.amount = opts.power,
.source = .RangedAttack,
.by_mob = state.dungeon.at(caster_c).mob,
}, .{ .noun = "The blazing javelin", .strs = &items.PIERCING_STRS });
victim.takeDamage(.{
.amount = opts.power,
.source = .RangedAttack,
.by_mob = state.dungeon.at(caster_c).mob,
.kind = .Fire,
}, .{ .noun = "The blazing javelin", .strs = &items.BURN_STRS });
}
}
}.f },
};

pub const BOLT_JAVELIN = Spell{
.id = "sp_javelin",
.name = "javelin",
Expand Down Expand Up @@ -923,13 +971,18 @@ pub const BOLT_FIREBALL = Spell{
}
}.f,
.noise = .Loud,
.effect_type = .{ .Custom = struct {
fn f(caster_coord: Coord, _: Spell, opts: SpellOptions, target: Coord) void {
const caster = state.dungeon.at(caster_coord).mob;
explosions.fireBurst(target, 2, .{ .initial_damage = opts.power, .culprit = caster });
state.dungeon.at(target).mob.?.addStatus(.Fire, 0, .{ .Tmp = opts.duration });
}
}.f },
.effect_type = .{
.Custom = struct {
fn f(caster_coord: Coord, _: Spell, opts: SpellOptions, target: Coord) void {
const caster = state.dungeon.at(caster_coord).mob;
explosions.fireBurst(target, 1, .{ .initial_damage = opts.power, .culprit = caster });

// Target might have been destroyed in explosion
if (state.dungeon.at(target).mob) |m_targ|
m_targ.addStatus(.Fire, 0, .{ .Tmp = opts.duration });
}
}.f,
},
};

pub const CAST_ENRAGE_UNDEAD = Spell{
Expand Down Expand Up @@ -1000,18 +1053,19 @@ pub const CAST_RESURRECT_FIRE = Spell{
.effect_type = .{ .Custom = _resurrectFire },
.checks_will = false,
};
fn _resurrectFire(_: Coord, _: Spell, opts: SpellOptions, coord: Coord) void {
fn _resurrectFire(caster_coord: Coord, _: Spell, opts: SpellOptions, coord: Coord) void {
const corpse = state.dungeon.at(coord).surface.?.Corpse;
if (corpse.raiseAsUndead(coord)) {
if (state.player.cansee(coord)) {
state.message(.SpellCast, "The {s} rises, burning with an unearthly flame!", .{
corpse.displayName(),
});
}
corpse.faction = state.dungeon.at(caster_coord).mob.?.faction;
corpse.addStatus(.Fire, 0, .Prm);
corpse.addStatus(.Fast, 0, .Prm);
corpse.addStatus(.Explosive, opts.power, .Prm);
corpse.addStatus(.Lifespan, opts.power, .{ .Tmp = 20 });
corpse.addStatus(.Lifespan, opts.power, .{ .Tmp = 10 });
}
}

Expand Down

0 comments on commit 4ce156f

Please sign in to comment.