Latest topics
» The good, the bad, and the ugly
Sun Jun 20, 2010 7:45 pm by Admin

» Events are happing
Wed Apr 14, 2010 11:29 pm by Admin

» Progress! . . .
Fri Apr 09, 2010 5:10 pm by Admin

» Soulmen(jordan)
Wed Feb 24, 2010 7:56 pm by soulmen

» Basic starting blocks
Wed Feb 24, 2010 7:41 pm by Admin

» Okay so uni isn’t so demanding as I first thought.
Mon Oct 26, 2009 4:39 pm by Admin

» MP Architecture: Client/Server or Peer-2-Peer?
Sun Oct 04, 2009 2:34 pm by Daemn

» What I am working on at the Moment READ!
Fri Sep 25, 2009 5:15 pm by Admin

» Development Framework available at SourceForge
Tue Sep 22, 2009 9:46 am by Hairein

Navigation
 Portal
 Index
 Memberlist
 Profile
 FAQ
 Search

Scripting!

Go down

Scripting!

Post by Admin on Wed Sep 09, 2009 9:37 pm

I haven't had much chance to look myself but these offer a bit of info on scripting. Which I figured would be what we need to do to write our game data outside the compiled source code.

Creating a Scripting System in C++ Part I: An Introduction by Greg Rosenblatt.
http://www.gamedev.net/reference/articles/article1633.asp
http://www.gamedev.net/reference/articles/article1686.asp
http://www.gamedev.net/reference/articles/article1788.asp
http://www.gamedev.net/reference/articles/article1803.asp
http://www.gamedev.net/reference/articles/article1877.asp

I shall also be uploading 2 zip files to the wiki, which you should have look at. I shall post the links here shortly

We will then be able to load data as such

#life=100
#attack=12

or in Civ file
[Buildings]=7
#TownHall
#LumberCamp
#Quary
#OreMine
#GoldMine
#Blacksmith
#GovenmentCentre

[BuildingRequirments]
<TownHall>=5 <Req>=2 #Blacksmith #Level=1 #GovenmentCentre #Level=1
<LumberCamp>=1 <Req>=1 #TownHall #Level=1
<Blacksmith>=1 <Req>=1 #TownHall #Level=3

Admin
Admin
Admin

Posts : 105
Points : 3504
Reputation : 3
Join date : 2009-07-16
Age : 28
Location : Wrexham, United Kingdom

View user profile http://spartanstudioforum.darkbb.com

Back to top Go down

Re: Scripting!

Post by Admin on Thu Sep 10, 2009 1:44 am

Update: To start with we will be making 4 civs. Athens, Sparta, Troy, Persia
The Nation of a player is read in from a file called, Nations.txt

Athens Athens.txt
Sparta Sparta.txt
Troy Troy.txt
Persia Persia.txt

this data gets read into an array of somesort

Need the program to open the respective nation file.
In this nation file we need to pull out certain bits of data.


List all buildings avalable to nation, up to a maximum of 20, with filenames.

[MEMBERS]
TownHall townhall_sparta.txt
LumberCamp lumbercamp_sparta.txt
Quarry quarry.txt
Blacksmith blacksmith.txt

[BuildingRequirments]
//These need to be accessed when determining weather certain building requirments have been met

Building=Blacksmith Level=1 Req=2 TownHall #level 3 OreMine #level 1

Buildingfiles

Name=Blacksmith
Wood=100
Marble=120
Bronze=60
Gold=25
BuildTime
BuildPtsGenerted

for example our user clicks to build a level 1 blacksmith. We need to tell the program which buildings need to be a certain level
in this example as our player is sparta, the program must open nation file "Sparta.txt" jump to [BuildingRequirments] and find out the number of requirments. Extact them an on by one place them into tthis function

buildRequirments(building_name, level)
buildRequirments(1, 3)


Last edited by Admin on Fri Sep 11, 2009 9:36 am; edited 1 time in total (Reason for editing : it was a mess, probably still is)

Admin
Admin
Admin

Posts : 105
Points : 3504
Reputation : 3
Join date : 2009-07-16
Age : 28
Location : Wrexham, United Kingdom

View user profile http://spartanstudioforum.darkbb.com

Back to top Go down

Re: Scripting!

Post by Admin on Fri Sep 11, 2009 9:39 am

  • The buildings that are to be used in the game should be writen to a text file as a list. If the name of the building isn't present then the building isn't in the game.

    The buildings data is to be stored in individual files, which data is to be extracted on request.
    When buildings become avaliable for a player is determined by the Nation file of the user.
    Nations have to be writen in a text file as a list, however they also need the full file name for their respective Nation file.


Athens, "Athens.txt"

The buildings a nation can construct are to be declared at the top of the Nation file. This idealy should be done in the format of.


TownHall "TownHall_Athens.txt"
Blacksmith "Blacksmith_Athens.txt"

The order in which these 'buildings' are stored should also indicate which point they fill in the territory array.
1st in list represented by array[i][2]
2nd in list represented by array[i][3]

TownHall is then used throughout the file to determine operations on it.

We need to tell the main program, what building we wish to construct. Donoted by its name.We also want the level that our building will become.
after this we need to determine what other buildings we need to consttruct the proposed building, stating the level required of these structures.


TownHall, 5, Blacksmith, 1
Blacksmith, 1, TownHall, 3, OreMine, 5

