Jump to content

need help trying to make a weapon deal more damage if user below 50 health


Recommended Posts

Hey it's me, back at it again with being bad at programming

Sorry for making another forum asking for help so soon, I couldn't find anything to help me with my issue in particular.

I'm trying to make the Shahanshah from TF2, where if you're below half health, it does more damage than if you're above half health.

I tried making it so that if you're below 50 health, it deals 50 damage instead of it's normal 30, as seen in line 27 of shana.lua.

Quote

local function onattack(inst, owner, target, attacker)
    local health = owner.components.health
    if inst ~= nil and inst:IsValid() and attacker ~= nil and attacker:IsValid() and (attacker.components.health.current) <= 50 then 
        health:DoDelta(-20)
    else
        target.components.health:DoDelta(0) 
    end
end

I tried and couldn't get it to work how I wanted it to, and i'm hoping that someone would be nice enough to help (again).

shana.lua

I just called it 'shana' so I didn't have to type Shahanshah every time

 

Edited by Danielance
making the title easier to understand
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
  • Create New...