Need help with a few triggers

RodyisGod

New Member
Reaction score
5
Ye i know, me again. Theres for some reason always a little thing that i do wrong "S

1. This is a Very Long jass Trigger [ Custom Attributes ].
I have all the objects, and raw codes set good.
But it doesnt seem to work..

JASS:
globals  
//Config. Options\\     
    // Attribute(Attribute System) ability rawcode
    private constant integer AS_Abil = 'A00B'
    // Blank item rawcode 
    private constant integer AS_Blank = 'I003'
    // Cancel item rawcode
    private constant integer AS_Cancel = 'I004'
    // Number of stat points remaining item rawcode
    private constant integer AS_Att = 'I008'
    // Increment Strength item rawcode
    private constant integer AS_Str = 'I007'
    // Increment Agility item rawcode
    private constant integer AS_Agi = 'I006'
    // Increment Intelligence item rawcode
    private constant integer AS_Int = 'I005'   

//Do not touch past here unless you pain for death!!\\
    private item array AS_I0
    private item array AS_I1
    private item array AS_I2
    private item array AS_I3
    private item array AS_I4
    private item array AS_I5
    private item array AS_IAtt0
    private item array AS_IAtt1
    private item array AS_IAtt2
    private item array AS_IAtt3
    private item array AS_IAtt4
    private item array AS_IAtt5
    
    private integer array AS_PointsPerLevel
    private integer array AS_LastLevel
    private integer array AS_Points
    private boolean array AS_Enabled    
    private boolean array AS_On
    
    private unit AS_Hero
endglobals


//**Library of functions**\\

//Enable system for hero
function AS_Enable takes unit u, integer i returns nothing
    local integer id = GetPlayerId(GetOwningPlayer(u))
    
    if AS_Enabled[id] then
        call BJDebugMsg("Error: "+GetPlayerName(GetOwningPlayer(u))+" already has the system running.")
        return
    endif
    
    set AS_I0[id] = CreateItem(AS_Str,0,0)
    call SetItemVisible(AS_I0[id],false)
    
    set AS_I1[id] = CreateItem(AS_Att,0,0)
    call SetItemVisible(AS_I1[id],false)
    
    set AS_I2[id] = CreateItem(AS_Agi,0,0)
    call SetItemVisible(AS_I2[id],false)
    
    set AS_I3[id] = CreateItem(AS_Blank,0,0)
    call SetItemVisible(AS_I3[id],false)
    
    set AS_I4[id] = CreateItem(AS_Int,0,0)
    call SetItemVisible(AS_I4[id],false)
    
    set AS_I5[id] = CreateItem(AS_Cancel,0,0)
    call SetItemVisible(AS_I5[id],false)
    call SetItemDroppable(AS_I5[id],false)
    
    set AS_LastLevel[id] = GetHeroLevel(u)
    set AS_Enabled[id] = true
    set AS_PointsPerLevel[id] = 7
endfunction

//When the hero levels up
private function AS_Level takes unit u returns nothing
    local integer points
    local integer id = GetPlayerId(GetOwningPlayer(u))
    
    if AS_Enabled[id]==true then
        set points = ((GetHeroLevel(u)-AS_LastLevel[id])*AS_PointsPerLevel[id])+AS_Points[id]
        set AS_LastLevel[id] = GetHeroLevel(u)
        if GetUnitAbilityLevel(u,AS_Abil)<1 and AS_On[id]==false then
            call UnitAddAbility(u,AS_Abil) 
            call UnitMakeAbilityPermanent(u,true,AS_Abil)
        endif
        if AS_On[id]==true then
            call SetItemCharges(AS_I1[id],points)
        endif
        set AS_Points[id] = points
        call IssueImmediateOrder(u,"replenishon") 
    endif  
endfunction

