From f005b66b2b29d58e501ae33b8b68930c9491e627 Mon Sep 17 00:00:00 2001 From: Chalwk77 Date: Sat, 8 Jul 2023 10:55:14 +1200 Subject: [PATCH] ... --- INDEV/Battle Royale.lua | 3 + INDEV/Battle Royale/about.md | 77 +++++++++---------- .../Battle Royale/commands/repair_weapons.lua | 4 +- INDEV/Battle Royale/events/on_start.lua | 2 - INDEV/Battle Royale/events/on_tick.lua | 1 + .../weapon degradation/degradation.lua | 18 +---- INDEV/Battle Royale/weapons/weapons.lua | 65 ++++++++++++++++ 7 files changed, 108 insertions(+), 62 deletions(-) create mode 100644 INDEV/Battle Royale/weapons/weapons.lua diff --git a/INDEV/Battle Royale.lua b/INDEV/Battle Royale.lua index f1c2f909..02f3e5c6 100644 --- a/INDEV/Battle Royale.lua +++ b/INDEV/Battle Royale.lua @@ -69,6 +69,9 @@ local BattleRoyale = { ['./Battle Royale/weapon degradation/'] = { 'degradation' }, + ['./Battle Royale/weapons/'] = { + 'weapons' + }, ['./Battle Royale/weight/'] = { 'weapons' } diff --git a/INDEV/Battle Royale/about.md b/INDEV/Battle Royale/about.md index 19f93ee9..54ee230f 100644 --- a/INDEV/Battle Royale/about.md +++ b/INDEV/Battle Royale/about.md @@ -2,51 +2,46 @@ Planned features: - [ ] Shrinking "safe zone" boundary (**WIP**) - - The safe zone will shrink over time, forcing players to move closer together. (**done**) - - Players outside the safe zone will take damage over time. (**done**) - - The safe zone will be marked on the map with flag poles (**WIP**) -- [x] Spectator mode: (**done**) - - Players will be able to spectate other players after they die. - - They will be invisible, invulnerable, and unable to interact with the world. -- [x] Limited lives: (**done**) - - Players will have a limited number of lives. - - Players will be able to spectate other players after they die. + - [x] The safe zone will shrink over time, forcing players to move closer together. + - [x] Players outside the safe zone will take damage over time. + - [ ] The safe zone will be marked on the map with flag poles +- [x] Spectator mode: + - [x] Players will be able to spectate other players after they die. + - [x] They will be invisible, invulnerable, and unable to interact with the world. +- [x] Limited lives: + - [x] Players will have a limited number of lives. + - [x] Players will be able to spectate other players after they die. - [ ] Randomized loot (**WIP**) - - Loot will be randomized and spawn in random locations (**done**) - - Loot includes ammo, weapons, powerups and special abilities (**WIP**) - - Nuke - - Stun grenades - - Air Strike ability - - Weapon parts (for weapon repair system) - - Ammo (different types) - - Weapons (different types) - - Grenade launcher - - Health boost (50%, 100%, 150%, 200%) - - Speed boost (1.2, 1.3, 1.4, 1.5) (**done**) -- [x] Sky spawn system: (**done**) - - Players will spawn in the sky and fall to the ground. - - Players will be invulnerable until they land. -- [x] Randomized player spawn locations: (**done**) - - No two players will spawn in the same location. -- [x] Weapon weights: (**done**) - - Weapons will have weights, and players will have a weight limit. - - Players will be able to drop weapons to reduce their weight. -- [x] Weapon degradation: (**done**) - - Weapons will degrade over time. - - Weapons will have a limited number of shots before they break. -- [ ] Weapons (**WIP**) - - Players will start with no weapons. (**done**) - - Weapons will have different stats, such as damage and degradation. (**WIP**) - - You will have to find weapon 'parts' to repair weapons. (**WIP**) -- [ ] Player attributes (**WIP**) - - Players will have attributes such as extra strength, speed, and health. (**WIP**) - - Attributes will be affected by the player's weight. + - [x] Loot will be randomized and spawn in random locations + - Loot includes ammo: + - [ ] Nuke + - [ ] Stun grenades + - [ ] Air Strike ability + - [x] Weapon parts (for weapon repair system) + - [ ] Ammo (different types) + - [ ] Weapons (different types) + - [ ] Grenade launcher + - [x] Health boost (50%, 100%, 150%, 200%) + - [x] Speed boost (1.2, 1.3, 1.4, 1.5) +- [x] Sky spawn system: + - [x] Players will spawn in the sky and fall to the ground. + - [x] Players will be invulnerable until they land. + - [x] No two players will spawn in the same location. +- [x] Weapon weights: + - [x] Weapons will have weights, and players will have a weight limit. + - [x] Players will be able to drop weapons to reduce their weight. +- [x] Weapon degradation: + - [x] Weapons will degrade over time. + - [x] Durability decreases when: *shooting*, *reloading* or *melee*. +- [x] Weapons (general): + - [x] Players will start with no weapons. + - [x] You will have to find weapon *parts* to repair damaged weapons. - [ ] Different types of ammo (**WIP**) - Armoured-piercing, explosive, nukes - - Golden bullets (one shot kill) -- [ ] Support for all stock maps: + - Golden bullets (one-shot kill) +- [ ] Support for all stock maps: (**WIP**) - It currently supports: - - `timberland`, `bloodgulch`, + - `timberland`, `bloodgulch`, - `dangercanyon`, `icefields` - `infinity`, `sidewinder` - `deathisland`, `gephyrophobia` diff --git a/INDEV/Battle Royale/commands/repair_weapons.lua b/INDEV/Battle Royale/commands/repair_weapons.lua index 829c0f9b..4d4ff13a 100644 --- a/INDEV/Battle Royale/commands/repair_weapons.lua +++ b/INDEV/Battle Royale/commands/repair_weapons.lua @@ -39,7 +39,7 @@ function Command:repairsWeapons(player) if (this_weapon ~= 0xFFFFFFFF and object ~= 0) then - local weapon = self.decay[object] + local weapon = self.weapons[object] local max = self.weapon_degradation.max_durability if (weapon and weapon.durability < max) then @@ -54,7 +54,7 @@ function Command:repairsWeapons(player) player.weapon_parts = nil if (repaired) then - player:newMessage('Weapon repaired!', 5) + player:newMessage('Weapons repaired!', 5) else player:newMessage('Nothing was repaired!', 5) end diff --git a/INDEV/Battle Royale/events/on_start.lua b/INDEV/Battle Royale/events/on_start.lua index 8f89272a..88b9735b 100644 --- a/INDEV/Battle Royale/events/on_start.lua +++ b/INDEV/Battle Royale/events/on_start.lua @@ -26,8 +26,6 @@ function event:onStart() self.death_message_address = sig_scan("8B42348A8C28D500000084C9") + 3 self.original_death_message_address = read_dword(self.death_message_address) - self.decay = {} - -- Disable Full Spectrum Vision: execute_command('disable_object "' .. 'powerups\\full-spectrum vision"') diff --git a/INDEV/Battle Royale/events/on_tick.lua b/INDEV/Battle Royale/events/on_tick.lua index 3aad980e..20aeefa3 100644 --- a/INDEV/Battle Royale/events/on_tick.lua +++ b/INDEV/Battle Royale/events/on_tick.lua @@ -38,6 +38,7 @@ function event:onTick() v:crateIntersect() v:setSpeed() --todo: move this to a function called every 1 second. v:spectate() + v:newWeapon() v:degrade() v:displaySecondaryHUD() end diff --git a/INDEV/Battle Royale/weapon degradation/degradation.lua b/INDEV/Battle Royale/weapon degradation/degradation.lua index 7befb3de..80284602 100644 --- a/INDEV/Battle Royale/weapon degradation/degradation.lua +++ b/INDEV/Battle Royale/weapon degradation/degradation.lua @@ -19,20 +19,6 @@ local function overheating(object) return (read_bit(object + 0x22C, 0) == 1) end -function weapons:getWeapon(object) - return self.decay[object] -end - -function weapons:addWeapon(object, weapon) - self.decay[object] = self.decay[object] or { - object = object, - weapon = weapon, - timer = self:new(), - durability = self.weapon_degradation.max_durability, -- 0% = broken, 100% = new - notify = true, - } -end - local function getAmmunition(object) -- non-energy weapons: @@ -110,12 +96,10 @@ function weapons:degrade() if (weapon == 0xFFFFFFFF) then return elseif (object == 0) then - self.decay[object] = nil + self.weapons[object] = nil return end - self:addWeapon(object, weapon) - weapon = self:getWeapon(object) local in_vehicle = self:inVehicle(dyn) diff --git a/INDEV/Battle Royale/weapons/weapons.lua b/INDEV/Battle Royale/weapons/weapons.lua new file mode 100644 index 00000000..8b088d30 --- /dev/null +++ b/INDEV/Battle Royale/weapons/weapons.lua @@ -0,0 +1,65 @@ +local weapons = {} + +function weapons:newWeapon() + + self.weapons = self.weapons or {} + + local id = self.id + local dyn = get_dynamic_player(id) + if (not player_alive(id) or dyn == 0) then + return + end + + local weapon = read_dword(dyn + 0x118) + local object = get_object_memory(weapon) + + if (weapon == 0xFFFFFFFF) then + return + elseif (object == 0) then + self.weapons[object] = nil + return + end + + -- Constructor for new weapon object: + if (not self.weapons[object]) then + + self.weapons[object] = { + damage_multiplier = 0, -- default damage multiplier + ammo_type = 0, -- default ammo type + object = object, + timer = self:new(), + durability = self.weapon_degradation.max_durability, -- 0% = broken, 100% = new + notify = true + } + + setmetatable(self.weapons[object], self) + self.__index = self + end +end + +-- Gets the weapon object: +function weapons:getWeapon(object) + return self.weapons[object] +end + +-- Sets the weapon ammo type: +function weapons:setAmmoType(type) + self.ammo_type = type +end + +-- Gets the weapon ammo type: +function weapons:getAmmoType() + return self.ammo_type +end + +-- Sets the weapon ammo damage multiplier: +function weapons:setAmmoDamage(mult) + self.damage_multiplier = mult +end + +-- Gets the weapon ammo damage multiplier: +function weapons:getAmmoDamage() + return self.damage_multiplier +end + +return weapons \ No newline at end of file