HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Using a "matching unit" tag without a unit comparison condition

09-06-2002, 04:06 AM#1
Guest
As the subject suggests, I'm trying to find a way to have a unit (and it's gotta be a random unit from a group, not a single unit) have an item of type (a boolean comparison) and have that same unit (or the "matching" unit) be given an item. The problem is, this is timer based, not based on a unit doing anything, so I can't use any event respsonses that I can think of.
So I need a way to either make "Hero has item of type" into a unit comparison (instead of a boolean comparison), or to somehow make the unit have to pass a unit comparison condition, then pass the "has item of type" comparison, then be given the item (and no, you can't use a matching unit in a condition of the same trigger, so I can't have:
Random unit from Group X Equal to Random Unit from Group X
(to sort of bypass the matching unit crap)
Matching Unit Has Item of Type Z
Give Matching unit Item Y

That doesn't work, because I guess it doesn't recognize matching units in conditions.

Anyways, if you've made it this far, and still understand me, and have some other solution, I'd really appreciate it, and might send you a pie in the mail.
Maybe.
If I really feel like it.
09-06-2002, 04:17 AM#2
dataangel
I really don't know _exactly_ what you're asking, but you probably want to look into variables. In any case.

Pick random unit from unit group matching condition unit has item = to true and do if picked unit is == rightkind then give picked unit item.
09-06-2002, 04:21 AM#3
dataangel
BTW, Nightfox, if what I just said doesn't help, rather than giving me the trigger details, just lemme know what's supposed to happen in the game. It'll probably be easier for me to figure out yer problem.
09-06-2002, 10:31 AM#4
Guest
And how do you do Pick Random unit from unit Group?
09-06-2002, 01:55 PM#5
Wakeman
Quote:
Originally posted by Nightfox
As the subject suggests, I'm trying to find a way to have a unit (and it's gotta be a random unit from a group, not a single unit) have an item of type (a boolean comparison) and have that same unit (or the "matching" unit) be given an item. The problem is, this is timer based, not based on a unit doing anything, so I can't use any event respsonses that I can think of.
So I need a way to either make "Hero has item of type" into a unit comparison (instead of a boolean comparison), or to somehow make the unit have to pass a unit comparison condition, then pass the "has item of type" comparison, then be given the item (and no, you can't use a matching unit in a condition of the same trigger, so I can't have:
Random unit from Group X Equal to Random Unit from Group X
(to sort of bypass the matching unit crap)
Matching Unit Has Item of Type Z
Give Matching unit Item Y

That doesn't work, because I guess it doesn't recognize matching units in conditions.

Anyways, if you've made it this far, and still understand me, and have some other solution, I'd really appreciate it, and might send you a pie in the mail.
Maybe.
If I really feel like it.

nightfox, it sounds like that you misunderstood the use of "matching unit". It only works with the function "units matching the conditions".
If you want to pick a random unit only, you should use "picked unit" instead.
e.g.
Pick random unit from group1 and do (if picked unit has itemZ then gives picked unit itemY)
09-06-2002, 04:54 PM#6
Guest
I'll ask again....
09-06-2002, 06:51 PM#7
Guest
Unit Group: Pick every unit in unit group and do action

Unit group: Every unit owned by player or in region matching condition (is a hero and has some item)

Action: Hero: Give item to Random Unit in Unit Group

If this doesn't work, you could make a Unit Group variable, clear it, then use the "Pick every unit in unit group and do action" to add them to the Unit Group variable. Then the Hero: Add item action will be given to Random Unit in that Unit Group variable.
09-06-2002, 07:30 PM#8
Guest
I think that last suggestion is what you'd have to do.

There is no pick random unit as two other people have suggested :rolleyes:
09-06-2002, 09:23 PM#9
Scio
there is a random unit from unit group function, juts choose ur group and ur good to go!
09-06-2002, 09:34 PM#10
Guest
Ok, here's the lowdown on this shit:
This is all for a trade skill system for a mmorpg type game. It's for taking a block of iron and smithing it into some iron armor, so:
When the unit enters the area, he's added to the unit group "blacksmiths" and a variable called "blacksmithworkers" has +1 added to it. Also, a timer is set. When the timer expires, if he has a block of iron in his inventory (a boolean condition), the guy has a block of iron removed, and a suit of armor is put in its place . It isn't a problem linking the last 2 actions (using the "hero manipulating item" tag).
Now, this is all fine and good with only one unit in "blacksmiths"(the unit group, not the variable), but if there is more than one unit, and one doesn't have block of iron, it could run the "unit has block of iron check" on one unit, but then try to take the iron away from another unit (even if he has none) and then give him the iron armor, thus getting some iron armor for free.
Or vice versa, it could check for a block of iron on a unit that doesn't have any (even though there's still some in "blacksmiths" who still have some) and you lose your chance at some iron for no reason.

What I really need is a way to remove units from "blacksmiths" when they don't have any more blocks of iron. Anyone know how to do that?
09-06-2002, 10:35 PM#11
Guest
OK, now I've stopped worrying about this and am focusing on removing units for "blacksmiths" when they run out of blocks of iron (so all the units in blacksmiths have blocks of iron, so the check doesn't matter), and I've gone about doing this by, after the timer runs out:
Pick every unit from (Blacksmiths) and If (Picked unit) has (Block of iron) Then (Do nothing) Else Remove picked unit from (Blacksmiths)
and I have it doing the same check, and if its an else, giving the unit 50% hp. And while doing this, I haven't found any units to be at 50% hp, so these actions don't seem to be happening.
So now I think my problem is using the "picked unit"tag, rather than the matching unit tag. Can anyone tell me what I'm doing wrong now plz?
09-06-2002, 10:49 PM#12
Guest
So you don't need a random unit? You want to have every unit in that group with Iron to get Armor?

Pick every unit in Playable map area matching ((((matching unit) is in BlackSmiths) equal to true) and (((matching unit) has an item of type Iron) equal to true) and do For Integer A 1 to 2 do If Integer A equal to 1 do (Remove Item carried by (picked unit) of type Iron) Else Do (Create Armor and give it to (picked unit)
09-07-2002, 12:32 AM#13
Guest
No. I've still got it taking an iron block from a random unit in Blacksmiths and giving that unit a suit of iron armor, but now I want the units in Blacksmiths that don't have any more iron blocks to be removed from the group without leaving the area.
09-07-2002, 06:43 AM#14
Guest
In the same trigger as you give them the armor, check to see if they are carrying the blocks. If yes, do nothing, else unit group: remove unit from unit group.