wc3campaigns
WC3C Homepage - www.wc3c.netUser Control Panel (Requires Log-In)Engage in discussions with other users and join contests in the WC3C forums!Read one of our many tutorials, ranging in difficulty from beginner to advanced!Show off your artistic talents in the WC3C Gallery!Download quality models, textures, spells (vJASS/JASS), systems, and scripts!Download maps that have passed through our rigorous approval process!

Go Back   Wc3C.net > Tutorials > JASS/AI scripts tutorials
User Name
Password
Register Rules Get Hosted! Chat Pastebin FAQ and Rules Members List Calendar



Reply
 
Thread Tools Search this Thread
Old 09-05-2008, 09:47 AM   #46
Flame_Phoenix
retired coder | real ilfe
 
Flame_Phoenix's Avatar
 
Join Date: Mar 2007
Posts: 2,208

Submissions (10)

Flame_Phoenix has a spectacular aura about (90)Flame_Phoenix has a spectacular aura about (90)Flame_Phoenix has a spectacular aura about (90)Flame_Phoenix has a spectacular aura about (90)

Send a message via MSN to Flame_Phoenix
Default

I believe the problem is in the filter, the computer doesn't know who is the triggerUnit, you have to use a globals for that effect or some other variable.
__________________
Check out my tutorials at:
1-Creating a Hero Tavern
2-Complete Icon Tutorial - ALL about Icons
3-Making a spell in vJass - Practice Session 1
Check out all my current spells at here
Finally, check my project:
Castle vs Castle Flame Edition
Flame_Phoenix is offline   Reply With Quote
Sponsored Links - Login to hide this ad!
Old 09-09-2008, 02:16 AM   #47
b_a_d
User
 
Join Date: Mar 2008
Posts: 9

b_a_d has little to show at this moment (0)

Default

i found the problem the was the int trigger should of been InitTrig_Stomp not InitStomp
b_a_d is offline   Reply With Quote
Old 11-27-2008, 09:56 AM   #48
Greencz
User
 
Greencz's Avatar
 
Join Date: Nov 2008
Posts: 7

Greencz has little to show at this moment (0)

Default

emmm it dont look so simple
Greencz is offline   Reply With Quote
Old 11-28-2008, 04:48 AM   #49
Beetlebomb
User
 
Join Date: May 2008
Posts: 1

Beetlebomb has little to show at this moment (0)

Default

Hello!

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
endfunction

function I2G takes integer i returns group
    return i
    return null
endfunction

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

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)
endfunction
    
function Stomp_CopyGroup takes group g returns group
    set bj_groupAddGroupDest = CreateGroup()
    call ForGroup(g, function GroupAddGroupEnum)
    return bj_groupAddGroupDest
endfunction

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
    loop
        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)
        else
            call SetUnitPosition (f, ux+40*Cos(a), uy+40*Sin(a))
            call GroupRemoveUnit(g, f)
        endif
    endloop
    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.
    else
        call DestroyGroup(I2G(GetStoredInteger(gc, s, "group")))
        call FlushStoredMission(gc, s)
        call DestroyTimer(GetExpiredTimer())
    endif
    set gc = null
    call DestroyGroup(g)
    set g = null
    set f = null
endfunction

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)
    loop
        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)
    endloop
    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
endfunction

//===========================================================================
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")
endfunction

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
Old 07-01-2009, 01:48 PM   #50
xX{E}lite Slayer
User
 
Join Date: Jul 2009
Posts: 1

xX{E}lite Slayer has little to show at this moment (0)

Default Question and Answer

Beetlebomb,
I think your problem may lie in your initial spell. If its based off channel, as most JASS spells are, then make sure the "Stats - Follow Through Time" of your spell in the Object Editor is NOT 120.00 (120 seconds <- The default setting for this option). I've fallen prey to that problem more than once, and half the time it was to blame for my dilemmas. If that's not the problem, make sure your timer coding in the JASS trigger is correct (It may be some accidental typo.)
I hope this helped you

