HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Spell 5: JASS - 'Rude Awakening' difficulty

10-06-2006, 11:38 AM#1
Fulla
Rude Awakneing: Turns all trees in a radius of the caster into Ents for a brief period to fight for the caster.

Ok, having difficulties with 'grouping' up the trees in a radius.
I think so far ive got it to pick them.

Now in GUI I just do kill 'picked' destructable, not sure can I do that in jass as well?
(I only have 2 tree types in the map so used the following condition, is there a way to do if desctructable is a tree?)

Collapse JASS:
function Trig_rudeawakening_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A062'
endfunction

function rudeawakening_Conditions_group takes nothing returns boolean
    return (GetDestructableTypeId(GetFilterDestructable()) == 'CTtc' or GetDestructableTypeId(GetFilterDestructable()) == 'CTtr')
endfunction

function Trig_rudeawakening_Actions takes nothing returns nothing
    local unit caster = GetTriggerUnit()
    local real area
    local integer level = GetUnitAbilityLevel(caster,'A062')
    set area = 400 + (50 * level)
    call EnumDestructablesInCircleBJ( area, GetUnitLoc(caster), Condition (function rudeawakening_Conditions_group))
    call KillDestructable(GetEnumDestructable())
    call CreateNUnitsAtLoc( 1, 'hfoo', Player(0), GetDestructableLoc(GetEnumDestructable()), bj_UNIT_FACING )
endfunction

//===========================================================================
function InitTrig_rudeawakening takes nothing returns nothing
    set gg_trg_rudeawakening = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_rudeawakening, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddAction( gg_trg_rudeawakening, function Trig_rudeawakening_Actions )
    call TriggerAddCondition( gg_trg_rudeawakening, Condition( function Trig_rudeawakening_Conditions ) )
endfunction

It doesnt like the
Collapse JASS:
 call KillDestructable(GetEnumDestructable())

thx for any help
10-06-2006, 11:55 AM#2
zen87
Quote:
Originally Posted by Fulla
Rude Awakneing: Turns all trees in a radius of the caster into Ents for a brief period to fight for the caster.
uhmm... i just wondering... if thats all u want isnt it that force of nature will be enought ?
10-06-2006, 12:27 PM#3
arpha_storm
It's a good practice to try and recreate default abilities.

Err... Try this?
Collapse JASS:
constant function rudeawakening_abilid takes nothing returns integer
    return 'A062'
endfunction

constant function rudeawakening_buffid takes nothing returns integer
    return 'B000'
endfunction

constant function rudeawakening_duration takes integer level returns real
    return level * 10 + 30.
endfunction

constant function rudeawakening_area takes integer level returns real
    return level * 50 + 400.
endfunction

constant function rudeawakening_treestopwn takes nothing returns boolean
    return (GetDestructableTypeId(GetFilterDestructable()) == 'CTtc') or (GetDestructableTypeId(GetFilterDestructable()) == 'CTtr')
    // just add ---- or (GetDestructableTypeId(GetFilterDestructable()) == 'XXXX') --- if you want to add more trees to be converted. XXXX is doh, teh destructable 4-char id.
endfunction

function rudeawakening_cond takes nothing returns boolean
    return GetSpellAbilityId() == rudeawakening_abilid()
endfunction

function rudeawakening_wakeuptrees takes nothing returns nothing
    local integer c = 0
    local integer level = GetUnitAbilityLevel(caster,rudeawakening_abilid())
    if (rudeawakening_treestopwn()) then
        call KillDestructable(GetEnumDestructable())
        set c = c + 1
        call CreateUnit(Player(0), 'hfoo', GetDestructableX(GetEnumDestructable()), GetDestructableY(GetEnumDestructable()), bj_UNIT_FACING)
        call UnitApplyTimedLife(GetLastCreatedUnit(), rudeawakening_buffid(), rudeawakening_duration(level))
    endif
endfunction

