• 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.

spreading disease

Status
Not open for further replies.
Level 7
Joined
Feb 4, 2005
Messages
289
What iwant to make is diffrent from smth uploaded here. A unit dies, i use pick every .... a small range from the position of the dying unit to add an ability that damages the picked units and ok so far.

If i use wait X seconds to make after that another pick every... with bigger range from the position of the dying, it doesnt work because of the 'wait'. You see i want to make this wave or circle causing ability to appear to eveyone but i dont know how else to do it since wait doesnt work.

Yes my idea is 1st small range, then pick every ... add this ability, greater range pick every..., then even greater range. What to do since wait doesnt work for that ?
 
Level 11
Joined
Feb 22, 2006
Messages
752
JASS:
function Trig_DeathWave_Conditions takes nothing returns boolean
    if ( GetUnitTypeId(GetTriggerUnit()) == 'h000' ) then //insert the raw code for the unit that you want in place of 'h000'
        return true
    endif
    return false
endfunction

function Trig_DeathWave_AddAbility takes nothing returns nothing
    call UnitAddAbility(GetEnumUnit(), 'A000') //insert the raw code of the ability you want to be added to the units in place of 'A000'
endfunction

function Trig_DeathWave_Actions takes nothing returns nothing
    local integer a = 1
    local unit u = GetTriggerUnit()
    local real x = GetUnitX(u)
    local real y = GetUnitY(u)
    loop
        exitwhen ( a > 5 ) //you can change the "5" to whatever you want depending on how many waves you want
        call ForGroup( GetUnitsInRangeOfLocAll( (100 * a), Location(x, y)), function Trig_DeathWave_AddAbility )
//you can change the 100 to whatever you want, depending how how far you want the range of each wave to be
        call TriggerSleepAction(1) //longer wait = slower waves, shorter wait = faster waves
    endloop
    set u = null
endfunction

//===========================================================================
function InitTrig_DeathWave takes nothing returns nothing
    set gg_trg_DeathWave = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_DeathWave, EVENT_PLAYER_UNIT_DEATH )
    call TriggerAddCondition( gg_trg_DeathWave, function Trig_DeathWave_Conditions )
    call TriggerAddAction( gg_trg_DeathWave, function Trig_DeathWave_Actions )
endfunction

This should work, though I don't really understand why you want an ability to be added to the units that get damaged when you can just damage them directly without an ability.
 
Level 11
Joined
Feb 22, 2006
Messages
752
Whoops :oops: I made a mistake and left out a line of code.

JASS:
function Trig_DeathWave_Conditions takes nothing returns boolean 
    if ( GetUnitTypeId(GetTriggerUnit()) == 'h000') then 
//insert the raw code for the unit that you want in place of 'h000' 
        return true 
    endif 
    return false 
endfunction 

function Trig_DeathWave_AddAbility takes nothing returns nothing 
    call UnitAddAbility(GetEnumUnit(), 'A000') 
//insert the raw code of the ability you want to be added to the units in place of 'A000' 
endfunction 

function Trig_DeathWave_Actions takes nothing returns nothing 
    local integer a = 1 
    local unit u = GetTriggerUnit() 
    local real x = GetUnitX(u) 
    local real y = GetUnitY(u) 
    loop 
    exitwhen ( a > 5 ) 
//you can change the "5" to whatever you want depending on how many waves you want 
    call ForGroup( GetUnitsInRangeOfLocAll( (100 * a), Location(x, y)), function Trig_DeathWave_AddAbility ) 
//you can change the 100 to whatever you want, depending how how far you want the range of each wave to be
    set a = a + 1
    call TriggerSleepAction(1) 
//longer wait = slower waves, shorter wait = faster waves 
    endloop 
    set u = null 
endfunction 

//=========================================================================== 
function InitTrig_DeathWave takes nothing returns nothing 
    set gg_trg_DeathWave = CreateTrigger( ) 
    call TriggerRegisterAnyUnitEventBJ( gg_trg_DeathWave, EVENT_PLAYER_UNIT_DEATH ) 
    call TriggerAddCondition( gg_trg_DeathWave, function Trig_DeathWave_Conditions ) 
    call TriggerAddAction( gg_trg_DeathWave, function Trig_DeathWave_Actions ) 
endfunction
 
Level 7
Joined
Feb 4, 2005
Messages
289
I have conditions to add too, could you code it with these conditions ? And btw i didnt know you would make the code so i will give you all the description of tha ability:

Ok the unit is summoned from item but that doesnt matter yes.

So Event: Unit - A unit Dies

C: (Unit-type of (Dying unit)) Equal to ....

A:

Unit Group - Pick every unit in (Units within 500.00 of (Position of (Dying unit))) and do (If ((((Picked unit) has buff Disease) Equal to False) and ((((Picked unit) is A structure) Equal to False) and (((Picked unit) is Mechanical) Equal to False))) then do (Unit - Add 'Disease Ability' to (Picked unit)) else do (Do nothing))

The ability makes continuous damage and is undispellable, damages all around the one who has it and the onwer of the ability like never removable ( i have conditions to remove it though).

So when added to the units within 500 of dying unit, i want after lets say 10 or more seconds (i can change this if you make a number for that time ) another action:

Unit Group - Pick every unit in (Units within 1000.00 of (Position of (Dying unit))) and do (If ((((Picked unit) has buff Disease) Equal to False) and ((((Picked unit) is A structure) Equal to False) and (((Picked unit) is Mechanical) Equal to False))) then do (Unit - Add 'Disease Ability' to (Picked unit)) else do (Do nothing))

