From 49b9141f32b6661cd36c69ad40ff5b470c791c4b Mon Sep 17 00:00:00 2001 From: Chalwk77 Date: Mon, 10 Jul 2023 20:25:43 +1200 Subject: [PATCH] . --- INDEV/Battle Royale/about.md | 34 ++++++++++++++++--- INDEV/Battle Royale/countdown/pre_game.lua | 3 ++ INDEV/Battle Royale/events/on_end.lua | 1 + .../Battle Royale/events/on_object_spawn.lua | 34 ++++--------------- INDEV/Battle Royale/events/on_start.lua | 6 ++-- INDEV/Battle Royale/hud/hud.lua | 5 +-- INDEV/Battle Royale/loot/spoils.lua | 2 +- .../Battle Royale/map settings/bloodgulch.lua | 8 ++--- INDEV/Battle Royale/safe zone/safe_zone.lua | 2 +- INDEV/Battle Royale/weapons/weapons.lua | 34 +++++++++++-------- 10 files changed, 72 insertions(+), 57 deletions(-) diff --git a/INDEV/Battle Royale/about.md b/INDEV/Battle Royale/about.md index b9626268..f1dc7709 100644 --- a/INDEV/Battle Royale/about.md +++ b/INDEV/Battle Royale/about.md @@ -1,6 +1,16 @@ # Battle Royale (WIP) -Planned features: +### Description: +Battle Royale is a game mode inspired by the popular game *PlayerUnknown's Battlegrounds* (PUBG). +The game mode is currently in development and is not ready for public release. + +Eliminate all other opponents while avoiding being trapped outside a shrinking "safe area", +with the winner being the last player alive. + +Players start with no weapons and must find them scattered around the map. +Loot crates will spawn randomly around the map, containing weapons, ammo, and other items. + +## Planned features: - [x] Shrinking "safe zone" boundary - [x] The safe zone will shrink over time, forcing players to move closer together. @@ -39,15 +49,31 @@ Planned features: - [x] Players will start with no weapons. - [x] You will have to find weapon *parts* to repair damaged weapons. - [x] Different types of ammo: - - [x] Armoured-piercing, - - [x] Explosive + - [x] Armoured-piercing bullets, + - [x] Explosive bullets - [x] Golden bullets (one-shot kill) -- [x] Support for these all stock maps: +- [x] Support for these stock maps: - `timberland`, `bloodgulch`, - `dangercanyon`, `icefields` - `infinity`, `sidewinder` - `deathisland`, `gephyrophobia` +# Coming in a future update: +- [ ] Custom commands to spawn loot crates on demand (for host testing purposes) +- [ ] Loot crate locations will be randomized every time they respawn. +- [ ] Tweaks to loot crate respawn time:
+ *All loot crates currently have the same respawn time (albeit configurable), across all maps (30 seconds). + Some spawn near weapons - these need to have a longer respawn time.* + +# Known bugs: +- ~~Energy weapons from loot crates don't have battery power.~~ +- ~~Receiving a weapon from a loot crate that you already have caused the server to crash.~~ +- Game doesn't end with the last man standing +- ~~Time remaining HUD keeps resetting when the zone shrinks.~~ +- ~~Nuke is crashing the server.~~ +- When receiving an overshield from a loot crate, you won't see the shield bar change until you take damage.
+ Unfortunately, this is a limitation of Halo's net code. + # [CODE](https://github.com/Chalwk77/HALO-SCRIPT-PROJECTS/tree/master/INDEV) ![alt text](https://progress-bar.dev/95/?title=Progress) \ No newline at end of file diff --git a/INDEV/Battle Royale/countdown/pre_game.lua b/INDEV/Battle Royale/countdown/pre_game.lua index 98755f3d..864800db 100644 --- a/INDEV/Battle Royale/countdown/pre_game.lua +++ b/INDEV/Battle Royale/countdown/pre_game.lua @@ -35,6 +35,9 @@ function timer:preGameTimer() self.safe_zone_timer = self:new() self.safe_zone_timer:start() + self.game_timer = self:new() + self.game_timer:start() + self:spawnLoot(self.looting.objects, 'loot') self:spawnLoot(self.looting.crates, 'crates') diff --git a/INDEV/Battle Royale/events/on_end.lua b/INDEV/Battle Royale/events/on_end.lua index 7f6a534c..5c63c6f4 100644 --- a/INDEV/Battle Royale/events/on_end.lua +++ b/INDEV/Battle Royale/events/on_end.lua @@ -1,6 +1,7 @@ local event = {} function event:onEnd() + self.game_timer = nil self.pre_game_timer = nil self.post_game_carnage_report = true end diff --git a/INDEV/Battle Royale/events/on_object_spawn.lua b/INDEV/Battle Royale/events/on_object_spawn.lua index f78dfec9..f9195417 100644 --- a/INDEV/Battle Royale/events/on_object_spawn.lua +++ b/INDEV/Battle Royale/events/on_object_spawn.lua @@ -36,20 +36,11 @@ function event:onObjectSpawn(player, map_id, parent_id, object_id, sapp_spawning end end --- Just in case (to prevent rare projectile glitch): -local function delete(rocket) - local object = get_object_memory(rocket) - if (object ~= 0) then - destroy_object(rocket) - end -end - -local function translate(rocket, object, x, y, z) +local function translate(object, x, y, z) write_vector3d(object + 0x5C, x, y, z) write_float(object + 0x68, 0) -- x velocity write_float(object + 0x6C, 0) -- y velocity - write_float(object + 0x70, -9999) -- z velocity - delete(rocket) + write_float(object + 0x70, -99999) -- z velocity end local function createNuke(total, radius, projectile, cx, cy, cz) @@ -59,33 +50,27 @@ local function createNuke(total, radius, projectile, cx, cy, cz) -- Rockets with no spread but spawn in a circle: for _ = 1, total do - local x = cx + (math.cos(angle) * radius) local y = cy + (math.sin(angle) * radius) local z = cz - local rocket = spawn_projectile(projectile, 0, x, y, z) local object = get_object_memory(rocket) - - translate(rocket, object, x, y, z) - + translate(object, x, y, z) angle = angle + angle_step end - -- Rockets with random spread: + --Rockets with random spread: for _ = 1, 5 do - local rocket = spawn_projectile(projectile, 0, cx, cy, cz) local object = get_object_memory(rocket) - local x = cx + rand(-radius, radius + 1) local y = cy + rand(-radius, radius + 1) local z = cz - - translate(rocket, object, x, y, z) + translate(object, x, y, z) end end +-- called every tick: function event:trackNuke() local nukes = self.nukes @@ -94,23 +79,16 @@ function event:trackNuke() end for k, v in pairs(self.nukes) do - local object = get_object_memory(v.meta_id) if (object == 0) then - self.nukes[k] = nil self:modifyRocket() - createNuke(5, 5, v.projectile, v.x, v.y, v.z) createNuke(5, 10, v.projectile, v.x, v.y, v.z) - self:rollbackRocket() - goto next end - v.x, v.y, v.z = read_vector3d(object + 0x5C) - :: next :: end end diff --git a/INDEV/Battle Royale/events/on_start.lua b/INDEV/Battle Royale/events/on_start.lua index dd805b2c..3ea533e3 100644 --- a/INDEV/Battle Royale/events/on_start.lua +++ b/INDEV/Battle Royale/events/on_start.lua @@ -83,8 +83,10 @@ function event:onStart() -- nuke: self.nukes = {} - -- safe zone timer and total game time: - self.total_time = self:getTotalGameTime() + -- Sets initial radius of the safe zone and the total game time: + self.total_time = self:setSafeZone() + + self.game_timer = self:new() local h, m, s = self:secondsToTime(self.total_time) timer(33, 'pluginLogo', h, m, s, self.end_after * 60) diff --git a/INDEV/Battle Royale/hud/hud.lua b/INDEV/Battle Royale/hud/hud.lua index b603912b..1a396aa1 100644 --- a/INDEV/Battle Royale/hud/hud.lua +++ b/INDEV/Battle Royale/hud/hud.lua @@ -8,11 +8,12 @@ function hud:getPrimaryHUD(distance) distance = floor(distance) local size = self.safe_zone_size local timer = self.safe_zone_timer + local game_time = self.game_timer -- total game time - local time_elapsed = timer:get() + local time_elapsed = timer:get() -- time remaining until the next shrink time_elapsed = self.duration - time_elapsed - local time_remaining = self.total_time - timer:get() + local time_remaining = self.total_time - game_time:get() -- game time remaining local h, m, s = self:secondsToTime(time_remaining) return format('Safe Zone: %s/%s | Zone Shrink: %.2f | Time Remaining: %s:%s:%s', diff --git a/INDEV/Battle Royale/loot/spoils.lua b/INDEV/Battle Royale/loot/spoils.lua index 8675f4c5..6a626ace 100644 --- a/INDEV/Battle Royale/loot/spoils.lua +++ b/INDEV/Battle Royale/loot/spoils.lua @@ -7,7 +7,7 @@ function spoils:giveNuke(args) local id = self.id assign_weapon(self:spawnObject(self.rocket_launcher, 0, 0, 0), id) - self.nuke_created = true + self.has_nuke = true self:newMessage('You unlocked ' .. args.label, 5) return true diff --git a/INDEV/Battle Royale/map settings/bloodgulch.lua b/INDEV/Battle Royale/map settings/bloodgulch.lua index 34438547..d9261124 100644 --- a/INDEV/Battle Royale/map settings/bloodgulch.lua +++ b/INDEV/Battle Royale/map settings/bloodgulch.lua @@ -26,7 +26,7 @@ return { -- How much the safe zone will shrink by (in world units): -- Default (5) -- - shrink_amount = 5, + shrink_amount = 15, --- End after: @@ -41,7 +41,7 @@ return { -- The minimum amount of players required to start the game: -- Default: (2) -- - required_players = 2, + required_players = 1, --- Game start delay: @@ -49,7 +49,7 @@ return { -- The start delay will not begin until the required players have joined. -- Default (30) -- - start_delay = 30, + start_delay = 1, --- Lives: @@ -223,7 +223,7 @@ return { spoils = { --- NUKE: - [1] = { + [1000000] = { label = 'Nuke', radius = 10, -- kills all players within this radius _function_ = 'giveNuke' diff --git a/INDEV/Battle Royale/safe zone/safe_zone.lua b/INDEV/Battle Royale/safe zone/safe_zone.lua index e5d56102..0490e75e 100644 --- a/INDEV/Battle Royale/safe zone/safe_zone.lua +++ b/INDEV/Battle Royale/safe zone/safe_zone.lua @@ -97,7 +97,7 @@ function SafeZone:outsideSafeZone() end end -function SafeZone:getTotalGameTime() +function SafeZone:setSafeZone() local min_size, max_size = self.safe_zone.min, self.safe_zone.max local reduction_rate, reduction_amount = self.duration, self.shrink_amount diff --git a/INDEV/Battle Royale/weapons/weapons.lua b/INDEV/Battle Royale/weapons/weapons.lua index a175d114..205c4874 100644 --- a/INDEV/Battle Royale/weapons/weapons.lua +++ b/INDEV/Battle Royale/weapons/weapons.lua @@ -46,8 +46,8 @@ function weapons:newWeapon() setmetatable(self.weapons[object], self) self.__index = self - if (self.nuke_created) then - self.nuke_created = false + if (self.has_nuke) then + self.has_nuke = false self.weapons[object]:setAmmoType(6) -- nuke self.weapons[object]:setAmmoDamage(100) -- damage multiplier write_word(object + 0x2B8, 1) -- primary @@ -223,14 +223,6 @@ function weapons:jamWeapon(player, dyn) return false end -local function getRandomKey(t) - local keys = {} - for k, _ in pairs(t) do - keys[#keys + 1] = k - end - return keys[rand(1, #keys + 1)] -end - local function hasThisWeapon(self, meta_id) local id = self.id @@ -245,7 +237,7 @@ local function hasThisWeapon(self, meta_id) local weapon = read_dword(dyn + 0x2F8 + i * 4) local object = get_object_memory(weapon) if (weapon ~= 0xFFFFFFFF and object ~= 0) then - count = i + 1 + count = count + 1 local tag_id = read_dword(object) if (tag_id == meta_id) then return true, count @@ -266,18 +258,29 @@ local function giveWeapon(self, key, weapon, args) assign_weapon(weapon, id) local object = get_object_memory(weapon) - if (primary) then - write_word(object + 0x2B8, primary) -- primary - write_float(object + 0x240, primary) -- battery - end + write_word(object + 0x2B8, primary) -- primary + + -- This is not working for some reason: + --write_float(object + 0x240, primary) -- battery + execute_command('battery ' .. id .. ' ' .. primary .. ' 0') + if (reserve) then write_word(object + 0x2B6, reserve) -- reserve end + sync_ammo(weapon) self:newMessage('[Unlocked] ' .. args.label, 5) end +local function getRandomKey(t) + local keys = {} + for k, _ in pairs(t) do + keys[#keys + 1] = k + end + return keys[rand(1, #keys + 1)] +end + function weapons:getRandomWeapon(args) local random_weapons = self.random_weapons @@ -294,6 +297,7 @@ function weapons:getRandomWeapon(args) while (has_weapon) do key = getRandomKey(random_weapons) weapon = random_weapons[key] + has_weapon = hasThisWeapon(self, key) end giveWeapon(self, key, weapon, args)