function rudeawakening takes nothing returns nothing
    local unit caster = GetTriggerUnit()
    local location targetloc = GetSpellTargetLoc()
    local integer level = GetUnitAbilityLevel(caster,rudeawakening_abilid())
    local real area = rudeawakening_area(level)

    call EnumDestructablesInCircleBJ( area, targetloc, function rudeawakening_wakeuptrees)
    call RemoveLocation(targetloc)
    set caster = null
    set targetloc = null
endfunction

//===========================================================================
function InitTrig_rudeawakening takes nothing returns nothing
    set gg_trg_rudeawakening = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_rudeawakening, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddAction( gg_trg_rudeawakening, function rudeawakening )
    call TriggerAddCondition( gg_trg_rudeawakening, Condition( function rudeawakening_cond ) )
endfunction

Hopefully (for the 3rd edit time) this would do? The buffid could be any buff, just to make those silly Ents mortal.

Hehe, isn't this a card from Magic: The Gathering?

Anyway, as you can see, I used a JESP-like config for uber easy edit (out of habit lol). I also shortened the names to save some bytes and uhh.. that's all I guess.
10-06-2006, 01:36 PM#4
Chuckle_Brother
Alrighty, no.
Collapse JASS:
local integer level = GetUnitAbilityLevel(caster,rudeawakening_abilid())

Will not work, locals will not pass from function to function. K, so for this, I am *hoping* that when these ents run out of time(not by death, only by elapsed life-time) they turn back into trees. Just cause it would look super cool.

To pass stuff to an enumeration of a group, you need to either globalize it it(in a global variable or in the gamecache).
Can't pimp out any code atm, since warcraft is temporarily trashed on my computer, but come 6 hours from now, I'll have my fix again and can be done with this withdrawl(will also finish up the LaneOrder function and the Bounty stuff.)
10-06-2006, 02:08 PM#5
Fulla
Quote:
uhmm... i just wondering... if thats all u want isnt it that force of nature will be enought ?

I tried that initially, but force of nature, teleports the ents automatically to the center of the circle.
Meaning If I made with triggers a Force Of nature cast over the caster, all ents would teleport from the tree locations around him.

Making it look very 'crappy' and trapping / making movement difficult each time.

Quote:
Hehe, isn't this a card from Magic: The Gathering?

Yup I was working on an MTG AoS ages ago, I still have lots of card ideas transferred into spells written down.
This was one of my favourites as it does pretty much exactly what the card does :D But also very practical/useful spell.

Quote:
To pass stuff to an enumeration of a group, you need to either globalize it

What global could I use? I assume a Destructable ARRAY, for each tree, then individually with a loop transform each one?
10-06-2006, 02:47 PM#6
Chuckle_Brother
Not for the trees, GetEnumDestructable() will do you for that. You need to globalize your caster so you know who to make them for.
10-06-2006, 06:32 PM#7
arpha_storm
Quote:
Originally Posted by Chuckle_Brother
Alrighty, no.
Collapse JASS:
local integer level = GetUnitAbilityLevel(caster,rudeawakening_abilid())

Will not work, locals will not pass from function to function. K, so for this, I am *hoping* that when these ents run out of time(not by death, only by elapsed life-time) they turn back into trees. Just cause it would look super cool.

To pass stuff to an enumeration of a group, you need to either globalize it it(in a global variable or in the gamecache).
Can't pimp out any code atm, since warcraft is temporarily trashed on my computer, but come 6 hours from now, I'll have my fix again and can be done with this withdrawl(will also finish up the LaneOrder function and the Bounty stuff.)

Oh yeah that was such a stupid mistake -_- thanks for pointing that out.
Fulla, you may attach the caster to the trigger
Collapse JASS:
call AttachObject(gg_trg_rudeawakening, "caster", caster)
using Vex's CS and retrieve it using
Collapse JASS:
call GetAttachedUnit(gg_trg_rudeawakening, "caster")

...
Hidden information:

Collapse JASS:
constant function rudeawakening_abilid takes nothing returns integer
    return 'A062'
endfunction

