1. Are you planning to upload your awesome spell or system to Hive? Please review the rules here.
    Dismiss Notice
  2. Choose the best Old Gods themed skin at the Texturing Contest #29 - Poll!
    Dismiss Notice
  3. Melee Mapping Contest #2 - Poll is up! Vote for the best competitive 1v1 map!
    Dismiss Notice
  4. Please help test custom maps and more on the latest PTR!
    Dismiss Notice
  5. Evolution complete! Make Darwin proud and go vote in the Techtree Contest #12 - Poll.
    Dismiss Notice
  6. Icon Contest #17 - Results are out! Step by to congratulate our winners!
    Dismiss Notice
  7. We've created the Staff Job Openings thread. We're currently in need of icon, video production, and social/multimedia positions to be filled. Thank you!
    Dismiss Notice

[vJass] Sw*ne Flu ! 1.1b

Submitted by -JonNny
This bundle is marked as approved. It works and satisfies the submission rules.
it even infected hive ? o_O



Swine Flu
Each unit which comes in range of this unit has a chance of getting infected by the Swine Flu and take damage over time. Each infected unit also has a lower chance to infect others. The Flu disappears after some seconds if the unit is not reinfected. The chance of Infection raises per level.


Changelog

v1.01
-fixed tooltips
-added a change for infecting units
-specified various adjustable values for infection
-improved scrip

FAQ

Why does the Spell lasts longer than the tooltip says?
-The effect will only disappear if the unit is not reinfected, means groups will reinfect themselfs

Whats about the bounty? Who does get the kill ?
-the owner of the beginning of the epidemic will be saved in the unit and transported that nothing gets messed up. Means if your hero infects a unit which will reinfect many others you will get bounty for them.

Why does this unit is not getting affected?
-There is a condition for the infection. Also you cannot infect units with the Swine Flu Skill like the test hero.

Can i infect other units which got infected before of an other player?
- Yes thats possible but only if your Flu has a higher level than the already infected. Else you must wait till its effect wears of.



code
Code (vJASS):
//////////////////////////////////////Globals with important values////////////////////////////////////////

scope SwineFlu

globals
    // The interval all units get checkes of bein infected / reinfected, higher values will increse the possible spread speed
    private real TimerPeriod = 0.5
   
    //your passive Swine Flu spell the hero must have
    private integer SwineFluSpell = 'A000'
   
    //The effect spell which is casted on enemys and causes their pain
    private integer SwineFluSpellEffect = 'A002'
   
    //The id of a dummy used to cast the spell above when a unit gets infected/ reinfected
    private integer CastDummyID =  'h002'
   
    //The buff an infected uni got of the effect spell
    private integer SwineFluBuffCode = 'B000'
   
    //The order id of the effect spell
    private string EffectOrderID = "unholyfrenzy"
   
    // Do not change the following
    private group Infected = CreateGroup()
    private group g = CreateGroup()
    private timer t = CreateTimer()
    private boolexpr filter = null
endglobals


///////////////////////////////////Defining most relevant Values////////////////////////////////////////////////

//Defines how long an infection will last without any reinfactions
private function DurationPerLevel takes integer level returns integer
    return 2 + level
endfunction

//Defines the infection range of the hero spreading the flu
private constant function InfectionRange takes real level returns real
    return 175 + 25 * level
endfunction

//Defines the infection range of an infected unit
private constant function InfectedInfectionRange takes real level returns real
    return 175 + 25 * level
endfunction

//Defines the chance per interval to infect a unit with the hero
private constant function InfectionChance takes real level returns real
    return 0.2+0.15*level
endfunction

//Defines the chance per interval of an infected unit to infect another
private constant function InfectedInfectionChance takes real level returns real
    return 0.12
endfunction

//The conditions a unit can be infected
private function InfectCondition takes unit a, player p returns boolean
    return not(IsUnitType(a, UNIT_TYPE_MECHANICAL)) and not(IsUnitType(a, UNIT_TYPE_MAGIC_IMMUNE)) and (GetWidgetLife(a) > 0) and IsPlayerEnemy(GetOwningPlayer(a),p) // The condition if a unit is infected