I have to admit, though, that this was an excellent tutorial and it provided insight on many aspects that are initial to most JASS spells and triggers. Well done, Blade, and we'll miss you!


Sadly, I came across a small error of my own in my coding;;
The code:
Collapse JASS:
function Trig_Stomp_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A000'
endfunction

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)
endfunction

function Stomp_CopyGroup takes group g returns group
    set bj_groupAddGroupDest = CreateGroup()
    call ForGroup(g, function GroupAddGroupEnum)
    return bj_groupAddGroupDest
endfunction

function Stomp_Move takes nothing returns nothing
    local string s = I2S(H2I(GetExpiredTimer()))
    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
    local real p = GetStoredReal(gc, s, "speed")-1.5/(1+0.5*i)
    local real fx = GetStoredReal(gc, s, "fx")+0.05
    if dur < 1+0.5*i then
        loop
            set f = FirstOfGroup(g)
            exitwhen f == null
            set ux = GetUnitX(f)
            set uy = GetUnitY(f)
            set a = Atan2(uy-y, ux-x)
            call SetUnitPosition(f, ux+p*Cos(a), uy+p*Sin(a))
            if fx >= 1 then
                call DestroyEffect(AddSpecialEffectTarget(GetAbilityEffectById('A000', EFFECT_TYPE_MISSILE, 1), f, GetAbilityEffectById('A000', EFFECT_TYPE_MISSILE, 2)))
            endif
            call GroupRemoveUnit(g, f)
        endloop
        call StoreReal(gc, s, "dur", dur)
        call StoreReal(gc, s, "speed", p)
        call StoreReal(gc, s, "fx", fx)
        if fx >= 1 then
            call StoreReal(gc, s, "fx", 0)
        endif
    else
        call DestroyGroup(I2G(GetStoredInteger(gc, s, "group")))
        call FlushStoredMission(gc, s)
        call DestroyTimer(GetExpiredTimer())
    endif
    set gc = null
    call DestroyGroup(g)
    set g = null
    set f = null
endfunction

function Trig_Stomp_Actions takes nothing returns nothing
    local unit c = GetTriggerUnit()
    local real x = GetUnitX(c)
    local real y = GetUnitY(c)
    local integer i = GetUnitAbilityLevel(c, 'A000')
    local boolexpr b = Condition(function Stomp_Filter)
    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))
    call DestroyEffect(AddSpecialEffect(GetAbilityEffectById('A000', EFFECT_TYPE_MISSILE, 0), x, y))
    call GroupEnumUnitsInRange(g, x, y, 200+50*i, b)
    set n = Stomp_CopyGroup(g)
    loop
        set f = FirstOfGroup(n)
        exitwhen f == null
        call UnitDamageTarget(c, f, 999*i, true, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_MAGIC, null)
        call GroupRemoveUnit(n, f)
    endloop
    call StoreInteger(gc, s, "level", i)
    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 c = 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
endfunction

//===========================================================================
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(GetAbilityEffectById('A000', EFFECT_TYPE_MISSILE, 0))
    call Preload(GetAbilityEffectById('A000', EFFECT_TYPE_MISSILE, 1))
endfunction

Okay, so it runs FINE - the units get damaged and moved and there are no compilation errors. HOWEVER, there are NO SPECIAL EFFECTS WHATSOEVER.
I've read through my code three times, and I'm beginning to get confused, and I have re-copied and replaced my code with the example provided in the tutorial TWICE, and still no impromptu solution has come my rather frustrated way yet.

Any solutions, anyone? It would be deeply appreciated
xX{E}lite Slayer is offline   Reply With Quote
Old 07-06-2009, 11:49 PM   #51
Michael Peppers
Lepus?
 
Michael Peppers's Avatar
 
Join Date: Jan 2009
Posts: 1,308

