• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

board Game Movement

Status
Not open for further replies.
Level 3
Joined
Jul 17, 2012
Messages
26
I'm trying to figure out how to allow units to move based on available moves from 2 die that have been rolled. The dice integers have been saved as global variables and each space has been assigned a region. Unit in each region are automatically added to unit groups.I want to do this without having to program in every possible move (from every possible position) using if-then statements.

I was thinking something like: Trigger: Unit is ordered to move Condition: Action: -Unit - Order (Closest unit to point in unit group) to (move targeting point)

I can't figure out how to add conditions to block spaces that have 2 or more enemy units in them. I also need to work out how to I guess compare some of the variables. for example [If triggering unit is in unit group 1 and the dice are 3 and 5 only allow units in unit group one to move to spaces 4 and/or 6]
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,255
Use arrays to map your grid. 2 Dimensional arrays are exactly what you need for this purpose. Each index in the 2D array can correspond to a tile.

You could store everything from unit groups to occupying player this way. If your grid is regular (repeating grid of shapes with equal side lengths) then you can calculate the points of the grid using simple translation mathematics.

I can't figure out how to add conditions to block spaces that have 2 or more enemy units in them. I also need to work out how to I guess compare some of the variables. for example [If triggering unit is in unit group 1 and the dice are 3 and 5 only allow units in unit group one to move to spaces 4 and/or 6]
There are two main approaches.
1. The user is always right. You pre-filer all possible choices he can make (or only generate valid choices which he can make, whichever is faster) and present these to the user. If he tries to not select a valid choice you ignore it or round to the nearest valid choice.
2. The game does not let you. You only validate orders that are made by the user. If the order is invalid (eg, an occupied tile) then you throw an error back at the user. This is less user friendly than 1 but a lot simpler since you do not need to deal with building valid choice lists and displaying/using them.
 
Status
Not open for further replies.
Top