#Modifier doesn't call OnAttack when run on dedis?

1 messages · Page 1 of 1 (latest)

dense wadi
#

I have a modifier for legion's moment of courage, added likewise:

function modifier_legion_commander_pf_moment_of_courage:OnAttackStart(event)
    if IsClient() or event.target ~= self:GetParent() then return end
    local hTarget = event.target
    local hAbility = self:GetAbility()

    if not hAbility:IsCooldownReady() or hTarget:PassivesDisabled() or not RollPseudoRandomPercentage(hAbility:GetSpecialValueFor("trigger_chance"), DOTA_PSEUDO_RANDOM_LEGION_MOMENT, hTarget) then return end

    hTarget:AddNewModifier(self:GetCaster(), hAbility, "modifier_legion_commander_pf_moment_of_courage_lifesteal", {duration = self.nBuffDuration})
end

lasts for 1 second, and is succesfully created, the lifestealer modifier has an OnAttack function, it works in tools/localhost, but breaks on dedis? will post second part in comments

#

On dedicated servers, only Created Lifesteal Modifier is printed. On local/tools, everything works fine:

[VScript] Created Lifesteal Modifier
[VScript] 0.05
[VScript] Created Lifesteal Modifier
[VScript] OnAttack called
[VScript] Early return conditions met
[VScript] false
[VScript] true
[VScript] false
[VScript] OnAttack called
[VScript] Early return conditions met
[VScript] false
[VScript] true
[VScript] false
[VScript] OnAttack called
[VScript] Performing attack
[VScript] OnAttack called
[VScript] Early return conditions met
[VScript] false
[VScript] false
[VScript] true
[VScript] Attacker is caster
[VScript] Effects
[VScript] destroying
dusky marsh
#

i think you dont need so much motifiers and you can paste all logic in one

pulsar crown
#
  • You define an attack modifier but don't use it
  • Why do you give 1000 attack speed if you forcibly perform an attack?

no issue having it separated into 2 modifiers, in fact its probably easier to handle that way
as for why it doesn't work on live servers, I can't say for sure without experiencing it myself
are you certain the modifier logic doesn't go through after the application? It might just not be printing into your console on live since the server host isn't your computer

#

I don't see anything specifically wrong with the code

lucid gulch
#

well, you won't get any server prints on dedicated server, your pc is just the client, not the host

#

if you put IsServer on each print, I bet all of them are false

dense wadi
dense wadi
lucid gulch
#

well I'm not sure why you would create another modifier for attacking. One modifier seems enough to me

#
  1. OnAttackStart listens to any unit attacking caster
  2. if the random procs, start an instant attack. Sandwich the PerformAttack with procattack tag.
  3. OnAttack listens to caster attack
  4. if procattack tag is true, give lifesteal
dense wadi
#

as i said im replicating valve's ability as it is exactly, and it really isn't issue here

lucid gulch
#

and that is how I replicate volvo's ability

dense wadi
#

I've also tried putting everything inside one modifier and it doesn't help

lucid gulch
#

does the problem exist with other abilities you made?
seems like if OnAttack bugged on dedis, other mods would crumble

dense wadi
#

No, i have quite a few using it and they all work fine lol

lucid gulch
#

well, you got your answer. or at least, localized the problem. that's one step

#

there are some possibilities that the server code fails. its not fire sure, but worth to check

  • missing modifier reference (as you mentioned, the leftover line)
  • unknown global variable (DOTA_PSEUDO_RANDOM_LEGION_MOMENT)
  • unknown custom function (hCaster:FindTalentValue)
#

I'd say it would be easier to start from scratch and slow

dense wadi
#

yeah i'll probably log errors into panorama for this

#
  • i tested without the line and its the same
  • its part of the dota engine and is before the modifier is added, so it does work
  • works on every other ability too
dense wadi
#

so no there's no error, the function is called and everything "works fine" but nothing actually happens..? i swear this is cursed

lucid gulch
#

told u, easier to go from scratch, or comment them all then uncomment bit by bit

dense wadi
lucid gulch
#

probably subtle differences between dedis and our client game engine
not enough to cause trouble, but enough to have this thing

#

like, GetDedicatedServerKey would have completely different result between dedis and ours

dense wadi
#

i get that but im not doing anything that wasn't done in other abilities or out of ordinary

lucid gulch
#

yea and like I said, the problem exists. no matter how loud you yell, it won't magically get fixed

#

so I advised to start from scratch or uncomment bit by bit

#

and as you finally learn what causes it, you may share some new info

#

it's not like I know how dedis work anyway, all about guesses and new infos

lucid gulch
#
modifier_lc_moc = class({})

function modifier_lc_moc:IsHidden()
    return true
end
function modifier_lc_moc:IsPurgable()
    return false
end

function modifier_lc_moc:OnCreated()
    self.nLifesteal = self:GetAbility():GetSpecialValueFor("hp_leech_percent") / 100
end

function modifier_lc_moc:DeclareFunctions()
    return {
        MODIFIER_EVENT_ON_ATTACK,
        MODIFIER_EVENT_ON_ATTACK_START,
    }
end

function modifier_lc_moc:OnAttackStart(event)
    if IsClient() or event.target ~= self:GetParent() then return end
    local hTarget = event.target
    local hAbility = self:GetAbility()

    if (not hAbility:IsCooldownReady()) or hTarget:PassivesDisabled() then return end

    -- roll chance
    if not RollPseudoRandomPercentage(hAbility:GetSpecialValueFor("trigger_chance"), hAbility:entindex(), hTarget) then return end

    -- counterattack
    self.procattack = true
    hAttacker:PerformAttack(hTarget, false, true, true, false, hAttacker:IsRangedAttacker(), false, false)
    SendOverheadEventMessage(nil, OVERHEAD_ALERT_HEAL, hAttacker, self.nLifesteal * event.damage, hCaster)
    self.procattack = false
end
#
function modifier_lc_moc_lifesteal:OnAttack(event)
    -- only proc on counterattack
    if not self.procattack then return end

    local hAttacker = event.attacker
    local hTarget = event.target
    local hAbility = self:GetAbility()
    local hCaster = self:GetCaster()
    hAttacker:HealWithParams(self.nLifesteal * event.damage, hAbility, true, true, self:GetCaster(), false)

    -- Effects
    local nAttackFX = ParticleManager:CreateParticle("particles/units/heroes/hero_legion_commander/legion_commander_courage_hit.vpcf", PATTACH_ABSORIGIN_FOLLOW, hAttacker)
    ParticleManager:SetParticleControlEnt(nAttackFX, 1, hAttacker, PATTACH_ABSORIGIN_FOLLOW, nil, Vector(0, 0, 0), true)
    ParticleManager:SetParticleControl(nAttackFX, 2, Vector(0, hAttacker:GetHullRadius(), 0)) -- there was a typo here
    ParticleManager:ReleaseParticleIndex(nAttackFX)

    ParticleManager:ReleaseParticleIndex(
        ParticleManager:CreateParticle("particles/units/heroes/hero_legion_commander/legion_commander_courage_tgt.vpcf", PATTACH_ABSORIGIN_FOLLOW, hTarget)
    )

    hAttacker:EmitSound("Hero_LegionCommander.Courage")
end
#

that's how I'd write it, also there's a typo in your code around the effects but probably not that significant