| 12-29-2006, 10:22 PM | #1 |
I was trying to do this with GUI but I think it's impossible without more than 1 trigger and some global variables and confusing crap, so here it is in JASS: JASS:function Trig_Shooting_Pistols_JASS_Func002Func004C takes nothing returns boolean if ( not ( udg_Pistol_Ammo[GetConvertedPlayerId(GetOwningPlayer(GetSpellAbilityUnit()))] <= 0 ) ) then return false endif return true endfunction function Trig_Shooting_Pistols_JASS_Func002Func007C takes nothing returns boolean if ( ( GetPlayerState(GetOwningPlayer(GetSpellAbilityUnit()), PLAYER_STATE_RESOURCE_GOLD) <= GetRandomInt(60, 75) ) ) then return true endif if ( ( GetPlayerState(GetOwningPlayer(GetSpellAbilityUnit()), PLAYER_STATE_RESOURCE_GOLD) <= 76 ) ) then return true endif return false endfunction function Trig_Shooting_Pistols_JASS_Func002C takes nothing returns boolean if ( not ( GetSpellAbilityId() == 'A01Y' ) ) then return false endif if ( not ( udg_Pistol_Ammo[GetConvertedPlayerId(GetOwningPlayer(GetSpellAbilityUnit()))] > 0 ) ) then return false endif if ( not Trig_Shooting_Pistols_JASS_Func002Func007C() ) then return false endif return true endfunction function Trig_Shooting_Pistols_JASS_Actions takes nothing returns nothing local unit u if ( Trig_Shooting_Pistols_JASS_Func002C() ) then set udg_Pistol_Ammo[GetConvertedPlayerId(GetOwningPlayer(GetSpellAbilityUnit()))] = ( udg_Pistol_Ammo[GetConvertedPlayerId(GetOwningPlayer(GetSpellAbilityUnit()))] - 1 ) call AdjustPlayerStateBJ( GetRandomInt(1, 8), GetOwningPlayer(GetSpellAbilityUnit()), PLAYER_STATE_RESOURCE_GOLD ) call TriggerSleepAction( 0.10 ) if ( Trig_Shooting_Pistols_JASS_Func002Func004C() ) then set u=GetSpellAbilityUnit() set udg_Player_Pistol_Reloading[GetConvertedPlayerId(GetOwningPlayer((u)))] = true call AdjustPlayerStateBJ( -5, GetOwningPlayer((u)), PLAYER_STATE_RESOURCE_LUMBER ) call UnitRemoveAbilityBJ( 'A01Y', (u) ) call PlaySoundOnUnitBJ( gg_snd_colt_clipout_C, 100, (u) ) call PolledWait( 2.00 ) call PlaySoundOnUnitBJ( gg_snd_colt_clipin_C, 100, (u) ) call PolledWait( 0.50 ) set udg_Pistol_Ammo[GetConvertedPlayerId(GetOwningPlayer((u)))] = 5 call UnitAddAbilityBJ( 'A01Y', (u) ) set udg_Player_Pistol_Reloading[GetConvertedPlayerId(GetOwningPlayer((u)))] = false else call IssueImmediateOrderBJ( GetSpellAbilityUnit(), "stop" ) endif else endif endfunction //=========================================================================== function InitTrig_Shooting_Pistols_JASS takes nothing returns nothing set gg_trg_Shooting_Pistols_JASS = CreateTrigger( ) call TriggerRegisterAnyUnitEventBJ( gg_trg_Shooting_Pistols_JASS, EVENT_PLAYER_UNIT_SPELL_CHANNEL ) call TriggerAddAction( gg_trg_Shooting_Pistols_JASS, function Trig_Shooting_Pistols_JASS_Actions ) endfunction |
| 12-29-2006, 11:39 PM | #2 |
1st of all, for your conditions, I don't think you need tons of those if's. I learnt that you can just use return [condition here] and it should work. Also, at the end of Trig_Shooting_Pistols_JASS_Actions, do set u = null
And I'll see if I can find anything else. EDIT: It works and you just want to get help for the leaks, right? |
| 12-29-2006, 11:57 PM | #3 | |
Quote:
I'll get to work on that stuff soon, thanks. |