Michael Peppers is a jewel in the rough (188)Michael Peppers is a jewel in the rough (188)Michael Peppers is a jewel in the rough (188)

Default

Quote:
Originally Posted by xX{E}lite Slayer
Okay, so it runs FINE - the units get damaged and moved and there are no compilation errors. HOWEVER, there are NO SPECIAL EFFECTS WHATSOEVER.

Why ?
Collapse JASS:
call DestroyEffect(AddSpecialEffectTarget(GetAbilityEffectById('A000', EFFECT_TYPE_MISSILE, 1), f, GetAbilityEffectById('A000', EFFECT_TYPE_MISSILE, 2)))

It should be
Collapse JASS:
call DestroyEffect(AddSpecialEffectTarget("Abilities\\Spells\\Orc\\WarStomp\\WarStompCaster.mdl", f, chest)) //or origin, or also head if you prefer

Of course, you may stick with GetAbilityEffectById, but it's slower than the direct string input.
__________________
Projects:Tutorials: Competitive AI Step by Step with AI Editor (Pending)
Resources: [AI Script] Michael Peppers's Melee AI template (Pending)

Last edited by Michael Peppers : 07-07-2009 at 11:34 AM.
Michael Peppers is offline   Reply With Quote
Old 07-07-2009, 11:29 AM   #52
Flame_Phoenix
retired coder | real ilfe
 
Flame_Phoenix's Avatar
 
Join Date: Mar 2007
Posts: 2,208

Submissions (10)

Flame_Phoenix has a spectacular aura about (90)Flame_Phoenix has a spectacular aura about (90)Flame_Phoenix has a spectacular aura about (90)Flame_Phoenix has a spectacular aura about (90)

Send a message via MSN to Flame_Phoenix
Default

You do realize Blade.dk left wc3 and this tutorial a long time ago right ? xD
__________________
Check out my tutorials at:
1-Creating a Hero Tavern
2-Complete Icon Tutorial - ALL about Icons
3-Making a spell in vJass - Practice Session 1
Check out all my current spells at here
Finally, check my project:
Castle vs Castle Flame Edition
Flame_Phoenix is offline   Reply With Quote
Old 07-07-2009, 11:33 AM   #53
Michael Peppers
Lepus?
 
Michael Peppers's Avatar
 
Join Date: Jan 2009
Posts: 1,308

Michael Peppers is a jewel in the rough (188)Michael Peppers is a jewel in the rough (188)Michael Peppers is a jewel in the rough (188)

Default

Quote:
Originally Posted by Flame_Phoenix
You do realize Blade.dk left wc3 and this tutorial a long time ago right ? xD
I know, I was answering to the post above :P
__________________
Projects:Tutorials: Competitive AI Step by Step with AI Editor (Pending)
Resources: [AI Script] Michael Peppers's Melee AI template (Pending)
Michael Peppers is offline   Reply With Quote
Old 12-15-2009, 03:00 PM   #54
sPyRaLz
User
 
Join Date: Aug 2003
Posts: 71

sPyRaLz is on a distinguished road (12)

Default

Im really sorry for bumping this up. But im trying to learn how to create a Jass spell.
Ive just spent two hours running through this and the spell doesn't work.

I get a green icon when i try to add it to my hero and no skill appears in the skill bar after i
add a level to the skill..

Also, it appears that this spell abuses the return bug..

Im running on 1.24b, does anyone know how to get around it?

PS: Im new to JASS, ive no idea how hashtables would come into play..
sPyRaLz is offline   Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off


All times are GMT. The time now is 11:40 PM.


Affiliates
The Hubb The JASS Vault Clan WEnW Campaign Creations Clan CBS GamesModding Flixreel Videos

Powered by vBulletin (Copyright ©2000 - 2019, Jelsoft Enterprises Ltd).
Hosted by www.OICcam.com
IT Support and Services provided by Executive IT Services