another ... seconds

Unit Group - Pick every unit in (Units within 2500.00 of (Position of (Dying unit))) and do (If ((((Picked unit) has buff Disease) Equal to False) and ((((Picked unit) is A structure) Equal to False) and (((Picked unit) is Mechanical) Equal to False))) then do (Unit - Add 'Disease Ability' to (Picked unit)) else do (Do nothing))

seconds

Unit Group - Pick every unit in (Units within 5000.00 of (Position of (Dying unit))) and do (If ((((Picked unit) has buff Disease) Equal to False) and ((((Picked unit) is A structure) Equal to False) and (((Picked unit) is Mechanical) Equal to False))) then do (Unit - Add 'Disease Ability' to (Picked unit)) else do (Do nothing))

seconds

Unit Group - Pick every unit in (Units within 7500.00 of (Position of (Dying unit))) and do (If ((((Picked unit) has buff Disease) Equal to False) and ((((Picked unit) is A structure) Equal to False) and (((Picked unit) is Mechanical) Equal to False))) then do (Unit - Add 'Disease Ability' to (Picked unit)) else do (Do nothing))

seconds

Unit Group - Pick every unit in (Units within 10000.00 of (Position of (Dying unit))) and do (If ((((Picked unit) has buff Disease) Equal to False) and ((((Picked unit) is A structure) Equal to False) and (((Picked unit) is Mechanical) Equal to False))) then do (Unit - Add 'Disease Ability' to (Picked unit)) else do (Do nothing))

Thats all and the ability is added. Then i can set with another triggers in which cases to be removed like heal or etc.

If you can code this for me with these ranges of the dying unit


!!! To ease me, please Call the Trigger 'Bio Disease' (no inverted commas ofc) so that i dont do repalce word. Also add the explanations away from the code so that i can directly paste and not remove those in grey.
 
Level 11
Joined
Feb 22, 2006
Messages
752
btw just so you know...10k range is like a quarter of the size of an epic-sized map. It seems a bit large (considering that if one unit dies no less than a quarter of the units on the map get infected)...but w/e

and just so you know you dont have to get rid of the gray text code ( the "//" tells the game to ignore all of the text on that line after the double slash)

JASS:
function Trig_Bio_Disease_Conditions takes nothing returns boolean 
    if ( GetUnitTypeId(GetTriggerUnit()) == 'h000' ) then
        return true 
    endif 
    return false 
endfunction 

function Trig_Bio_Disease_Range takes integer a returns real
    if ( a == 1 ) then
        return 500
    elseif ( a == 2 ) then
        return 1000
    elseif ( a == 3 ) then
        return 2500
    elseif ( a == 4 ) then
        return 5000
    elseif ( a == 5 ) then
        return 7500
    elseif ( a == 6 ) then
        return 10000
    endif
    return 0
endfunction

function Trig_Bio_Disease_AddAbility takes nothing returns nothing
    if ( GetUnitAbilityLevel(GetEnumUnit(), 'B000') < 1 and IsUnitType(GetEnumUnit(), UNIT_TYPE_MECHANICAL) == false and IsUnitType(GetEnumUnit(), UNIT_TYPE_STRUCTURE) == false ) then
        call UnitAddAbility(GetEnumUnit(), 'A000')
    endif
endfunction 

function Trig_Bio_Disease_Actions takes nothing returns nothing 
    local integer a = 1 
    local unit u = GetTriggerUnit() 
    local real x = GetUnitX(u) 
    local real y = GetUnitY(u) 
    loop 
        exitwhen ( a > 6 ) 
        call ForGroup( GetUnitsInRangeOfLocAll( Trig_Bio_Disease_Range(a), Location(x, y)), function Trig_Bio_Disease_AddAbility )  
        call TriggerSleepAction(10) 
        set a = a + 1
    endloop 
    set u = null 
endfunction 

//=========================================================================== 
function InitTrig_Bio_Disease takes nothing returns nothing 
    set gg_trg_Bio_Disease = CreateTrigger( ) 
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Bio_Disease, EVENT_PLAYER_UNIT_DEATH ) 
    call TriggerAddCondition( gg_trg_Bio_Disease, function Trig_Bio_Disease_Conditions ) 
    call TriggerAddAction( gg_trg_Bio_Disease, function Trig_Bio_Disease_Actions ) 
endfunction

ok, this is the revised code that does what you described. Everywhere you see 'A000', replace it with the raw code for your disease. Everywhere you see 'B000', replace it with raw code for your disease buff. Everywhere you see 'h000', replace it with the raw code for your dying unit.

The function Trig_Bio_Disease_Range controls the range for each progressive "wave" of disease. To change the number of waves, change the "6" in the line of code "exitwhen ( a > 6 )" to however many waves you want. If you change the number of waves, make sure you also change Trig_Bio_Disease_Range to correspond with the correct number of waves.

To change the time between each "wave", change the number in "TriggerSleepAction(10)".

btw...what is an inverted comma...?
 
Level 7
Joined
Feb 4, 2005
Messages
289
' inverted comma


.....

I made it and when i try to save the map with this script it insantly drops me from the editor, quits.

Can you fix it? It can be because something in the name is wrong even thouh i have it as name: Bio Disease or i dont know what esle can be the problem. Allow me to send a map with the abilities so that it recognizes the same trigger used for the code. PM me your email and i will send you a map, you will be able to do it from there, since the code is not created with the same trigger when i try.
 
Status
Not open for further replies.
Top