- Joined
- Aug 15, 2007
- Messages
- 37
I am creating a TD in which a player gathers magic (gold), and uses mana wells to refine the magic into a desired type. There are six different types the wells can be, one being a Generic type which is what I am using in this example.
The effect I am going for is this:
The well regenerates mana by subtracting magic from the Magic Pool, with a cooldown time of 20 secs.
The wells spell can be autocast, or done manually
The ability is deactivated when magic reaches 0 or the wells mana is full
The wells max mana is increased by 1 every round
As of now, I am using invisibility as the base of the spell (I've tried others as well). And calling the trigger when a players gold is > 0. I have also just started using the CasterSystem.
The problem I am having is that the well won't cast the spell automatically when the trigger is called. If I manually cast the spell, it will though.
Some other things I've tried:
I have created a check var (using a leaderboard) that was incremented for every well that was selected in the group. This was inside the if statement, and it showed that the conditions were true and it was selecting the right units.
Any advice would be appreciated, thanks.
The effect I am going for is this:
The well regenerates mana by subtracting magic from the Magic Pool, with a cooldown time of 20 secs.
The wells spell can be autocast, or done manually
The ability is deactivated when magic reaches 0 or the wells mana is full
The wells max mana is increased by 1 every round
As of now, I am using invisibility as the base of the spell (I've tried others as well). And calling the trigger when a players gold is > 0. I have also just started using the CasterSystem.
The problem I am having is that the well won't cast the spell automatically when the trigger is called. If I manually cast the spell, it will though.
JASS:
function RegenMana_Actions takes nothing returns nothing
local group manaWellsG = CreateGroup()
local unit tempWell
local player p = GetTriggerPlayer()
call SetPlayerTechResearched(p,'R002',1)
set manaWellsG = GetUnitsOfPlayerAndTypeId(p,'e002')
loop
set tempWell = FirstOfGroup(manaWellsG)
exitwhen tempWell == null
if ((GetUnitState(tempWell,UNIT_STATE_MAX_MANA) != GetUnitState(tempWell,UNIT_STATE_MANA)) and (GetPlayerState(p,PLAYER_STATE_RESOURCE_GOLD) > 0)) then
call CasterCastAbility(GetOwningPlayer(tempWell),'Aivs',"invisibility",tempWell,true)
call GroupRemoveUnit(manaWellsG,tempWell)
//
//set players gold - 1
//set units mana + 1
//wait length of spell cooldown and call trigger again
endif
endloop
// cleanup
endfunction
function InitTrig_RegenMana takes nothing returns nothing
set gg_trg_RegenMana = CreateTrigger()
call TriggerRegisterPlayerStateEvent(gg_trg_RegenMana,Player(0),PLAYER_STATE_RESOURCE_GOLD,GREATER_THAN,0.)
call TriggerAddAction(gg_trg_RegenMana,function RegenMana_Actions)
endfunction
I have created a check var (using a leaderboard) that was incremented for every well that was selected in the group. This was inside the if statement, and it showed that the conditions were true and it was selecting the right units.
Any advice would be appreciated, thanks.
Last edited by a moderator: