mirror of
https://github.com/SK8-ENGINE/skate-3-rust-engine.git
synced 2026-10-26 19:47:44 +00:00
Revert "Add mod gameplay APIs and zombie shooter example"
This reverts commit df0affd2e3.
This commit is contained in:
1 parent
df0affd2e3
commit
ae96db7c48
14 files changed
+9
-389
No files matched your search
@@ -1,9 +0,0 @@
|
||||
# Block Zombie Shooter
|
||||
|
||||
Enable the mod from Escape > Mods. The skater carries a small block pistol.
|
||||
Press controller RB or keyboard F to fire in the direction the skater faces.
|
||||
Zombies are non-physical block targets that approach the player. Press R to restart.
|
||||
|
||||
The gun is a local visual attached to the displayed RIGHTHAND bone. Zombie movement,
|
||||
hits, health, score and waves are Lua-owned arcade rules; they do not alter native
|
||||
Skate collision, ragdoll, scoring or animation state.
|
||||
@@ -1,141 +0,0 @@
|
||||
local zombies = {}
|
||||
local wave, score, health = 0, 0, 100
|
||||
local fire_was_down, restart_was_down = false, false
|
||||
|
||||
local function remove_zombie(i)
|
||||
sdk.scene.remove('zombie-body-' .. i)
|
||||
sdk.scene.remove('zombie-head-' .. i)
|
||||
end
|
||||
|
||||
local function clear_zombies()
|
||||
for i = 1, 12 do remove_zombie(i) end
|
||||
zombies = {}
|
||||
end
|
||||
|
||||
local function equip()
|
||||
-- These are bone-local primitives: body, barrel and grip form a tiny pistol.
|
||||
sdk.scene.held_cube('gun-body', 'RIGHTHAND', {0.00, -0.10, 0.06}, {0.10, 0.28, 0.12}, {0.12, 0.12, 0.14})
|
||||
sdk.scene.held_cube('gun-barrel', 'RIGHTHAND', {0.00, -0.24, 0.06}, {0.07, 0.30, 0.08}, {0.20, 0.20, 0.23})
|
||||
sdk.scene.held_cube('gun-grip', 'RIGHTHAND', {0.00, -0.08, -0.02}, {0.08, 0.11, 0.18}, {0.08, 0.08, 0.09})
|
||||
end
|
||||
|
||||
local function draw_zombie(i, zombie)
|
||||
local hurt = zombie.hp < math.floor(sdk.settings.hits)
|
||||
local body_color = hurt and {0.65, 0.18, 0.12} or {0.18, 0.55, 0.16}
|
||||
sdk.scene.cube('zombie-body-' .. i, {zombie.x, zombie.y + 0.85, zombie.z}, {0.7, 1.3, 0.5}, body_color)
|
||||
sdk.scene.cube('zombie-head-' .. i, {zombie.x, zombie.y + 1.75, zombie.z}, {0.55, 0.55, 0.55}, {0.35, 0.78, 0.28})
|
||||
end
|
||||
|
||||
local function spawn_wave()
|
||||
clear_zombies()
|
||||
wave = wave + 1
|
||||
local p = sdk.player.read().position
|
||||
local count = math.floor(sdk.settings.zombies)
|
||||
for i = 1, count do
|
||||
local angle = (i / count) * math.pi * 2 + wave * 0.37
|
||||
local radius = 12 + (i % 3) * 3
|
||||
zombies[i] = {
|
||||
x = p[1] + math.sin(angle) * radius,
|
||||
y = p[2],
|
||||
z = p[3] + math.cos(angle) * radius,
|
||||
hp = math.floor(sdk.settings.hits),
|
||||
attack = 0,
|
||||
}
|
||||
draw_zombie(i, zombies[i])
|
||||
end
|
||||
end
|
||||
|
||||
local function hud(message)
|
||||
sdk.ui.text('zombie-hud', string.format('ZOMBIES | health %d | score %d | wave %d', health, score, wave))
|
||||
sdk.ui.text('zombie-help', message or 'RB / F: shoot | R: restart | Shots travel where the skater faces')
|
||||
end
|
||||
|
||||
local function restart()
|
||||
score, health, wave = 0, 100, 0
|
||||
spawn_wave()
|
||||
hud()
|
||||
end
|
||||
|
||||
local function shoot()
|
||||
if health <= 0 then return end
|
||||
local player = sdk.player.read()
|
||||
if player.bailing then return end
|
||||
local dx, dz = math.sin(player.heading), math.cos(player.heading)
|
||||
local best, best_distance
|
||||
for i, zombie in pairs(zombies) do
|
||||
local x, z = zombie.x - player.position[1], zombie.z - player.position[3]
|
||||
local forward = x * dx + z * dz
|
||||
if forward > 0 and forward < 35 then
|
||||
local side_squared = math.max(0, x * x + z * z - forward * forward)
|
||||
if side_squared < 0.75 * 0.75 and (not best_distance or forward < best_distance) then
|
||||
best, best_distance = i, forward
|
||||
end
|
||||
end
|
||||
end
|
||||
sdk.scene.cube('muzzle-flash', {
|
||||
player.position[1] + dx * 1.1,
|
||||
player.position[2] + 1.25,
|
||||
player.position[3] + dz * 1.1,
|
||||
}, {0.13, 0.13, 0.13}, {1.0, 0.65, 0.1})
|
||||
sdk.time.after('muzzle-flash', 0.06, function() sdk.scene.remove('muzzle-flash') end)
|
||||
if best then
|
||||
local zombie = zombies[best]
|
||||
zombie.hp = zombie.hp - 1
|
||||
if zombie.hp <= 0 then
|
||||
remove_zombie(best)
|
||||
zombies[best] = nil
|
||||
score = score + 100
|
||||
else
|
||||
draw_zombie(best, zombie)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function update()
|
||||
local fire_down = sdk.input.down('KeyF') or sdk.input.action(73) > 0.5
|
||||
if fire_down and not fire_was_down then shoot() end
|
||||
fire_was_down = fire_down
|
||||
local restart_down = sdk.input.down('KeyR')
|
||||
if restart_down and not restart_was_down then restart() end
|
||||
restart_was_down = restart_down
|
||||
if health <= 0 then hud('GAME OVER | Press R to restart') else hud() end
|
||||
end
|
||||
|
||||
local function fixed(event)
|
||||
if health <= 0 then return end
|
||||
local p = sdk.player.read().position
|
||||
local alive = 0
|
||||
for i, zombie in pairs(zombies) do
|
||||
alive = alive + 1
|
||||
local x, z = p[1] - zombie.x, p[3] - zombie.z
|
||||
local distance = math.sqrt(x * x + z * z)
|
||||
if distance > 0.001 then
|
||||
local step = math.min(distance, sdk.settings.speed * event.dt)
|
||||
zombie.x = zombie.x + x / distance * step
|
||||
zombie.z = zombie.z + z / distance * step
|
||||
end
|
||||
zombie.y = p[2]
|
||||
zombie.attack = math.max(0, zombie.attack - event.dt)
|
||||
if distance < 1.25 and zombie.attack <= 0 then
|
||||
health = math.max(0, health - 10)
|
||||
zombie.attack = 0.75
|
||||
end
|
||||
draw_zombie(i, zombie)
|
||||
end
|
||||
if alive == 0 then spawn_wave() end
|
||||
if health <= 0 then clear_zombies() end
|
||||
end
|
||||
|
||||
return {
|
||||
on_load = function() equip(); restart(); sdk.log('Block Zombie Shooter loaded') end,
|
||||
on_update = update,
|
||||
on_fixed_update = fixed,
|
||||
on_settings = function() restart() end,
|
||||
on_event = function(event)
|
||||
if event.name == 'world_changed' then
|
||||
fire_was_down, restart_was_down = false, false
|
||||
equip()
|
||||
restart()
|
||||
end
|
||||
end,
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
{
|
||||
"id": "community.zombie-shooter",
|
||||
"api": 1,
|
||||
"name": "Block Zombie Shooter",
|
||||
"version": "1.0.0",
|
||||
"author": "Skate Rust Engine",
|
||||
"description": "A tiny arcade shooter. The skater holds a block pistol; press RB or F to shoot approaching block zombies.",
|
||||
"entry": "main.lua",
|
||||
"settings": {
|
||||
"zombies": {
|
||||
"type": "number",
|
||||
"label": "Zombies per wave",
|
||||
"description": "Number of block zombies spawned in each wave.",
|
||||
"default": 6,
|
||||
"min": 1,
|
||||
"max": 12,
|
||||
"step": 1
|
||||
},
|
||||
"speed": {
|
||||
"type": "number",
|
||||
"label": "Zombie speed",
|
||||
"description": "Movement speed in metres per second.",
|
||||
"default": 1.5,
|
||||
"min": 0.25,
|
||||
"max": 5,
|
||||
"step": 0.25
|
||||
},
|
||||
"hits": {
|
||||
"type": "number",
|
||||
"label": "Hits per zombie",
|
||||
"description": "Shots required to remove one zombie.",
|
||||
"default": 2,
|
||||
"min": 1,
|
||||
"max": 5,
|
||||
"step": 1
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-7
@@ -81,13 +81,7 @@ function sdk.ui.text(key, text) end
|
||||
---@param size Vec3 Each component >0 and <=100 metres.
|
||||
---@param color Vec3 Each sRGB component in 0..1.
|
||||
function sdk.scene.cube(key, position, size, color) end
|
||||
---@param key string Owner-local stable visual key.
|
||||
---@param bone string Exact installed skeleton bone name, e.g. RIGHTHAND.
|
||||
---@param offset Vec3 Local metres in the selected bone frame, each component within ±10.
|
||||
---@param size Vec3 Each component >0 and <=10 metres.
|
||||
---@param color Vec3 Each sRGB component in 0..1.
|
||||
function sdk.scene.held_cube(key, bone, offset, size, color) end
|
||||
---@param key string Remove owner's text, world cube, or held cube; absent is a no-op.
|
||||
---@param key string Remove owner's text or cube; absent is a no-op.
|
||||
function sdk.scene.remove(key) end
|
||||
---@param key string Timer key, 1..64 bytes. Existing timer is replaced.
|
||||
---@param seconds number Finite delay 0..86400 active Update seconds.
|
||||
|
||||
Reference in new issue
Block a user