Apolyton Archive  |  Preserved copy of the Apolyton Civilization Site forums as they ran on Ultimate Bulletin Board, 1998–2001. Read-only; nothing here can be posted to or replied to.  |  Forum index |  About this archive |  The 2005 site & forums

  Apolyton Civilization Site Forums
  CtP2-Creation
  Request help from SLIC expert

Post New Topic  Post A ReplyPost A Reply In A New Window

profile | register | preferences | faq | search next newest topic | next oldest topic bottom of page
Author
Topic:   Request help from SLIC expert Format for Better Printing
Steph
Settler
Mazamet, France
Dec 2000
posted March 11, 2001 10:20   Click Here to See the Profile for StephClick Here to Email Steph  send a private message to Steph
Edit/Delete Message    Reply To And Quote This Message
IP: Logged, Admin Access Only
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
Prince
Apolyton Borg Hengelo/Enschede, The Netherlands
Nov 1999
posted March 12, 2001 10:22   Click Here to See the Profile for LocutusClick Here to Email Locutus  send a private message to LocutusSend a Message to UIN: 52912776 Visit Locutus's Homepage!
Edit/Delete Message    Reply To And Quote This Message
IP: Logged, Admin Access Only
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
Settler
Mazamet, France
Dec 2000
posted March 12, 2001 12:43   Click Here to See the Profile for StephClick Here to Email Steph  send a private message to Steph
Edit/Delete Message    Reply To And Quote This Message
IP: Logged, Admin Access Only
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?

Locutus
Prince
Apolyton Borg Hengelo/Enschede, The Netherlands
Nov 1999
posted March 12, 2001 14:50   Click Here to See the Profile for LocutusClick Here to Email Locutus  send a private message to LocutusSend a Message to UIN: 52912776 Visit Locutus's Homepage!
Edit/Delete Message    Reply To And Quote This Message
IP: Logged, Admin Access Only
Steph,
What are the specs of your computer? I just remembered Alpha Wulf had some similiar problems a while ago and I couldn't explain those either. Then, out of despair, I suggested it might be his computer: the code that displays the units in the build-manager might be executed earlier/faster than the code that disables these units, and hence (sometimes) showing the units when it's not supposed to. AW tried the exact same code on a slower computer (where the display part is executed slower/later than the disable code) and it *did* work correctly...

Of course this doesn't mean my theory has to be correct, but it did show the problem could well be system-specific. Any chance you could repeat the experiment? Try out the same code on a different computer? I'll try to run the code on my system tonight or tomorrow, but I'm quite busy so I can't promise anything. Besides, I'm almost 100% positive that it will work on my sytstem as I have tested similiar things thoroughly in the past without encountering any problems.

Steph
Settler
Mazamet, France
Dec 2000
posted March 14, 2001 12:48   Click Here to See the Profile for StephClick Here to Email Steph  send a private message to Steph
Edit/Delete Message    Reply To And Quote This Message
IP: Logged, Admin Access Only
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
Settler
Oxford, England
Jan 2000
posted March 15, 2001 20:14   Click Here to See the Profile for Peter TriggsClick Here to Email Peter Triggs  send a private message to Peter Triggs
Edit/Delete Message    Reply To And Quote This Message
IP: Logged, Admin Access Only
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
Settler
Oxford, England
Jan 2000
posted March 15, 2001 20:16   Click Here to See the Profile for Peter TriggsClick Here to Email Peter Triggs  send a private message to Peter Triggs
Edit/Delete Message    Reply To And Quote This Message
IP: Logged, Admin Access Only
No, don't try that. I'll e-mail it to you; I can never get this thing to work.

Peter

Steph
Settler
Mazamet, France
Dec 2000
posted March 16, 2001 14:52   Click Here to See the Profile for StephClick Here to Email Steph  send a private message to Steph
Edit/Delete Message    Reply To And Quote This Message
IP: Logged, Admin Access Only
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
Settler
Vancouver, Canada
Feb 2001
posted March 16, 2001 20:24   Click Here to See the Profile for Madd_MugsyClick Here to Email Madd_Mugsy  send a private message to Madd_Mugsy
Edit/Delete Message    Reply To And Quote This Message
IP: Logged, Admin Access Only
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
Settler
Mazamet, France
Dec 2000
posted March 17, 2001 12:39   Click Here to See the Profile for StephClick Here to Email Steph  send a private message to Steph
Edit/Delete Message    Reply To And Quote This Message
IP: Logged, Admin Access Only
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.
Locutus
Prince
Apolyton Borg Hengelo/Enschede, The Netherlands
Nov 1999
posted March 17, 2001 13:21   Click Here to See the Profile for LocutusClick Here to Email Locutus  send a private message to LocutusSend a Message to UIN: 52912776 Visit Locutus's Homepage!
Edit/Delete Message    Reply To And Quote This Message
IP: Logged, Admin Access Only
Madd_Mugsy,
I don't think that does the trick in this particular situation. And even in the case of civ-specific units there are more elegant ways of doing this in SLIC2 (check out the Chris B's 'Another SLIC Help Request.' thread, that contains some examples of civ-specific units). In SLIC1 it was indeed the best (if not only) way of doing this (though I don't think the trade-bug could be resolved in SLIC1, you'd need more SLIC2 code to do that).

Steph,
I have no idea what could be causing your problems, so I guess using smaller increments in techs is the way to go.

Steph
Settler
Mazamet, France
Dec 2000
posted March 18, 2001 05:56   Click Here to See the Profile for StephClick Here to Email Steph  send a private message to Steph
Edit/Delete Message    Reply To And Quote This Message
IP: Logged, Admin Access Only
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
Settler
Oxford, England
Jan 2000
posted March 18, 2001 19:00   Click Here to See the Profile for Peter TriggsClick Here to Email Peter Triggs  send a private message to Peter Triggs
Edit/Delete Message    Reply To And Quote This Message
IP: Logged, Admin Access Only
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.
Apolyton Civilization Site Forums
> > > CtP2-Creation Forum

next newest topic | next oldest topictop of page

All times are EDT

Administrative Options: Close Topic | Archive/Move | Delete Topic | Top
Post New Topic  Post A ReplyPost A Reply In A New Window
Hop to:

Contact Us
Apolyton Civilization Site

Powered by: Ultimate Bulletin Board, Version 5.44a
© Infopop Corporation (formerly Madrona Park, Inc.), 1998 - 2000.

AltaVista Type or paste text or Web address (beginning with http://) here:
Powered
by Systran
Translate from: 

Front Page | Civilization III | Dinosaurs | Civilization II | Call to Power | Call to Power II | Alpha Centauri | Alternative Civs | Misc | Links | About ACS | GameStats
GameLeague | Scenario League | HAC | Civilization Scenario Collection | Spanish CivII Site | Clash of Civs | CtP Maps | Art of War | WesW's Ctp1/2 Site