Hi,
I am a relative newbie and I have been struggling with a problem for several days now and I need some help. It's quite long-winded (sorry) so i'll start from the top.
I am trying to make a turn-based 2-player strategy game based on the warhammer 40K tabletop game (i.e. tabletop wargame). In this game there are many different types of units that the player can control, each unit with many stats, these are:
WeaponSkill (WS)
BallisticSkill (BS)
Strength (S)
Toughness (T)
Wounds (W)
Leadership (Ld)
Save (Sv)
I thought the best way to input all these units would be to make a new public structure, termed Infantry. This is shown below:
I created a public function to add units stats as below:
Let's take 2 units - a "Space Marine" and a "Fire Warrior". I can add all the relevant stats easily by typing the following:
This would mean that, for instance:
FireWarrior.Race = "Tau"
Still awake? Cool.
When 1 unit shoots at another unit, I call a function named ShootingEngine. This is quite long and complex but it requires to be passed to it the following variables by value:
Attackers BS
Attackers S
Defenders T
Defenders Sv
I can do this quite easily if I want say, the "FireWarrior" to attack the "Space Marine" (therefore, space marine = defender) as I simply use the following syntax (the variable 'Result' stores the outcome of the shooting):
Result = ShootingEngine(FireWarrior.BallisticSkill, FireWarrior.Strength, SpaceMarine.Toughness, SpaceMarine.Save)
Fine and dandy. HERE IS THE PROBLEM IF YOU ARE STILL AWAKE!
As you can imagine, there will be many more than 2 units and hundreds of combinations of attackers and defenders. I have 2 more variables which I hoped would solve the problem:
PlayerOne (a string variable that stores the name of the unit currently controlled by player one, e.g. "FireWarrior")
PlayerTwo (a string variable that stores the name of the unit currently controlled by player two, e.g. "SpaceMarine")
I want to be able to do the following:
Result = ShootingEngine(PlayerOne.BallisticSkill, PlayerOne.Strength, PlayerTwo.Toughness, PlayerTwo.Save)
IS THIS CLEAR? I want to somehow figure out a way to make the compiler see 'PlayerOne.Strength' as the same as 'FireWarrior.Strength' (assuming that PlayerOne = "FireWarrior")
I hope someone can help me and I appreciate it if you got this far.
FieldDoc
I am a relative newbie and I have been struggling with a problem for several days now and I need some help. It's quite long-winded (sorry) so i'll start from the top.
I am trying to make a turn-based 2-player strategy game based on the warhammer 40K tabletop game (i.e. tabletop wargame). In this game there are many different types of units that the player can control, each unit with many stats, these are:
WeaponSkill (WS)
BallisticSkill (BS)
Strength (S)
Toughness (T)
Wounds (W)
Leadership (Ld)
Save (Sv)
I thought the best way to input all these units would be to make a new public structure, termed Infantry. This is shown below:
Visual Basic:
Public Structure Infantry
Public Race As String
Public Name As String
Public Points As Short
Public WeaponSkill As Short
Public BallisticSkill As Short
Public Strength As Short
Public Toughness As Short
Public Wounds As Short
Public Initiative As Short
Public Attacks As Short
Public Leadership As Short
Public Save As Short
Public Weapon As String
End Structure
Visual Basic:
Public Function AddInfantry(ByVal Race As String, ByVal Name As String, ByVal Points _
As Short, ByVal WeaponSkill As Short, ByVal BallisticSkill As Short, _
ByVal Strength As Short, ByVal Toughness As Short, ByVal Wounds As Short, _
ByVal Initiative As Short, ByVal Attacks As Short, ByVal Leadership As Short, _
ByVal Save As Short, ByVal Weapon As Short) As Infantry
With AddInfantry
.Race = Race
.Name = Name
.Points = Points
.WeaponSkill = WeaponSkill
.BallisticSkill = BallisticSkill
.Strength = Strength
.Toughness = Toughness
.Wounds = Wounds
.Initiative = Initiative
.Attacks = Attacks
.Leadership = Leadership
.Save = Save
.Weapon = Weapon
End With
End Function
Visual Basic:
Public FireWarrior = AddInfantry("Tau", "Firewarrior", 10, 2, 3, 3, 3, 1, 2, 1, 7, 4, 10)
FireWarrior.Race = "Tau"
Still awake? Cool.
When 1 unit shoots at another unit, I call a function named ShootingEngine. This is quite long and complex but it requires to be passed to it the following variables by value:
Attackers BS
Attackers S
Defenders T
Defenders Sv
I can do this quite easily if I want say, the "FireWarrior" to attack the "Space Marine" (therefore, space marine = defender) as I simply use the following syntax (the variable 'Result' stores the outcome of the shooting):
Result = ShootingEngine(FireWarrior.BallisticSkill, FireWarrior.Strength, SpaceMarine.Toughness, SpaceMarine.Save)
Fine and dandy. HERE IS THE PROBLEM IF YOU ARE STILL AWAKE!
As you can imagine, there will be many more than 2 units and hundreds of combinations of attackers and defenders. I have 2 more variables which I hoped would solve the problem:
PlayerOne (a string variable that stores the name of the unit currently controlled by player one, e.g. "FireWarrior")
PlayerTwo (a string variable that stores the name of the unit currently controlled by player two, e.g. "SpaceMarine")
I want to be able to do the following:
Result = ShootingEngine(PlayerOne.BallisticSkill, PlayerOne.Strength, PlayerTwo.Toughness, PlayerTwo.Save)
IS THIS CLEAR? I want to somehow figure out a way to make the compiler see 'PlayerOne.Strength' as the same as 'FireWarrior.Strength' (assuming that PlayerOne = "FireWarrior")
I hope someone can help me and I appreciate it if you got this far.
FieldDoc
Last edited by a moderator: