• 🏆 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!
  • ✅ The POLL for Hive's Texturing Contest #33 is OPEN! Vote for the TOP 3 SKINS! 🔗Click here to cast your vote!

Passive abilities as upgrades?

Status
Not open for further replies.
Level 3
Joined
Aug 15, 2007
Messages
37
I've been searching through the forums about upgrades, and I've noticed a lot threads talking about using passive abilities instead of upgrades. I've yet to find one that really goes into detail about how it works though. And I have no clue of how to do this. All I can seem to use in the Object editor is "techtree req's" which only allows units, upgrades or equivalents.
If someone could direct me to a tutorial on this, or give me a brief summary on how to do this, I would greatly appreciate it.
Thanks.
 
Level 3
Joined
Aug 15, 2007
Messages
37
I'm not exactly sure what you mean by that.
What I'm interested in, is a way to control spell requirements. Initially I was using upgrades, but that doesn't work because you can't downgrade.
Example: A spell costs two white mana and 1 green mana. If you have enough of mana of those types, you can cast the spell. If not, the spell is disabled and when you roll over the icon with the cursor, the tooltip tells you what is required to cast it.
Any clue of how to do that?
 
Level 3
Joined
Aug 15, 2007
Messages
37
So, every time a player gains a point of a certain mana type, I create a dummy unit and use it as a requirement for spells.
Example:
A player gains 1 red mana, and it increases the total amount of red mana to 4.
I create a dummy unit named "4 Red Mana ", that is used in a spells techtree req.'s.
Q1) If I create the dummy unit "4 Red Mana" would I still have to have 1,2 and 3, or could I delete them and still cast a spell that requires only 2 Red mana?
Q2)If so, how would this be done? (dummy unit levels?)
-(If not, that would require up to 432 dummy units!!! Saying, 6 players, with 6 mana types, maxed out at 12)

If I'm leaving out any steps, please let me know.
Thanks.
 
Level 21
Joined
Aug 21, 2005
Messages
3,699
Sure you can't.

What you do is: you create 1 dummy unit for each mana type, for example "Red Mana" or "Green Mana".
Now you need to create a trigger like this:
  • Events
    • don't know what event you want, let's say a unit picks up an item
  • Conditions
    • Item - Item being manipulated = Red Mana pool
  • Actions
    • Unit - create 1 'red mana' for owner of unit manipulating the item
Since you have 12 mana types, you'll need 12 of these triggers...
then you add for example "red mana" and "green mana" to techtree requirements and "1" and "3" to techtree requirements levels in your ability. This means that, in order to cast the ability, you need to have 1 red mana and 3 green mana.

Finally, you need to create a trigger for each spell that actually removes 1 red mana and 3 green mana from your mana dummies whenever you cast the spell. this trigger would be something like:
  • Events
    • Unit - a unit starts casting an ability
  • Conditions
    • Ability - ability being cast equal to Myuberability
  • Actions
    • Unit - remove random unit from (units of unit type "Red mana" owned by owner of casting unit)
    • For each Integer A from 1 to 3 do actions:
      • Loop - Actions
        • Unit - remove random unit from (units of unit type "Green mana" owned by owner of casting unit)
Leaks 2 unit groups.
You need one of these triggers for each spell... Spells that use the same mana can share 1 trigger ofcourse.
 
Level 3
Joined
Aug 15, 2007
Messages
37
Ok. I'm using a dummy unit (it's a hero actually, I tried using a footman at first but I couldn't find a way to increase or decrease his levels??)
The problem I'm having now, is that I can't seem to get my dummy to level up past level 2. It works the first time I use the ability, but only once.
Here's the code
JASS:
function Trig_ChannelManaBeginCast_Copy_Conditions takes nothing returns boolean
    return ( GetSpellAbilityId() == 'A00D' ) // A00D is Channel Mana
endfunction

function Trig_ChannelManaBeginCast_Copy_Actions takes nothing returns nothing
    local player p  = GetOwningPlayer(GetTriggerUnit())
    local multiboarditem mbitem
    local group g = CreateGroup()
    local unit dummy

  //===== Gold is Magic that's collected from the mine. Channel Mana is an ability =====
  //===== that takes harvested Magic and channels it into a specific Mana Pool =========  
    if ( GetPlayerState(p,PLAYER_STATE_RESOURCE_GOLD) > 0 )  then
                                           //Magic Miner //      
        if (GetUnitTypeId(GetTriggerUnit()) == 'e002') then
       //===== Decrease magic and increase Generic Mana (1 of the 6 types) =============
            call SetPlayerState(p, PLAYER_STATE_RESOURCE_GOLD, (GetPlayerState(p,PLAYER_STATE_RESOURCE_GOLD) - 1) )
            set udg_genericMana[GetPlayerId(p)] = (udg_genericMana[GetPlayerId(p)]+1)
       
       //===== Show the mana gain on the multiboard ====================================      
            set mbitem = MultiboardGetItem(udg_mboard[GetPlayerId(p)],1,2)
            call MultiboardSetItemValueBJ( udg_mboard[GetPlayerId(p)],2, 1, I2S(udg_genericMana[GetPlayerId(p)]))

       //===== Raise the level of Generic Mana dummy to be used as spell requirements === 
            set g = GetUnitsOfPlayerAndTypeId(p,'H005')
            set dummy = FirstOfGroup(g)
            call SetHeroLevelBJ(dummy,2,false)
              
              //call LeaderboardSetItemValue(bj_lastCreatedLeaderboard,LeaderboardGetPlayerIndex(bj_lastCreatedLeaderboard,p),GetHeroLevel(dummy))
        endif 
    else
        call IssueImmediateOrder(GetTriggerUnit(),"stop")
    endif
    
    set p = null
    set mbitem = null
    set dummy = null
    set g = null
endfunction

//===========================================================================
function InitTrig_ChannelManaBeginCast_Copy takes nothing returns nothing
    set gg_trg_ChannelManaBeginCast_Copy = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_ChannelManaBeginCast_Copy, EVENT_PLAYER_UNIT_SPELL_CHANNEL )
    call TriggerAddCondition( gg_trg_ChannelManaBeginCast_Copy, Condition( function Trig_ChannelManaBeginCast_Copy_Conditions ) )
    call TriggerAddAction( gg_trg_ChannelManaBeginCast_Copy, function Trig_ChannelManaBeginCast_Copy_Actions )
endfunction

?????

Does any of this leak, by the way?
 
Level 3
Joined
Aug 15, 2007
Messages
37
Do you think that's the problem?
Initially I tried it without the BJ's but I just found it easier for testing purposes.
If you need more info, just let me know.
 
Level 3
Joined
Aug 15, 2007
Messages
37
I fixed the leveling dummy issue. (you'd probably hunt me down and kick me in the nuts if I told you what was wrong)
But now, there is another problem. The use of <techtree-requirements-levels>
with units, is only for an amount of the required unit types.
Example:
unit- Tower
techtree req's - Generic Mana
techtree req's levels - 2

I thought it would mean it requires a level 2 Generic Mana Unit, but it means it actually requires 2 Generic Mana units.
There's got to be a better way to do this.
 
Level 40
Joined
Dec 14, 2005
Messages
10,532
No, it wouldn't be the problem you were just leaking ;)

(Your question at the bottom is the only one I noticed)

As for techtree reqs... use more than one unit-type of dummy? That actually helps you that it works that way, though, because it makes it easier to make units that require a lot of basic mana.
 
Status
Not open for further replies.
Top