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

[Trigger] Tic-Tac-Toe system

Status
Not open for further replies.
Level 9
Joined
Jan 1, 2009
Messages
94
I'm currently working on a fun map, invented by me and a friend.
Its some kind of Tic-Tac-Toe extreme and therefor i tried to create a system, which creates the X or O for the player.

On the map are 9 Boxes with one unit in it which looks like an O, X or an invisible one (saved in an unitarray named Kasten_inner[])

each Box is surrounded by 4 flags (all saved in unitgrouparray named Kasten[]), which all have to be conquered to mark the Box.

Int[] is just an integerarray for the loop action.

The Boxes and Flags are all saved in the arrays at map initialization.

The flags are saved in the array like this:

  • Unit Group - Add flagpole 0023 <gen> to Kasten[1]
  • Unit Group - Add flagpole 0024 <gen> to Kasten[1]
  • Unit Group - Add flagpole 0025 <gen> to Kasten[1]
  • Unit Group - Add flagpole 0026 <gen> to Kasten[1]
  • Unit Group - Add flagpole 0027 <gen> to Kasten[2]
  • Unit Group - Add flagpole 0028 <gen> to Kasten[2]

and the centerunit (which is at the beginnig an invisible unit) like this:

  • Set Kasten_inner[1] = empty box 0000 <gen>

This system should mark a Box with an X or O if the player ownes all 4 Flags surrounding it:

  • Events
    • Map initialization
    • Time - Every 0.30 seconds of game time
  • Conditions
  • Actions
    • For each (Integer Int[1]) from 1 to 9, do (Actions)
      • Loop - Actions
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • (Number of units in (Units owned by Player 1 (Red) matching (((Matching unit) is in Kasten[Int[1]]) Equal to True))) Equal to 4
            • (Owner of Kasten_inner[Int[1]]) Not equal to Player 1 (Red)
          • Then - Actions
            • Unit - Create 1 X for Player 1 (Red) at (Position of Kasten_inner[Int[1]]) facing Default building facing (270.0) degrees
            • Set Kasten_inner[Int[1]] = (Last created unit)
            • Game - Display to (All players) the text: |c00ff0000Sign set!...
          • Else - Actions
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • (Number of units in (Units owned by Player 2 (Blue) matching (((Matching unit) is in Kasten[Int[1]]) Equal to True))) Equal to 4
            • (Owner of Kasten_inner[Int[1]]) Not equal to Player 2 (Blue)
          • Then - Actions
            • Unit - Create 1 O for Player 2 (Blue) at (Position of Kasten_inner[Int[1]]) facing Default building facing (270.0) degrees
            • Unit - Remove Kasten_inner[Int[1]] from the game
            • Set Kasten_inner[Int[1]] = (Last created unit)
            • Game - Display to (All players) the text: |c00ff0000Sign Set!...
          • Else - Actions
The system just works for the first box, but i want it to work for all 9 boxes so i think i made a mistake with the loop, but i just don't get it.

Could anyone help me?
If more triggers need to be posted please tell.

PS: I actually know that i have some leaks in it, but i just want to get it work first and then remove leaks.
 
Level 17
Joined
Jun 17, 2010
Messages
2,275
instead of a periodic event, use a spell to cast the x or o, and use the event effect of an ability, put the second if then else statement in the else of the first if then else statement, and fix the leaks. If it still doesnt work post what you fixed, and any other triggers that may be connected to this one.
 
Level 13
Joined
May 11, 2008
Messages
1,198
huh. why don't you give two units a set of items. one unit gets a set of x markers, another unit gets a set of o markers. when they drop an item, check to see if it's dropped into the box. if it was the unit's turn, that's fine, if the box didn't already have an item. otherwise, give the item back and make him try again.

other ideas could work too. like maybe nine critters...depend on which unit kills one, the o or x mark comes about. perhaps the critters can only be killed by casting a spell on them...and you can take away the spell when it's not the unit's turn. you'd probably have to take away the wander ability.
 
Level 5
Joined
Nov 30, 2010
Messages
184
I don't think there is a need for the flag variable. When a player conquers a flag, it changes owner to that player.
The trigger: for the conquering of the flag will be like this:
Event: when a unit comes within 100 range of flag 0000 (or you can use regions)
Action: change the owner of flag 0000 to owner of triggering unit.
You need to duplicate this trigger 16 times for all the flags.
Then the trigger for conquering the whole box will be as follows
Event: every 0.01 seconds.
Condition: the owner for flag 0000 is player 1
the owner for flag 0001 is player 1
the owner for flag 0002 is player 1
the owner for flag 0003 is player 1
Action: set temp_Point to position of invisible unit 0000 (or O unit)
Remove invisible unit 0000
Create a X unit at temp_Poin
Custom script: removelocation (udg_temp_Point)
Duplicate this 9 times for all the boxes.
You may or may not use this trigger. I understand it is a lot of work to implement this but this is the only way I know (for now) that can achieve what you want.

Give rep points to those who have helped you^^
 
Level 9
Joined
Jan 1, 2009
Messages
94
Sorry for my late answer, i didn't had much time this week.

@ InfinateAnswers:
I don't understand, why i should bind the whole trigger to a cast and which cast this should be? There is no cast in this whole process so why make it more comlicated?

@ SanKakU:
I made it like this, because i wanted to make the players slay each others "flag-conquerer". With this model the game takes more time and its more fun to have a Hero, which has abilities to kill other units.

@ Mac_MacNuggets:
I thought about the same and in real it would be what i tried to do with my system.
And here's the reason, why i didn't did it like u said: There 9 boxes, each surrounded by 4 flags so 36 flags in total. Therefor i had to make 36 triggers for the flags and one trigger with 9 if-then-else conditions to set the mark (this wouldn't be so complicated, but it takes time :p).

I just thought i could simplify thinks this way, but i looks like it causes more problems than my laziness is worth :p

I think i'll do it like u said Mac_MacNuggets.

PS: Rep will be given in a few seconds
 
Status
Not open for further replies.
Top