Skip to content

Commit

Permalink
feat: add REPAIR_DRONE enemy
Browse files Browse the repository at this point in the history
  • Loading branch information
BigJk committed Aug 26, 2024
1 parent f992cab commit a61af0c
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 0 deletions.
40 changes: 40 additions & 0 deletions assets/scripts/enemies/repair_drone.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
REPAIR_DRONE_HEAL = 2

register_enemy("REPAIR_DRONE", {
name = "Repair Drone",
description = "A drone designed to repair and support other machines.",
look = [[]rr[]],
color = "#00ff00",
initial_hp = 10,
max_hp = 10,
gold = 50,
intend = function(ctx)
local opponents = get_opponent_guids(PLAYER_ID)

-- Check if any opponent needs healing
for _, opponent_guid in ipairs(opponents) do
local opponent = get_actor(opponent_guid)
if opponent_guid ~= ctx.guid and opponent.hp < opponent.max_hp then
return "Heal " .. highlight(REPAIR_DRONE_HEAL) .. " HP to an ally"
end
end

return "Standby..."
end,
callbacks = {
on_turn = function(ctx)
local opponents = get_opponent_guids(PLAYER_ID)

-- Check if any opponent needs healing
for _, opponent_guid in ipairs(opponents) do
local opponent = get_actor(opponent_guid)
if opponent_guid ~= ctx.guid and opponent.hp < opponent.max_hp then
heal(ctx.guid, opponent_guid, REPAIR_DRONE_HEAL)
return nil
end
end

return nil
end
}
})
18 changes: 18 additions & 0 deletions assets/scripts/events/act_0/enemies.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ It seems to be eating the metal from the walls. It looks at you and after a few
if math.random() < 0.25 then
add_actor_by_enemy("RUST_MITE")
end
if math.random() < 0.15 then
add_actor_by_enemy("REPAIR_DRONE")
end
return GAME_STATE_FIGHT
end
}
Expand All @@ -41,6 +44,9 @@ It looks at you and says "Corpse. Clean. Engage.".
if math.random() < 0.25 then
add_actor_by_enemy("CLEAN_BOT")
end
if math.random() < 0.15 then
add_actor_by_enemy("REPAIR_DRONE")
end
return GAME_STATE_FIGHT
end
}
Expand All @@ -63,6 +69,9 @@ It seems to be waiting for its prey to come closer and there is no way around it
if math.random() < 0.25 then
add_actor_by_enemy("CYBER_SPIDER")
end
if math.random() < 0.15 then
add_actor_by_enemy("REPAIR_DRONE")
end
return GAME_STATE_FIGHT
end
}
Expand All @@ -85,6 +94,9 @@ register_event("LASER_DRONE", {
if math.random() < 0.10 then
add_actor_by_enemy("LASER_DRONE")
end
if math.random() < 0.15 then
add_actor_by_enemy("REPAIR_DRONE")
end
return GAME_STATE_FIGHT
end
}
Expand All @@ -104,6 +116,9 @@ register_event("PLASMA_GOLEM", {
description = "Fight!",
callback = function()
add_actor_by_enemy("PLASMA_GOLEM")
if math.random() < 0.05 then
add_actor_by_enemy("REPAIR_DRONE")
end
return GAME_STATE_FIGHT
end
}
Expand All @@ -123,6 +138,9 @@ register_event("CYBER_SLIME", {
description = "Fight!",
callback = function()
add_actor_by_enemy("CYBER_SLIME")
if math.random() < 0.10 then
add_actor_by_enemy("REPAIR_DRONE")
end
return GAME_STATE_FIGHT
end
}
Expand Down

0 comments on commit a61af0c

Please sign in to comment.