Requesting help creating a mod
Avatar

HI, so i'm pretty new to payday 2 modding, i could hardly get weapon tweak datas to work (lol) but i'm trying something new. Currently trying to give the Thanatos "Explosive bulles". Spoiler = it is not working. Maybe one of you all can help me! thank you!
This is my mod lua =

function ThanatosExplosiveBullets:fire(weapon_unit, ...)
    if weapon_unit:base():get_name_id() ~= "m95" then
        return self.orig.fire(self, ...)
    end
    
    local result = self.orig.fire(self, ...)
    
    if result.hit_enemy then
        local hit_position = result.rays[#result.rays].position
        local explosion_damage = 500
        local explosion_radius = 100
        local damage_params = {
            position = hit_position,
            damage = explosion_damage,
            range = explosion_radius,
            owner = weapon_unit
        }
        managers.explosion:play_sound_and_effects(hit_position, math.UP, explosion_radius)
        managers.explosion:give_local_player_dmg(hit_position, explosion_radius, explosion_damage)
        managers.explosion:explode_on_client_damage(nil, damage_params)
    end

    return result
end

Hooks:PostHook(WeaponThanatos, "fire", "ThanatosExplosiveBullets", ThanatosExplosiveBullets.fire)

and in my mod.txt i'm calling this=

    {
      "hook_id": "new_m95",
      "script_path": "thanatos_explosive.lua"
    }

(i know the hook is probably wrong but i tried some other hooks and just ended there)

Replies

No Replies Found

34 1432