endfunction

 //The condition if trigger should run (refers to the event : EVENT_PLAYER_HERO_SKILL)
private function RunCondition takes nothing returns boolean
    return (GetUnitAbilityLevel(GetTriggerUnit(),SwineFluSpell) != 0)
endfunction

//////////////////////////////////Main Struckt//Do not change//////////////////////////////////////////////

private struct Infection
    static integer Index = 0
    static Infection array Data
    integer left
    unit u = null
    player p
    integer level
    static method create takes nothing returns Infection
        local Infection data = Infection.allocate()
        set Infection.Data[Infection.Index] = data
        set Infection.Index = Infection.Index + 1
        return data
    endmethod
endstruct

////////////////////////////////Main script// Do not edit unless you understand it////////////////////////////////

private function AddSwineFlu takes unit target, integer level, player a returns nothing
    local unit dummy = CreateUnit(a,CastDummyID,GetUnitX(target),GetUnitY(target),0)
    call UnitAddAbility(dummy,SwineFluSpellEffect)
    call SetUnitAbilityLevel(dummy,SwineFluSpellEffect,level)
    call UnitApplyTimedLife(dummy, 'BTLF', 0.75)
    call IssueTargetOrder( dummy,  EffectOrderID,target)
    set dummy = null
endfunction

private function GetStructOfUnit takes unit u returns integer
    local Infection data
    local integer i = 0
    loop
        exitwhen i >= Infection.Index
        set data = Infection.Data[i]
        if data.u == u then
            return i
        endif
        set i = i +1
    endloop
    return 0        
endfunction

private constant function NullFilter takes nothing returns boolean
    return true
endfunction

function Callback takes nothing returns nothing
    local Infection data
    local integer i = 0
    local integer ii = 0
    local integer level = 0
    local unit b
    local unit a
    local real x
    local real y
    local real c
    local integer max = Infection.Index
    loop //looping through all structs
        exitwhen i >= max
        set data = Infection.Data[i]
        set a = data.u
        if (GetWidgetLife(a) > 0) and (data.left != 0) then //buff gets removed +  struct destroey if the unit is dead or its infection timer expires
            if data.left != -1 then
                set data.left = data.left-1 // decreases infection timer , -1 means its forever (in this case for your hero)
            endif
            set level = data.level
            set x = GetUnitX(a)
            set y = GetUnitY(a)
            if GetOwningPlayer(a) == data.p then
                call GroupEnumUnitsInRange(g, x, y,InfectionRange(I2R(data.level)), filter)
            else
                call GroupEnumUnitsInRange(g, x, y,InfectedInfectionRange(I2R(data.level)), filter)
            endif
            call GroupRemoveUnit(g,a)
            loop //looping through all units in range
                set b = FirstOfGroup(g)            
                exitwhen b == null
                call GroupRemoveUnit(g,b)
                set ii = GetStructOfUnit(b)
                set c = GetRandomReal(0.00,1.00)
                if ((c < InfectionChance(data.level) and GetOwningPlayer(a) == data.p) or (c < InfectedInfectionChance(data.level) and GetOwningPlayer(a) != data.p)) and InfectCondition(b,data.p) == true and ((Infection.Data[ii].left != -1) or not(IsUnitInGroup(b,Infected)))then
                    if not(IsUnitInGroup(b,Infected)) then
                        //Infecting the target
                        call GroupAddUnit(Infected,b)  
                        call AddSwineFlu(b,data.level,data.p)
                        call Infection.create()
                        set Infection.Data[Infection.Index-1].u = b
                        set Infection.Data[Infection.Index-1].p = data.p
                        set Infection.Data[Infection.Index-1].level = data.level
                        set Infection.Data[Infection.Index-1].left = R2I(I2R(DurationPerLevel(data.level))/TimerPeriod)                        
                    else
                        //Reinfecting the target
                        if Infection.Data[ii].level < data.level then
                            set Infection.Data[ii].level = data.level
                            set Infection.Data[ii].p = data.p
                            call AddSwineFlu(b,data.level,data.p)
                            set Infection.Data[ii].left = R2I(I2R(DurationPerLevel(data.level))/TimerPeriod)    
                        else
                            set Infection.Data[ii].left = R2I(I2R(DurationPerLevel(data.level))/TimerPeriod)    
                        endif
                    endif
                endif
            endloop
        else
            //detroying struct + removing buff
            call UnitRemoveAbility(data.u, SwineFluBuffCode)
            call GroupRemoveUnit(Infected,data.u)
            set data.u = null
            set data.p = null
            call Infection.destroy(data)
            set ii = i
            loop                
                exitwhen ii == Infection.Index
                set Infection.Data[ii] = Infection.Data[ii+1]
                set ii = ii + 1
            endloop
            set i = i -1
            set Infection.Index = Infection.Index - 1
            set max = max - 1            
        endif
        set i = i + 1
        set ii = 0
        set level = 0
    endloop
    set a = null
    set b = null
