 |
|  |
 |
|
E
|
 |
July 24,2005 Ctp2 Tiles in sig!
May 1999 time: 21:18
|
|
Well my idea worked and the code now limits it to specific good.
code:
//Added by E - If Unit needs a city good it checks if the city has the resource
if(rec->GetNeedsCityGood() > 0) {
sint32 g;
bool found = false;
for(g = 0; g < g_theResourceDB->NumRecords(); g++) {
if(IsLocalResource(g)) {
if(HasResource(g) && rec->GetNeedsCityGoodIndex()== g)
found = true;
break;
}
}
if(!found)
return FALSE;
}
But I I think because of the LocalRsource part when I trade it, the city can no longer produce it and the receiving city cant. Not exactly what I want but its useful because perhaps in a agame you have to choose between building sophisticated units (or buildings) or selling it for profit. I think Oil could be used for that.
Last edited by E on 06-08-2005 at 10:33
|
|
|  |
 |
|
Martin Gühmann
|
 |
Berlin, Germany
Mar 2001 time: 06:18
|
|
quote: Originally posted by E
elements? not sure what you mean, do mean functions? all we have is IsLocalResource and HasResource. |
I told you to take a close look on the Resource class, it contains a member called m_supply. That's an array of integers. To figure out how many elements it contains I told you to take a look on the CityData constructor. A constructor is this special function that has the name of the class, and the destructor by the way is a function with the same name but with a ~ in front it.
In the CityData constructor you can see that the members of type Resource are initialized with g_theResourceDB->NumRecords(), that means that the number of elements you have wrapped in these objects are equal to the number of records you have in the ResourceDB for each good one element.
Now you have to understand with these elements represent. So check the resource class. Espeacilly these add methods.
quote: Originally posted by E
I did try to create:
code:
//this city is buying some sint32 resource added by E 9-Aug-05
BOOL CityData::IsBuyingResource(sint32 resource) const
{
return m_buyingResources[resource] > 0;
}
It didnt work because I got:
code:
F:\SVN-Code\trunk\ctp2_code\gs\gameobj\CityData.cpp(4850) : error C2039: 'IsBuyingResource' : is not a member of 'CityData'
F:\SVN-Code\trunk\ctp2_code\gs\gameobj\citydata.h(147) : see declaration of 'CityData'
F:\SVN-Code\trunk\ctp2_code\gs\gameobj\CityData.cpp(4851) : error C2270: 'IsBuyingResource' : modifiers not allowed on nonmember functions
F:\SVN-Code\trunk\ctp2_code\gs\gameobj\CityData.cpp(4852) : error C2065: 'm_buyingResources' : undeclared identifier
F:\SVN-Code\trunk\ctp2_code\gs\gameobj\CityData.cpp(4852) : error C2109: subscript requires array or pointer type
I guess I have to do something with the sellingto code there but then I get into the whole identifying the city issue which I think is not what I need. |
Obviously you did not modify CtiyData.h. But however you don't need to add such a method, because you can use m_buyingResources, m_sellingResources, m_collectingResources
quote: Originally posted by E
IsLocalResource appears to test if its collecting a resource in the cityradius. HasREsource check if it is collectingmore of a resource than its selling. So it looks likeit checks if it is NOT selling the resource that IsLocal. |
I think this is right but for clearity I reword it. It checks whether the good in question is in the city radius and that the city does not sell it.
quote: Originally posted by E
NOt sure what you are implying here...Are you saying what I specify for the Unit affects how the NeedsCityGood works? Or are saying that since I said all three are whats preferred, I was only meaning in time we may not want to limit how resources are utilized to build things. Mainly since the discussion is pretty diverse on it. But for now I'll settle with whats in the radius and if its buying the resource. |
I gave you three possibilities:
First the only one good choice.
Second the at least one of good choice.
Third the all good choice.
The first possibility contain only one good:
First case:
good1
The last two posibilities consits of lists of goods:
Second case:
good1
||good2
||good3
||good4
Third case:
good1
&&good2
&&good3
&&good4
So again what happens if you reduce the list in case 2 and 3 to just one element, so that only the first element of these list is left for instance?
-Martin
|
|
|  |
 |
|  |
All times are GMT. The time now is 05:18. Apolyton Time is 00:18. |
top of page
|
|
|
Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is ON
vB code is ON
Smilies are ON
[IMG] code is ON
|
|
|
|
|
|