Please note that this isn't the correct way of doing this, just the way I see as the most flexable. You may add variables, functions, classes, even namespaces if you want, as long as it works and gets the required data, but most of all the job done.

Admin
Admin
Admin

Posts : 105
Points : 3504
Reputation : 3
Join date : 2009-07-16
Age : 28
Location : Wrexham, United Kingdom

View user profile http://spartanstudioforum.darkbb.com

Back to top Go down

Re: Scripting!

Post by diego_pmc on Sat Sep 12, 2009 6:28 pm

I nearly finished writing the draft of the scripting system. There are still a few (pretty weird) errors I have to fix, and then I'll post it here as well. In the mean time, if anyone is interested in taking a look and maybe help with fixing the error, please click here:
http://www.dreamincode.net/forums/index.php?showtopic=125368

If you have any kind of observations related to how the scripting system currently works (maybe you would like data to be saved in a different format, etc), please post them here instead of that thread I just mentioned.
avatar
diego_pmc
Novice
Novice

Posts : 4
Points : 3243
Reputation : 0
Join date : 2009-09-10
Age : 25

View user profile

Back to top Go down

Re: Scripting!

Post by Admin on Sat Sep 12, 2009 8:18 pm

I'll have a better look tonight, One thing though, you may want to look at this file BuildingClass.h
I don't acctualy think it matters that you've made a file buildings.h. Just that we use a copy constructor for the resources.

Resources & resource, In a .cpp file we do this at the moment.

Resources current_player_resources (some array/list elsewhere)

Resources building_cost(wood, marble, bronze, gold)
BuildingsClass building_data(building_cost, blah, blah, blah . . . . . . .)

I suspect that this can stay the same, just the referances where the data is pulled from will be extracted/set by your buildings.h file right?

we just set, say the wood var, for example to -> int BldGold(TextFile&) http://ageofgreeks.wikispaces.com/file/detail/08Sept2009.rar/87675023


Last edited by Admin on Sat Sep 12, 2009 8:41 pm; edited 1 time in total

Admin
Admin
Admin

Posts : 105
Points : 3504
Reputation : 3
Join date : 2009-07-16
Age : 28
Location : Wrexham, United Kingdom

View user profile http://spartanstudioforum.darkbb.com

Back to top Go down

Re: Scripting!

Post by diego_pmc on Sat Sep 12, 2009 9:13 pm

Oh, okay. That's not hard to change at all. As I said, for now I only want to get the basic stuff in place.

EDIT: Also, my "building.h" is pretty much supposed to be later integrated into the "BuildingClass.h" you mentioned. The reason I didn't extend on the already existing header is just so that I could concentrate on the scripting system alone. (Same with "civilization.h".)

EDIT 2: So let's see if I understood this correctly: you would like "building.h" to have an instance of class Resources, something like 'required_resources', which would store what that building needs in order to be built, right?

And then I suppose the player would have an instance of that class as well, which would hold the amount of resources the player has ATM.

Also, I think it would be better if instead of having two functions, 'AddWood(int)' and 'RemoveWood(int)', we would have just the 'AddWood(int)' function, and if we wanted to take some wood away, we would just pass a negative int as a parameter.


Last edited by diego_pmc on Sat Sep 12, 2009 10:45 pm; edited 3 times in total
avatar
diego_pmc
Novice
Novice

Posts : 4
Points : 3243
Reputation : 0
Join date : 2009-09-10
Age : 25

View user profile

Back to top Go down

Re: Scripting!

Post by Admin on Sat Sep 12, 2009 9:49 pm

EDIT 2: So let's see if I understood this correctly: you would like "building.h" to have an instance of class Resources, something like 'required_resources', which would store what that building needs in order to be built, right?

yes this is correct. somthing like that, just work on reading the data in for now, it shouldn't be to hard to join everything together later.

Also, I think it would be better if instead of having two classes, 'AddWood(int)' and 'RemoveWood(int)', we would have just the 'AddWood(int)' class, and if we wanted to take some wood away, we would just pass a negative int as a parameter.

yes it's a bit daft to have two functions for basicaly the same thing. I ment to get rid of one of them earlier. So yea, just go ahead and take it out.

Admin
Admin
Admin

Posts : 105
Points : 3504
Reputation : 3
Join date : 2009-07-16
Age : 28
Location : Wrexham, United Kingdom

View user profile http://spartanstudioforum.darkbb.com

Back to top Go down

Re: Scripting!

Post by diego_pmc on Thu Sep 17, 2009 5:58 pm

Hey, I haven't been able to work on the program during these past wekk days — school. Smile I'll probably manage to work on during weekends, so I figured I should mention that my progress is going to slow down a little bit.
avatar
diego_pmc
Novice
Novice

Posts : 4
Points : 3243
Reputation : 0
Join date : 2009-09-10
Age : 25

View user profile

Back to top Go down

Re: Scripting!

Post by Admin on Thu Sep 17, 2009 9:15 pm

Alright, no problem, thanks for letting us know. I've been doing a bit myself

Admin
Admin
Admin

Posts : 105
Points : 3504
Reputation : 3
Join date : 2009-07-16
Age : 28
Location : Wrexham, United Kingdom

View user profile http://spartanstudioforum.darkbb.com

Back to top Go down

Re: Scripting!

Post by Sponsored content


Sponsored content


Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum