[Simple] First JASS Code need help

R 3 T R O

New Member
Reaction score
12
Ok. I've got a pistol trigger i made in jass here are the 2 i created. My question is the 2nd one works better then the 1st one because if the player does not have the required amount of gold, then it will issue the unit to Hold Position causing the ability to stop, is there a way to combine
JASS:
return i=='A001' or i=='A02C'
and
JASS:
if udg_Rounds<i>&gt;=4 then</i>
so that if it returns false then it will do
JASS:
call IssueImmediateOrder(u,&quot;holdposition&quot;)
instead of me using this in the acaul action of the trigger
JASS:
    if udg_Rounds<i>&gt;=4 then
        call AttachSoundToUnit(gg_snd_Pistol,u)
        call SetSoundVolume(gg_snd_Pistol, 100)
        call StartSound(gg_snd_Pistol)
        set udg_Rounds<i> = udg_Rounds<i> - 3
        call SetPlayerState(p,PLAYER_STATE_RESOURCE_GOLD,udg_Rounds<i>)
    else
        call IssueImmediateOrder(u,&quot;holdposition&quot;)</i></i></i></i>





JASS:
function PistolFireConditions takes nothing returns boolean
    local integer i = GetSpellAbilityId()
    local player p = GetTriggerPlayer()
    local integer id = GetConvertedPlayerId(p)
    return udg_Rounds[id]&gt;=4 and i==&#039;A001&#039; or i==&#039;A02C&#039;
endfunction

function PistolFire takes nothing returns nothing
    local unit u = GetTriggerUnit()
    local player p = GetOwningPlayer(u)
    local integer i = GetConvertedPlayerId(p)
    call AttachSoundToUnit(gg_snd_Pistol,u)
    call SetSoundVolume(gg_snd_Pistol, 100)
    call StartSound(gg_snd_Pistol)
    set udg_Rounds<i> = udg_Rounds<i> - 5
    call SetPlayerState(p,PLAYER_STATE_RESOURCE_GOLD,udg_Rounds<i>)
    set u = null
endfunction

//===========================================================================
function InitTrig_Pistol takes nothing returns nothing
    set gg_trg_Pistol = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Pistol, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition(gg_trg_Pistol,Condition(function PistolFireConditions))
    call TriggerAddAction(gg_trg_Pistol,function PistolFire)
endfunction</i></i></i>


and

JASS:
function PistolFireConditions takes nothing returns boolean
    local integer i = GetSpellAbilityId()
    local player p = GetTriggerPlayer()
    local integer id = GetConvertedPlayerId(p)
    return i==&#039;A001&#039; or i==&#039;A02C&#039;
endfunction

function PistolFire takes nothing returns nothing
    local unit u = GetTriggerUnit()
    local player p = GetOwningPlayer(u)
    local integer i = GetConvertedPlayerId(p)
    if udg_Rounds<i>&gt;=4 then
        call AttachSoundToUnit(gg_snd_Pistol,u)
        call SetSoundVolume(gg_snd_Pistol, 100)
        call StartSound(gg_snd_Pistol)
        set udg_Rounds<i> = udg_Rounds<i> - 3
        call SetPlayerState(p,PLAYER_STATE_RESOURCE_GOLD,udg_Rounds<i>)
    else
        call IssueImmediateOrder(u,&quot;holdposition&quot;)
    set u = null
endfunction

//===========================================================================
function InitTrig_Pistol takes nothing returns nothing
    set gg_trg_Pistol = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Pistol, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition(gg_trg_Pistol,Condition(function PistolFireConditions))
    call TriggerAddAction(gg_trg_Pistol,function PistolFire)
endfunction</i></i></i></i>
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top