• 🏆 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!

Making A Trigger that Recognizes Items on the ground?

Status
Not open for further replies.
Level 5
Joined
Jun 8, 2009
Messages
101
I have a puzzle in a map im making, The object is to drop certain colored items on their colored platforms.

My problem is i cant get a trigger to recognize that they have been placed in the right spot.

Ive tried triggers like

Unit loses an item

wait 1.00

If RedFlower is in Region 87 = True

Then Set Flowers + 1
Else Do Nothing

But it doesnt seem to work... any help?
 
Level 5
Joined
Jun 8, 2009
Messages
101
  • DekuFlowers
    • Events
      • Unit - A unit enters Region 055 <gen>
    • Conditions
      • And - All (Conditions) are true
        • Conditions
          • (FlowerBlue is in FlowerBlue <gen>) Equal to True
          • (FlowerRed is in FlowerRed <gen>) Equal to True
          • (yellowflower is in FlowerYellow <gen>) Equal to True
          • (FlowerPink is in FlowerPink <gen>) Equal to True
          • (FlowerGreen is in FlowerGreen <gen>) Equal to True
          • (FlowerGold is in FlowerGold <gen>) Equal to True
    • Actions
      • Sound - Play OOT_Secret_Mono <gen>
      • Special Effect - Create a special effect at (Center of Region 055 <gen>) using Abilities\Spells\Undead\DarkRitual\DarkRitualTarget.mdl
      • Item - Create (Deku Tree) Big Key at (Center of Region 055 <gen>)
      • Set BigKeyDeku = (Last created item)
this is my original
 
Level 4
Joined
Aug 22, 2008
Messages
100
I think this will work.

  • Red Flower
    • Events
      • Time - Every 0.04 seconds of game time
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (YourItem is in YourRegion) Equal to True
        • Then - Actions
          • Set YourBolean = True
          • -------- Shows that the item is in the region --------
        • Else - Actions
          • Set YourBolean = False
          • -------- If you pick up the item again --------
(You can change the event on this trigger to if you enter a region)
  • Checking if all is done
    • Events
      • Time - Every 0.04 seconds of game time
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • And - All (Conditions) are true
            • Conditions
              • YourBolean Equal to True
              • YourOtherBolean Equal to True
              • YourOtherBolean Equal to True
              • YourOtherBolean Equal to True
        • Then - Actions
          • Trigger - Turn off (This trigger)
          • -------- If you turn of the trigger it will still continue the remaining actions but wont be able to run again --------
          • -------- Do whatever is supposed to happen --------
        • Else - Actions
Tell me if it helped.
 
Last edited:
Level 5
Joined
Jun 8, 2009
Messages
101
No it diddnt, it has to be a bug or something

I set the flower to its switch
  • DekuDoor1
    • Events
      • Unit - Infected Deku Scrub (Lv2) 0138 <gen> Dies
    • Conditions
    • Actions
      • Sound - Play SecretFound <gen> at 100.00% volume, attached to Infected Deku Scrub (Lv2) 0138 <gen>
      • Destructible - Open Dungeon Door (Vertical) 1716 <gen>
      • Item - Create Yellow Deku Flower at (Position of (Dying unit))
      • Set yellowflower = (Last dropped item)
Then when i drop it here....

  • FlowerYellow
    • Events
      • Time - Every 0.50 seconds of game time
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (yellowflower is in Floweryellow <gen>) Equal to True
        • Then - Actions
          • Game - Display to (All players) the text: Yellow Flower Has Been...
          • Set FlowerYellowPlaced = 1
        • Else - Actions
          • Set FlowerYellowPlaced = 0
It still doesnt do this, even though i just set it to spam the fuck out of that message just to see if it would work, no spammy :(

Does it loes it's attachment when its dropped? or should i just have it check for that certain item type on that location?
 
Level 4
Joined
Aug 22, 2008
Messages
100
Set your yellowflower to last created item instead of last dropped item.

Chewii is right that should fix it (Just when i was about to turn of the computer i saw that you had responded) (Srry for double post :sadpanda: i removed it)
 
Level 5
Joined
Jun 8, 2009
Messages
101
wow that was the problem the whole time >:eek: lmao ty ty cant believe i diddnt notice that

what do you mean a leak? i dont know anything about those although i see topics about that all the time, im sure i have lots of them. i dono how to fix them though
 
Level 11
Joined
Dec 5, 2009
Messages
846
what do you mean a leak? i dont know anything about those although i see topics about that all the time, im sure i have lots of them. i dono how to fix them though

I can show you how to remove them and a thread about them. You see this one here this trigger, well it leaks.

  • Item - Create Yellow Deku Flower at (Position of (Dying unit))
It leaks cuz of its position...
So how to remove that you just create a point variable. Set it as ''position of dying unit'' Put the variable in that trigger and the remove it. So like this:

  • Set Temp_Point = (Position of (Dying unit))
  • Item - Create Yellow Deku Flower at (Temp_point)
  • Custom script: call RemoveLocation(udg_Temp_Point)
Now this is leakless. also unitgroup leaks. playergroups.... ETC.

Read more about leaks here: http://www.hiveworkshop.com/forums/triggers-scripts-269/things-leak-35124/
 
Level 4
Joined
Jul 23, 2008
Messages
99
I am just thinking that when unit drop items, a variable will save the item's position. Then, check it with condition that region contains "item" = true, and do your actions.

Huh... once again my hand is very far from WE and I can't give you the trigger right now. But sure I able to do it...
 
Level 13
Joined
May 11, 2008
Messages
1,198
GetItemX and GetItemY could be useful functions... i think i wrote some code using those...you might find the functions i wrote useful.

if you want the full system that i wrote i can put it in a pastebin for you.

here's the last part of the second library, which is probably the most useful for you:
btw the /**/ style comments need to be compiled with latest jasshelper?...so you can convert them to // style comments if you need to...
JASS:
/*Snippet Extension by SanKakU*/

//example:
/*
make a timer run every 1 second of game time.
then make it check
if cru(somespecialunit,somespecialregion) then
...do your thing.

or better yet...
a unit drops an item...(using GT) 
if cri(GetManipulatedItem(),thestash) then
probably pull up some more conditions and make a recipe, or something like that.

it could also be used to remove items that are cluttering up the map if there are lots
of creeps and item drops on your map.
for example...
a unit drops an item...(using GT) 
run a timer for 2 minutes, then check
if cri(GetManipulatedItem(),thebattlefield) then
remove the item.
these are just a few ideas off the top of my head.
*/

//use this function to check if an item is in a box/rect/region
function cxyi takes item x, real x1, real y1, real x2, real y2 returns boolean
if GetItemX(x) > x1 and GetItemX(x) < x2 and GetItemY(x) > y1 and GetItemY(x) < y2 then
return true
endif
return false
endfunction
//this one is same as above, but for a unit
function cxyu takes unit x, real x1, real y1, real x2, real y2 returns boolean
if GetUnitX(x) > x1 and GetUnitX(x) < x2 and GetUnitY(x) > y1 and GetUnitY(x) < y2 then
return true
endif
return false
endfunction
//this one is same as above, but for a destructable
function cxyd takes destructable x, real x1, real y1, real x2, real y2 returns boolean
if GetDestructableX(x) > x1 and GetDestructableX(x) < x2 and GetDestructableY(x) > y1 and GetDestructableY(x) < y2 then
return true
endif
return false
endfunction
//use this function to check if an item is in a box/rect/region
//you only give the item and the rect (region), no xyxy like the above functions
function cri takes item x, rect y returns boolean
if GetItemX(x) > GetRectMinX(y) and GetItemX(x) < GetRectMaxX(y) and GetItemY(x) > GetRectMinY(y) and GetItemY(x) < GetRectMaxY(y) then
return true
endif
return false
endfunction
//use this function to check if a unit is in a box/rect/region
//you only give the unit and the rect, no xyxy like the above functions
function cru takes unit x, rect y returns boolean
if GetUnitX(x) > GetRectMinX(y) and GetUnitX(x) < GetRectMaxX(y) and GetUnitY(x) > GetRectMinY(y) and GetUnitY(x) < GetRectMaxY(y) then
return true
endif
return false
endfunction
//use this function to check if a destructable is in a box/rect/region
//you only give the destructable and the rect, no xyxy like the above functions
function crd takes destructable x, rect y returns boolean
if GetDestructableX(x) > GetRectMinX(y) and GetDestructableX(x) < GetRectMaxX(y) and GetDestructableY(x) > GetRectMinY(y) and GetDestructableY(x) < GetRectMaxY(y) then
return true
endif
return false
endfunction

GT is a system written by someone else, you can find it at thehelper.net if you need it. i think it's nice to use as you can specify an exact type of item in the event.
you should also be able to find it in my the demon hunt tournament map...and i think there's also the uac system or did i rename it idfu(another one written by someone else)... which might be useful if you're using items a lot in your map...not sure what the triggers look like in TDHT as i've been working on TAF for a while...

since you appear to be using regions you'll probably find the cri, cru, crd functions the most useful.

i'm not sure exactly how exactly to use it in gui, but you use custom script and you basically run the function to check if the result is true or false or whatever. obviously true means it's in the box, and false means it's not.
in jass it looks like
if cri(x,y)==true then
x is item, whether it's triggering item or whatever. and y is the region.
it's possible you'll need GT to get the proper event...like i said you can get it either in my map or at thehelper.net

also, i might mention that setting variables and creating them at the same time is easier in jass...since i guess i gave you a jass solution rather than gui i might as well throw that bit in there.
 
Last edited:
Level 13
Joined
May 11, 2008
Messages
1,198
your kidding right?
1. some 1 allready helped the person who needed help.
2. he barely knows what leaks are, you want him to do jass?
3. did i mention the problem is solved?

what i posted is for anyone who might be reading the thread wondering if there's any tips for beginner jass users who might be attracted to the subject.
jass is a lot easier than gui...i wouldn't be able to make a system in gui...it's so glitchy. gui is best for when you're dealing with a lot of functions that you don't know what they do or how to use them...otherwise, i prefer jass.
 
Status
Not open for further replies.
Top