Guild Researches

Post all your tuts or request for tuts here.
Post Reply
alexander19
Posts: 180
Joined: Fri Apr 02, 2010 1:05 pm

Guild Researches

Post by alexander19 »

Hello everyone!

Been working on the guilds page for my game and thus far had no problem.
But now I got stuck on the researches script.
What I do have is a donation page ,where guild members can donate an x amount of gold and another page called researches where guild members with a high rank can research different upgrades from which all members will benefit.
The thing is that the researches will have different prices and everytime you do a research,the next level will have its price higher and so on...

I couldnt think of a good way of doing it,so I made 2 tables inside the database :

Code: Select all

researches:

id   	 tinyint(2)  	   	  	
name 	varchar(30) 			
description 	varchar(255) 			
cost 	int(9) 			
level 	tinyint(2) 			
image 	varchar(100)

researched:

pid   	 int(6)  (pid=the id of the guild that made this research)	   	  	
name 	varchar(30) 			
description 	varchar(255) 			
cost 	int(9) 			
level 	tinyint(2) 			
image 	varchar(100) 


So what I thought of,is to show all researches on a page(that werent researched before)(for instance if I have 2 upgrades..attack and defense,and did attack before,now it will show attack lvl 2 and defense lvl 1) and add a RESEARCH button for all upgrades and when clicked, it would insert the current upgrade inside the "researched" table,and change the lvl and price of the next upgrade of the same type.

In essence I could do most of this stuff but I really dont got a starting point for the price & level change of the upgrades.

I noticed that in most browser based rts games they used a varbinary database type for the price/construction time/level of the current building and so on.

Eg:for price it would be something like this(20-40-60-80-100-120-140-160-180-200)..and then proly use an array to get the values.
But how could I make an interaction between the research's price and lvl?

Any hints regarding this ideea or any other research system would be greatly appreciated.

Alexander,
Rastan
Posts: 126
Joined: Tue Apr 13, 2010 1:48 am

Re: Guild Researches

Post by Rastan »

You could just set up in a good spot 2 fields on a table with the base level of upgrade ad their respective type when you create a guild. Then you could increment the level of the upgrade for the id in that field and have the code call the current level of the upgrade and put it to some type of static equation using current level as the changing variable. i.e. attack 3 is current attack. Level 4 will cost 3 x 1000 or whatever fits the bill for the amount of currency that is appropriate. Then you could just pull the current level out of the DB and manipulate it to show the cost. This would be similar to the way Halls did leveling equations in the tutorials.

That way you don't need a set field that tells the costs in the DB. The code would just apply the equation and you could echo out the number it came up with as the price. The hardest part would be making a good equation doing it that way.
alexander19
Posts: 180
Joined: Fri Apr 02, 2010 1:05 pm

Re: Guild Researches

Post by alexander19 »

hmmm I think I got your point..gonna try to put this in code.
Thanks for your help!
Post Reply

Return to “Tutorials”