endfunction

function Swine_Flu_Actions takes nothing returns nothing
    local integer i
    local unit u = GetTriggerUnit()
    if IsUnitInGroup(u,Infected) then
        //modifing the current struct if the unit had Swineflue before
        set i = GetStructOfUnit(u)
        set Infection.Data[i].p = GetOwningPlayer(u)
        set Infection.Data[i].level = GetUnitAbilityLevel(u,SwineFluSpell)
    else
        //creating the struct and adding the hero
        call GroupAddUnit(Infected,u)
        call Infection.create()
        set Infection.Data[Infection.Index-1].u = u
        set Infection.Data[Infection.Index-1].left = -1
        set Infection.Data[Infection.Index-1].p = GetOwningPlayer(u)
        set Infection.Data[Infection.Index-1].level = GetUnitAbilityLevel(u,SwineFluSpell)
        if Infection.Data[Infection.Index-1].Index == 1 then
            call TimerStart(t, TimerPeriod, true, function Callback)
        endif
    endif
    set u = null
endfunction

//===========================================================================
function InitTrig_Swine_Flu takes nothing returns nothing
    local integer index
    local boolexpr cond = Condition( function RunCondition )
    set filter = Filter(function NullFilter)
    set gg_trg_Swine_Flu = CreateTrigger(  )
    set index = 0
    loop
        call TriggerRegisterPlayerUnitEvent(gg_trg_Swine_Flu, Player(index),EVENT_PLAYER_HERO_SKILL, filter)
        set index = index + 1
        exitwhen index == bj_MAX_PLAYER_SLOTS
    endloop
    call TriggerAddCondition( gg_trg_Swine_Flu, cond )
    call TriggerAddAction( gg_trg_Swine_Flu, function Swine_Flu_Actions )
    set cond = null
endfunction

endscope


Keywords:
Swine, Flu, Epidemic, Infect, Infection, Pig, JonNny, vJass
Contents

Noch eine WARCRAFT-III-Karte (Map)