constant function rudeawakening_buffid takes nothing returns integer
    return 'B000'
endfunction

constant function rudeawakening_duration takes integer level returns real
    return level * 10 + 30.
endfunction

constant function rudeawakening_area takes integer level returns real
    return level * 50 + 400.
endfunction

constant function rudeawakening_treestopwn takes nothing returns boolean
    return (GetDestructableTypeId(GetFilterDestructable()) == 'CTtc') or (GetDestructableTypeId(GetFilterDestructable()) == 'CTtr')
    // just add ---- or (GetDestructableTypeId(GetFilterDestructable()) == 'XXXX') --- if you want to add more trees to be converted. XXXX is doh, teh destructable 4-char id.
endfunction

function rudeawakening_cond takes nothing returns boolean
    return GetSpellAbilityId() == rudeawakening_abilid()
endfunction

function rudeawakening_wakeuptrees takes nothing returns nothing
    local integer c = 0
    local unit caster = GetAttachedUnit(gg_trg_rudeawakening, "caster")
    local integer level = GetUnitAbilityLevel(caster,rudeawakening_abilid())
    if (rudeawakening_treestopwn()) then
        call KillDestructable(GetEnumDestructable())
        set c = c + 1
        call CreateUnit(Player(0), 'hfoo', GetDestructableX(GetEnumDestructable()), GetDestructableY(GetEnumDestructable()), bj_UNIT_FACING)
        call UnitApplyTimedLife(GetLastCreatedUnit(), rudeawakening_buffid(), rudeawakening_duration(level))
    endif
    set caster = null
endfunction

function rudeawakening takes nothing returns nothing
    local unit caster = GetTriggerUnit()
    local location targetloc = GetSpellTargetLoc()
    local integer level = GetUnitAbilityLevel(caster,rudeawakening_abilid())
    local real area = rudeawakening_area(level)
    call AttachObject(gg_trg_rudeawakening, "caster", caster)
    call EnumDestructablesInCircleBJ( area, targetloc, function rudeawakening_wakeuptrees)
    call CleanAttachedVars(gg_trg_rudeawakening)
    call RemoveLocation(targetloc)
    set caster = null
    set targetloc = null
endfunction

//===========================================================================
function InitTrig_rudeawakening takes nothing returns nothing
    set gg_trg_rudeawakening = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_rudeawakening, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddAction( gg_trg_rudeawakening, function rudeawakening )
    call TriggerAddCondition( gg_trg_rudeawakening, Condition( function rudeawakening_cond ) )
endfunction
10-06-2006, 08:28 PM#8
Chuckle_Brother
Nope, I am helping him with DoD, only Tables.

Change that to:

call SetTableObject("[GlobalInfo]","Caster",cast)

and

local unit caster = GetTableUnit("[GlobalInfo]","Caster")
10-06-2006, 11:03 PM#9
Fulla
I tried your way arpha_method, by replacing the bit with Chucks bit.

came up

Collapse JASS:
return (GetDestructableTypeId(GetFilterDestructable()) == 'CTtc') or (GetDestructableTypeId(GetFilterDestructable()) == 'CTtr')


Constant function is being called from a non constant function.
10-07-2006, 08:12 AM#10
arpha_storm
Change
Collapse JASS:
constant function rudeawakening_treestopwn
to
Collapse JASS:
function rudeawakening_treestopwn
Sorry about those mistakes. >_<
10-07-2006, 09:16 AM#11
Fulla
ok, awesome it works now :-)

1 problem thou, the expiration timer doesnt apply to the Ents made instead it gets the last crated unit, which happens to be my hero.
So he just dies after X seconds when casting spell hehe

------------------

Also Id like to further upgrade it by having a differnet Ent per level.
To follow the JESP standard how could I do this?

Collapse JASS:
constant function rudeawakening_tree takes nothing returns unit
    return level1 unit ??
         level 2 unit ??
endfunction

thx
10-07-2006, 09:44 AM#12
arpha_storm
Hmm ok I'll try to fix that.

