Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion assets/cubyz/blocks/amber_ore.zig.zon
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
.textureRoughness = 0.1,
.modifiers = .{
.{
.id = "light",
.id = "base_stat",
.targetProperty = "swingSpeed",
.strength = 0.5,
.restriction = .{
.id = .encased,
Expand Down
3 changes: 2 additions & 1 deletion assets/cubyz/blocks/branch/baobab.zig.zon
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
.textureRoughness = 0.7,
.modifiers = .{
.{
.id = "durable",
.id = "base_stat",
.targetProperty = "maxDurability",
.strength = 0.45,
},
},
Expand Down
3 changes: 2 additions & 1 deletion assets/cubyz/blocks/branch/birch.zig.zon
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
.textureRoughness = 0.7,
.modifiers = .{
.{
.id = "durable",
.id = "base_stat",
.targetProperty = "maxDurability",
.strength = 0.45,
},
},
Expand Down
3 changes: 2 additions & 1 deletion assets/cubyz/blocks/branch/bolete.zig.zon
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
.textureRoughness = 0.5,
.modifiers = .{
.{
.id = "durable",
.id = "base_stat",
.targetProperty = "maxDurability",
.strength = 0.45,
},
},
Expand Down
3 changes: 2 additions & 1 deletion assets/cubyz/blocks/branch/cirrus.zig.zon
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
.textureRoughness = 0.7,
.modifiers = .{
.{
.id = "light",
.id = "base_stat",
.targetProperty = "swingSpeed",
.strength = 0.15,
},
},
Expand Down
3 changes: 2 additions & 1 deletion assets/cubyz/blocks/branch/glimmergill.zig.zon
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
.textureRoughness = 0.5,
.modifiers = .{
.{
.id = "durable",
.id = "base_stat",
.targetProperty = "maxDurability",
.strength = 0.50,
},
},
Expand Down
3 changes: 2 additions & 1 deletion assets/cubyz/blocks/branch/mahogany.zig.zon
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
.textureRoughness = 0.7,
.modifiers = .{
.{
.id = "durable",
.id = "base_stat",
.targetProperty = "maxDurability",
.strength = 0.45,
},
},
Expand Down
3 changes: 2 additions & 1 deletion assets/cubyz/blocks/branch/oak.zig.zon
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
.textureRoughness = 0.7,
.modifiers = .{
.{
.id = "durable",
.id = "base_stat",
.targetProperty = "maxDurability",
.strength = 0.45,
},
},
Expand Down
3 changes: 2 additions & 1 deletion assets/cubyz/blocks/branch/palm.zig.zon
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
.textureRoughness = 0.7,
.modifiers = .{
.{
.id = "durable",
.id = "base_stat",
.targetProperty = "maxDurability",
.strength = 0.45,
},
},
Expand Down
3 changes: 2 additions & 1 deletion assets/cubyz/blocks/branch/pine.zig.zon
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
.textureRoughness = 0.7,
.modifiers = .{
.{
.id = "durable",
.id = "base_stat",
.targetProperty = "maxDurability",
.strength = 0.45,
},
},
Expand Down
3 changes: 2 additions & 1 deletion assets/cubyz/blocks/branch/toadstool.zig.zon
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
.textureRoughness = 0.5,
.modifiers = .{
.{
.id = "durable",
.id = "base_stat",
.targetProperty = "maxDurability",
.strength = 0.45,
},
},
Expand Down
3 changes: 2 additions & 1 deletion assets/cubyz/blocks/branch/willow.zig.zon
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
.textureRoughness = 0.7,
.modifiers = .{
.{
.id = "durable",
.id = "base_stat",
.targetProperty = "maxDurability",
.strength = 0.45,
},
},
Expand Down
8 changes: 5 additions & 3 deletions assets/cubyz/blocks/diamond_ore.zig.zon
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@
.textureRoughness = 0.1,
.modifiers = .{
.{
.id = "fragile",
.strength = 0.5,
.id = "base_stat",
.targetProperty = "maxDurability",
.strength = -0.5,
.restriction = .{
.id = .not,
.child = .{
Expand All @@ -37,7 +38,8 @@
},
},
.{
.id = "powerful",
.id = "base_stat",
.targetProperty = "damage",
.strength = 0.5,
.restriction = .{
.id = .encased,
Expand Down
3 changes: 2 additions & 1 deletion assets/cubyz/blocks/jade_ore.zig.zon
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
.textureRoughness = 0.1,
.modifiers = .{
.{
.id = "durable",
.id = "base_stat",
.targetProperty = "maxDurability",
.strength = 1.5,
.restriction = .{
.id = .encased,
Expand Down
5 changes: 3 additions & 2 deletions assets/cubyz/blocks/obsidian.zig.zon
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@
.textureRoughness = 0.1,
.modifiers = .{
.{
.id = "fragile",
.strength = 0.33,
.id = "base_stat",
.targetProperty = "maxDurability",
.strength = -0.33,
},
},
},
Expand Down
3 changes: 2 additions & 1 deletion assets/cubyz/blocks/planks/baobab.zig.zon
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
.swingSpeed = 4.2,
.modifiers = .{
.{
.id = "durable",
.id = "base_stat",
.targetProperty = "maxDurability",
.strength = 0.4,
},
},
Expand Down
3 changes: 2 additions & 1 deletion assets/cubyz/blocks/planks/birch.zig.zon
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
.textureRoughness = 0.7,
.modifiers = .{
.{
.id = "durable",
.id = "base_stat",
.targetProperty = "maxDurability",
.strength = 0.4,
},
},
Expand Down
3 changes: 2 additions & 1 deletion assets/cubyz/blocks/planks/cirrus.zig.zon
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
.textureRoughness = 0.7,
.modifiers = .{
.{
.id = "light",
.id = "base_stat",
.targetProperty = "swingSpeed",
.strength = 0.1,
},
},
Expand Down
3 changes: 2 additions & 1 deletion assets/cubyz/blocks/planks/mahogany.zig.zon
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
.textureRoughness = 0.7,
.modifiers = .{
.{
.id = "durable",
.id = "base_stat",
.targetProperty = "maxDurability",
.strength = 0.4,
},
},
Expand Down
3 changes: 2 additions & 1 deletion assets/cubyz/blocks/planks/oak.zig.zon
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
.textureRoughness = 0.7,
.modifiers = .{
.{
.id = "durable",
.id = "base_stat",
.targetProperty = "maxDurability",
.strength = 0.4,
},
},
Expand Down
3 changes: 2 additions & 1 deletion assets/cubyz/blocks/planks/palm.zig.zon
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
.swingSpeed = 5.2,
.modifiers = .{
.{
.id = "durable",
.id = "base_stat",
.targetProperty = "maxDurability",
.strength = 0.4,
},
},
Expand Down
3 changes: 2 additions & 1 deletion assets/cubyz/blocks/planks/pine.zig.zon
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
.textureRoughness = 0.7,
.modifiers = .{
.{
.id = "durable",
.id = "base_stat",
.targetProperty = "maxDurability",
.strength = 0.4,
},
},
Expand Down
3 changes: 2 additions & 1 deletion assets/cubyz/blocks/planks/willow.zig.zon
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
.textureRoughness = 0.7,
.modifiers = .{
.{
.id = "durable",
.id = "base_stat",
.targetProperty = "maxDurability",
.strength = 0.4,
},
},
Expand Down
5 changes: 3 additions & 2 deletions assets/cubyz/blocks/ruby_ore.zig.zon
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@
.textureRoughness = 0.1,
.modifiers = .{
.{
.id = "fragile",
.strength = 0.45,
.id = "base_stat",
.targetProperty = "maxDurability",
.strength = -0.45,
.restriction = .{
.id = .not,
.child = .{
Expand Down
5 changes: 3 additions & 2 deletions assets/cubyz/blocks/sandstone/_defaults.zig.zon
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@
.textureRoughness = 0.9,
.modifiers = .{
.{
.id = "fragile",
.strength = 0.20,
.id = "base_stat",
.targetProperty = "maxDurability",
.strength = -0.20,
.restriction = .{
.id = .not,
.child = .{
Expand Down
3 changes: 2 additions & 1 deletion assets/cubyz/blocks/voidstone/_defaults.zig.zon
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
.textureRoughness = 0.4,
.modifiers = .{
.{
.id = "durable",
.id = "base_stat",
.targetProperty = "maxDurability",
.strength = 0.1,
},
.{
Expand Down
10 changes: 5 additions & 5 deletions src/items.zig
Original file line number Diff line number Diff line change
Expand Up @@ -800,13 +800,13 @@ pub const ProceduralItemType = struct { // MARK: ProceduralItemType
pixelSourcesOverlay: [16][16]u8,
};

const ProceduralItemProperty = enum {
damage,
maxDurability,
pub const ProceduralItemProperty = enum(u8) {
damage = 0,
maxDurability = 1,
/// how long it takes before the next swing happens
swingSpeed,
swingSpeed = 2,

fn fromString(string: []const u8) ?ProceduralItemProperty {
pub fn fromString(string: []const u8) ?ProceduralItemProperty {
return std.meta.stringToEnum(ProceduralItemProperty, string) orelse {
std.log.err("Couldn't find procedural Item property {s}.", .{string});
return null;
Expand Down
7 changes: 1 addition & 6 deletions src/proceduralItem/modifiers/_list.zig
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
pub const bad_at = @import("bad_at.zig");
pub const durable = @import("durable.zig");
pub const fragile = @import("fragile.zig");
pub const good_at = @import("good_at.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");
pub const base_stat = @import("base_stat.zig");
54 changes: 54 additions & 0 deletions src/proceduralItem/modifiers/base_stat.zig
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
const std = @import("std");

const main = @import("main");
const ProceduralItem = main.items.ProceduralItem;

pub const Data = packed struct(u128) { strength: f32, targetProperty: main.items.ProceduralItemProperty, pad: u88 = undefined };

pub const priority = 1;

fn getModifierName(data: Data) []const u8 {
if (data.strength >= 0) {
switch (data.targetProperty) {
.damage => return "#f84a00**Powerful**",
.maxDurability => return "#500090**Durable**",
.swingSpeed => return "#9fffde**Light**",
}
} else {
switch (data.targetProperty) {
.damage => return "#fcb5e3**Weak**",
.maxDurability => return "#ccddff**Fragile**",
.swingSpeed => return "#ffcc30**Heavy**",
}
}
}

pub fn loadData(zon: main.ZonElement) Data {
return .{
.strength = zon.get(f32, "strength") orelse 0,
.targetProperty = main.items.ProceduralItemProperty.fromString(zon.get([]const u8, "targetProperty") orelse "missing .targetProperty field") orelse blk: {
std.log.err("replacing with .damage", .{});
break :blk .damage;
},
};
}

pub fn combineModifiers(data1: Data, data2: Data) ?Data {
if (data1.targetProperty != data2.targetProperty) return null;
return .{
.strength = std.math.hypot(data1.strength, data2.strength),
.targetProperty = data1.targetProperty,
};
}

pub fn changeProceduralItemParameters(proceduralItem: *ProceduralItem, data: Data) void {
proceduralItem.setProperty(data.targetProperty, proceduralItem.getProperty(data.targetProperty)*(1 + data.strength));
}

pub fn printTooltip(outString: *main.ListManaged(u8), data: Data) void {
if (data.strength >= 0) {
outString.print("{s} #808080(#30ca64+**{d:.0}% #808080{})", .{getModifierName(data), data.strength*100, data.targetProperty});
} else {
outString.print("{s} #808080(#fd3535**{d:.0}% #808080{})", .{getModifierName(data), data.strength*100, data.targetProperty});
}
}
24 changes: 0 additions & 24 deletions src/proceduralItem/modifiers/durable.zig

This file was deleted.

Loading
Loading