Skip to content

Commit abea2ce

Browse files
committed
basic loot system
1 parent 0a5f0aa commit abea2ce

3 files changed

Lines changed: 55 additions & 35 deletions

File tree

Rogylus/Assets/Scripts/loot.lua

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
Loot = {
2+
Components = {}
3+
}
4+
5+
function Loot.create_physical_loot(scene, position, type, value)
6+
local loot = scene:create_entity()
7+
loot:add(Loot.Components.LootComponent)
8+
loot:add(type)
9+
loot:add(Loot.Components.ValueComponent, { value = value })
10+
11+
local loot_model_root = scene:create_mesh_entity(Assets.loot_model_asset)
12+
13+
loot_model_root:child_of(loot)
14+
loot_model_root:set_name("loot_model")
15+
16+
local tc = loot:get_mut(Core.TransformComponent)
17+
tc:set_position(position)
18+
19+
loot:add(Core.BoxColliderComponent)
20+
local loot_bc = loot:get_mut(Core.BoxColliderComponent)
21+
loot_bc:set_size(vec3.new(0.3, 0.3, 0.3))
22+
loot_bc:set_offset(vec3.new(0, 0.0, 0))
23+
24+
loot:add(Core.RigidBodyComponent)
25+
local loot_rb = loot:get_mut(Core.RigidBodyComponent)
26+
loot_rb:set_type(1)
27+
loot_rb:set_is_sensor(true)
28+
loot:modified(Core.RigidBodyComponent)
29+
30+
return loot
31+
end
32+
33+
return Loot

Rogylus/Assets/Scripts/scene.lua

Lines changed: 5 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -233,35 +233,6 @@ function spawn_enemies(scene, count)
233233
end
234234
end
235235

236-
function create_loot(scene, position, type, value)
237-
local loot = scene:create_entity()
238-
loot:add(Components.LootComponent)
239-
loot:add(type)
240-
loot:add(Components.ValueComponent, { value = value })
241-
242-
local loot_model_root = scene:create_mesh_entity(Assets.loot_model_asset)
243-
244-
loot_model_root:child_of(loot)
245-
loot_model_root:set_name("loot_model")
246-
247-
local tc = loot:get_mut(Core.TransformComponent)
248-
tc:set_position(position)
249-
250-
loot:add(Core.BoxColliderComponent)
251-
local loot_bc = loot:get_mut(Core.BoxColliderComponent)
252-
loot_bc:set_size(vec3.new(0.3, 0.3, 0.3))
253-
loot_bc:set_offset(vec3.new(0, 0.5, 0))
254-
255-
loot:add(Core.RigidBodyComponent)
256-
local loot_rb = loot:get_mut(Core.RigidBodyComponent)
257-
loot_rb:set_type(1)
258-
loot_rb:set_is_sensor(true)
259-
loot_rb:set_allowed_dofs(AllowedDOFs.TranslationX + AllowedDOFs.TranslationZ + AllowedDOFs.RotationY)
260-
loot:modified(Core.RigidBodyComponent)
261-
262-
return loot
263-
end
264-
265236
function on_scene_start(scene)
266237
Assets.load_assets(WORKING_DIR)
267238

@@ -310,7 +281,7 @@ function on_scene_start(scene)
310281
Player.add_xp(player_c, xp_reward)
311282
Player.add_gold(player_c, ec_data.gold_reward)
312283
scene:defer(function(s)
313-
create_loot(s, tc_data.position, HealComponent, 1)
284+
Loot.create_physical_loot(s, tc_data.position, HealComponent, 1)
314285
end)
315286
end
316287

@@ -529,12 +500,11 @@ function on_viewport_render(scene)
529500
local entity = item_it:entity(i - 1)
530501

531502
if entity:has(Components.WeaponComponent) then
532-
local wc = entity:get(Components.WeaponComponent)
533-
ImGui.Button(entity:name(), item_size, item_size)
503+
if ImGui.Button(entity:name(), item_size, item_size) then
504+
local ic = entity:get_mut(Components.ItemComponent)
505+
ic:set_in_use(true)
506+
end
534507
ImGui.SameLine()
535-
-- ImGui.Text("Weapon")
536-
-- ImGui.Text("Damage Range: " .. tostring(wc.min_damage) .. "-" .. tostring(wc.max_damage))
537-
-- ImGui.Text("Cooldown: " .. tostring(wc.cooldown))
538508
end
539509
end
540510
end

notes.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
- every level up get character stats,
2+
- basic stats
3+
- pets
4+
- curses with advantages
5+
- every wave you get chance of dropping weapons from enemies
6+
- all drops are based on your luck stat or completely random or based on how long you have survived maybe
7+
- every couple wave you get a boss which will drop weapon runes
8+
- use that runes to change how your weapon behaves
9+
- you could still have a gold system where you upgrade just the stats of a weapon, get consumables, other stuff
10+
11+
TODOs:
12+
13+
- Dash
14+
- Flat damage items
15+
- Adds damage on top after the weapon damage range has been calculated
16+
- Charge attacks
17+
- 3 choices after levelup 2 is visible upgrades and 1 is a random

0 commit comments

Comments
 (0)