Customise Consent Preferences

We use cookies to help you navigate efficiently and perform certain functions. You will find detailed information about all cookies under each consent category below.

The cookies that are categorised as "Necessary" are stored on your browser as they are essential for enabling the basic functionalities of the site. ... 

Always Active

Necessary cookies are required to enable the basic features of this site, such as providing secure log-in or adjusting your consent preferences. These cookies do not store any personally identifiable data.

No cookies to display.

Functional cookies help perform certain functionalities like sharing the content of the website on social media platforms, collecting feedback, and other third-party features.

No cookies to display.

Analytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics such as the number of visitors, bounce rate, traffic source, etc.

No cookies to display.

Performance cookies are used to understand and analyse the key performance indexes of the website which helps in delivering a better user experience for the visitors.

No cookies to display.

Advertisement cookies are used to provide visitors with customised advertisements based on the pages you visited previously and to analyse the effectiveness of the ad campaigns.

No cookies to display.

[ad_1]

I’m growing a third-person capturing type sport and I wish to implement an armor system. The system that I’ve envisioned doesn’t scale back the harm to 0, however by half. So the incoming harm is 50%. The armor takes the opposite 50% of harm and is diminished by that quantity. Gamers choose up armor objects from the map.

The problem that I am encountering is an edge case the place the harm > armor. This is what I’ve tried up to now:

Try 1:

-- Performs harm discount based mostly on armor, if any.  Robotically
-- provides the armor attribute to the humanoid if it does not already
-- exist.
native operate processArmor(goal, harm)
    -- Verify if the participant really has armor.  If not
    -- then return full harm.
    native armor = goal.human:GetAttribute("Armor")
    if armor == nil or armor == 0 then
        if armor == nil then
            goal.human:SetAttribute("Armor", 0)
        finish
        return harm
    finish

    -- If the participant does have armor > 0, then scale back the incoming
    -- harm.
    native d2 = harm / 2
    native t = d2
    d2 -= armor
    armor -= t - d2
    harm = d2

    -- Replace armor stat and return.
    goal.human:SetAttribute("Armor", armor)
    return harm
finish

Try 2:

-- Performs harm discount based mostly on armor, if any.  Robotically
-- provides the armor attribute to the humanoid if it does not already
-- exist.
native operate processArmor(goal, harm)
    -- Verify if the participant really has armor.  If not
    -- then return full harm.
    native armor = goal.human:GetAttribute("Armor")
    if armor == nil or armor == 0 then
        if armor == nil then
            goal.human:SetAttribute("Armor", 0)
        finish
        return harm
    finish

    -- If the participant does have armor > 0, then scale back the incoming
    -- harm.
    if harm == armor then
        armor = 0
    elseif harm < armor then
        armor -= harm
    elseif harm > (armor * 2) then
    else
        native t = harm - armor * 2
        harm -= armor
    finish

    -- Replace armor stat and return.
    goal.human:SetAttribute("Armor", armor)
    return harm
finish

Try 3:

-- Performs harm discount based mostly on armor, if any.  Robotically
-- provides the armor attribute to the humanoid if it does not already
-- exist.
native operate processArmor(goal, harm)
    -- Verify if the participant really has armor.  If not
    -- then return full harm.
    native armor = goal.human:GetAttribute("Armor")
    if armor == nil or armor == 0 then
        if armor == nil then
            goal.human:SetAttribute("Armor", 0)
        finish
        return harm
    finish
    
    -- If the participant does have armor > 0, then scale back the incoming
    -- harm.
    native d2 = harm / 2
    if armor == d2 then
        harm = d2
        armor = 0
    elseif armor > d2 then
        harm = d2
        armor -= d2
    else
        -- harm / 2 > armor
        harm = ((d2 - armor) * 2) + armor
        armor = 0
    finish

    -- Replace armor stat and return.
    goal.human:SetAttribute("Armor", armor)
    return harm
 finish

Goal is only a desk that comprises references to the elements of the participant that was hit. On this case, I am utilizing the Humanoid beneath the participant’s character mannequin. Try 3 appears to be the most effective guess, however beneath testing, the method beneath the else appears to scale back to harm -= armor.

I’ve achieved some analysis on the topic, however every little thing that I’ve discovered up to now includes RPG type video games. At this level, I am on the lookout for strategies.

Thanks.

[ad_2]

Leave a Reply

Your email address will not be published. Required fields are marked *