HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Spell 6: Jass - Fireball

10-08-2006, 11:40 AM#1
Fulla
Fireball - Launches a fireball towards target point. Om impact detonates damaging all nearby enemy units and forcing them backwards.

Im using Vile's knockback functionsfor this.
But for some reason I cant even get the group working??

Collapse JASS:
                //################################################################\\
                //                                                                \\
                //                     Configuration Section                      \\
                //                                                                \\
                //################################################################\\

constant function Fireball_abilid takes nothing returns integer
    return 'A05Q'
endfunction

constant function Fireball_damage takes integer level returns real
    return level * 50.
endfunction

constant function Fireball_area takes integer level returns real
    return level * 100. + 50.
endfunction

               //################################################################\\
               //                                                                \\
               //                        Spell Section                           \\
               //                                                                \\
               //################################################################\\

function Fireball_cond takes nothing returns boolean
    return GetSpellAbilityId() == Fireball_abilid()
endfunction

function Fireball_Conditions_group takes nothing returns boolean
    return GetWidgetLife(GetFilterUnit())>0.405 and IsUnitEnemy(GetFilterUnit(), udg_tempplayer) and (IsUnitType(GetFilterUnit(), UNIT_TYPE_MECHANICAL) == false)
endfunction

function Fireball takes nothing returns nothing
    local unit caster = GetTriggerUnit()
    local group targets
    local location targetloc = GetSpellTargetLoc()
    local real newx = GetLocationX(targetloc)
    local real newy = GetLocationY(targetloc)
    local integer level = GetUnitAbilityLevel(caster,Fireball_abilid())
    local real area = Fireball_area(level)
    local real damage = Fireball_damage(level)
    local real distance = DistanceBetweenPoints(GetUnitLoc(caster), targetloc)
    local boolexpr b  = Condition(function Fireball_Conditions_group)
    set udg_tempplayer = GetOwningPlayer(caster)
    call DestroyEffect(AddSpecialEffectLoc("Objects\\Spawnmodels\\Other\\NeutralBuildingExplosion\\NeutralBuildingExplosion.mdl", targetloc))
    call RemoveLocation(targetloc)
    call GroupEnumUnitsInRange(targets, newx, newy, 300, b)
    call DisplayTextToForce(GetPlayersAll(), I2S(CountUnitsInGroup(targets)))
    call DestroyGroup(targets)
    call DestroyBoolExpr(b)
    set b = null
    set caster = null
    set targetloc = null
endfunction

//===========================================================================
function InitTrig_Fireball takes nothing returns nothing
    set gg_trg_Fireball = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Fireball, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddAction( gg_trg_Fireball, function Fireball )
    call TriggerAddCondition( gg_trg_Fireball, Condition( function Fireball_cond ) )
endfunction

Ive tried grouping without a condition same problem.
Is it really not grouping, or will the display text not work like that?

thx
10-08-2006, 12:13 PM#2
arpha_storm
Since you're already using Vexorian's CS, abuse it! XD
I used ProjectileLaunch because it stops the triggering trigger's threads for the knockback effect (DamagingProjectileLaunchAOE would fit but the knockback won't work, it doesn't stop threads).

Here's my code so far, I'll test it right now.
Hidden information:
Collapse JASS:
                //################################################################\\
                //                                                                \\
                //                     Configuration Section                      \\
                //                                                                \\
                //################################################################\\

constant function Fireball_AbilId takes nothing returns integer
    return 'A05Q'
endfunction

constant function Fireball_Damage takes integer level returns real
    return level * 50.
endfunction

constant function Fireball_Area takes integer level returns real
    return level * 100. + 50.
endfunction

function Fireball_DamageOptions takes nothing returns integer
    return DamageTypes(ATTACK_TYPE_NORMAL, DAMAGE_TYPE_FIRE) + DamageException(UNIT_TYPE_MECHANICAL, 0)
    // Attack type is spell, damage type is fire (dunno if what it does) and excempts mechanicals from damage.
endfunction

               //################################################################\\
               //                                                                \\
               //                        Spell Section                           \\
               //                                                                \\
               //################################################################\\

function Fireball_Cond takes nothing returns boolean
    return GetSpellAbilityId() == Fireball_AbilId()
endfunction

function Fireball takes nothing returns nothing
    local unit caster = GetTriggerUnit()
    local location target = GetSpellTargetLoc()
    local location cLoc = GetUnitLoc(caster)
    local integer level = GetUnitAbilityLevel(caster, Fireball_AbilId())

    call ProjectileLaunchLoc("Abilities\\Weapons\\RedDragonBreath\\RedDragonMissile.mdl", 425, 0.05, cLoc, 40, target, 0)
    call DestroyEffect(AddSpecialEffectLoc("Objects\\Spawnmodels\\Other\\NeutralBuildingExplosion\\NeutralBuildingExplosion.mdl", target))
    call DamageUnitsInAOEExLoc(caster, Fireball_Damage(level), target, Fireball_Area(level), false, Fireball_DamageOptions())
    // call vile's AOE knockback function here.

    call RemoveLocation(target)
    call RemoveLocation(cLoc)
    set caster = null
    set target = null
    set cLoc = null
endfunction

//===========================================================================
function InitTrig_Fireball takes nothing returns nothing
    set gg_trg_Fireball = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(gg_trg_Fireball, EVENT_PLAYER_UNIT_SPELL_EFFECT)
    call TriggerAddCondition(gg_trg_Fireball, Condition(function Fireball_Cond))
    call TriggerAddAction(gg_trg_Fireball, function Fireball)
endfunction


This looks more complicated lol, it's because the way vile's knockback functions require a group while Vex's does not.
10-08-2006, 12:41 PM#3
Fulla
thx again,

However, sorry only using the Tables, not the whole system :D.

It says
'expected a name' on
Collapse JASS:
    return DamageTypes(ATTACK_TYPE_NORMAL, DAMAGE_TYPE_FIRE) + DamageException(UNIT_TYPE_MECHANICAL, 0)


EDIT: It would probably be better to not exclude mechanical from damage.
Only the pushback effect, e.g. towers (so excluding from group)
10-08-2006, 01:01 PM#4
arpha_storm
Why not the whole system? Those functions were from CS. Anyway, fixing code now, I seem to be getting an invalid number of args error, I can't see why, so yeah, just hang in there.

EDIT: Okay, this should work now.. Except that the projectile won't show. I don't know why though.
Collapse JASS:
constant function Fireball_AbilId takes nothing returns integer
    return 'A05Q'
endfunction

constant function Fireball_Damage takes integer level returns real
    return level * 50.
endfunction

constant function Fireball_Area takes integer level returns real
    return level * 100. + 50.
endfunction

function Fireball_DamageOptions takes nothing returns integer
    return DamageTypes(ATTACK_TYPE_NORMAL, DAMAGE_TYPE_FIRE) + DamageException(UNIT_TYPE_STRUCTURE, 0.33)
    // Attack type is spell, damage type is fire (dunno if what it does) and structures take less damage
endfunction

function Fireball_Affected takes nothing returns boolean
    return (GetUnitState(GetFilterUnit(), UNIT_STATE_LIFE) > 0.405) and IsUnitEnemy(GetFilterUnit(), GetOwningPlayer(GetSpellAbilityUnit())) and (IsUnitType(GetFilterUnit(), UNIT_TYPE_MECHANICAL) == false) and (IsUnitType(GetFilterUnit(), UNIT_TYPE_STRUCTURE) == false)
endfunction

function Fireball_Cond takes nothing returns boolean
    return GetSpellAbilityId() == Fireball_AbilId()
endfunction

function Fireball takes nothing returns nothing
    local unit caster = GetTriggerUnit()
    local location target = GetSpellTargetLoc()
    local location cLoc = GetUnitLoc(caster)
    local integer level = GetUnitAbilityLevel(caster, Fireball_AbilId())

    call ProjectileLaunchLoc("Abilities\\Weapons\\LordofFlameMissile\\LordofFlameMissile.mdl", 350, 0.25, cLoc, 60, target, 0)
    call DestroyEffect(AddSpecialEffectLoc("Objects\\Spawnmodels\\Other\\NeutralBuildingExplosion\\NeutralBuildingExplosion.mdl", target))
    call DamageUnitsInAOEExLoc(caster, Fireball_Damage(level), target, Fireball_Area(level), false, Fireball_DamageOptions())
    call KnockbackFunctions_KBGroup(GetUnitsInRangeOfLocMatching(Fireball_Area(level), target, Condition(function Fireball_Affected)), GetLocationX(target), GetLocationY(target), 35, 2, 0.05, true, true, true, true)
    call RemoveLocation(target)
    call RemoveLocation(cLoc)
    set caster = null
    set target = null
    set cLoc = null
endfunction

//===========================================================================
function InitTrig_Fireball takes nothing returns nothing
    set gg_trg_Init = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(gg_trg_Init, EVENT_PLAYER_UNIT_SPELL_EFFECT)
    call TriggerAddCondition(gg_trg_Init, Condition(function Fireball_Cond))
    call TriggerAddAction(gg_trg_Init, function Fireball)
endfunction

Phew, had a lot of problems there X_X
10-08-2006, 02:50 PM#5
Fulla
Collapse JASS:
call ProjectileLaunchLoc("Abilities\\Weapons\\LordofFlameMissile\\LordofFlameMissile.mdl", 350, 0.25, cLoc, 60, target, 0)



Expected a function name?
Ive looked at it a few times, I cant see anything wrong with it?
10-09-2006, 01:30 AM#6
Chuckle_Brother
@Fulla - What hes suggesting will work, but at this point, implementing the CS is like bringing in the army to solve a domestic dispute.

The issue is that you never created the group:
Collapse JASS:
    local group targets

And GroupEnumUnitsInRange doesn't return anything. Boom, problem solved.