• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!
  • ✅ The POLL for Hive's Texturing Contest #34 is OPEN! Vote for the TOP 3 SKINS! 🔗Click here to cast your vote!
  • ✅ The POLL for Hive's Techtree Contest #20 is OPEN! Vote for the TOP 3 FACTIONS! 🔗Click here to cast your vote!

How would i detect bounces?

Status
Not open for further replies.
Level 13
Joined
Mar 24, 2010
Messages
950
for example chain lighting, if i wanted to add a purge affect on each unit affected by the chain all the way down the line how would i do that?
Im not sure how to address any unit after the first targeted unit.

I really hope it doesnt involve a .03 event in order to do this. Otherwise i may not bother with it.
 
If I had to do this, the first thing I would try is making a specific dummy unit-type to cast the base chain-lightning type spell. If you have a hero or some odd other unit casting the chain lightning, replace the hero's base spell with channel and trigger the dummy in when the channel based spell is cast, order the dummy to cast the real chain lightning.

I would have a separate damage detection trigger that can filter the 'damaging unit', and then check if the damaging unit-type matches the dummy that can only cast that specific chain lightning. If this is true, then activate another dummy/trigger to cast a purge type spell on the 'damaged unit'. [I use Weep's GUI Friendly Damage Detection System in my map, and this method would work with that system.]

Granted this only works if the chain-spell is doing some type of damage (although it might still work if the damage is a negative value, maybe for a healing type spell).

Dunno if this will actually work but it's how I would try to do it.
 
for example chain lighting, if i wanted to add a purge affect on each unit affected by the chain all the way down the line how would i do that?
Im not sure how to address any unit after the first targeted unit.

I really hope it doesnt involve a .03 event in order to do this. Otherwise i may not bother with it.

well you cannot really do it in the normal chain lightning... coz there is no function to get units hit by chain lightning...
 
kk, i've made you the whole code in vjass,
heres the code:


custom text: set Lightning_Radius = RadiusOfLightning
custom text: set Lightning_Damage = DamageOfLightning
make sure you understend this effects all lightnings.


JASS:
library Lightning
    globals
        public real         radius           = 300 // radius of spell
        public real         Damage           = 300
        private group       Group            = CreateGroup()
        private lightning   LightningSFX
        private lightning   LightningSFX2
    endglobals
    
private function GetIfThenElse takes unit u returns boolean
    return GetUnitState(u, UNIT_STATE_LIFE) > 0.405 and not IsUnitType(u, UNIT_TYPE_STRUCTURE)
endfunction

private function ReducingIfThenElse takes nothing returns boolean
    return GetIfThenElse(GetFilterUnit())
endfunction

private function ChainLightning takes unit u returns nothing
    local unit Target = null
    local real x = GetUnitX(u)
    local real y = GetUnitY(u)
    local boolexpr ber = Condition(function ReducingIfThenElse)
    local location l = Location(0, 0)
    local location l2 = Location(0, 0)
    call GroupEnumUnitsInRange(Group, x, y, radius, ber)
    loop
    set Target = FirstOfGroup(Group)
    exitwhen Target == null
    call MoveLocation(l, x, y)
    set x = GetUnitX(Target)
    set y = GetUnitY(Target)
    call MoveLocation(l2, x, y)
    call AddLightningLoc("CLPB", l, l2)
    set LightningSFX = GetLastCreatedLightningBJ()
    call AddLightningLoc("CLSB", l, l2)
    set LightningSFX2 = GetLastCreatedLightningBJ()
    call UnitDamageTarget(u, Target, Damage, false, true, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_WHOKNOWS)
    call DestroyLightning(LightningSFX)
    call DestroyLightning(LightningSFX2)
    set LightningSFX = null
    set LightningSFX2 = null
    endloop
endfunction
endlibrary

Few important notes:
if you dont touch radius/damage inside game, they are both setted into 300!

change this:
JASS:
private function GetIfThenElse takes unit u returns boolean
    return result = GetUnitState(u, UNIT_STATE_LIFE) > 0.405 and not IsUnitType(u, UNIT_TYPE_STRUCTURE)
endfunction

return result = blah blah is your condition,
if all inside it is true it adds the unit to the group, and damages him.

i did not test it, if you find any bugs pm me and ill fix it.

good luck with you'r map.

(Btw, you wanted to add purge effect,
just do between those lines of codes:

JASS:
    call UnitDamageTarget(u, Target, Damage, false, true, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_WHOKNOWS)
// Your purge here!
    call DestroyLightning(LightningSFX)
 
In case you don't want to use vJASS,you can create a dummy ability that will have same description as chain lightning. When it's casted,use dummy to cast chain lightning on target. Then using damage detection system,check if unit type of damage dealer is dummy,if so,then use another dummy to cast purge on damaged unit.
 
you dont really need the locations... you can use the x,y... and AddLightning native
you also dont need the lightning effects globals
and use GetWidgetLife instead of GetUnitState
and combine GetIfThenElse and ReducingIfThenElse
and you leak 2 locations because you created 2 local locations but did not Removed it...
and also that local boolexpr... you dont need it anyways... just use the ConditionFunction directly...
plus I think it would leak since you dont set the local boolexpr variable to null...
and WEAPON_TYPE_WHOKNOWS == null so just put null there (the moderators always say this to me...)
and I turned it to ATTACK_TYPE_SPELL since using normal would mean that armor reduction will effect the chain lightning...

and I changed the locals x,y,Target to be globals... I think its faster if you just set them than creating them everytime the function is called...

I've remove the not part and made it just != true since if he put another filter there, the not will affect every condition after it...

and lastly I placed the damage and lightning effect function into the Filter so that you wont need the FoG loop anymore (also the reason why I converted everything to globals)

btw, this one uses three parameters... rather than using two custom scripts

custom text: set Lightning_Radius = RadiusOfLightning
custom text: set Lightning_Damage = DamageOfLightning

I made them into parameters of the function to make it just a one liner function call


JASS:
library Lightning //by dardas
    globals
        private real         radius           = 0.00
        private real         Damage           = 0.00
        private group       Group            = CreateGroup()
        private real x = 0.00
        private real y = 0.00
        private unit Caster = null
    endglobals

  private function ReducingIfThenElse takes nothing returns boolean
    if GetWidgetLife(GetFilterUnit()) > 0.405 and IsUnitType(GetFilterUnit(), UNIT_TYPE_STRUCTURE) != true then
            call DestroyLightning(AddLightning("CLPB", true, x, y, GetUnitX(GetFilterUnit()), GetUnitY(GetFilterUnit())))
            call DestroyLightning(AddLightning("CLSB", true, x, y, GetUnitX(GetFilterUnit()), GetUnitY(GetFilterUnit())))
            call UnitDamageTarget(Caster, GetFilterUnit(), Damage, false, true, ATTACK_TYPE_SPELL, DAMAGE_TYPE_NORMAL, null)
    endif
    return true
  endfunction

  private function ChainLightning takes unit u, real aoe, real damager returns nothing
    set Caster = u
    set x = GetUnitX(Caster)
    set y = GetUnitY(Caster)
    set radius = aoe
    set Damage = damager
    call GroupEnumUnitsInRange(Group, x, y, radius, Condition(function ReducingIfThenElse))
  endfunction
endlibrary
 
Last edited:
thanks for the info, also atm i am more comfortable with gui so i'll probably take that route thanks tho anyway :)

Edit:
that gui spell seems to be semi broken it only bounces twice when says up to 8 maybe i can fix it if i take a look at it later
 
I think my option is the easiest...if using GUI.

yeah, that was pretty easy, at least if he has a damage detection system... though it would require 2 dummy units in the OE... or at least an extra one if you already have a generic dummy caster unit in the OE... since the one that will cast the real chain lightning would need to be a different dummy unit since if not, the damage detection will run for all damage caused by the generic dummy caster...

anyway dardas' suggestion is pretty easy to use, both the GUI and JASS/vJASS... not to say that the jass one doesnt really need JASS/vJASS knowledge, though you need JNGP to compile it...
 
yeah dardas' suggestion seems to semi work without the damage system but for some reason it only works for the first 2 jumps, if anyone cares to fix this for me would appreciate it :) or i guess i will get to it when i can find some more time.
 
yeah dardas' suggestion seems to semi work without the damage system but for some reason it only works for the first 2 jumps, if anyone cares to fix this for me would appreciate it :) or i guess i will get to it when i can find some more time.

I forgot something...
JASS:
if GetWidgetLife(GetFilterUnit()) > 0.405 and IsUnitType(GetFilterUnit(), UNIT_TYPE_STRUCTURE) != true then
            call DestroyLightning(AddLightning("CLPB", true, x, y, GetUnitX(GetFilterUnit()), GetUnitY(GetFilterUnit())))
            call DestroyLightning(AddLightning("CLSB", true, x, y, GetUnitX(GetFilterUnit()), GetUnitY(GetFilterUnit())))
            call UnitDamageTarget(Caster, GetFilterUnit(), Damage, false, true, ATTACK_TYPE_SPELL, DAMAGE_TYPE_NORMAL, null)
            set x = GetUnitX(GetFilterUnit()) //Add this
            set y = GetUnitY(GetFilterUnit()) //Add this
    endif
    return true

--> to make it look like a chain coz the original one will look like a fork lightning... I'm not sure if that will fix your problem though...

btw what happens after 2 jumps? anyway, you're using the original one that dardas posted or the edited or the GUI?
 
yeah i edited dardas link to the gui way
https://www.hiveworkshop.com/forums...ls-279/how-make-chain-spell-gui-version-7015/
at first the hero didnt even have the spell so i added it and tried it out and it worked it jumped twice, i dont recall if the lighting kept going or not but i know the added triggered affect stopped after 2 and was suppose to go 8 times.
Didnt look through the code at that time tho i just know it wasnt fully functional yet..

Edit:
oh wow i think i just found the prob maybe.
Set MB_level = (Level of Unknown (A000) for MB_prev)
might also be the wait is too long. for checking
 
Status
Not open for further replies.
Back
Top