Difficult logical problem

Monictor

New Member
Reaction score
0
EDIT: I had posted the wrong trigger for the action trigger earlier... here is the right one.

Intro: My game is a turn-based game that places units on a grid. I have a turn system in place that goes from one unit to the next based on certain conditions. I am in the last stages of making the beta, but before I release it I need a method to put a time limit on each unit's turn so that one player cannot sit on his turn infinitely, even when he has no more action points, and ruin the game for everyone else.

The turn system is controlled by three basic types of triggers: 1. a master trigger which determines which unit's turn it is on the battlefield, 2. an action trigger that is run by the master trigger that begins the unit's turn, and 3. a stop trigger that is activated by an "End Turn" ability on the active unit which the controlling player presses when finished and reactivates the master trigger.

Here are examples of the action and stop triggers:

Trigger:
  • Wolf1
    • Events
    • Conditions
    • Actions
      • Trigger - Run Cathedral Deact Stat <gen> (ignoring conditions)
      • Unit - Add Wolf Attack to AWolf[BG1Action]
      • Unit - Add End Turn to AWolf[BG1Action]
      • If ((AWolf[BG1Action] has buff Entangling Roots ) Equal to False) then do (Hero - Create Move Item (4) and give it to AWolf[BG1Action]) else do (Do nothing)
      • Hero - Create Active Turn and give it to AWolf[BG1Action]
      • Unit - Set mana of AWolf[BG1Action] to 52.00
      • Selection - Select AWolf[BG1Action] for (Owner of AWolf[BG1Action])
      • Camera - Pan camera for (Owner of AWolf[BG1Action]) to (Position of AWolf[BG1Action]) over 1.25 seconds
      • Special Effect - Create a special effect attached to the overhead of AWolf[BG1Action] using Abilities\Spells\Human\MagicSentry\MagicSentryCaster.mdl
      • Set TurnEffect[BG1Action] = (Last created special effect)
      • Special Effect - Create a special effect attached to the chest of AWolf[BG1Action] using Abilities\Spells\Other\Charm\CharmTarget.mdl
      • Set TurnCharm[BG1Action] = (Last created special effect)
      • Wait 1.00 game-time seconds
      • Special Effect - Destroy TurnCharm[BG1Action]
      • Wait 40.00 game-time seconds
      • Unit - Order AWolf[BG1Action] to Night Elf Mountain Giant - Taunt


In this action trigger, BG1Action is a integer set by the master trigger that determines which player's turn it is. AWolf[1] refers to player 1's Wolf. AWolf and other unit variables are set when the unit is selected. At the end of the trigger you see a 40sec wait and an order to Taunt. Taunt is the Base Order ID of the "End Turn" ability. However, there are two problems with this. The first is that the BG1Action variable is modified after each turn when it determines what player owns the unit whose next turn it is. It can affect another player's Wolf if the first player ends his turn before the 40 seconds is up. Consecutive turns for the same type of unit can happen very often, and this will prematurely end the second Wolf's turn. The second problem is that when there are fewer units on the board, like if it gets down to 1v1, if the same Wolf's 2nd turn comes up in less than 40 seconds of the beginning of his previous turn, then it will end his turn early. (If the End Turn order comes up when it is not the unit's turn, it doesn't do anything because the ability is removed by the end turn trigger.)

Here is the end turn trigger so you can get an idea.

Trigger:
  • WolfStop
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
      • And - All (Conditions) are true
        • Conditions
          • (Ability being cast) Equal to End Turn
          • (Unit-type of (Triggering unit)) Equal to Wolf
    • Actions
      • Unit - Remove Wolf Attack from (Triggering unit)
      • Unit - Set mana of (Triggering unit) to ((Mana of (Casting unit)) + (4.00 x (Current life of (Item carried by (Casting unit) of type Move Item (4)))))
      • Special Effect - Destroy TurnEffect[(Player number of (Owner of (Triggering unit)))]
      • Special Effect - Create a special effect attached to the chest of (Triggering unit) using Abilities\Spells\Human\Invisibility\InvisibilityTarget.mdl
      • Set EndTurnDetonate[(Player number of (Owner of (Triggering unit)))] = (Last created special effect)
      • Wait 1.00 game-time seconds
      • Special Effect - Destroy EndTurnDetonate[(Player number of (Owner of (Triggering unit)))]
      • Unit - Remove Entangling Roots buff from (Triggering unit)
      • Unit - Remove Paralyze buff from (Triggering unit)
      • If ((Battleground ONE <gen> contains (Triggering unit)) Equal to True) then do (Trigger - Turn on Cathedral Master Trigger <gen>) else do (Do nothing)
      • If ((Battleground TWO <gen> contains (Triggering unit)) Equal to True) then do (Trigger - Turn on Forest Master Trigger <gen>) else do (Do nothing)
      • If ((Battleground THREE <gen> contains (Triggering unit)) Equal to True) then do (Trigger - Turn on Waterfall Master Trigger <gen>) else do (Do nothing)
      • Item - Remove (Item carried by (Triggering unit) of type Active Turn)
      • Item - Remove (Item carried by (Triggering unit) of type Move Item (3))
      • Item - Remove (Item carried by (Triggering unit) of type Move Item (4))
      • Item - Remove (Item carried by (Triggering unit) of type Move Item (5))
      • Unit - Remove End Turn from (Triggering unit)


I need to figure out a way to cancel the End Turn order if the player activates End Turn by himself. I do not want the end turn to just be on a timer because I want the player to be able to activate it so the game goes as fast as possible. I am wondering if there is a JASS function that can do this or something.

Any ideas are greatly appreciated, and +rep. If you need any more info or clarification, plz ask.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      • Ghan
        Administrator - Servers are fun

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top