• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

Trigger Fix

Status
Not open for further replies.
Level 10
Joined
Mar 19, 2010
Messages
622
I've created an Item System for my map. Can anyone who is good at trigger help me on improving this system?

System Info:
Sys Name: Item Type & Level Sys
MUI/MPI?: MPI
Sys Description:
Description
Seperate items into Boots, Glove, Helm, Chest(Armor), Mainhand and Offhand. Every player can have max one unit using this system.
Each unit cannot have more then one of each type of item. Main hand are mainly weapons. Weapons are also categorized into 2 types, One-handed, which you can have one of this with an offhand item; Two-handed, which you cannot wear an offhand item with this type of item. Item Level part makes item shows it's item level on their charge(I've done this in object editor) and hero cannot use a item which has a higher item level then the hero's level.
Credits: -Flood- cuz I'm making a much much more simple ver of his Item sys with some change made to fit it in my map.(I felt that wanna try to create a sys my self so I decided to created this. Not to say that -Flood-'s sys is bad)
Triggers:
  • Item Type Configuration
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set IS_Boots = Charged
      • Set IS_Chest = Permanent
      • Set IS_Glove = Purchasable
      • Set IS_Helmet = Campaign
      • Set IS_MainHand = Powerup
      • Set IS_OffHand = Artifact
  • Level Limitation
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • ((Triggering unit) is A Hero) Equal to True
      • (Charges remaining in (Item being manipulated)) Greater than (Hero level of (Triggering unit))
    • Actions
      • Set IS_IL_PG[(Player number of (Owner of (Triggering unit)))] = (Player group((Owner of (Triggering unit))))
      • Hero - Drop (Item being manipulated) from (Triggering unit)
      • Game - Display to IS_IL_PG[(Player number of (Owner of (Triggering unit)))] the text: (Your Hero doesn't meet the level requirement of + ((Name of (Item being manipulated)) + (. It require + ((String((Item level of (Item being manipulated)))) + level to being able to aqire it.|r))))
      • Custom script: call DestroyForce(udg_IS_IL_PG)
  • Pick Boots
    • Events
      • Unit - A unit Is issued an order targeting an object
    • Conditions
      • And - All (Conditions) are true
        • Conditions
          • ((Triggering unit) is A Hero) Equal to True
          • (Item-class of (Target item of issued order)) Equal to IS_Boots
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • IS_BootsEqp[(Player number of (Owner of (Triggering unit)))] Equal to False
        • Then - Actions
          • Set IS_BootsEqp[(Player number of (Owner of (Triggering unit)))] = True
          • Item - Remove (Item carried by (Triggering unit) of type |cff808080Boots|r)
          • Hero - Give (Item being manipulated) to (Triggering unit)
        • Else - Actions
          • Unit - Order (Triggering unit) to Stop
          • Game - Display to (Player group((Owner of (Triggering unit)))) the text: You cannot have ite...
  • Drop Boots
    • Events
      • Unit - A unit Loses an item
    • Conditions
      • And - All (Conditions) are true
        • Conditions
          • ((Triggering unit) is A Hero) Equal to True
          • (Item-class of (Item being manipulated)) Equal to IS_Boots
    • Actions
      • Set IS_BootsEqp[(Player number of (Owner of (Triggering unit)))] = False
      • Hero - Create |cff808080Boots|r and give it to (Triggering unit)
  • Pick MH
    • Events
      • Unit - A unit Is issued an order targeting an object
    • Conditions
      • And - All (Conditions) are true
        • Conditions
          • ((Triggering unit) is A Hero) Equal to True
          • (Item-class of (Target item of issued order)) Equal to IS_MainHand
    • Actions
      • Set IS_IL_PG[(Player number of (Owner of (Triggering unit)))] = (Player group((Owner of (Triggering unit))))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • IS_MainHandEqp[(Player number of (Owner of (Triggering unit)))] Equal to False
        • Then - Actions
          • Set IS_MainHandEqp[(Player number of (Owner of (Triggering unit)))] = True
          • Item - Remove (Item carried by (Triggering unit) of type |cff808080MainHand|r)
          • Hero - Give (Item being manipulated) to (Triggering unit)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Item level of (Item being manipulated)) Equal to 2
            • Then - Actions
              • Set IS_THEqp = True
              • Hero - Drop the item from slot 4 of (Triggering unit)
              • Hero - Create |cff808080Dual Welding|r and give it to (Triggering unit)
            • Else - Actions
          • Custom script: call DestroyForce(udg_IS_IL_PG)
        • Else - Actions
          • Unit - Order (Triggering unit) to Stop
          • Game - Display to IS_IL_PG[(Player number of (Owner of (Triggering unit)))] the text: You cannot have mor...
          • Custom script: call DestroyForce(udg_IS_IL_PG)
DropMH
Events
Unit - A unit Loses an item
Conditions
((Triggering unit) is A Hero) Equal to True
(Item-class of (Item being manipulated)) Equal to IS_MainHand
Actions
Set IS_MainHandEqp[(Player number of (Owner of (Triggering unit)))] = False
Hero - Create |cff808080MainHand|r and give it to (Triggering unit)
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Item level of (Item being manipulated)) Equal to 2
Then - Actions
Set IS_THEqp = False
Hero - Drop the item from slot 4 of (Triggering unit)
Item - Remove (Last dropped item)
Hero - Create |cff808080Offhand|r and give it to (Triggering unit)
Else - Actions


Note: The Drop n Pick Trigger I've made one for every item type, chaging some part so I don't think I need to post all of them but if needed, please tell me so I'ill post it.
 
Last edited:
Level 37
Joined
Mar 6, 2006
Messages
9,240
  • Item Level Limitation
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • And - All (Conditions) are true
        • Conditions
          • ((Triggering unit) is A Hero) Equal to True
          • (Charges remaining in (Item being manipulated)) Greater than (Hero level of (Triggering unit))
    • Actions
      • Hero - Drop (Item being manipulated) from (Triggering unit)
      • Game - Display to (Player group((Owner of (Triggering unit)))) the text: (Your Hero doesn't meet the level requirement of + ((Name of (Item being manipulated)) + (. It require + ((String((Item level of (Item being manipulated)))) + level to being able to aqire it.|r))))

You leak player groups.

This
  • Conditions
    • ((Triggering unit) is A structure) Equal to True
    • ((Triggering unit) is A structure) Equal to True
works the same as this
  • Conditions
    • And - All (Conditions) are true
      • Conditions
        • ((Triggering unit) is A structure) Equal to True
        • ((Triggering unit) is A Hero) Equal to True
The first one generates less code, and is therefore better.
 
Level 37
Joined
Mar 6, 2006
Messages
9,240
  • Game - Display to (Player group(Player 1 (Red))) the text: I is teh leak
->
JASS:
call DisplayTextToForce( GetForceOfPlayer(Player(0)), "TRIGSTR_075" )

and...

JASS:
function GetForceOfPlayer takes player whichPlayer returns force
    local force f = CreateForce()
    call ForceAddPlayer(f, whichPlayer)
    return f
endfunction

f leaks.
 
Status
Not open for further replies.
Top