@LBFN - I had a deeper look at this but i can see a bit of a problem with it. Although it seems a nice way to set up a type within a type the problem i have is i need to make arrays for the factions which now i cant do because things like Knights(1).info(2).Health - to link it to that faction wouldnt work. So i cant seem to find a way to categorise things without starting with having things set up like faction(1).something
Faction info is huge, there are all sorts of flags and info so i presume everything has to be based around it somehow.
Another problem i come to is things happening at the same time. I could have multiple factions attacking multiple factions so i need to cycle through pretty much everything updating data as i go and this is making my head spin trying to work it out.
@Bulsatar - i like the sound of doing an external file reading in and altering then saving data out to a file but i have not gone that far just yet so i will need to brush up on my "creating, saving, loading, reading files" programming before i could attempt somthing like this but i reckon its a viable option. To second what you said about pen and paper, i already have masses of sheets full of scribblings working out what variables i will need and may need and what certain values are worth and what limitations the AI has and how it makes decisions and so on. Its not really working for me reading through it again at the moment because i keep changing so much when i realise i cant go any further with something or get stuck and have to rewrite.
For anyone who is interested here is all the code i wrote so far but this does not include the combat system as i was building it a different way in a seperate project first and i was going to work around fitting it in when i got it right.
Second i am far from finished (the AI doesnt even make any decisions yet), even the screen will be laid out differently as i now realise i need a larger bit at the top and to squeeze all the other info in at the bottom but i can come to all that later. This combat system is whats holding me up.
Randomize Timer()
Global Time = Timer()
Global Seconds ` How many seconds the game has been going
Global LatestNews As String
Type KnightType
Number As Integer ` Amount of knights
Strength As Integer
Health As Integer
EndType
Type FactionType
KingName As String ` Faction Leaders Name
Number As Integer ` Faction Number
BoxPosition As Integer ` Which box on the screen the info will be read out at
Money As Integer ` How much money the faction has
Tactic As Integer ` 1-3 which tactic they choose (1 - Aggresive, 2 - Normal, 3 - Defence)
Peasants As Integer ` How many peasants
Knights As KnightType ` How many Knights
Defence As Integer ` The defence bonus of the faction (1 - 10 depending on upgrades)
Latest As String ` Shows the last action the faction performed, i.e upgraded tower, is attacking x
STime As Integer ` SpawnTime - This is the time for how long the faction has been going.
MoneyCounter As Integer ` A resettable counter for when taxes are paid
MoneyFlag As Integer ` This is a flag to denote certain milestones have been achieved like the first 1000 coins, or 10,000 coins
PeasantCounter As Integer ` A resettable counter for when peasants are spawned
EndType
` Box 1 shows the latest news, this is an array to store and move the latest news around
Global Dim Lines(6) as string
For a = 1 to 5
Lines(a) = "Blank"
Next a
Global DesiredFactions = 5 ` How many factions are desired at the time. 5 At first, usually only one after that per counter.
ScreenSetup()
InitialiseGame()
`Main Game Loop
Do
Cls
If Timer() > Time + 1000
Inc Seconds
For a = 1 To 5
Inc Faction(a).STime
Next a
Time = Timer()
Endif
If DesiredFactions > 0
SpawnFaction()
Endif
OutputDisplay()
IncreasePeasants()
IncreaseMoney()
Loop
Function ScreenSetup()
Cls
Set Window On
a = Desktop Width()
b = Desktop Height()
c = a/2
d = b/2
e = c / 2
f = d / 2
Set Display Mode c, d, 32
Set Window Position e, f
EndFunction
Function InitialiseGame()
`This creates all the arrays and data for the names (undim everything if you play again)
Dim Title$(4)
Dim Fnames$(11)
Dim EndTitle$(21)
For a = 1 To 4
Read Title$(a)
Next a
For a = 1 To 11
Read Fnames$(a)
Next a
For a = 1 To 21
Read EndTitle$(a)
Next a
DATA "Sir", "Lord", "King", "Baron"
DATA "John", "David", "Somarl", "Enerzeal", "Richard", "Paul", "James", "Glanthor", "Robert", "Nathaniel", "Roger"
DATA "The Coward", "The Bastard", "The Depraved", "The Brave", "The Lionheart", "The Warmonger", "The Slimy", "The Hopeless", "The Wise", "The Glorious", "The Stonewall", "The Fool", "The Feared", "The Incredible", "The Mighty", "The Gluttonous", "The Merciful", "The Kind", "The Wicked", "The Conqueror", "The Noble"
`End Name bit
Global Dim Faction(5) As FactionType
Global Time As Integer ` Setup timer for countdowns etc
Time = Timer()
SpawnFaction()
Endfunction
Function SpawnFaction()
For a = 1 To 5
If DesiredFactions > 0
If Faction(a).Number = 0
Faction(a).KingName = SpawnKingName(Name$)
Faction(a).Number = a
Faction(a).BoxPosition = a + 1
Faction(a).Money = Rnd(300) + 200
Faction(a).Tactic = Rnd(2) + 1
Faction(a).Peasants = RND(4) + 1
Faction(a).Knights.Number = 0
Faction(a).STime = Seconds
Faction(a).MoneyFlag = 0
Endif
Dec DesiredFactions
If DesiredFactions < 1 Then Exit
EndIf
Next a
Endfunction
Function SpawnKingName(Name$)
KingTitle$ = Title$(RND(3) + 1)
KingFName$ = Fnames$(RND(10) + 1)
KingEndTitle$ = EndTitle$(RND(20) + 1)
Name$ = KingTitle$ + " " + KingFName$ + " " + KingEndTitle$
Endfunction Name$
Function CleanAssets()
Undim Faction(5)
UnDim Title$(4)
UnDim Fnames$(5)
UnDim EndTitle$(5)
Endfunction
Function OutputDisplay()
remstart
````````````````````````````````````````````
````````````````````````````````````````````
Print "Timer : ", Timer()
Print "Time : ", Time
Print "Seconds : ", Seconds
For a = 1 To 5
Print "Faction ", a, " STime : ", Faction(a).STime
Next a
````````````````````````````````````````````
````````````````````````````````````````````
remend
`Draw Lines to break up the screen
Line Screen Width() / 2, 0, Screen Width() / 2,Screen Height()
Line 0, Screen Height() / 3, Screen Width(), Screen Height() / 3
Line 0, Screen Height() / 3 * 2, Screen Width(), Screen Height() / 3 * 2
`Update the contents of box one which displays overall events.
EventUpdate()
b = 10 ` Position of text variable for first box
c = 130 ` c, d and e are colour variables for first box
d = 130
e = 130
For a = 1 to 5
ink RGB(c, d, e), RGB(0,0,0)
Text 10, b, "" + Lines(a)
Inc b, 20
Inc c, 25
Inc d, 25
Inc e, 25
Next a
For a = 1 to 5
If Faction(a).BoxPosition = 2
Text Screen Width() /2 + 10, 10, "Faction Leader : " + Faction(a).KingName
Text Screen Width() /2 + 10, 30, " Money : " + Str$(Faction(a).Money) + " Coins"
Text Screen Width() /2 + 10, 50, " Tactic : " + Str$(Faction(a).Tactic)
Text Screen Width() /2 + 10, 70, " Peasants : " + Str$(Faction(a).Peasants)
Text Screen Width() /2 + 10, 90, " Knights : " + Str$(Faction(a).Knights.Number)
Text Screen Width() /2 + 10, 110, " Defence : " + Str$(Faction(a).Defence)
Text Screen Width() /2 + 10, 130, " Latest Action : " + Faction(a).Latest
Endif
If Faction(a).Boxposition = 3
Text 10,Screen Height() / 3 + 10, "Faction Leader : " + Faction(a).KingName
Text 10,Screen Height() / 3 + 30, " Money : " + Str$(Faction(a).Money) + " Coins"
Text 10,Screen Height() / 3 + 50, " Tactic : " + Str$(Faction(a).Tactic)
Text 10,Screen Height() / 3 + 70, " Peasants : " + Str$(Faction(a).Peasants)
Text 10,Screen Height() / 3 + 90, " Knights : " + Str$(Faction(a).Knights.Number)
Text 10,Screen Height() / 3 + 110, " Defence : " + Str$(Faction(a).Defence)
Text 10,Screen Height() / 3 + 130, " Latest Action : " + Faction(a).Latest
Endif
If Faction(a).Boxposition = 4
Text Screen Width() /2 + 10, Screen Height() / 3 + 10, "Faction Leader : " + Faction(a).KingName
Text Screen Width() /2 + 10, Screen Height() / 3 + 30, " Money : " + Str$(Faction(a).Money) + " Coins"
Text Screen Width() /2 + 10, Screen Height() / 3 + 50, " Tactic : " + Str$(Faction(a).Tactic)
Text Screen Width() /2 + 10, Screen Height() / 3 + 70, " Peasants : " + Str$(Faction(a).Peasants)
Text Screen Width() /2 + 10, Screen Height() / 3 + 90, " Knights : " + Str$(Faction(a).Knights.Number)
Text Screen Width() /2 + 10, Screen Height() / 3 + 110, " Defence : " + Str$(Faction(a).Defence)
Text Screen Width() /2 + 10, Screen Height() / 3 + 130, " Latest Action : " + Faction(a).Latest
Endif
If Faction(a).Boxposition = 5
Text 10,Screen Height() / 3 * 2 + 10, "Faction Leader : " + Faction(a).KingName
Text 10,Screen Height() / 3 * 2 + 30, " Money : " + Str$(Faction(a).Money) + " Coins"
Text 10,Screen Height() / 3 * 2 + 50, " Tactic : " + Str$(Faction(a).Tactic)
Text 10,Screen Height() / 3 * 2 + 70, " Peasants : " + Str$(Faction(a).Peasants)
Text 10,Screen Height() / 3 * 2 + 90, " Knights : " + Str$(Faction(a).Knights.Number)
Text 10,Screen Height() / 3 * 2 + 110, " Defence : " + Str$(Faction(a).Defence)
Text 10,Screen Height() / 3 * 2 + 130, " Latest Action : " + Faction(a).Latest
Endif
If Faction(a).Boxposition = 6
Text Screen Width() /2 + 10,Screen Height() / 3 * 2 + 10, "Faction Leader : " + Faction(a).KingName
Text Screen Width() /2 + 10,Screen Height() / 3 * 2 + 30, " Money : " + Str$(Faction(a).Money) + " Coins"
Text Screen Width() /2 + 10,Screen Height() / 3 * 2 + 50, " Tactic : " + Str$(Faction(a).Tactic)
Text Screen Width() /2 + 10,Screen Height() / 3 * 2 + 70, " Peasants : " + Str$(Faction(a).Peasants)
Text Screen Width() /2 + 10,Screen Height() / 3 * 2 + 90, " Knights : " + Str$(Faction(a).Knights.Number)
Text Screen Width() /2 + 10,Screen Height() / 3 * 2 + 110, " Defence : " + Str$(Faction(a).Defence)
Text Screen Width() /2 + 10,Screen Height() / 3 * 2 + 130, " Latest Action : " + Faction(a).Latest
Endif
Next a
Endfunction
Function IncreasePeasants()
For a = 1 To 5
If Faction(a).STime > Faction(a).PeasantCounter + 4
Inc Faction(a).Peasants, RND(2) + 1
Faction(a).PeasantCounter = Faction(a).STime
Endif
Next a
Endfunction
Function IncreaseMoney()
For a = 1 To 5
If Faction(a).STime > Faction(a).MoneyCounter + 15
Inc Faction(a).Money, Faction(a).Peasants * 4
Faction(a).MoneyCounter = Faction(a).STime
Endif
Next a
Endfunction
Function EventUpdate()
For a = 1 to 5
If Faction(a).MoneyFlag = 0
If Faction(a).Money = 1000 or Faction(a).Money > 1000
Inc Faction(a).MoneyFlag ` So it wont repeat this process everytime they get 1000, i only want it to report once.
Faction(a).Latest = "Has hit 1000 coins"
LatestNews = Faction(a).KingName + " has collected 1000 coins already"
BoxUpdate()
Endif
EndIf
If Faction(a).MoneyFlag = 1
If Faction(a).Money = 5000 or Faction(a).Money > 5000
Inc Faction(a).MoneyFlag ` So it wont repeat this process everytime they get 5000, i only want it to report once.
Faction(a).Latest = "Has hit 5000 coins"
LatestNews = Faction(a).KingName + " has collected 5000 coins already"
BoxUpdate()
Endif
EndIf
If Faction(a).MoneyFlag = 2
If Faction(a).Money = 10000 or Faction(a).Money > 10000
Inc Faction(a).MoneyFlag ` So it wont repeat this process everytime they get 10000, i only want it to report once.
Faction(a).Latest = "Has hit 10000 coins"
LatestNews = Faction(a).KingName + " has collected 10000 coins already"
BoxUpdate()
Endif
EndIf
Next a
Endfunction (LatestNews)
Function BoxUpdate() `Function for swapping the lines out, making earlier news rise to the top and new news is inserted at the bottom
Lines(6) = LatestNews
For a = 1 to 5
Lines(a) = Lines(a+1)
Next a
Endfunction
Youll have to leave it running about 3 minutes to see its full potential so far lol.
Its not much but you might be able to see where i am trying to go with this.
I really need help with it though as its like staring at a blank canvas and just not being able to paint, its horrible.
Much appreciated.