• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Synergy - Fireshield & Sunburst

Planned to submit to the mini spell contest, but i missed the deadline. Left it lying around, finally decided to upload it.

Fireshield - Forms a shield of fire around a target unit. The shield blocks incoming damage, most effectively ranged.

Sunburst - Summons a mighty sunray to devastate all nearby enemies. During daytime it is so strong that fireshields hit by this spell burst, dealing moderate damage to all enemies around them.

First spell submission, don't flame me too much.


v 1.00: Uploaded.

v 1.10: Followed hvo-busterkomo's and -JonNny's suggestions, neatened code, also replaced locs with coordinates and replaced gg_trg_ with lt_ .

v 1.11: Replaced BJs with natives.


Realized I had uploaded the wrong version, anyone who has this please redownload.



JASS:
function Damage takes unit z, group x returns nothing    
    local unit v
    local group x2 = CreateGroup()
    local player dp = GetOwningPlayer(z)
    
    loop
        set v = FirstOfGroup(x)
        
    // Clearing out all allied units from the valid targets
        
        if IsUnitAlly(v,dp) == false then
            call GroupRemoveUnit(x,v)
            call GroupAddUnit(x2,v)
        else
            call GroupRemoveUnit(x,v)
        endif
        
        exitwhen v == null
    endloop
     
    loop
        set v = FirstOfGroup(x2) 
        
    // Creating an effect and damaging all units left to damage
        
        call DestroyEffect(AddSpecialEffectTarget("Abilities\\Spells\\Other\\Incinerate\\IncinerateBuff.mdl",v,"head"))
        call UnitDamageTarget(z,v,(50.00 * (I2R(GetUnitUserData(z)))),false,false,ATTACK_TYPE_NORMAL,DAMAGE_TYPE_FIRE,WEAPON_TYPE_WHOKNOWS)
        
    // Dealing the damage. The Custom Value is set by the Shield Trigger, changing that "50" changes the damage
        
        exitwhen v == null                                                                                     
        call GroupRemoveUnit(x2,v)
    endloop
    
    call DestroyGroup(x) 
    
    // Cleaning memory leaks
    
    call DestroyGroup(x2)
    set x = null
    set x2 = null
    set dp = null
    set v = null
    set z = null
endfunction

function ShieldBurst takes nothing returns nothing
    local group g = CreateGroup()
    local group s = CreateGroup()
    local group d = CreateGroup()
    local group f = CreateGroup()
    local unit c = GetSpellAbilityUnit()
    local player p = GetOwningPlayer(c)
    local unit u
    local location l = GetUnitLoc(c)
    call GroupEnumUnitsInRangeOfLoc(g,l,375,null)
    
    loop
        set u = FirstOfGroup(g)
        
        if GetUnitAbilityLevel(u,'B000') > 0 then 
        
    // Enumerating all units with Fireshield and the units around them
        
            call GroupRemoveUnit(g,u)
            call UnitAddAbility(u,'A008') 
            
    //Adding a Spellbook that stops the effects of the Fireshield
            
            call GroupEnumUnitsInRangeOfLoc(d,GetUnitLoc(u),200,null)
            call Damage(u,d) 
            
    // Calling the function to damage surrounding enemies
            
            call DestroyEffect(AddSpecialEffectTarget("Abilities\\Spells\\Other\\Doom\\DoomDeath.mdl",u,"origin")) // Creating the blast effect.
            call GroupAddUnit(s,u)
        else
            call GroupRemoveUnit(g,u)
        endif
        
        exitwhen u == null
    endloop
    
    call DestroyGroup(d)
     
    // Cleaning memory leaks
    
    set d = null
    call DestroyGroup(s)
    set s = null
    call DestroyGroup(g)
    set g = null
    call DestroyGroup(f)
    set f = null
    set c = null
    set u = null
    call RemoveLocation(l)
    set l = null
    set p = null
endfunction

function BurstCondition takes nothing returns boolean
    return GetSpellAbilityId() == 'A002' and GetTimeOfDay() > 6.00 and GetTimeOfDay() < 18.00 
    
    // Condition, checking spell id and daytime
    
endfunction

function InitTrig_SunBurst takes nothing returns nothing
    local trigger lt_SunBurst = CreateTrigger(  )
    local integer iTrig2 = 0
    
    loop
        call TriggerRegisterPlayerUnitEvent( lt_SunBurst, Player(iTrig2),EVENT_PLAYER_UNIT_SPELL_CAST ,null)
        set iTrig2 = iTrig2 + 1
        exitwhen iTrig2 >= bj_MAX_PLAYER_SLOTS
    endloop
    
    call TriggerAddCondition( lt_SunBurst, Condition( function BurstCondition ) )
    call TriggerAddAction( lt_SunBurst, function ShieldBurst)
endfunction


JASS:
function Shield takes nothing returns nothing 
    local unit j = GetSpellTargetUnit()
    local integer i = 0
    call UnitAddAbility(j,'A001')
    
    // Adding the Spellbook that contains the aura used for the bonus
    
    call SetUnitUserData(j,GetUnitAbilityLevel(GetSpellAbilityUnit(),'A003'))
    
    // Setting the unit's Custom Value, used to determine Sunburst damage
    
    loop
        call TriggerSleepAction(0.50)
        
        if GetUnitAbilityLevel(j,'B000') <= 0 then
            call UnitAddAbility(j,'A001')
        endif
        
        set i =  (i + 1)
        
        // Checking every half second, stops when the duration has expired, or unit no longer has the ability
        
        exitwhen i ==  4 + (8 * GetUnitAbilityLevel(GetSpellAbilityUnit(),'A003')) or GetUnitAbilityLevel(j,'B002') > 0  // To change duration change that "4".
    endloop
    
    call SetUnitUserData(j,0)
    
    // Cleaning memory leaks
    
    call UnitRemoveAbility(j,'A001')
    call UnitRemoveAbility(j,'A008')
    set i = 0
    set j = null
endfunction

function ShieldCondition takes nothing returns boolean
    return GetSpellAbilityId() == 'A003'
    
    // Condition, checking spell id
    
endfunction

function InitTrig_Shield takes nothing returns nothing
    local trigger lt_Shield = CreateTrigger()
    local integer iTrig1 = 0
    
    loop
        call TriggerRegisterPlayerUnitEvent( lt_Shield, Player(iTrig1),EVENT_PLAYER_UNIT_SPELL_CAST ,null)
        set iTrig1 = iTrig1 + 1
        exitwhen iTrig1 >= bj_MAX_PLAYER_SLOTS
    endloop
    
    call TriggerAddCondition( lt_Shield, Condition( function ShieldCondition ) )
    call TriggerAddAction( lt_Shield, function Shield)
endfunction


JASS:
function BurstEffect takes nothing returns nothing
    local real rX = GetUnitX(GetSpellAbilityUnit())
    local real rY = GetUnitY(GetSpellAbilityUnit())
    local real rX2 = rX + 300
    local real rY2 = rY + 75
    local integer el = 0
    local unit eu
    local group eg = CreateGroup()
    local boolean bX = false
    local boolean bY = false
    
    loop
        set el = (el + 1)
        
        // Creating 12 dummy units to create the effect
        
        call GroupAddUnit(eg,CreateUnit(GetOwningPlayer(GetSpellAbilityUnit()),'o000',rX,rY,270))
        exitwhen el == 12
    endloop
    
    set el = 0
    
    loop
        set eu = FirstOfGroup(eg)
        
        // Actually casting the effect
                
        if bX == false then
            set rX2 = rX2 - 75
        else                                
            set rX2 = rX2 + 75
        endif
        
        if bY == false then
            set rY2 = rY2 - 75
        else
            set rY2 = rY2 + 75
        endif
        
        call IssuePointOrder(eu,"shockwave",rX2,rY2)
        call UnitApplyTimedLife(eu,'B001',0.50)
        call GroupRemoveUnit(eg,eu)
        set el = (el + 1)
        
        if rX2 == rX + -225 then
            set bX = true
        endif
        
        if rY2 == rY + -225 then
            set bY = true
        endif
        
        if rY2 == rY + 225 then
            set bY = false
        endif
        
        exitwhen el == 12
    endloop  
    
    // Cleaning memory leaks
        
    set eu = null
    call DestroyGroup(eg)
    set eg = null
endfunction

function EffectCondition takes nothing returns boolean
    return GetSpellAbilityId() == 'A002'
    
    // Condition, checking spell id
    
endfunction

function InitTrig_Effect takes nothing returns nothing
    local trigger lt_Effect = CreateTrigger()
    local integer iTrig3 = 0
    
    loop
        call TriggerRegisterPlayerUnitEvent( lt_Effect, Player(iTrig3),EVENT_PLAYER_UNIT_SPELL_CAST ,null)
        set iTrig3 = iTrig3 + 1
        exitwhen iTrig3 >= bj_MAX_PLAYER_SLOTS
    endloop

    call TriggerAddCondition( lt_Effect, Condition( function EffectCondition ) )
    call TriggerAddAction( lt_Effect, function BurstEffect)
endfunction



Keywords:
synergy, fire, shield, burst
Contents

Spell - Fireshield & Sunburst (Map)

Reviews
18:24, 14th Jun 2009 hvo-busterkomo: Decent effects (although I'm not sure about the synergy). It's worthy of approval as it is now, but I'd like you to make some improvements. 1. Don't use the gg_trg prefix for local triggers. 2. You should...

Moderator

M

Moderator

18:24, 14th Jun 2009
hvo-busterkomo:
Decent effects (although I'm not sure about the synergy). It's worthy of approval as it is now, but I'd like you to make some improvements.
1. Don't use the gg_trg prefix for local triggers.
2. You should indent your code. It significantly improves readability.
3. You could easily use coordinates instead of locations. In fact, it would improve your OffSetLocation() a lot.
4. There's a lot of BJs you can easilly replace with natives.
 
Level 9
Joined
Aug 2, 2008
Messages
219
The spells are not really creative but they seem to work, another thing is the fireshield is useless in this map, because the workers won´t attack so you may add some units who will attack.
I diden´t find any leak in the code for now (remarkabel if this is your first spell), but you use some BJ´s so remove them. I also recommend to use gloabals for the rawcode, so the user of your spell dont need to go trough the whole code and check every rawcode is correct. The commets are ok so over all i would say 3.5/5.
 
Level 9
Joined
Aug 2, 2008
Messages
219
Ok so it might be the easiest way for you to get JNGP it will turn the fontcolor of the BJ`s red so (by the default configuration) you can better find them. Well what i meant by using gloabals for the rawcodes is this:
JASS:
globals // Using the gloabals block in this way is only possible with JNGP
integer SPELL_ID_A = '1234'
endglobals

function some_func takes nothing returns boolean
return GetSpellAbilityId() == SPELL_ID_A 
endfunction

globals // Using the gloabals block in this way is only possible with JNGP
integer SPELL_ID_B = '4321'
endglobals
If you have questions about JNGP please read the site from the link.
 
Level 9
Joined
Aug 2, 2008
Messages
219
Features of JassNewGenPack:
- Grimoire (1.5)
- JassHelper (0.9.G.1) (This makes you able to use [v]JASS)
- Grim Extension Pack (1.0b)
- PJass (1.0k)
- TESH 0.7.0.3 (Unofficial update by Van Damm and Zoxc)
- Risc's Colorizer FINAL
- UMSWE (5.0)
- Reinventing the Craft (0.20)

I dont really know but PJass could be the compiler/parser for [v]Jass.
So this is what i think, but it also could be wrong:wink:
 
Level 11
Joined
Jul 2, 2008
Messages
601
If I'm not mistaken, vJass stands for Vexorian Jass, isn't it? It's kinda a standard. JNPG - just a module for WE to work with jass more easily. JASS spells can be any kinds anyway. (So, it doesn't mean that spells created in JNPG are vJass)

pJass... dunno... pGUI - Paladon's GUI, pJass - ? ;D
 
Level 9
Joined
Aug 2, 2008
Messages
219
Well as far as i know PJASS is some kind of syntax checker ( or parser or a compiler for vjass… these things are of course very different but for me they are the same^^). Dont kill me if im wrong but i think pjass converts vjass into normal jass so for example it adds all variable in a globals block somwhere in the code to the one on top of the script and creates the struct and so on… But hey wait i think our nice talk is gettin off topic. We should help Reaper with his spell.
 
Level 17
Joined
Mar 17, 2009
Messages
1,349
PJASS? :p haha that's new to me...

However, about Fire Shiel:
Since when does fire "block" damage? :p

Well, ideas aren't much of creative ideas... but if altered i guess they would end up real nice ;)

EDIT:

i cant differ on whether how the spells work together work together or not :p

however, it once bugged and shield stayed on for minutes...
 
Last edited:
Level 15
Joined
Jan 31, 2007
Messages
502
Hmm :p long ago that ive seen a Jass spell since i learned vJass
good old times... nah ... if i look at the code they seem not to be that great

your coding is not that bad :) its mui and leakless
but its quite ugly, not easy to read and not that efficient
e.g. i do not know why you check every half second if the unit got the shield buff to add an ability
also the 13 k location variables you use in your SunBurst can be replaced by a loop

to make things easier to read build in some spaces and some descriptions of important variables (which spell code is needed here ect

heres one example of your code
JASS:
loop
call TriggerSleepAction(0.50)
if UnitHasBuffBJ(j,'B000') == false then
call UnitAddAbility(j,'A001')
endif
set i =  (i + 1)  // Checking every half second, stops when the duration has expired, or unit no longer has the ability.
exitwhen i ==  8 + (8 * GetUnitAbilityLevelSwapped('A003',GetSpellAbilityUnit())) or UnitHasBuffBJ(j,'B002') == true  // To change duration change the integers.
endloop

JASS:
loop
    call TriggerSleepAction(0.50)
    if UnitHasBuffBJ(j,'B000') == false then
        call UnitAddAbility(j,'A001')
    endif
    set i =  (i + 1)  // Checking every half second, stops when the duration has expired, or unit no longer has the ability.
    exitwhen i ==  8 + (8 * GetUnitAbilityLevelSwapped('A003',GetSpellAbilityUnit())) or UnitHasBuffBJ(j,'B002') == true  // To change duration change the integers.
endloop


all in all i must say that they seem to work properly but these arent great idead and it could be done better [3/5]
 
Top