Reviews
Moderator
17:55, 7th Oct 2009 TriggerHappy187: Im approving this though there could still be some improvements.
  1. 17:55, 7th Oct 2009
    TriggerHappy187:

    Im approving this though there could still be some improvements.
     
  2. aaron

    aaron

    Joined:
    Oct 18, 2008
    Messages:
    512
    Resources:
    6
    Maps:
    2
    Spells:
    4
    Resources:
    6
    OMG ITS SWINE FLU xD they have it where i live now :(
     
  3. SuperCoke

    SuperCoke

    Joined:
    Jan 21, 2009
    Messages:
    53
    Resources:
    0
    Resources:
    0
    Someone had to do this sooner or later right?

    This seems awsome :p
     
  4. NoAmmoSrry

    NoAmmoSrry

    Joined:
    May 2, 2009
    Messages:
    402
    Resources:
    0
    Resources:
    0
    lol

    no funny lol ppl can die from swine flu! OH NOES!
     
  5. Septimus

    Septimus

    Joined:
    May 3, 2008
    Messages:
    4,181
    Resources:
    49
    Packs:
    1
    Maps:
    35
    Spells:
    8
    Tutorials:
    5
    Resources:
    49
    Sounds like abomination disease cloud ability.
     
  6. SuperCoke

    SuperCoke

    Joined:
    Jan 21, 2009
    Messages:
    53
    Resources:
    0
    Resources:
    0
    Yes, yes it does.

     
  7. thereallywhitekid

    thereallywhitekid

    Joined:
    Nov 18, 2008
    Messages:
    115
    Resources:
    0
    Resources:
    0
    Ahhhhhhhhhhhh............................ I don't wanna get swine flu. They invaded mexico, Hong Kong, Warcraft III?! I'll migrate in...................... (TO BE CONTINUED, pum, pom BOM!!!!)
     
  8. breebree123

    breebree123

    Joined:
    Apr 5, 2009
    Messages:
    712
    Resources:
    0
    Resources:
    0
    OMG.. .there is swine flu at hive?ahhhh!!!!i'll get infected(LOL)
     
  9. baassee

    baassee

    Joined:
    Nov 14, 2008
    Messages:
    3,221
    Resources:
    17
    Spells:
    14
    Tutorials:
    3
    Resources:
    17
    thought I don't like the sarcasm of a global diesease that can get real bad if it's not fading as it is now.

    Thought the same as septimus really ...
     
  10. Peetoon

    Peetoon

    Joined:
    Mar 14, 2009
    Messages:
    97
    Resources:
    0
    Resources:
    0
    It's not like disease cloud at all. Well, I guess it's similar, being a DoT with the same special effects and all. However, this spell is more like that Plague spell from DotA -- those who get infected can infect other units.

    Good work!
     
  11. Dark_Dragon

    Dark_Dragon

    Joined:
    Jul 19, 2007
    Messages:
    588
    Resources:
    8
    Tools:
    1
    Spells:
    7
    Resources:
    8
    lol XD Swine Flu!

    anyway nicely done, here few coding things:

    1. I2R(level)*I2R(level) can be I2R(level*level)
    2. Would be that i noticed you are using your own Infection.Data[] index system but you still use .allocate for that.

    In order to reduce variables generated by struct as well as allocator and destructor make your struct extend array

    Code (vJASS):

    struct some extends array
        integer i
        real x
        static integer CurrId = 0

         static method create takes nothing returns thistype
             local thistype this = thistype(thistype.CurrId+1)
             
             set this.i = 6
             set this.x = 3.14159
             set thistype.CurrId = integer(this)

              return (this)
         endmethod

         public method free takes nothing returns nothing
             local thistype last = thistype(thistype.CurrId)
             set this.i = last.i
             set this.x = last.x
             set last.i = 0
             set last.x = 0.
             set thistype.CurrId = integer(last) - 1
         endmethod
    endstruct

    local some s = some.create()
    local some array sarr
    local integer i = 1
    set s.i = 53
    set sarr[0] = some.create()
    set sarr[1] = some.create()
    set sarr[1].i = sarr[0].i * 3

    loop
    exitwhen (i > some.CurrId)
        call BJDebugMsg(I2S(some(i).i))
        set i = i + 1
    endloop

    // this up will display:
    53
    6
    18
    // continue code

    call s.free()
    call sarr[0].free()
    call sarr[1].free()
     


    if you do all that structs do not need extra variables and you dont need that array variable + vjass does not generate destroy and allocate methodes.

    i think you will find great use of this!


    Other then that spell is good works fine is MUI, Leakfree, Bugfree, Speed is good enough 0.5 or 2 FPS is really fast so people with slow CPU will have no lagg...

    well 5/5!
    Greets!
    ~Dark Dragon
     
  12. Kingz

    Kingz

    Joined:
    Jun 5, 2008
    Messages:
    2,470
    Resources:
    6
    Spells:
    5
    Tutorials:
    1
    Resources:
    6
    I don't think a disease can be funny, but a pig can^^
    Anyway downloading now...
     
  13. -JonNny

    -JonNny

    Joined:
    Jan 31, 2007
    Messages:
    486
    Resources:
    12
    Icons:
    3
    Maps:
    4
    Spells:
    4
    Tutorials:
    1
    Resources:
    12
    My intention was not to make fun about the illness itself. Sure its a serous theme and we should think about it but it still gave me the idea to create this... I think too many people do not really think about it. i mean.. the tourists rates in mexica only decreased by 30% or sth.. thats a perfect way to spread it all over thw world. i hope it will end up like BSE or sth.
    If some people dislike the name i can rename it because basicly its a simple disease

    hmm.. right.. i never really played undead.. its quie similar .. but it has major differences.
    yes it infects units which will take damage over time but they will be able reinfect others. Also the strengh of this spell is to infect groups which will reinfect their selves and keep the infection alive.


    hmm.. thx, Dark_Dragon
    Thats a quite nice aspect.. i will think about using such a similar thing ...
     
  14. howl2000

    howl2000

    Joined:
    Sep 13, 2008
    Messages:
    255
    Resources:
    0
    Resources:
    0
    I really like the idea of a swine flu ability, but I think you should make it so a unit casts it and the pig should stampede forth across the field infecting everyone. Then it's usable by other units and still makes since.
     
  15. Guishiu

    Guishiu

    Joined:
    Apr 7, 2008
    Messages:
    160
    Resources:
    3
    Spells:
    3
    Resources:
    3
    Spell works great. I love it. It even lets the higher levels takeover the lower levels as stated. And actually kills units, I got on Yahoo this morning and found out that Swine Flu can kill Americans! OH NO!
    It would cool if it caused some sort of panic within the groups of units that are infected. Like randomly some of them become Feared and begin to run around all crazy and some people dont care. Just an idea. Kinda like the RL.
     
  16. -JonNny

    -JonNny

    Joined:
    Jan 31, 2007
    Messages:
    486
    Resources:
    12
    Icons:
    3
    Maps:
    4
    Spells:
    4
    Tutorials:
    1
    Resources:
    12
    Hmm.. funny idea but the main part of this spell should be the disease itself and not other special scripted effects. But the Spell effect for the disease is free editable, means you could instead spread a silence or whatever


    hmm.. this brought me to the idea that this with could easily changed into a motivation spell with edited tooltips, a commander hero and a positive effect speading over allies only :p would be a 2 min edit time
    sth like "Teamwork" or whatever, that the commander motivades his allies which got a damage bonus and will be able to motivade others. Then the effect would wear off after being alone for some time loosing the motivation...
    rofl that would also be awesome, now even i could have a use of it for my survival xD
     
  17. PsychoNerdial

    PsychoNerdial

    Joined:
    Jan 6, 2009
    Messages:
    836
    Resources:
    0
    Resources:
    0
    I guess the spell is nice but...
    People can react very strongly to this, as the Swine Flu is an existing FATAL disease...
    Anyways, nice job^^
     
  18. Deuterium

    Deuterium

    Joined:
    Mar 17, 2009
    Messages:
    1,301
    Resources:
    2
    Spells:
    1
    Tutorials:
    1
    Resources:
    2
    well... true Swine Flu might be a deadly disease... but JonNys idea of doing this is VERY VERY creative! and he's making it less deadly and feared by doing this :)

    and i find the idea really funny :D
     
  19. -JonNny

    -JonNny

    Joined:
    Jan 31, 2007
    Messages:
    486
    Resources:
    12
    Icons:
    3
    Maps:
    4
    Spells:
    4
    Tutorials:
    1
    Resources:
    12
    thanks :)
    tomorrow i got time i ill add some hints for changing this into a activadeable one and may ill add a demo map with another use of this system (the one i mentioned before using it as a "motivation" spell)