 |
|  |
 |
|
Steph
|
|
Mazamet, France
Dec 2000 time: 05:14
|
|
As using 2 different tech in EnableAdvance for units doesn't work, I have tried to use SLIC.
Here is the code.
int_f mod_CanCityBuildUnit(city_t theCity, int_t theUnit)
{
if (theUnit == UnitDB(UNIT_LEGION))
{
if(HasAdvance(theCity.owner, AdvanceDB(ADVANCE_MILITARISM)))
{
return 1; // can build this
}
else
{
return 0; // can't build this
}
}
if (theUnit == UnitDB(UNIT_HUNTER))
{
if(HasAdvance(theCity.owner, AdvanceDB(ADVANCE_WHEEL)))
{
return 1; // can build this
}
else
{
return 0; // can't build this
}
}
return 1; // can build all other units
}
This way, legion should be buildable only if the player has the techs militarism and iron working (iron working is used in the unit.txt with EnableAdvance, and militarism via SLIC).
Trouble is :
- Legion can appear in the buildable units list as soon as I discover Iron Working. But they do not appear every time ! ("random" behaviour every time you open the build list of the city). When I try to add the unit, it is not added in the list... Most of the time... If I click fast enough, I can add some legions in the lists (like 2 legions if I click 10 times...).
How can I make it work??
|
|
|  |
 |
|
Locutus
|
|
ACS CTP1/2 Manager & Civ4 Co-Manager
|
 |
