1. Updated Resource Submission Rules: All model & skin resource submissions must now include an in-game screenshot. This is to help speed up the moderation process and to show how the model and/or texture looks like from the in-game camera.
    Dismiss Notice
  2. DID YOU KNOW - That you can unlock new rank icons by posting on the forums or winning contests? Click here to customize your rank or read our User Rank Policy to see a list of ranks that you can unlock. Have you won a contest and still havn't received your rank award? Then please contact the administration.
    Dismiss Notice
  3. The poll for Hive's 12th Concept Art Contest is up! Go cast your vote for your favourite genie!
    Dismiss Notice
  4. Travel to distant realms and encounter scenes unknown to the common folk. The Greatest of Adventures is upon us with the 8th Cinematic Contest. Join in on a fun ride.
    Dismiss Notice
  5. The 18th Icon Contest is ON! Choose any ingame unit and give him/her Hero abilities. Good luck to all.
    Dismiss Notice
  6. Contestants are to create a scene set in the Stone Age. Come and see what you can come up with. We wish you the best of luck!
    Dismiss Notice
  7. Colour outside the lines! Techtree Contest #13 is a go. The contest is optionally paired.
    Dismiss Notice
  8. Greetings cerebrates, our Swarm needs new spawners that will have numerous children. Join the HIVE's 31st Modeling Contest - Spawners and Spawned! The contest is optionally paired.
    Dismiss Notice
  9. Check out the Staff job openings thread.
    Dismiss Notice
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

[Solved] Ability projectile won't pass through corpses.

