mirror of
https://github.com/PixelGuys/Cubyz.git
synced 2025-08-03 11:17:05 -04:00
More modifiers
This commit is contained in:
parent
d2deb2c17a
commit
0cb195dce6
@ -10,5 +10,11 @@
|
||||
.colors = .{
|
||||
0xff847bce, 0xff8b9fe0, 0xff94c6ea, 0xffb0eaf6, 0xffffffff,
|
||||
},
|
||||
.modifiers = .{
|
||||
.{
|
||||
.id = "fragile",
|
||||
.strength = 0.4,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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");
|
||||
|
@ -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;
|
||||
}
|
||||
|
18
src/tool/modifiers/fragile.zig
Normal file
18
src/tool/modifiers/fragile.zig
Normal 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;
|
||||
}
|
18
src/tool/modifiers/heavy.zig
Normal file
18
src/tool/modifiers/heavy.zig
Normal 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;
|
||||
}
|
18
src/tool/modifiers/light.zig
Normal file
18
src/tool/modifiers/light.zig
Normal 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;
|
||||
}
|
18
src/tool/modifiers/powerful.zig
Normal file
18
src/tool/modifiers/powerful.zig
Normal 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;
|
||||
}
|
18
src/tool/modifiers/single_use.zig
Normal file
18
src/tool/modifiers/single_use.zig
Normal 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;
|
||||
}
|
18
src/tool/modifiers/weak.zig
Normal file
18
src/tool/modifiers/weak.zig
Normal 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;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user