More modifiers

This commit is contained in:
IntegratedQuantum 2025-02-25 22:07:26 +01:00
parent d2deb2c17a
commit 0cb195dce6
10 changed files with 124 additions and 4 deletions

View File

@ -10,5 +10,11 @@
.colors = .{
0xff847bce, 0xff8b9fe0, 0xff94c6ea, 0xffb0eaf6, 0xffffffff,
},
.modifiers = .{
.{
.id = "fragile",
.strength = 0.4,
},
},
},
}

View File

@ -563,7 +563,7 @@ pub const Tool = struct { // MARK: Tool
self.tooltip.appendSlice("\nModifiers:\n");
for(self.modifiers) |modifier| {
modifier.printTooltip(&self.tooltip);
self.tooltip.append('\n');
self.tooltip.appendSlice("§\n");
}
_ = self.tooltip.pop();
}

View File

@ -1,2 +1,8 @@
pub const durable = @import("durable.zig");
pub const fragile = @import("fragile.zig");
pub const heavy = @import("heavy.zig");
pub const light = @import("light.zig");
pub const powerful = @import("powerful.zig");
pub const single_use = @import("single_use.zig");
pub const weak = @import("weak.zig");

View File

@ -6,13 +6,13 @@ const Tool = main.items.Tool;
pub const priority = 1;
pub fn combineModifiers(strength1: f32, strength2: f32) f32 {
return strength1 + strength2;
return @max(0, strength1) + @max(0, strength2);
}
pub fn changeToolParameters(tool: *Tool, strength: f32) void {
tool.maxDurability *= 1 + strength;
tool.maxDurability *= 1 + @max(0, strength);
}
pub fn printTooltip(outString: *main.List(u8), strength: f32) void {
outString.writer().print("#500090**Durable#808080 *Increases durability by §**{d:.0}%", .{strength*100}) catch unreachable;
outString.writer().print("#500090**Durable**#808080 *Increases durability by **{d:.0}%", .{@max(0, strength)*100}) catch unreachable;
}

View File

@ -0,0 +1,18 @@
const std = @import("std");
const main = @import("root");
const Tool = main.items.Tool;
pub const priority = 1;
pub fn combineModifiers(strength1: f32, strength2: f32) f32 {
return 1 - (1 - std.math.clamp(strength1, 0, 1))*(1 - std.math.clamp(strength2, 0, 1));
}
pub fn changeToolParameters(tool: *Tool, strength: f32) void {
tool.maxDurability *= 1 - std.math.clamp(strength, 0, 1);
}
pub fn printTooltip(outString: *main.List(u8), strength: f32) void {
outString.writer().print("#ccddff**Fragile**#808080 *Decreases durability by **{d:.0}%", .{std.math.clamp(strength, 0, 1)*100}) catch unreachable;
}

View File

@ -0,0 +1,18 @@
const std = @import("std");
const main = @import("root");
const Tool = main.items.Tool;
pub const priority = 1;
pub fn combineModifiers(strength1: f32, strength2: f32) f32 {
return @max(0, strength1) + @max(0, strength2);
}
pub fn changeToolParameters(tool: *Tool, strength: f32) void {
tool.swingTime *= 1 + @max(0, strength);
}
pub fn printTooltip(outString: *main.List(u8), strength: f32) void {
outString.writer().print("#ffcc30**Heavy**#808080 *Increases swing time by **{d:.0}%", .{@max(0, strength)*100}) catch unreachable;
}

View File

@ -0,0 +1,18 @@
const std = @import("std");
const main = @import("root");
const Tool = main.items.Tool;
pub const priority = 1;
pub fn combineModifiers(strength1: f32, strength2: f32) f32 {
return 1 - (1 - std.math.clamp(strength1, 0, 1))*(1 - std.math.clamp(strength2, 0, 1));
}
pub fn changeToolParameters(tool: *Tool, strength: f32) void {
tool.swingTime *= 1 - std.math.clamp(strength, 0, 1);
}
pub fn printTooltip(outString: *main.List(u8), strength: f32) void {
outString.writer().print("#9fffde**Light**#808080 *Decreases swing time by **{d:.0}%", .{std.math.clamp(strength, 0, 1)*100}) catch unreachable;
}

View File

@ -0,0 +1,18 @@
const std = @import("std");
const main = @import("root");
const Tool = main.items.Tool;
pub const priority = 1;
pub fn combineModifiers(strength1: f32, strength2: f32) f32 {
return @max(0, strength1) + @max(0, strength2);
}
pub fn changeToolParameters(tool: *Tool, strength: f32) void {
tool.power *= 1 + @max(0, strength);
}
pub fn printTooltip(outString: *main.List(u8), strength: f32) void {
outString.writer().print("#f84a00**Powerful**#808080 *Increases power by **{d:.0}%", .{@max(0, strength)*100}) catch unreachable;
}

View File

@ -0,0 +1,18 @@
const std = @import("std");
const main = @import("root");
const Tool = main.items.Tool;
pub const priority = 1000;
pub fn combineModifiers(strength1: f32, strength2: f32) f32 {
return @max(1, @min(strength1, strength2));
}
pub fn changeToolParameters(tool: *Tool, strength: f32) void {
tool.maxDurability = @max(1, strength);
}
pub fn printTooltip(outString: *main.List(u8), strength: f32) void {
outString.writer().print("#800000**Single-use**#808080 *Sets durability to **{d:.0}", .{@max(1, strength)}) catch unreachable;
}

View File

@ -0,0 +1,18 @@
const std = @import("std");
const main = @import("root");
const Tool = main.items.Tool;
pub const priority = 1;
pub fn combineModifiers(strength1: f32, strength2: f32) f32 {
return 1 - (1 - std.math.clamp(strength1, 0, 1))*(1 - std.math.clamp(strength2, 0, 1));
}
pub fn changeToolParameters(tool: *Tool, strength: f32) void {
tool.power *= 1 - std.math.clamp(strength, 0, 1);
}
pub fn printTooltip(outString: *main.List(u8), strength: f32) void {
outString.writer().print("#fcb5e3**Weak**#808080 *Decreases power by **{d:.0}%", .{std.math.clamp(strength, 0, 1)*100}) catch unreachable;
}