Discussion in 'Triggers & Scripts' started by xYours Trulyx, Aug 11, 2019.

  1. xYours Trulyx

    xYours Trulyx

    Joined:
    Jan 9, 2016
    Messages:
    858
    Resources:
    0
    Resources:
    0
    Hey all.

    I'm using kawas11's Breath of Fire spell and it seems to be working fine. However, despite being told to only damage Alive units, the spell seems to try and damage dead units as the projectiles won't go pass their corpses.

    Here's the boolean that specifies it to only damage alive units:
    Code (Text):

    private function DamageFilter takes unit target, player owner returns boolean
            return (UnitAlive(target)) and (not IsUnitType(target, UNIT_TYPE_MAGIC_IMMUNE)) and (not IsUnitType(target, UNIT_TYPE_STRUCTURE)) and (not IsUnitType(target, UNIT_TYPE_FLYING)) and (IsUnitEnemy(target, owner))
        endfunction
     
    Thanks in advance.
     
  2. Pyrogasm

    Pyrogasm

    Joined:
    Feb 27, 2007
    Messages:
    2,797
    Resources:
    1
    Spells:
    1
    Resources:
    1
    The UnitAlive native is actually declared somewhere in the script? Try commenting out all other parts of that Boolean logic to rule out them being a problem.
     
  3. xYours Trulyx

    xYours Trulyx

    Joined:
    Jan 9, 2016
    Messages:
    858
    Resources:
    0
    Resources:
    0
    Code (Text):

    static method onCollide takes Missile missile, unit hit returns boolean
                if DamageFilter(hit, missile.owner) then
           
                    call UnitDamageTarget(missile.source, hit, missile.damage, false, false, ATTACK_TYPE, DAMAGE_TYPE, null)
                    call DestroyEffect(AddSpecialEffectTarget(DAMAGE_EFFECT, hit, DAMAGE_EFFECT_ATTACH))
     
    This is the only one that I can find. It deals damage when the projectile comes to an impact with a unit under those specific conditions.
     
  4. Pyrogasm

    Pyrogasm

    Joined:
    Feb 27, 2007
    Messages:
    2,797
    Resources:
    1
    Spells:
    1
    Resources:
    1
    I understand what you're saying, but that's not what I'm asking. UnitAlive is actually declared somewhere in the script like this:
    native UnitAlive takes unit whichUnit returns boolean
    ?

    I'm suggesting you reduce that filter return value to:
    return (UnitAlive(target)) //and (not IsUnitType(target, UNIT_TYPE_MAGIC_IMMUNE)) and (not IsUnitType(target, UNIT_TYPE_STRUCTURE)) and (not IsUnitType(target, UNIT_TYPE_FLYING)) and (IsUnitEnemy(target, owner))
    to see if that actually makes the dead checking work (of course the other checks are important too).

    Instead of UnitAlive you can use GetWidgetLife(target) > 0.405.
     
  5. xYours Trulyx

    xYours Trulyx

    Joined:
    Jan 9, 2016
    Messages:
    858
    Resources:
    0
    Resources:
    0
    Aah, I see. Sorry, my Jass is very poor.
    Here's what the native looks like:
    native UnitAlive takes unit id returns boolean


    I tried these, but still didn't work. The projectiles still won't go through corpses.
     
  6. Pyrogasm

    Pyrogasm

    Joined:
    Feb 27, 2007
    Messages:
    2,797
    Resources:
    1
    Spells:
    1
    Resources:
    1
    That UnitAlive looks fine. What if you just put
    return false
    there? It shouldn't collide with anything (and also do no damage) but if for some reason it does then something is funky somewhere else. Also try that alternative life check method I put above.
     
  7. xYours Trulyx

    xYours Trulyx

    Joined:
    Jan 9, 2016
    Messages:
    858
    Resources:
    0
    Resources:
    0
    I got this error after saving the map:
    Code (Text):
    Line 5243: Not enough arguments given to function : UnitAlive
    Clicking it takes you to the private function DamageFilter.
     
  8. Pyrogasm

    Pyrogasm

    Joined:
    Feb 27, 2007
    Messages:
    2,797
    Resources:
    1
    Spells:
    1
    Resources:
    1
    Sorry not being clear, I didn't mean modifying the unitalive native definition. I meant:
    Code (vJASS):
    private function DamageFilter takes unit target, player owner returns boolean
        return false //(UnitAlive(target)) and (not IsUnitType(target, UNIT_TYPE_MAGIC_IMMUNE)) and (not IsUnitType(target, UNIT_TYPE_STRUCTURE)) and (not IsUnitType(target, UNIT_TYPE_FLYING)) and (IsUnitEnemy(target, owner))
    endfunction

    //or this:
    private function DamageFilter takes unit target, player owner returns boolean
        return GetWidgetLife(target) > 0.405 //and (not IsUnitType(target, UNIT_TYPE_MAGIC_IMMUNE)) and (not IsUnitType(target, UNIT_TYPE_STRUCTURE)) and (not IsUnitType(target, UNIT_TYPE_FLYING)) and (IsUnitEnemy(target, owner))
    endfunction
     
  9. xYours Trulyx

    xYours Trulyx

    Joined:
    Jan 9, 2016
    Messages:
    858
    Resources:
    0
    Resources:
    0
    This one doesn't damage enemies and still collide with corpses.
    This one damages enemies and also collide with corpses.

    So I guess something funky is going on somewhere else? I could post the entire jass if you need it.
     
  10. Pyrogasm

    Pyrogasm

    Joined:
    Feb 27, 2007
    Messages:
    2,797
    Resources:
    1
    Spells:
    1
    Resources:
    1
    Yes, something weird is happening elsewhere, since with false there it should never find a target and not collide with anything. I would guess in whatever missile system that spell uses there is a unitsinrange check that doesn't properly ignore dead units.
     
  11. xYours Trulyx

    xYours Trulyx

    Joined:
    Jan 9, 2016
    Messages:
    858
    Resources:
    0
    Resources:
    0
    Oh, darn. The missile system this code uses is too long for me to read and with my retarded vJass knowledge, I can never understand it.

    Well, I appreciate your help. Sorry for wasting your time. Guess I'll just try to find another similar spell.
     
  12. Pyrogasm

    Pyrogasm

    Joined:
    Feb 27, 2007
    Messages:
    2,797
    Resources:
    1
    Spells:
    1
    Resources:
    1
    It's not the missile system; it's a silly implementation of a global 'remove when hitting a unit or tree' flag. Right now the missile will end on any unit, not just units that match the flag. You need to replace this method:
    Code (vJASS):

            static method onCollide takes Missile missile, unit hit returns boolean
                if DamageFilter(hit, missile.owner) then
         
                    call UnitDamageTarget(missile.source, hit, missile.damage, false, false, ATTACK_TYPE, DAMAGE_TYPE, null)
                    call DestroyEffect(AddSpecialEffectTarget(DAMAGE_EFFECT, hit, DAMAGE_EFFECT_ATTACH))
                 
                endif
             
                return REMOVE
         
            endmethod

    With this:
    Code (vJASS):

            static method onCollide takes Missile missile, unit hit returns boolean
                if DamageFilter(hit, missile.owner) then
         
                    call UnitDamageTarget(missile.source, hit, missile.damage, false, false, ATTACK_TYPE, DAMAGE_TYPE, null)
                    call DestroyEffect(AddSpecialEffectTarget(DAMAGE_EFFECT, hit, DAMAGE_EFFECT_ATTACH))

                    return REMOVE
                endif
             
                return false
         
            endmethod
     
  13. xYours Trulyx

    xYours Trulyx

    Joined:
    Jan 9, 2016
    Messages:
    858
    Resources:
    0
    Resources:
    0

    Wow, it works perfectly now. Big thanks for your help!

    Thread solved.