HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Mana Ammunition Triggers

10-20-2007, 08:32 PM#1
Drek-ker
Okay, I'm nt the best at triggers and such so after looking around and searching I decided to just post asking, whats the triggers to make a simple ammunition system using mana as the ammunition, help is appreciated .
10-20-2007, 08:37 PM#2
Dil999
Your going to have to tell us what you mean by Ammunition System...
10-20-2007, 08:39 PM#3
Drek-ker
What i mean is, if a unit fires at another, the attacking unit loses 1 mana, and when your mana reaches zero you cannot fire anymore.
10-20-2007, 10:29 PM#4
TaintedReality
Just use a shockwave ability as the attack. Make a new shockwave ability and customize damage and the projectile. You'll probably want to lower the area of effect too, unless its a huge missile. Then just set the mana cost to 1.
10-20-2007, 11:27 PM#5
legend_tisman
<- NOT TESTED ->
Collapse JASS:
function Trig_Mana_Usage_Actions takes nothing returns nothing

    local unit u = GetAttacker()
    local player p = GetOwningPlayer(u)
    local integer i = GetConvertedPlayerId(p)

    if  GetUnitStateSwap(UNIT_STATE_MANA, u) == 0 then
        call IssueImmediateOrder(u,"holdposition")
        set u = null
        return
    else
        call SetUnitStateSwap(UNIT_STATE_MANA, u),GetUnitStateSwap(UNIT_STATE_MANA, u) - 1)
        set u = null
    endif
endfunction

//===========================================================================
function InitTrig_Mana_Usage takes nothing returns nothing
    set gg_trg_Mana_Usage = CreateTrigger(  )
    call TriggerAddAction( gg_trg_Mana_Usage, function Trig_Mana_Usage_Actions )
endfunction 
10-21-2007, 07:30 PM#6
Hydrolisk
What I don't understand is, how do you NOT know how to make such a simple "system." [Censor for a long time, here] Smart one. Not.

Both of the above will work fine, unless there's errors in the above.

The summary of the trigger you would use is below.

Whenever your unit attacks another, check if your unit has at least 1 mana. If it doesn't, order it to stop. If it DOES, then subtract 1 from its current mana.

Of course, my way might be a little laggy and may bug if you're using a fast attacking unit, or perhaps one with fast attack animations. Other than that, it's fine.
10-22-2007, 06:53 PM#7
Drek-ker
Yes but point out the trigger that says "Subtract" from the menu.
10-22-2007, 07:33 PM#8
Salbrismind
Quote:
Originally Posted by Drek-ker
Yes but point out the trigger that says "Subtract" from the menu.

Unit- Set Mana of [Unit] to [Unit's mana-1]
10-22-2007, 08:00 PM#9
Anopob
It's not really different from the above code, but if that doesn't work, try:

Collapse JASS:
function Trig_Mana_Attack_Conditions takes nothing returns boolean
    return GetUnitTypeId(GetAttacker()) == 'z001'
endfunction

function Trig_Mana_Attack_Actions takes nothing returns nothing
    local unit u = GetAttackedUnitBJ()
    local unit a = GetAttacker()
    local player p = GetOwningPlayer(a)
    local real life = GetUnitStateSwap(UNIT_STATE_LIFE, u)

    if GetUnitStateSwap(UNIT_STATE_MANA, a) == 0.00 then
        call IssueImmediateOrderBJ( a, "stop" )
    else
     if GetUnitStateSwap(UNIT_STATE_LIFE, u) < life then
    endif
        call SetUnitManaBJ( GetAttacker(), ( GetUnitStateSwap(UNIT_STATE_MANA, GetAttacker()) - 1 ) )
     endif

    set u = null
    set a = null
    set p = null
endfunction

//===========================================================================
function InitTrig_Mana_Attack takes nothing returns nothing
    set gg_trg_Mana_Attack = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Mana_Attack, EVENT_PLAYER_UNIT_ATTACKED )
    call TriggerAddCondition( gg_trg_Mana_Attack, Condition( function Trig_Mana_Attack_Conditions ) )
    call TriggerAddAction( gg_trg_Mana_Attack, function Trig_Mana_Attack_Actions )
endfunction