| 11-20-2003, 11:47 PM | #1 |
I have a logic error in the follwing trigger's action portion, and I cannot see what it is. If someone could help me out that would be great. I have a region called Player1 Portal, and int variable called Player1ProjectedPop. These are fine. I am trying to send all the units, in the portal (not the circle of power that is always there) through to the other region(making 6 there). As u see I have a condition that says if the picked unit is not equal to Circle of Power. then do other actions. For someoreason this works so far in testing, however the circle is transfered too. Here is the trigger: Unit Group - Pick every unit in (Units in Player1 Portal <gen>) and do (Actions) Loop - Actions If (All Conditions are True) then do (Then Actions) else do (Else Actions) If - Conditions (Player 1 (Red) Food cap) Greater than or equal to Player1ProjectedPop (Unit-type of (Picked unit)) Not equal to Circle of Power Then - Actions Unit - Create 6 (Unit-type of (Picked unit)) for Player 1 (Red) at (Center of Player1 Start <gen>) facing Default building facing degrees Unit - Remove (Picked unit) from the game Else - Actions I know there is another better way for the top action, but I want the condtions to work before I try the other way. -Thanks Trepidity |
| 11-21-2003, 01:58 AM | #2 |
You need to bind your conditions with an AND statement. Right now it will do it if one OR the other is true. You want it to happen if both are true. |
| 11-21-2003, 02:08 AM | #3 | |
Quote:
No... the Multiple IF statements uses (all conditions are true) which is basically an AND. I was gonna say the same thing, but I noticed that it made some sense.... --- I'd do it this way, see if it works? E: Unit enters Region C: Unit-Type Not Equal Circle of Power A: If C: (Enough food) Then Unit - Create 6 Unit-type(Triggering Unit) for <player> at <location> facing <default> Unit - Remove (Triggering Unit) Else Do nothing --- I think it'll be cleaner and get the job done :D |
| 11-21-2003, 02:13 AM | #4 |
Oops, I missed that one lol. Triggers look so funny as plain text. I would reccommend what you suggested though. |
| 11-21-2003, 02:21 AM | #5 |
lol. ummm I have used the same method for a different trigger in my map as above in the reply(didnt copy it, just they happen to be the same). But for this purpose it doesnt fit. I have it setup so that if the projected population for after the units goes through is greater than the food cap, then it stay at the portal and does not go through. This function works perfectly. I am trying to make a trigger that sends units through automatically when the food cap is raised to make room(ie. a farm is constructed) if they are still in the portal, and only one of them(because each farm has 6 food) Already the user can just leave and re-enter the portal, which works fine, but I am trying to add a convenience. My trigger runs when the farm is constructed just fine. If there is one unit at the portal when a new farm is built, it works fine. It is when multiple units are at the portal that it gets funny. I posted another thread asking about picking a random unit(other than the circle of power) from this. If I could, I would just send it through.(Only one farm in this map can be made at a time.) Thats what I am trying to do. Feel free to post the answer in this thread or the other. Thanks for the help. |
| 11-21-2003, 02:37 AM | #6 |
Code:
Unit Group - Pick every unit in (Units in Player1 portal <gen> matching ((Unit-type of (Matching unit)) Not equal to Circle of Power)) and do (Actions)
Loop - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Player 1 (Red) Food cap) Greater than or equal to Player1ProjectedPop
Then - Actions
Unit - Create 6 (Unit-type of (Picked unit)) for Player 1 (Red) at (Center of Player1 Start <gen> ) facing Default building facing degrees
Unit - Remove (Picked unit) from the game
Else - Actions
Do nothingTry that... EDIT: I will explain the actual logic error, since I am bored. Your trigger was ordered to select all of the units in the region, then check to see if the unit picked was not equal to a circle of power - well at least one of those units picked was not a circle of power. So picked unit = circle of power - false, see what I mean? So the problem was it isn't singling out the circle of power for the condition check, and when it reached the actions the circle of power is still "picked" because there is no order to "unpick" a unit. So you need to make it pick all *except* the circle of power ;) Unit Group - Pick all units in (Region matching condition) and make this condition the item - type comparison so it doesn't pick it at all. Anyway, if that doesn't work, I will look up the identical trigger I have on one of my maps.. I hope I didn't word it wrong since I just cooked that up with a new trigger on the blank map I currently have open. |
| 11-21-2003, 02:57 AM | #7 |
hmmmm...I put in exactly that and it gives me two problems: A: Only transfers units if one is in the portal B: When it does transfer that one unit, the Circle of Power is transfered too. As to why I am not yet sure. I will try to figure it out. If u see why, or see a better way to acheive this leme know. By the way: The Player1ProjectedPop is incremented by 6 when the unit enters the region(portal), and decremented when they leave(leaves region, not transfered thorugh portal). I tested to make sure that works, and it does. I am just trying to pick one unit, any unit other than the Circle, in the region and automatically send it through when a new farm is built. If there is one unit there, send it through. If there are more than one, somehow (maybe random) pick one and send it through leaving the others behind. I hope that makes sense. |
| 11-21-2003, 03:07 AM | #8 |
Off the top of my head... Code:
Unit Group - Pick every unit in (Random 1 units from (Units in Player1 portal <gen> matching ((Unit-type of (Matching unit)) Not equal to Circle of Power))) and do (Your action(s)) I must have worded the other one wrong, I will look it up and see if there is any differences from that and my working trigger. |
| 11-21-2003, 03:41 AM | #9 |
Ok that helped a ton. It is now picking one of the units and tranfering it. The only issue now is that it is sometimes picking the Circle of Power. Here is what I have: Unit Group - Pick every unit in (Random 1 units from (Units in Player1 Portal <gen> matching ((Unit-type of (Matching unit)) Not equal to Circle of Power))) and do (Actions) Loop - Actions Unit - Create 6 (Unit-type of (Picked unit)) for Player 1 (Red) at (Center of Player1 Start <gen>) facing Default building facing degrees Unit - Remove (Picked unit) from the game Do you see why the condition to exclude Circle of Power's is being ingnored? I cant see it. Thanks so much! -Trepidity |
| 11-21-2003, 04:56 AM | #10 |
I believe it is just in the code, one thing or another needs to be changed to another value. But unfortunately, I don't have the answer to that myself - the trigger I have refers to a unit type that doesn't even exist on my map so it can't be chosen at all. I just assumed my trigger was pretty standard, I got it from referencing a few other maps anyway. |
| 11-21-2003, 07:19 AM | #11 |
Use 'Units selected by (Player whatever)'. Picked unit is for "Pick all units in:". |
| 11-21-2003, 02:12 PM | #12 | |
Quote:
In fact there is no logic flaw, I can bet you that those circle of powers are either the medium or the biggest ones and you are using the small one in the condition. |
| 11-21-2003, 04:55 PM | #13 |
I just wanna say thanks to everyone who particpated in this thread. I have a working trigger now. It is below incase someone needs a simalar trigger: Code:
[color=silver]
[font=courier new]
Check Plyr 1 Portal
Events
Unit - A unit owned by Player 1 (Red) Finishes construction
Conditions
Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Number of units in (Units in Player1 Portal <gen>)) Greater than 1
Then - Actions
Unit Group - Pick every unit in (Random 1 units from (Units in Player1 Portal <gen> matching ((Unit-type of (Matching unit)) Not equal to Circle of Power (large)))) and do (Actions)
Loop - Actions
Unit - Create 6 (Unit-type of (Picked unit)) for Player 1 (Red) at (Center of Player1 Start <gen>) facing Default building facing degrees
Unit - Remove (Picked unit) from the game
Else - Actions
[/font] [/color] -Trepidity:ggani: |
