Skip to content

Commit

Permalink
Fixed Shield hurt_preset and Dozer ECM crash (#6)
Browse files Browse the repository at this point in the history
* Fixed Shield hurt_preset and Dozer ECM crash

* Fixed custom heists crashing on crime.net

* Add files via upload

* Create pickups

* Delete Classic Heisting/units/pickups

* Create temp

* Delete Classic Heisting/units/ammoclip.lua

* Add files via upload

* Delete Classic Heisting/units/pickups/temp

* Update mod.txt
  • Loading branch information
TheRant-man authored May 16, 2024
1 parent cc09b8e commit 0797bc1
Show file tree
Hide file tree
Showing 4 changed files with 201 additions and 7 deletions.
8 changes: 4 additions & 4 deletions Classic Heisting/managers/menu/crimenetcontractgui.lua
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ function CrimeNetContractGui:init(ws, fullscreen_ws, node)
next_top = ghost_warning_text:bottom()
end

local job_heat_value = managers.job:get_job_heat(job_data.job_id)
local job_heat_value = managers.job:get_job_heat(job_data.job_id) or 0
local ignore_heat = job_heat_value > 0 and self._customizable
local job_heat_mul = ignore_heat and 0 or managers.job:get_job_heat_multipliers(job_data.job_id) - 1
local job_heat = math.round(job_heat_mul * 100)
Expand Down Expand Up @@ -1085,7 +1085,7 @@ function CrimeNetContractGui:set_potential_rewards(show_max)
local difficulty_stars = job_data.difficulty_id - 2
local gui_panel = self._contract_panel
local potential_level_up_text = gui_panel:child("potential_level_up_text")
local job_heat_value = managers.job:get_job_heat(job_data.job_id)
local job_heat_value = managers.job:get_job_heat(job_data.job_id) or 0
local contract_visuals = job_data.contract_visuals or {}
local total_xp, dissected_xp, total_payout, base_payout, risk_payout = nil

Expand Down Expand Up @@ -1251,7 +1251,7 @@ function CrimeNetContractGui:set_all(t, dt)
local difficulty_stars = job_data.difficulty_id - 2
local gui_panel = self._contract_panel
local potential_level_up_text = gui_panel:child("potential_level_up_text")
local job_heat_value = managers.job:get_job_heat(job_data.job_id)
local job_heat_value = managers.job:get_job_heat(job_data.job_id) or 0
local contract_visuals = job_data.contract_visuals or {}
local xp_min = contract_visuals.min_mission_xp and (type(contract_visuals.min_mission_xp) == "table" and contract_visuals.min_mission_xp[difficulty_stars + 1] or contract_visuals.min_mission_xp) or 0
local total_xp, dissected_xp = managers.experience:get_contract_xp_by_stars(job_data.job_id, job_stars, difficulty_stars, job_data.professional, #narrative_chains, {
Expand Down Expand Up @@ -1621,4 +1621,4 @@ function CrimeNetContractGui:mouse_moved(o, x, y)
end

return false, "arrow"
end
end
3 changes: 2 additions & 1 deletion Classic Heisting/mod.txt
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@
{ "hook_id" : "lib/network/base/networkpeer", "script_path": "network/base/networkpeer.lua" },
{ "hook_id" : "lib/network/base/basenetworksession", "script_path": "network/base/basenetworksession.lua" },
{ "hook_id" : "lib/units/beings/player/states/playerstandard", "script_path": "units/beings/player/states/playerstandard.lua" },
{ "hook_id" : "lib/setups/setup", "script_path": "setups/setup.lua" }
{ "hook_id" : "lib/setups/setup", "script_path": "setups/setup.lua" },
{"hook_id":"lib/units/pickups/ammoclip","script_path":"units/pickups/ammoclip.lua"}
],
"updates" : [
{
Expand Down
5 changes: 3 additions & 2 deletions Classic Heisting/tweak_data/charactertweakdata.lua
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ Hooks:PostHook(CharacterTweakData, "init", "restore_init", function(self, tweak_
self.tank.damage.explosion_damage_mul = 0.75
self.tank.move_speed = presets.move_speed.very_slow
self.tank.ecm_hurts = {
ears = {min_duration = 7, max_duration = 9}
ears = 8
}
self.tank.damage.hurt_severity = presets.hurt_severities.only_light_hurt

Expand All @@ -187,6 +187,7 @@ Hooks:PostHook(CharacterTweakData, "init", "restore_init", function(self, tweak_
self.shield.headshot_dmg_mul = self.shield.HEALTH_INIT / 6
self.shield.move_speed = presets.move_speed.fast
self.shield.damage.explosion_damage_mul = 0.25
self.shield.damage.hurt_severity = presets.hurt_severities.only_explosion_hurts
self.shield.weapon.is_smg.FALLOFF = {
{
r = 0,
Expand Down Expand Up @@ -6772,4 +6773,4 @@ function CharacterTweakData:_set_overkill_290()
self.tank.weapon.is_shotgun_mag.focus_dis = 200
self.tank.weapon.is_shotgun_pump.focus_dis = 200
self.flashbang_multiplier = 2
end
end
192 changes: 192 additions & 0 deletions Classic Heisting/units/pickups/ammoclip.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,192 @@
AmmoClip = AmmoClip or class(Pickup)
AmmoClip.EVENT_IDS = {
bonnie_share_ammo = 1,
register_grenade = 16
}
local CABLE_TIE_GET_CHANCE = 0
local CABLE_TIE_GET_AMOUNT = 0

function AmmoClip:init(unit)
AmmoClip.super.init(self, unit)

self._ammo_type = ""
self._ammo_box = self._unit:name() == Idstring("units/pickups/ammo/ammo_pickup")

if self._ammo_box then
self:reload_contour()
end
end

function AmmoClip:reload_contour()
if self._ammo_box and self._unit:contour() then
if managers.user:get_setting("ammo_contour") then
self._unit:contour():add("deployable_selected")
else
self._unit:contour():remove("deployable_selected")
end
end
end

function AmmoClip:_pickup(unit)
if self._picked_up then
return
end

local player_manager = managers.player
local inventory = unit:inventory()

if not unit:character_damage():dead() and inventory then
local picked_up = false

if self._projectile_id then
if managers.blackmarket:equipped_projectile() == self._projectile_id and not player_manager:got_max_grenades() then
player_manager:add_grenade_amount(self._ammo_count or 1)

picked_up = true
end
else
local available_selections = {}

for i, weapon in pairs(inventory:available_selections()) do
if inventory:is_equipped(i) then
table.insert(available_selections, 1, weapon)
else
table.insert(available_selections, weapon)
end
end

local success, add_amount = nil

for _, weapon in ipairs(available_selections) do
if not self._weapon_category or self._weapon_category == weapon.unit:base():weapon_tweak_data().categories[1] then
success, add_amount = weapon.unit:base():add_ammo(1, self._ammo_count)
picked_up = success or picked_up

if self._ammo_count then
self._ammo_count = math.max(math.floor(self._ammo_count - add_amount), 0)
end

if picked_up and tweak_data.achievement.pickup_sticks and self._weapon_category == tweak_data.achievement.pickup_sticks.weapon_category then
managers.achievment:award_progress(tweak_data.achievement.pickup_sticks.stat)
end
end
end
end

if picked_up then
self._picked_up = true
local rand = math.random()

if rand <= CABLE_TIE_GET_CHANCE and self._ammo_box then
managers.player:add_cable_ties(CABLE_TIE_GET_AMOUNT)
end

if not self._projectile_id and not self._weapon_category then
local restored_health = nil

if not unit:character_damage():is_downed() and player_manager:has_category_upgrade("temporary", "loose_ammo_restore_health") and not player_manager:has_activate_temporary_upgrade("temporary", "loose_ammo_restore_health") then
player_manager:activate_temporary_upgrade("temporary", "loose_ammo_restore_health")

local values = player_manager:temporary_upgrade_value("temporary", "loose_ammo_restore_health", 0)

if values ~= 0 then
local restore_value = math.random(values[1], values[2])
local num_more_hp = 1

if player_manager:num_connected_players() > 0 then
num_more_hp = player_manager:num_players_with_more_health()
end

local base = tweak_data.upgrades.loose_ammo_restore_health_values.base
local sync_value = math.round(math.clamp(restore_value - base, 0, 13))
restore_value = restore_value * (tweak_data.upgrades.loose_ammo_restore_health_values.multiplier or 0.1)
local percent_inc = player_manager:upgrade_value("player", "gain_life_per_players", 0) * num_more_hp + 1

print("[AmmoClip:_pickup] Percent increase for health pickup is: ", percent_inc - 1)

restore_value = restore_value * percent_inc
local damage_ext = unit:character_damage()

if not damage_ext:need_revive() and not damage_ext:dead() and not damage_ext:is_berserker() then
damage_ext:restore_health(restore_value, true)
unit:sound():play("pickup_ammo_health_boost", nil, true)
end

if player_manager:has_category_upgrade("player", "loose_ammo_restore_health_give_team") then
managers.network:session():send_to_peers_synched("sync_unit_event_id_16", self._unit, "pickup", 2 + sync_value)
end
end
end

if player_manager:has_category_upgrade("temporary", "loose_ammo_give_team") and not player_manager:has_activate_temporary_upgrade("temporary", "loose_ammo_give_team") then
player_manager:activate_temporary_upgrade("temporary", "loose_ammo_give_team")
managers.network:session():send_to_peers_synched("sync_unit_event_id_16", self._unit, "pickup", AmmoClip.EVENT_IDS.bonnie_share_ammo)
end
elseif self._projectile_id then
player_manager:register_grenade(managers.network:session():local_peer():id())
managers.network:session():send_to_peers_synched("sync_unit_event_id_16", self._unit, "pickup", AmmoClip.EVENT_IDS.register_grenade)
end

if Network:is_client() then
managers.network:session():send_to_host("sync_pickup", self._unit)
end

unit:sound():play(self._pickup_event or "pickup_ammo", nil, true)
self:consume()

if self._ammo_box then
player_manager:send_message(Message.OnAmmoPickup, nil, unit)
end

return true
end
end

return false
end

function AmmoClip:sync_net_event(event, peer)
local player = managers.player:local_player()

if not alive(player) or not player:character_damage() or player:character_damage():is_downed() or player:character_damage():dead() then
return
end

if event == AmmoClip.EVENT_IDS.bonnie_share_ammo then
local inventory = player:inventory()

if inventory then
local picked_up = false

for id, weapon in pairs(inventory:available_selections()) do
picked_up = weapon.unit:base():add_ammo(tweak_data.upgrades.loose_ammo_give_team_ratio or 0.25) or picked_up
end

if picked_up then
player:sound():play(self._pickup_event or "pickup_ammo", nil, true)

for id, weapon in pairs(inventory:available_selections()) do
managers.hud:set_ammo_amount(id, weapon.unit:base():ammo_info())
end
end
end
elseif event == AmmoClip.EVENT_IDS.register_grenade then
if peer and not self._grenade_registered then
managers.player:register_grenade(peer:id())

self._grenade_registered = true
end
elseif AmmoClip.EVENT_IDS.bonnie_share_ammo < event then
local damage_ext = player:character_damage()

if not damage_ext:need_revive() and not damage_ext:dead() and not damage_ext:is_berserker() then
local restore_value = event - 2 + (tweak_data.upgrades.loose_ammo_restore_health_values.base or 3)
restore_value = restore_value * (tweak_data.upgrades.loose_ammo_restore_health_values.multiplier or 0.1)
restore_value = restore_value * (tweak_data.upgrades.loose_ammo_give_team_health_ratio or 0.35)

if damage_ext:restore_health(restore_value, true, true) then
player:sound():play("pickup_ammo_health_boost", nil, true)
end
end
end
end

0 comments on commit 0797bc1

Please sign in to comment.