• 🏆 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!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

What is wrong with Unit Uses an item

Status
Not open for further replies.
Level 20
Joined
Jan 6, 2008
Messages
2,627
Okay, you can see my title, it says alot.

When im making a trigger with actions of an item, it only runs once, and sometimes only with one item, if i had 2. and it only works with the first one, take it off, and then use it again, but it's unusable, now, is there a way to prevent this?
 
Level 20
Joined
Jan 6, 2008
Messages
2,627
  • Item Use
    • Events
      • Unit - A unit Uses an item
    • Conditions
    • Actions
      • For each (Integer A) from 15 to 200, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Item-type of (Item being manipulated)) Equal to InvsystemItems[(Integer A)]
            • Then - Actions
              • Set Point = (Position of SlotDests[ItemSlot[(Integer A)]])
              • Destructible - Pick every destructible within 40.50 of Point and do (Actions)
                • Loop - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Destructible-type of (Picked destructible)) Not equal to ItemDestructibles[(Integer A)]
                      • (Destructible-type of (Picked destructible)) Not equal to Background
                      • ItemUsed[ItemSlot[(Integer A)]] Equal to No destructible
                    • Then - Actions
                      • Item - Remove (Item being manipulated)
                      • Destructible - Create a ItemDestructibles[(Integer A)] at Point facing 0.00 with scale 0.75 and variation 1
                      • Set ItemUsed[ItemSlot[(Integer A)]] = (Last created destructible)
                    • Else - Actions
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • (Destructible-type of (Picked destructible)) Equal to ItemDestructibles[(Integer A)]
                        • Then - Actions
                          • Game - Display to (All players) the text: Slot is already in ...
                        • Else - Actions
              • Custom script: call RemoveLocation(udg_Point)
            • Else - Actions
And the drop trigger NOt the whole
  • For each (Integer A) from 1 to 14, do (Actions)
    • Loop - Actions
      • For each (Integer B) from 15 to 200, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • TrackBoolean2[(Integer A)] Equal to True
            • Then - Actions
              • Set Point = (Position of SlotDests[(Integer A)])
              • Destructible - Pick every destructible within 40.50 of Point and do (Actions)
                • Loop - Actions
                  • Set Point2 = (Position of (Picked destructible))
                  • Destructible - Pick every destructible within 40.50 of Point2 and do (Actions)
                    • Loop - Actions
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • ItemDestructibles[(Integer B)] Equal to (Destructible-type of SelectedDest)
                          • TrackBoolean2[14] Equal to True
                        • Then - Actions
                          • Set TempInt = (TempInt + 1)
                          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            • If - Conditions
                              • TempInt Equal to 1
                            • Then - Actions
                              • Destructible - Remove ItemUsed[ItemSlot[(Integer A)]]
                              • Destructible - Remove SelectedDest
                              • Set ItemUsed[ItemSlot[(Integer A)]] = No destructible
                              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                • If - Conditions
                                  • (Number of items carried by Paladin 0001 <gen>) Equal to 6
                                • Then - Actions
                                  • Game - Display to (All players) the text: Your item has been ...
                                  • Set Point3 = (Position of Paladin 0001 <gen>)
                                  • Item - Create InvsystemItems[(Integer B)] at Point3
                                  • Custom script: call RemoveLocation(udg_Point3)
                                • Else - Actions
                                  • Hero - Create InvsystemItems[(Integer B)] and give it to Paladin 0001 <gen>
                            • Else - Actions
                        • Else - Actions
                  • Custom script: call RemoveLocation(udg_Point2)
              • Custom script: call RemoveLocation(udg_Point)
            • Else - Actions
  • Set SelectedDest = No destructible
 
Slaydon,

  • For each (Integer A) from 1 to 14, do (Actions)
    • Loop - Actions
      • For each (Integer B) from 15 to 200, do (Actions)
        • Loop - Actions
Why?

  • Hero - Create InvsystemItems[(Integer B)] and give it to Paladin 0001 <gen>
Avoid static values if they are no settings.

The whole destructable pickup thing is totally awful.

Recode it please.


Btw, give us more information about the item data.
 
Level 20
Joined
Jan 6, 2008
Messages
2,627
Slaydon,

  • For each (Integer A) from 1 to 14, do (Actions)
    • Loop - Actions
      • For each (Integer B) from 15 to 200, do (Actions)
        • Loop - Actions
Why?

  • Hero - Create InvsystemItems[(Integer B)] and give it to Paladin 0001 <gen>
Avoid static values if they are no settings.

The whole destructable pickup thing is totally awful.

Recode it please.


Ofcourse i will clean it, and it shouldnt b Paladin 0001 in the end;P, and the loops, i dont know its the only way it works ;/

I will do alot of recoding ;S
 
Problem is:
Too many loops and pickups.

Wc3 got a thread crash after an amount of nesting of big loops / enumation.
Therefor it won't work correctly.

Just think about it:
One loop iterates from 1 to 14
Another one from 15 to 200.
That means 185 * 14 executions of every action in that loops INSTANTLY.

I mean, can you see how 2590 enumerations are to much for wc3 to handle at the same time?
 
Level 17
Joined
Jun 12, 2007
Messages
1,261
My post didn't make it? I posted before. Owel.

What I said in my post that somehow failed;
One of your if's that check a variable, that's where it goes wrong.

You did not post the entire drop trigger right? Well do so, I think you are setting one of the variables to nothing rendering the first trigger unable to run.

I'm leaning towards this one being changed in another loop in your map.
  • (Item-type of (Item being manipulated)) Equal to InvsystemItems[(Integer A)]
EDIT: The loop is not his problem Anachron, sure it takes a lot from wc3, but it can handle it. (I do agree that it has to be rewritten though.)
 
Level 20
Joined
Jan 6, 2008
Messages
2,627
if it is
  • For each (Integer A) from 1 to 14, do (Actions)
    • Loop - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • TrackBoolean2[(Integer A)] Equal to True
        • Then - Actions
          • For each (Integer B) from 15 to 200, do (Actions)
            • Loop - Actions
it would only run it once, since it will check 14 times, then check 200.
 
So you fixed it?
The first code has this in it:
  • For each (Integer A) from 1 to 14, do (Actions)
    • Loop - Actions
      • For each (Integer B) from 15 to 200, do (Actions)
        • Loop - Actions
Edit:
So ok, here we go:

To fix it, create a new hashtable.
Into that hashtable, save with the key of the TrackAble the dataset into the table.

On TrackableEvent, you load the dataset of the table, while you use the key oft the trackable.
Now you know which trackable has been used and also exactly know the slot that has been used.

Also try to avoid loop whenever you can. For checking for a variable being another one or such, loading is mostly better as
looping through the whole struct.
 
Status
Not open for further replies.
Top