[Trigger] Double Weapons Prevent?

Status
Not open for further replies.

ILH

ILH

Model Reviewer
Level 34
Joined
May 8, 2012
Messages
1,580
So I had been inactive for a long time that i forgot few things xd

Well i need some triggers (GUI) to prevent a unit having double weapons. This thing is also implemented in some RPG maps.

Example:

I have a peasant, and there was 2 weapons on the ground, lets call it weapon A and weapon B. I take weapon A, and then when i tried to pick the weapon B, it should be cancelled and weapon B will be dropped on the ground.

So the problem is, what's the trigger? :goblin_jawdrop:
I tried but it didnt worked :v
 

Chaosy

Tutorial Reviewer
Level 40
Joined
Jun 9, 2011
Messages
13,223
Firstly there are multiple systems in the spell section that does it for you. Even if you don't want to use them, you can study them and learn how they work.

I have not done such a system myself, but I have read about how they work somewhere.. I don't remember where. Basically you put all weapon items in the consumable category (for example) all helmets in the permanent section and so on.

Once you have done that you can simple check if the unit carries an item in the category X

The second option would be to manually store the item type of each item into a variable. (I would recommend hashtables for this) This is actually really simple but extremely boring copy and paste work.
 
  • Like
Reactions: ILH

ILH

ILH

Model Reviewer
Level 34
Joined
May 8, 2012
Messages
1,580
Yep, that's why the weapons i used was in Artifact category, and the others in another category.

I don't know how to check if the unit carries an item in the category X, i couldn't find the "Conditions" that suits for it
And yeah, I have tried the hashtable thing before posting this thread but it turned out that I got confused how the thing works...
 

Chaosy

Tutorial Reviewer
Level 40
Joined
Jun 9, 2011
Messages
13,223
try something like this:
  • Actions
    • Set check = False
    • For each (Integer A) from 1 to 6, do (Actions)
      • Loop - Actions
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • (Item-class of (Item carried by your_unit in slot (Integer A))) Equal to Powerup
          • Then - Actions
            • Set check = True
            • Custom script: set bj_forLoopAIndex = bj_forLoopAIndexEnd
          • Else - Actions
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • check Equal to True
      • Then - Actions
        • Game - Display to (All players) the text: unit carries itemtype X
      • Else - Actions
 

sentrywiz

S

sentrywiz

So I had been inactive for a long time that i forgot few things xd

Well i need some triggers (GUI) to prevent a unit having double weapons. This thing is also implemented in some RPG maps.

Example:

I have a peasant, and there was 2 weapons on the ground, lets call it weapon A and weapon B. I take weapon A, and then when i tried to pick the weapon B, it should be cancelled and weapon B will be dropped on the ground.

So the problem is, what's the trigger? :goblin_jawdrop:
I tried but it didnt worked :v

@Chaosy gave a fine solution, but it is inefficient if you don't have an array of items. Because for each weapon you have, you will have to make a separate trigger with separate condition until you cover each combination of weapon items which will just make you mad.

If you ONLY need a trigger for this time only, then use @Chaosy's solution.
Otherwise, find a system.
 

Chaosy

Tutorial Reviewer
Level 40
Joined
Jun 9, 2011
Messages
13,223
@Chaosy gave a fine solution, but it is inefficient if you don't have an array of items. Because for each weapon you have, you will have to make a separate trigger with separate condition until you cover each combination of weapon items which will just make you mad.

If you ONLY need a trigger for this time only, then use @Chaosy's solution.
Otherwise, find a system.

I actually think the method in question isn't too ineffective. I am pretty sure you can have a single trigger to handle it all.

Basically this is what I would do:

Unit acquires an item.
set itemClass = Item Class of item being manipulated
-trigger I posted earlier here (with a few modifications)-

You'd get away with a very short trigger actually.
 
Just create a boolean for the item ex: Weapon_Check[Player Number of Player 1] = False

  • Weapon Check
  • Events
    • Unit - Acquires an item
  • Conditions
    • (Hero Manipulating Item) is a Hero equal to true
    • Item-class of (Item being manipulated) equal to Artifact
  • Actions
    • Set - Temp_Integer = Player Number of (Owner of Hero manipulating item)
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • Weapon_Check[Temp_Integer] Equal to false
      • Then - Actions
        • Set - Weapon_Check[Temp_Integer] = True
      • Else - Actions
        • Game - Display to (Owner of Hero Manipulating Item) the text: unit carries itemtype X
this is what I use in my equipment system..
 
  • Like
Reactions: ILH
Status
Not open for further replies.
Top