Detect more than 1 type weapon

Status
Not open for further replies.
Level 18
Joined
Jun 2, 2009
Messages
1,193
Hello everyone. I am trying to create weapon and armor system and it is extremely confusing to me. I have a resource named "JFA Orpg" and i have the system but it is Jass, my friend created it for me and i cannot implement it into my new map.

Anyway, here is the scenario. In my map i have only 2 armor and 2 weapons. I have created system like this.

  • SilahVar
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • ((Triggering unit) is in SilahGrubu) Equal to False
      • Or - Any (Conditions) are true
        • Conditions
          • (Item-type of (Item being manipulated)) Equal to IRON SWORD
          • (Item-type of (Item being manipulated)) Equal to IRON SWORD FAKE VERSION
          • (Item-type of (Item being manipulated)) Equal to STONE CLAW
          • (Item-type of (Item being manipulated)) Equal to STONE CLAW FAKE VERSION
    • Actions
      • Unit Group - Add (Triggering unit) to SilahGrubu
When unit picks an item, simply joins it to SilahGrubu




And in the opposite, this trigger removes unit from unit group when drops its weapon

  • SilahYok
    • Events
      • Unit - A unit Loses an item
    • Conditions
      • ((Triggering unit) is in SilahGrubu) Equal to True
      • Or - Any (Conditions) are true
        • Conditions
          • (Item-type of (Item being manipulated)) Equal to IRON SWORD
          • (Item-type of (Item being manipulated)) Equal to IRON SWORD FAKE VERSION
          • (Item-type of (Item being manipulated)) Equal to STONE CLAW
          • (Item-type of (Item being manipulated)) Equal to STONE CLAW FAKE VERSION
    • Actions
      • Unit Group - Remove (Triggering unit) from SilahGrubu

And this trigger detects if unit has a weapon. If unit within SilahGrubu group, that means it has weapon, so drop the weapon.

  • No2Silah
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • ((Triggering unit) is in SilahGrubu) Equal to True
      • Or - Any (Conditions) are true
        • Conditions
          • (Item-type of (Item being manipulated)) Equal to IRON SWORD
          • (Item-type of (Item being manipulated)) Equal to IRON SWORD FAKE VERSION
          • (Item-type of (Item being manipulated)) Equal to STONE CLAW
          • (Item-type of (Item being manipulated)) Equal to STONE CLAW FAKE VERSION
    • Actions
      • Hero - Drop (Item being manipulated) from (Triggering unit)
Our unit have the Bear Form ability. We can change the unit to Peasant or Warrior. This is why i have created fake versions of weapons. When unit enters Warrior form, i want to give it to REAL version of the weapon. But if it transforms into Peasant, i want to remove weapon and give it to FAKE version.

  • SilahGercegiKopyasi
    • Events
      • Unit - A unit Acquires an item
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Item-type of (Item being manipulated)) Equal to STONE CLAW FAKE VERSION
          • (Unit-type of (Triggering unit)) Equal to Savasci
        • Then - Actions
          • Item - Remove (Item carried by (Triggering unit) of type STONE CLAW FAKE VERSION)
          • Hero - Create STONE CLAW and give it to (Triggering unit)
          • Unit Group - Add (Triggering unit) to SilahGrubu
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Item-type of (Item being manipulated)) Equal to IRON SWORD FAKE VERSION
              • (Unit-type of (Triggering unit)) Equal to Savasci
            • Then - Actions
              • Hero - Drop (Item carried by (Triggering unit) of type Create IRON SWORD FAKE VERSION) from (Triggering unit)
              • Hero - Create IRON SWORD and give it to (Triggering unit)
              • Unit Group - Add (Triggering unit) to SilahGrubu
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Item-type of (Item being manipulated)) Equal to STONE CLAW
                  • (Unit-type of (Triggering unit)) Equal to Toplayici
                • Then - Actions
                  • Item - Remove (Item carried by (Triggering unit) of type STONE CLAW)
                  • Hero - Create STONE CLAW FAKE VERSION and give it to (Triggering unit)
                  • Unit Group - Add (Triggering unit) to SilahGrubu
                • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Unit-type of (Triggering unit)) Equal to Toplayici
                      • (Item-type of (Item being manipulated)) Equal to IRON SWORD
                    • Then - Actions
                      • Hero - Drop (Item carried by (Triggering unit) of type Demir Kilic) from (Triggering unit)
                      • Hero - Create IRON SWORD FAKE VERSION and give it to (Triggering unit)
                      • Unit Group - Add (Triggering unit) to SilahGrubu
                    • Else - Actions
                      • Do nothing
And this trigger checks the form of the unit.

  • KarakterDonusumSilah
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to WARRIOR/PEASANT TRANSFORM
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Savasci[(Player number of (Owner of (Triggering unit)))] Equal to False
          • ((Triggering unit) has an item of type Tas Pence (toplayici modu)) Equal to True
        • Then - Actions
          • Set Savasci[(Player number of (Owner of (Triggering unit)))] = True
          • Item - Remove (Item carried by (Triggering unit) of type STONE CLAW FAKE VERSION)
          • Hero - Create STONE CLAW and give it to (Triggering unit)
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Savasci[(Player number of (Owner of (Triggering unit)))] Equal to True
              • ((Triggering unit) has an item of type STONE CLAW) Equal to True
            • Then - Actions
              • Set Savasci[(Player number of (Owner of (Triggering unit)))] = False
              • Item - Remove (Item carried by (Triggering unit) of type STONE CLAW)
              • Unit Group - Remove (Triggering unit) from SilahGrubu
              • Hero - Create STONE CLAW FAKE VERSION and give it to (Triggering unit)
              • Unit Group - Add (Triggering unit) to SilahGrubu
            • Else - Actions
I know it is not the proper way to do that. How to make it work properly? You can suggest different way to do that..
 
Level 23
Joined
Feb 27, 2019
Messages
727
I have a suggestion. It uses Player Number as Index but I am pretty sure it can be used with Unit Index as well. You can add new sets of weapons by copy paste one of the Acquire triggers and also adding the new items to the Lose trigger.

  • Iron Sword Acquire
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • Or - Any (Conditions) are true
        • Conditions
          • (Item-type of (Item being manipulated)) Equal to IRON SWORD FAKE VERSION
          • (Item-type of (Item being manipulated)) Equal to IRON SWORD
      • ZzzTrigs Equal to False
    • Actions
      • Set VariableSet ZzzTrigs = True
      • Set VariableSet Int = (Player number of (Triggering player))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ItemType[Int] Equal to (Item-type of No item)
        • Then - Actions
          • -------- Doesnt have Weapon --------
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • IsBear[Int] Equal to False
            • Then - Actions
              • -------- Isnt Bear --------
              • Set VariableSet ItemType[Int] = IRON SWORD FAKE VERSION
            • Else - Actions
              • -------- Is Bear --------
              • Set VariableSet ItemType[Int] = IRON SWORD
          • Item - Remove (Item being manipulated)
          • Hero - Create ItemType[Int] and give it to (Triggering unit)
        • Else - Actions
          • -------- Has Weapon --------
          • Set VariableSet TempPoint = (Position of (Triggering unit))
          • Item - Move (Item being manipulated) to TempPoint
          • Custom script: call RemoveLocation(udg_TempPoint)
      • Set VariableSet ZzzTrigs = False
  • Stone Claw Acquire
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • Or - Any (Conditions) are true
        • Conditions
          • (Item-type of (Item being manipulated)) Equal to STONE CLAW FAKE VERSION
          • (Item-type of (Item being manipulated)) Equal to STONE CLAW
      • ZzzTrigs Equal to False
    • Actions
      • Set VariableSet ZzzTrigs = True
      • Set VariableSet Int = (Player number of (Triggering player))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ItemType[Int] Equal to (Item-type of No item)
        • Then - Actions
          • -------- Doesnt have Weapon --------
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • IsBear[Int] Equal to False
            • Then - Actions
              • -------- Isnt Bear --------
              • Set VariableSet ItemType[Int] = STONE CLAW FAKE VERSION
            • Else - Actions
              • -------- Is Bear --------
              • Set VariableSet ItemType[Int] = STONE CLAW
          • Item - Remove (Item being manipulated)
          • Hero - Create ItemType[Int] and give it to (Triggering unit)
        • Else - Actions
          • -------- Has Weapon --------
          • Set VariableSet TempPoint = (Position of (Triggering unit))
          • Item - Move (Item being manipulated) to TempPoint
          • Custom script: call RemoveLocation(udg_TempPoint)
      • Set VariableSet ZzzTrigs = False
  • Weapon Lose
    • Events
      • Unit - A unit Loses an item
    • Conditions
      • Or - Any (Conditions) are true
        • Conditions
          • (Item-type of (Item being manipulated)) Equal to IRON SWORD FAKE VERSION
          • (Item-type of (Item being manipulated)) Equal to IRON SWORD
          • (Item-type of (Item being manipulated)) Equal to STONE CLAW FAKE VERSION
          • (Item-type of (Item being manipulated)) Equal to STONE CLAW
      • ZzzTrigs Equal to False
    • Actions
      • Set VariableSet ItemType[(Player number of (Triggering player))] = (Item-type of No item)
  • Cast Bear Form
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to WARRIOR/PEASANT TRANSFORM
    • Actions
      • Set VariableSet Int = (Player number of (Triggering player))
      • -------- Set IsBear = True/False --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • IsBear[Int] Equal to False
        • Then - Actions
          • Set VariableSet IsBear[Int] = True
        • Else - Actions
          • Set VariableSet IsBear[Int] = False
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ItemType[Int] Equal to (Item-type of No item)
        • Then - Actions
        • Else - Actions
          • -------- Replace Weapon --------
          • Set VariableSet TempItemType = ItemType[Int]
          • Item - Remove (Item carried by (Triggering unit) of type ItemType[Int])
          • Hero - Create TempItemType and give it to (Triggering unit)
 

Attachments

  • Weapon System.w3m
    20.3 KB · Views: 14

Uncle

Warcraft Moderator
Level 69
Joined
Aug 10, 2018
Messages
7,166
When you Drop the Item being manipulated you cause the "Lose Item" event to run, which runs the SilahYok trigger and removes the unit from SilahGrubu.

What you want to do is this when Dropping the extra item:
  • Trigger - Turn off SilahYok
  • Hero - Drop (Item being manipulated) from (Triggering unit)
  • Trigger - Turn on SilahYok

Now SilahYok won't run when the extra item is dropped. The unit still has a weapon so it'll remain in SilahGrubu as intended.

I'm not sure if there are other issues in your triggers.
 
Level 23
Joined
Feb 27, 2019
Messages
727
It seems when the unit is revived it will be revived as the version before the morph, unless it works differently with Heroes. There is also no default way to detect when a unit is revived, only Heroes as far as I can see. The item would then need to be refreshed upon revival.
 
Level 18
Joined
Jun 2, 2009
Messages
1,193
When you Drop the Item being manipulated you cause the "Lose Item" event to run, which runs the SilahYok trigger and removes the unit from SilahGrubu.

What you want to do is this when Dropping the extra item:
  • Trigger - Turn off SilahYok
  • Hero - Drop (Item being manipulated) from (Triggering unit)
  • Trigger - Turn on SilahYok

Now SilahYok won't run when the extra item is dropped. The unit still has a weapon so it'll remain in SilahGrubu as intended.

I'm not sure if there are other issues in your triggers.
Probably but [db]east's trigger worked perfectly

I have a suggestion. It uses Player Number as Index but I am pretty sure it can be used with Unit Index as well. You can add new sets of weapons by copy paste one of the Acquire triggers and also adding the new items to the Lose trigger.
Your trigger worked perfectly. Thank you SO much my friend!
 
Level 18
Joined
Jun 2, 2009
Messages
1,193
Hmm i have an extra question. This will be my template. What if it comes to Armors?
We don't have to give fake version or remove real version when it comes to armors.

I just want to detect unit wears armor or not. If wears. I think it will be simpler than our trigger.
 
Level 23
Joined
Feb 27, 2019
Messages
727
I see it as a challenge I have to beat. I have to make it as good as possible in GUI^^ just as I finished the other system I got an idea for a better one, but I will talk about it in the bottom.