Hengelo, The Netherlands
Nov 1999 time: 06:14
|
|
Well, I tested these CanCityBuildxxx functions thoroughly and never had any problems with them, they always work perfectly for me. The only thing that could go wrong here (and in the other thread) that I can think of is a bug in the user-defined functions which Mr Ogre warned us about (though he didn't give much details on this bug, so I have no idea when it could occur or why). If you're being plagued by this bug, you should be able get around it by storing arguments of the function in local variables before using them instead of using them directly. So in your case it should look like this:
code: int_f mod_CanCityBuildUnit(city_t theCity, int_t theUnit) {
city_t tmpCity; // added
int_t tmpUnit; // added
tmpUnit = theUnit; // added
tmpCity = theCity; // added
if (tmpUnit == UnitDB(UNIT_LEGION)) {
if(HasAdvance(tmpCity.owner, AdvanceDB(ADVANCE_MILITARISM))) {
return 1; // can build this
} else {
return 0; // can't build this
}
}
if (tmpUnit == UnitDB(UNIT_HUNTER)) {
if(HasAdvance(tmpCity.owner, AdvanceDB(ADVANCE_WHEEL))) {
return 1; // can build this
} else {
return 0; // can't build this
}
}
return 1; // can build all other units
}
I didn't test this, so let me know if this works...
[This message has been edited by Locutus (edited March 12, 2001).]
|
|
|  |
 |
|
Steph
|
|
Mazamet, France
Dec 2000 time: 05:14
|
|
It still doesn't work !
I may have hunter in the list before I research wheel, and clicking on it doesn't not always add it in the queue. And after I discover wheel, hunter are not added to the list...
Do you think it could be because I have a lot of units and tech?
|
|
|  |
 |
|
Steph
|
|
Mazamet, France
Dec 2000 time: 05:14
|
|
My comp is a PIII 500 Mhz with 256 Mo. I agree with your idea, as the result is not systematic, and could very well depend on the speed of each part. Unfortunately, I cannot try it on a slower computer (at my office we only have faster computer). And even If I could, I don't think I will downgrade my PC just to play my mod!
I think it could not work on my PC du to the number of techs / units I have (150 units and 250 tehcs I should say). This may slow down the checking part. I will try the SLIC code with the original CTP files, and see if it runs well. In that case, I may need a faster PC, not a slower one.
|
|
|  |
 |
|
Peter Triggs
|
|
Gone Fishin, Canada
Jan 2000 time: 05:14
|
|
Steph,
I think your problem might originate in the way you modified Locutus's original code. Try this:
code:
--------------------------------------------------------------------------------
int_f mod_CanCityBuildUnit(city_t theCity, int_t theUnit) { if (theUnit == UnitDB(UNIT_LEGION)) { if(HasAdvance(theCity.owner, AdvanceDB(ADVANCE_MILITARISM))&& HasAdvance(theCity.owner, AdvanceDB(ADVANCE_IRON_WORKING)) )
{ return 1; // can build this } else { return 0; // can't build this } } if (theUnit == UnitDB(UNIT_HUNTER)) { if(HasAdvance(theCity.owner, AdvanceDB(ADVANCE_WHEEL))&& HasAdvance(theCity.owner, AdvanceDB(ADVANCE_???)) )
{ return 1; // can build this } else { return 0; // can't build this } } return 1; // can build all other units}
--------------------------------------------------------------------------------
The '???' are for your other advance in this case. It's untested but with luck it should over-ride the advance prerequisites in Units.txt.
|
|
|  |
 |
|
Peter Triggs
|
|
Gone Fishin, Canada
Jan 2000 time: 05:14
|
|
No, don't try that. I'll e-mail it to you; I can never get this thing to work.
Peter
|
|
|  |
 |
|
Steph
|
|
Mazamet, France
Dec 2000 time: 05:14
|
|
I still doesn't work. The "forbidden" unit still appears in the list from time to time. However, as it happens perhaps 10% of the time, and that in that case you cannot always add the unit to the queue, I think I can try to keep it that way. I don't really like it, as it could allow a player to build unit to early (like a nuke sub with submarine warfare, but witout fission!). The really bad thing is that the unit is not avalaible once the tehc has been discovered
Another solution would be to add tech (like nuclear submarine). What do you think? Should I add some techs, or keep a SLIC code that works 90% of the time?
I hope the "barracks" SLIC code will work better, and by combining the two code, I can make it really fun to play
I may also have another solution : what if, at the beginning of each turn, I remove from the queue any unit that should not be there
[This message has been edited by Steph (edited March 16, 2001).]
|
|
|  |
 |
|
Madd_Mugsy
|
 |
Vancouver, Canada
Feb 2001 time: 21:14
|
|
Here's a solution that can be used for this problem and for the civ-specific unit problem:
Add separate techs for units that require two or more techs to build. Grant these techs automatically using SLIC once the required two plus techs have been discovered so the player doesn't need to research them... like:
trigger 'GiveTech' when (HasAdvance(player,ID_ADVANCE_1) && HasAdvance(player, ID_ADVANCE_2))
{
//code here
}
That's CTP1 syntax, but the concept will do the trick. It'll also work for civ-specific units, when each civ has a tech corresponding to it's civ, like ADVANCE_ROMAN, etc, and each unit needs a combination of advances, like ADVANCE_JAPANESE and ADVANCE_IRON_WORKING for the samurai, etc.
plus - no more worries about oddities in the build-lists. One problem though, how do you keep the ai from trading these advances? Offhand I'd say remove the advance from their research lists, but would that do it?
|
|
|  |
 |
|
Steph
|
|
Mazamet, France
Dec 2000 time: 05:14
|
|
As I'm not very confident with SLIC code, I have decided to add a lot of "small techs", that would not cost much, and will give my units.
|
|
|  |
 |
|
Steph
|
|
Mazamet, France
Dec 2000 time: 05:14
|
|
I'm really disappointed that the SLIC code doesn't work. I don't mind that much adding new techs for my units (even if it is a bit strange sometimes, as they are not as important as other : having "nuclear carrier" beside "naval aviation" and "nuclear power" is not that good I think). What really upset me is that I can't use the barrack code! I had planned to use it a lot with barracks, stable, weapon manufacture, submarine factory, etc.
|
|
|  |
 |
|
Peter Triggs
|
|
Gone Fishin, Canada
Jan 2000 time: 05:14
|
|
Steph, you're right, this is very disappointing. I thought it might be your modifications that were causing the deviations so I tested it on the standard advances tree and got different but equally unsatisfactory results. I can't understand why. It seems the CanCityBuildUnit function can't be modified to do what you want it to do. This doesn't mean you can't do it, it just means you'd have to start from basics and write your own code, along the lines of the idea you suggested above. I guess we could use some help, from someone like Mr Ogre or whoever it was that worked in this area.
|
|
|  |
All times are GMT. The time now is 05:14. Apolyton Time is 00:14. |
top of page
|
| archivepost |
|
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
|
|
|
|
|
|