EDIT: After 3 tests, I think this should work now.

Collapse JASS:
constant function RudeAwakening_AbilId takes nothing returns integer
    return 'A062'
endfunction

constant function RudeAwakening_BuffId takes nothing returns integer
    return 'B000'
endfunction

constant function RudeAwakening_Duration takes integer level returns real
    return level * 10 + 30.
endfunction

constant function RudeAwakening_Area takes integer level returns real
    return level * 50 + 400.
endfunction

constant function RudeAwakening_EntType takes integer level returns integer
    if (level == 1) then
        return 'ent1'
    elseif (level == 2) then
        return 'ent2'
    elseif (level == 3) then
        return 'ent3'
    elseif (level == 4)
        return 'ent4'
    endif
    return 'ent1'
    // just add more elseifs if your rudeawakening has more than 4 levels.
endfunction        

constant function RudeAwakening_TreesToPwn takes nothing returns boolean
    return (GetDestructableTypeId(GetFilterDestructable()) == 'CTtc') or (GetDestructableTypeId(GetFilterDestructable()) == 'CTtr')
    // just add ---- or (GetDestructableTypeId(GetFilterDestructable()) == 'XXXX') --- if you want to add more trees to be converted. XXXX is doh, teh destructable 4-char id.
endfunction

function RudeAwakening_Cond takes nothing returns boolean
    return GetSpellAbilityId() == RudeAwakening_AbilId()
endfunction

function RudeAwakening_WakeUpTrees takes nothing returns nothing
    local unit caster = GetTableUnit("[GlobalInfo]", "Caster")
    local integer level = GetUnitAbilityLevel(caster,RudeAwakening_AbilId())
    if (RudeAwakening_TreesToPwn() and (GetDestructableLife(GetEnumDestructable()) > 0.405)) then
        call KillDestructable(GetEnumDestructable())
        call DestroyEffect(AddSpecialEffect("Abilities\\Spells\\NightElf\\ManaBurn\\ManaBurnTarget.mdl", GetDestructableX(GetEnumDestructable()), GetDestructableY(GetEnumDestructable())))
        call UnitApplyTimedLife(CreateUnit(Player(0), RudeAwakening_EntType(level), GetDestructableX(GetEnumDestructable()), GetDestructableY(GetEnumDestructable()), bj_UNIT_FACING), RudeAwakening_BuffId(), RudeAwakening_Duration(level))
    endif
    set caster = null
endfunction

function RudeAwakening takes nothing returns nothing
    local unit caster = GetTriggerUnit()
    local location targetloc = GetSpellTargetLoc()
    local integer level = GetUnitAbilityLevel(caster,RudeAwakening_AbilId())
    local real area = RudeAwakening_Area(level)
    call SetTableObject("[GlobalInfo]", "Caster", caster)
    call EnumDestructablesInCircleBJ(area, targetloc, function RudeAwakening_WakeUpTrees)
    call RemoveLocation(targetloc)
    set caster = null
    set targetloc = null
endfunction

//===========================================================================
function InitTrig_RudeAwakening takes nothing returns nothing
    set gg_trg_RudeAwakening = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_RudeAwakening, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddAction( gg_trg_RudeAwakening, function RudeAwakening )
    call TriggerAddCondition( gg_trg_RudeAwakening, Condition( function RudeAwakening_Cond ) )
endfunction

Another bug fix: The one I made last time will turn _DEAD_ trees into Ents, so, there, fixed that.
Thanks to blu_da_noob for his post (a unit dies when hp is equal or less than 0.405). Although I'm not quite sure if he's the one who said that lol (I can't seem to find it argh -- oh yes found it: http://www.wc3campaigns.net/showpost...&postcount=17).

And please rename your trigger from rudeawakening to RudeAwakening. XD
10-07-2006, 12:47 PM#13
Fulla
Yup works fine now :-)

thx for help
10-07-2006, 04:42 PM#14
arpha_storm
No problem, happy to help :)