View Single Post
Old 11-28-2008, 05:48 AM   #49
Join Date: May 2008
Posts: 1

Beetlebomb has little to show at this moment (0)



Thank you for taking the time to write such a good tutorial for people that are interested in learning JASS. I've read and looked over the tutorial very thoroughly and I have managed to get my Stomp Ability to work, the only problem is is that they duration for how long they are moving seems to be really long. Can you, or anyone else with the common knowledge possibly look at my trigger? I'd like to figure out what's wrong and understand how some parts work. I'll put notes in the code.

Here it is:

Collapse JASS:
function H2I takes handle h returns integer
    return h
    return 0

function I2G takes integer i returns group
    return i
    return null

function Trig_Stomp_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A004'

function Stomp_Filter takes nothing returns boolean
    return IsPlayerEnemy(GetOwningPlayer(GetTriggerUnit()), GetOwningPlayer(GetFilterUnit())) and GetWidgetLife(GetFilterUnit()) > 0.405 and not IsUnitType(GetFilterUnit(), UNIT_TYPE_FLYING)
function Stomp_CopyGroup takes group g returns group
    set bj_groupAddGroupDest = CreateGroup()
    call ForGroup(g, function GroupAddGroupEnum)
    return bj_groupAddGroupDest

function Stomp_Move takes nothing returns nothing
    local string s = I2S(H2I(GetExpiredTimer())) // Is this some form of Event? If you can, please explain this to me :(.
    local gamecache gc = udg_AbilityCache
    local real x = GetStoredReal(gc, s, "x")
    local real y = GetStoredReal(gc, s, "y")
    local integer i = GetStoredInteger(gc, s, "level")
    local group g = Stomp_CopyGroup(I2G(GetStoredInteger(gc, s, "group")))
    local real dur = GetStoredReal(gc, s, "dur")+0.05
    local real ux
    local real uy
    local real a
    local unit f
    if dur < 1+0.5*i then
        set f = FirstOfGroup(g)
        exitwhen f == null
        set ux = GetUnitX(f)
        set uy = GetUnitY(f)
        set a = Atan2(uy-y, ux-x)
        if GetUnitState(f, UNIT_STATE_LIFE) <= 0 then
        call GroupRemoveUnit(g, f)
            call SetUnitPosition (f, ux+40*Cos(a), uy+40*Sin(a))
            call GroupRemoveUnit(g, f)
    call StoreReal(gc, s, "dur", dur) //What is this doing right now? I thought the 'dur' variable was already called from the if/then/else. Isn't this an integer or real? I'm not quite sure where this begins or ends.
        call DestroyGroup(I2G(GetStoredInteger(gc, s, "group")))
        call FlushStoredMission(gc, s)
        call DestroyTimer(GetExpiredTimer())
    set gc = null
    call DestroyGroup(g)
    set g = null
    set f = null

function Trig_Stomp_Actions takes nothing returns nothing
    local unit u = GetTriggerUnit()
    local real x = GetUnitX(u)
    local real y = GetUnitY(u)
    local integer i = GetUnitAbilityLevel(u, 'A004')
    local boolexpr b = Condition(function Stomp_Filter) //What is a boolexpr? Just a boolean? Sometimes when looking up new calls on JassCraft I'll see boolexpr as one of the 'takes' followed by some strange command that I dont understand. I hope I'm being clear enough.
    local group g = CreateGroup()
    local group n
    local unit f
    local gamecache gc = udg_AbilityCache
    local timer t = CreateTimer()
    local string s = I2S(H2I(t))  //I lost track of what this does. It converts an integer into a string, but isn't it already a string? Is a string considered a handle and if so why does it convert it back to an integer if it already began as a integer?
    call DestroyEffect(AddSpecialEffect("Abilities\\Spells\\Orc\\WarStomp\\WarStompCaster.mdl", x, y))
    call GroupEnumUnitsInRange(g, x, y, 300+50*i, b)
    set n = Stomp_CopyGroup(g)
        set f = FirstOfGroup(n)
        exitwhen f == null
        call UnitDamageTarget(u, f, 100*i, true, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_MAGIC, null)
        call GroupRemoveUnit(n, f)
    call StoreInteger(gc, s, "level", i) //Why does the gamecache store strings also? Is the quotation marks the variable title when you want to refer back to it?
    call StoreInteger(gc, s, "group", H2I(g))
    call StoreReal(gc, s, "x", x)
    call StoreReal(gc, s, "y", y)
    call TimerStart(t, 0.05, true, function Stomp_Move)
    set u = null
    call DestroyBoolExpr(b)
    set b = null
    set g = null
    call DestroyGroup(n)
    set n = null
    set f = null
    set gc = null
    set t = null

function InitTrig_Stomp takes nothing returns nothing
    set gg_trg_Stomp = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Stomp, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Stomp, Condition( function Trig_Stomp_Conditions ) )
    call TriggerAddAction( gg_trg_Stomp, function Trig_Stomp_Actions )
    call Preload("Abilities\\Spells\\Orc\\WarStomp\\WarStompCaster.mdl")

I know no one has posted here in a while so I hope I'm not writing this in the wrong area.

Thank you to anyone willing to even take a second glance at my delema!
Beetlebomb is offline   Reply With Quote