//Swap the inventory
private function AS_SwapInv takes unit u, integer whichway returns nothing
    local integer id = GetPlayerId(GetOwningPlayer(u))
    local item it
    
    if whichway==1 then
        set AS_IAtt0[id] = UnitRemoveItemFromSlot(u,0)
        call SetItemVisible(AS_IAtt0[id],false)
        call SetItemVisible(AS_I0[id],true)
        call UnitAddItem(u,AS_I0[id])
        
        set AS_IAtt1[id] = UnitRemoveItemFromSlot(u,1)
        call SetItemVisible(AS_IAtt1[id],false)
        call SetItemCharges(AS_I1[id],AS_Points[id])
        call SetItemVisible(AS_I1[id],true)
        call UnitAddItem(u,AS_I1[id])
        
        set AS_IAtt2[id] = UnitRemoveItemFromSlot(u,2)
        call SetItemVisible(AS_IAtt2[id],false)
        call SetItemVisible(AS_I2[id],true)
        call UnitAddItem(u,AS_I2[id])
        
        set AS_IAtt3[id] = UnitRemoveItemFromSlot(u,3)
        call SetItemVisible(AS_IAtt3[id],false)
        call SetItemVisible(AS_I3[id],true)
        call UnitAddItem(u,AS_I3[id])
        
        set AS_IAtt4[id] = UnitRemoveItemFromSlot(u,4)
        call SetItemVisible(AS_IAtt4[id],false)
        call SetItemVisible(AS_I4[id],true)
        call UnitAddItem(u,AS_I4[id])
        
        set AS_IAtt5[id] = UnitRemoveItemFromSlot(u,5)
        call SetItemVisible(AS_IAtt5[id],false)
        call SetItemVisible(AS_I5[id],true)
        call UnitAddItem(u,AS_I5[id])
        
        set AS_On[id] = true
    else
        set it = UnitRemoveItemFromSlot(u,0)
        call SetItemVisible(it,false)
        call SetItemVisible(AS_IAtt0[id],true)
        call UnitAddItem(u,AS_IAtt0[id])
        
        set it = UnitRemoveItemFromSlot(u,1)
        call SetItemVisible(it,false)
        call SetItemVisible(AS_IAtt1[id],true)
        call UnitAddItem(u,AS_IAtt1[id])
        
        set it = UnitRemoveItemFromSlot(u,2)
        call SetItemVisible(it,false)
        call SetItemVisible(AS_IAtt2[id],true)
        call UnitAddItem(u,AS_IAtt2[id])
        
        set it = UnitRemoveItemFromSlot(u,3)
        call SetItemVisible(it,false)
        call SetItemVisible(AS_IAtt3[id],true)
        call UnitAddItem(u,AS_IAtt3[id])
        
        set it = UnitRemoveItemFromSlot(u,4)
        call SetItemVisible(it,false)
        call SetItemVisible(AS_IAtt4[id],true)
        call UnitAddItem(u,AS_IAtt4[id])
        
        set it = UnitRemoveItemFromSlot(u,5)
        call SetItemVisible(it,false)
        call SetItemVisible(AS_IAtt5[id],true)
        call UnitAddItem(u,AS_IAtt5[id])
        
        set AS_On[id] = false
    endif    
    
    set it = null
endfunction

//Returns what slot the item is in
private function AS_GetItemSlot takes unit hero, item it returns integer
    local integer i = 0
	
    loop
        exitwhen i==6
        if UnitItemInSlot(hero,i)==it then
            return i
        endif
        set i = i + 1
    endloop
	
    return -1
endfunction

//**Working Functions**\\

//Add attribute option when the hero levels
private function AS_level_Actions takes nothing returns nothing
    call AS_Level(GetTriggerUnit())
endfunction

//Swap inventory for the hero when needed
private function AS_TRO_Child takes nothing returns nothing
    call IssueImmediateOrder(AS_Hero,"replenishon")
    call IssueImmediateOrder(AS_Hero,"replenishlifeoff")
    
    call ReleaseTimer(GetExpiredTimer() )
endfunction
private function AS_TRO takes unit hero returns nothing
    set AS_Hero = hero
    call TimerStart(NewTimer(),0.,false,function AS_TRO_Child)
endfunction 
private function AS_inven_Actions takes nothing returns nothing
    local unit hero = GetTriggerUnit()
    local integer order = GetIssuedOrderId()
    local integer temp = 0
    
    if not IsUnitType(hero,UNIT_TYPE_HERO) then
        set hero = null
        return
    endif
    if order==OrderId("replenish") then
        call UnitRemoveAbility(hero,AS_Abil)
        call AS_SwapInv(hero,1)
    elseif order==OrderId("replenishoff") then
        call AS_TRO(hero)
    endif 
	
    set hero = null
endfunction

//Add attributes when selected
private function AS_att_Actions takes nothing returns nothing
    local unit hero = GetManipulatingUnit()
    local item used = GetManipulatedItem()
    local integer id = GetPlayerId(GetOwningPlayer(hero))
    local integer array temp
	
    if not AS_On[id] then
        set hero = null
        set used = null
        return
    endif
    set temp[0] = AS_GetItemSlot(hero,used)
    set temp[1] = AS_Points[id]-1
    if temp[0]!=5 or temp[1]<0 then
        call ModifyHeroStat( temp[0]/2,hero,bj_MODIFYMETHOD_ADD,1)
        set AS_Points[id] = temp[1]
        call SetItemCharges(AS_I1[id],temp[1])
        if temp[1]==0 then
            call AS_SwapInv(hero,0)
        endif
    elseif temp[1]>=0 then
        call AS_SwapInv(hero,0)
        call UnitAddAbility(hero,AS_Abil)
        call UnitMakeAbilityPermanent(hero,true,AS_Abil)
        call IssueImmediateOrder(hero,"replenishon")
    else
        call AS_SwapInv(hero,0)
    endif
	
    set hero = null
    set used = null
endfunction

//===========================================================================
private function Init_AttributeSystem takes nothing returns nothing
    local trigger level = CreateTrigger() 
    local trigger inven = CreateTrigger() 
    local trigger att = CreateTrigger()     
    
    call TriggerRegisterAnyUnitEventBJ(level, EVENT_PLAYER_HERO_LEVEL )
    call TriggerAddAction( level, function AS_level_Actions )
    
    call TriggerRegisterAnyUnitEventBJ( inven, EVENT_PLAYER_UNIT_ISSUED_ORDER )
    call TriggerRegisterAnyUnitEventBJ( inven, EVENT_PLAYER_UNIT_ISSUED_TARGET_ORDER )
    call TriggerRegisterAnyUnitEventBJ( inven, EVENT_PLAYER_UNIT_ISSUED_POINT_ORDER )
    call TriggerAddAction( inven, function AS_inven_Actions )
    
    call TriggerRegisterAnyUnitEventBJ( att, EVENT_PLAYER_UNIT_USE_ITEM )
    call TriggerAddAction( att, function AS_att_Actions )
endfunction   

endlibrary


2. This Random Weather system lags every 60 seconds it changes weather.
Anyway too fix the lag?

Trigger:
  • Weather
    • Events
      • Time - Every 60.00 seconds of game time
    • Conditions
    • Actions
      • Environment - Remove (Last created weather effect)
      • Wait 10.00 seconds
      • Set Random_Weather = (Random integer number between 1 and 7)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Random_Weather Equal to 1
        • Then - Actions
          • Environment - Create at (Playable map area) the weather effect Ashenvale Rain (Heavy)
          • Environment - Turn (Last created weather effect) On
          • Game - Display to (All players) the text: Random Weather is: ...
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Random_Weather Equal to 2
            • Then - Actions
              • Environment - Create at (Playable map area) the weather effect Ashenvale Rain (Light)
              • Environment - Turn (Last created weather effect) On
              • Game - Display to (All players) the text: Random Weather is: ...
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Random_Weather Equal to 3
                • Then - Actions
                  • Environment - Create at (Playable map area) the weather effect Northrend Blizzard
                  • Environment - Turn (Last created weather effect) On
                  • Game - Display to (All players) the text: Random Weather is: ...
                • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • Random_Weather Equal to 4
                    • Then - Actions
                      • Environment - Create at (Playable map area) the weather effect Wind (Heavy)
                      • Environment - Turn (Last created weather effect) On
                      • Game - Display to (All players) the text: Random Weather is: ...
                    • Else - Actions
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • Random_Weather Equal to 5
                        • Then - Actions
                          • Environment - Create at (Playable map area) the weather effect Rays Of Light
                          • Environment - Turn (Last created weather effect) On
                          • Game - Display to (All players) the text: Random Weather is: ...
                        • Else - Actions
                          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            • If - Conditions
                              • Random_Weather Equal to 6
                            • Then - Actions
                              • Environment - Create at (Playable map area) the weather effect Northrend Snow (Heavy)
                              • Environment - Turn (Last created weather effect) On
                              • Game - Display to (All players) the text: Random Weather is: ...
                            • Else - Actions
                              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                • If - Conditions
                                  • Random_Weather Equal to 7
                                • Then - Actions
                                  • Environment - Create at (Playable map area) the weather effect Northrend Snow (Light)
                                  • Environment - Turn (Last created weather effect) On
                                  • Game - Display to (All players) the text: Random Weather is: ...
                                • Else - Actions


3.This small Gui-Trigger doesnt stop players from attacking allies.
Trigger:
  • Block Friendly Attacking
    • Events
      • Unit - A unit owned by Player 1 (Red) Is attacked
      • Unit - A unit owned by Player 2 (Blue) Is attacked
      • Unit - A unit owned by Player 3 (Teal) Is attacked
      • Unit - A unit owned by Player 4 (Purple) Is attacked
      • Unit - A unit owned by Player 5 (Yellow) Is attacked
      • Unit - A unit owned by Player 6 (Orange) Is attacked
      • Unit - A unit owned by Player 7 (Green) Is attacked
      • Unit - A unit owned by Player 8 (Pink) Is attacked
      • Unit - A unit owned by Player 9 (Gray) Is attacked
    • Conditions
      • Or - Any (Conditions) are true
        • Conditions
      • ((Attacking unit) is in (Units owned by Player 1 (Red))) Equal to True
      • ((Attacking unit) is in (Units owned by Player 2 (Blue))) Equal to True
      • ((Attacking unit) is in (Units owned by Player 3 (Teal))) Equal to True
      • ((Attacking unit) is in (Units owned by Player 4 (Purple))) Equal to True
      • ((Attacking unit) is in (Units owned by Player 5 (Yellow))) Equal to True
      • ((Attacking unit) is in (Units owned by Player 6 (Orange))) Equal to True
      • ((Attacking unit) is in (Units owned by Player 7 (Green))) Equal to True
      • ((Attacking unit) is in (Units owned by Player 8 (Pink))) Equal to True
    • Actions
      • Unit - Order (Attacking unit) to Stop


4.Same for this one it doesnt stop attacking, Items.
Trigger:
  • Block Item Attacking
    • Events
      • Unit - A unit Is issued an order targeting an object
    • Conditions
      • (Issued order) Equal to (Order(Attack))
      • ((Target item of issued order) is in (Playable map area)) Equal to True
    • Actions
      • Game - Display to Player Group - Player 1 (Red) the text: Sad.. Trying to att...
      • Game - Display to Player Group - Player 2 (Blue) the text: Sad.. Trying to att...
      • Game - Display to Player Group - Player 3 (Teal) the text: Sad.. Trying to att...
      • Game - Display to Player Group - Player 4 (Purple) the text: Sad.. Trying to att...
      • Game - Display to Player Group - Player 5 (Yellow) the text: Sad.. Trying to att...
      • Game - Display to Player Group - Player 6 (Orange) the text: Sad.. Trying to att...
      • Game - Display to Player Group - Player 7 (Green) the text: Sad.. Trying to att...
      • Game - Display to Player Group - Player 8 (Pink) the text: Sad.. Trying to att...
      • Unit - Order (Attacking unit) to Stop


I KNOW this can be hard to do for a random person you dont know.
but uhmm.. Thanks ++, for the ones trying or giving me the fix.
 
General chit-chat
Help Users
  • Monovertex Monovertex:
    How are you all? :D
    +1
  • Ghan Ghan:
    Howdy
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top