Yes, that would be a lot simpler. You can add more items in the Conditions for these two triggers.

  • Ring Gold Acquire
    • Events
    • Conditions
      • (Item-type of (Item being manipulated)) Equal to Gold Ring
    • Actions
      • Set VariableSet Int = (Player number of (Triggering player))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • PigHasRing[Int] Equal to False
        • Then - Actions
          • Set VariableSet PigHasRing[Int] = True
        • Else - Actions
          • Trigger - Turn off Ring Gold Lose <gen>
          • Hero - Drop (Item being manipulated) from AllPigsArray[Int].
          • Trigger - Turn on Ring Gold Lose <gen>
  • Ring Gold Lose
    • Events
    • Conditions
      • (Item-type of (Item being manipulated)) Equal to Gold Ring
    • Actions
      • Set VariableSet Int = (Player number of (Triggering player))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • PigHasRing[Int] Equal to True
        • Then - Actions
          • Set VariableSet PigHasRing[Int] = False
        • Else - Actions

Turning off and on triggers works similarly to setting a boolean to true and then false. In the triggers in the previous post, if the ZzzTrigs boolean returns true it wont run the trigger actions but in contrast to turning off the trigger it will still check all the conditions. So turning off triggers and then on appears better. In the new version i removed the boolean and added a custom script to call a function that turns off triggers and another one that turns them on. These functions are found in the Trigger Editor when clicking on the top map name text that has the map icon.

Talking about the previous triggers, here is a revive trigger that should remove issues when the morphed unit is revived. I added a system often used to swap inventory slot for items that have been replaced. The action "Unit - Order Unit to Move (Item) to inventory slot #" will interrupt the units current order. That is not an issue in this trigger since the unit has just revived.

  • Revive and Interupting Slot Swap
    • Events
      • Unit - A unit Finishes reviving
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Keeper of the Grove
    • Actions
      • Set VariableSet Int = (Player number of (Triggering player))
      • Set VariableSet IsBear[Int] = False
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ItemType[Int] Equal to (Item-type of No item)
        • Then - Actions
        • Else - Actions
          • Set VariableSet TempUnit = (Triggering unit)
          • For each (Integer ItemL) from 1 to 6, do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Item carried by TempUnit in slot ItemL) Equal to (Item carried by TempUnit of type ItemType[Int])
                • Then - Actions
                  • Set VariableSet TempItemType = ItemType[Int]
                  • Item - Remove (Item carried by TempUnit of type ItemType[Int])
                  • Hero - Create TempItemType and give it to TempUnit
                  • Unit - Order TempUnit to move (Last created item) to inventory slot ItemL.
                  • Custom script: exitwhen true
                • Else - Actions

and here is an updated version of the Cast Bear Form trigger with a system that swaps inventory slots but doesnt interrupt orders.

  • Cast Bear Form and Uninterupting Slot Swap
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to WARRIOR/PEASANT TRANSFORM
    • Actions
      • Set VariableSet Int = (Player number of (Triggering player))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • IsBear[Int] Equal to False
        • Then - Actions
          • Set VariableSet IsBear[Int] = True
        • Else - Actions
          • Set VariableSet IsBear[Int] = False
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ItemType[Int] Equal to (Item-type of No item)
        • Then - Actions
        • Else - Actions
          • Set VariableSet TempUnit = (Triggering unit)
          • For each (Integer ItemL) from 1 to 6, do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Item carried by TempUnit in slot ItemL) Equal to No item
                • Then - Actions
                  • Set VariableSet TempBool[ItemL] = True
                  • Hero - Create Cheese and give it to TempUnit
                • Else - Actions
          • Set VariableSet TempItemType = ItemType[Int]
          • Item - Remove (Item carried by TempUnit of type ItemType[Int])
          • Hero - Create TempItemType and give it to TempUnit
          • For each (Integer ItemL) from 1 to 6, do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • TempBool[ItemL] Equal to True
                • Then - Actions
                  • Set VariableSet TempBool[ItemL] = False
                  • Item - Remove (Item carried by TempUnit in slot ItemL)
                • Else - Actions

I was thinking that you may get rid of a lot of problems and code by just adding and removing/disabling an ability from the item, or unit, instead of two different items. That is dependent on how you are using the items in other triggers and such. What is the reason you want to change the weapon to another item? What is the difference between the real version and the fake version?
 

Attachments

  • WeaponSystem1.0.w3m
    22.1 KB · Views: 10
Last edited:
Status
Not open for further replies.
Top