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
  Need help with basic slic functions

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:   Need help with basic slic functions Format for Better Printing
Chris B
Warlord
Canton, CT
Oct 2000
posted January 26, 2001 23:20   Click Here to See the Profile for Chris BClick Here to Email Chris B  send a private message to Chris B Visit Chris B's Homepage!
Edit/Delete Message    Reply To And Quote This Message
IP: Logged, Admin Access Only
IF this is already posted somewhere, let me know, but I think it'd be good to have a basic reference point for some commonly used functions in slic. I've learned a little by checking out the scenario file in certain cenarios but if someone could do a walk through them I'd be glad.
1) making a unit, building or wonder civ specific
2) making a unit building or wonder city specific
3) creating custom victory conditions
4)Setting alliances
5) creating General type units, that are replaced as they die
6) creating wonder enabled units or improvements
7) adding messages that appear when you start
can anybody help with at least sum of these???? Me and many others (im sure) would greatly appreciate it.

[This message has been edited by Chris B (edited January 26, 2001).]
kormer
Chieftain

Jan 2001
posted January 27, 2001 17:26   Click Here to See the Profile for kormerClick Here to Email kormer  send a private message to kormer
Edit/Delete Message    Reply To And Quote This Message
IP: Logged, Admin Access Only
For setting alliances you will need to use LogregardEvent() and SetTrust() functions first to make nations like each other. Then you will have to manually make an alliance or pact from within the game. This is very annoying since there is no function to create an alliance from within the slic coding.

For messages when a game starts, thats complicated, very complicated in fact. Go download my dawn of a new millenium scenario beta thats over at omnigods site. Check out scenario.slc and follow it from there, but it provides an excellent example of how to setup individual messages for each nation.

heardie
GGS Co-Webmaster

Aug 1999
posted January 27, 2001 20:05   Click Here to See the Profile for heardieClick Here to Email heardie  send a private message to heardieSend a Message to UIN: 55652350 Visit heardie's Homepage!
Edit/Delete Message    Reply To And Quote This Message
IP: Logged, Admin Access Only
Okay thiis will be a bit brief, sorry.

1+2. You can use 'CreateUnit' or Event: CreateBuiliding for these.

See the file Slic2Func in Apolyton's modification section for the required variables.

3. The way I do it is with 'if' statments.
If you have a scenario and you need 7 cities, than everytime youo take a city, make 'citysTaken = citysTaken + 1". Then evveryturn check if 'citysTaken' == 7 and if it does they win.

4. Kormer explained that.

5. Create the unit in units.txt. Then too make it replalced when he dies, i would check the alexander code and borrow some of that, because that happens there.

6. Check
IfWonderBuilt(is that a function??) and if it is allow the unit to be built.(Maybe??)

7. Messages at start?
scenario.slc

code:

HandleEvent(BeginTurn) 'Your_Function' pre
{
Message (g.player, 'YourMessage');
DisableTrigger('Your_Function');
}


msg.slc
code:

messagebox 'YourMessage' {
Show();
Title(ID_TITLE);
Text(ID_TEXT
Button(ID_EXIT)
{
Kill();
}
}

scen_str.txt

code:

ID_TITLE "Your title here"
ID_TEXT " You message heree"

and in scenario.slc you must #include "msg.slc"


hope that helps

Chris B
Warlord
Canton, CT
Oct 2000
posted January 28, 2001 08:51   Click Here to See the Profile for Chris BClick Here to Email Chris B  send a private message to Chris B Visit Chris B's Homepage!
Edit/Delete Message    Reply To And Quote This Message
IP: Logged, Admin Access Only
sure does, but how do you include message.slc?
heardie
GGS Co-Webmaster

Aug 1999
posted January 28, 2001 17:58   Click Here to See the Profile for heardieClick Here to Email heardie  send a private message to heardieSend a Message to UIN: 55652350 Visit heardie's Homepage!
Edit/Delete Message    Reply To And Quote This Message
IP: Logged, Admin Access Only
quote:

Originally posted by Chris B on 01-28-2001 08:51 AM
sure does, but how do you include message.slc?

code:

#include "message.slc"

Chris B
Warlord
Canton, CT
Oct 2000
posted January 28, 2001 20:41   Click Here to See the Profile for Chris BClick Here to Email Chris B  send a private message to Chris B Visit Chris B's Homepage!
Edit/Delete Message    Reply To And Quote This Message
IP: Logged, Admin Access Only
I still dont understand how to make a unit available to only one civ or city
heardie
GGS Co-Webmaster

Aug 1999
posted January 29, 2001 00:10   Click Here to See the Profile for heardieClick Here to Email heardie  send a private message to heardieSend a Message to UIN: 55652350 Visit heardie's Homepage!
Edit/Delete Message    Reply To And Quote This Message
IP: Logged, Admin Access Only
That can be done
HandleEvent(StartBuilding(or similar) 'StartBuilding_f' pre

if city[0] == 'The city youu want'{
return CONTINUE;
else
return STOP;
}

This assumes you know what city it is. There is probably a better way too

Locutus
Prince
Apolyton Borg Hengelo/Enschede, The Netherlands
Nov 1999
posted January 30, 2001 06:23   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
Making a unit/building/wonder civ-specific or wonder dependent: (1, 2, 6)

Very simple actually. I'm surprised to see none of the other SLICers know this, I explained it several times already. Not that I mind explaining it again (only good for my postcount ), but still...

To do any of these things, you should use the mod_* functions. So to make a unit civ-specific, use this:

code:

int_f mod_CanCityBuildUnit(city_t theCity, int_t theUnit) {
city_t tmpCity;
int_t tmpUnit;
tmpUnit = theUnit;
tmpCity = theCity;

if (tmpUnit == UnitDB(UNIT_SAMURAI)) { // if samurai
if (PlayerCivilization(tmpCity.owner) == CivilizationIndex("JAPANESE")) {
return 1; // japanese can build it
} else {
return 0; // other civs can't
}
} elseif (tmpUnit == UnitDB(UNIT_MARINE)) { // if marine
if (PlayerCivilization(tmpCity.owner) == CivilizationIndex("AMERICANS")) {
return 1; // americans can build it
} elseif (PlayerCivilization(tmpCity.owner) == CivilizationIndex("ENGLISH")) {
return 1; // english can build it
} else {
return 0; // other civs can't
}
// } elseif (... -> etc. until all civ specific units have been treated
} else { // if other unit
return 1; // everyone can always build it
}
}


Here's another example for making buildings wonder enabled:

code:

int_f mod_CanCityBuildBuilding(city_t theCity, int_t theBuilding) {
city_t tmpCity;
int_t tmpBuilding;
tmpBuilding = theBuilding;
tmpCity = theCity;

if (tmpBuilding == BuildingDB(IMPROVE_BROKERAGE)) { // if brokerage
if (PlayerHasWonder(tmpCity.owner, WonderDB(WONDER_LONDON_EXCHANGE)) {
return 1; // civ with London Exchange can build it
} else {
return 0; // other civs can't
}
// } elseif (... -> etc. until all wonder enabled buildings have been treated
} else { // if other building
return 1; // everyone can always build it
}
}


You can do similar things for specific cities and many other conditions. Simply replace the if-conditions with whatever you need. If you have cities in variables, ala the Alexander the Great scenario, you can simply check if current city is city in variable: 'if (LondonCity == tmpCity) {' or 'if (LondonLoc == tmpCity.location) {'. If you don't have the cities in variables, use more generic techniques, like 'if (player[0].capital == tmpCity) {' (once you set player[0] to tmpCity.owner) or 'if (CityIsNamed(tmpCity, "Amsterdam")) {'. Though in this case you should keep in mind that people might rename cities or relocate the capital.

For wonders you can use mod_CanCityBuildWonder and for advances mod_CanPlayerHaveAdvance (where the city argument is replaced by a player argument). Check out the various Activision scenarios for more examples.

Victory conditions (3) can get pretty complicated, but heardie gave a nice and simple example. Have a look at the existing scenarios for more examples and try a few things yourself. If there are specific things that you can't get done, post those here. But victory conditions in general is not specific enough, the possibilities are endless.

Setting alliances (4): Kormer explained that, but you can also do it without SLIC if you prefer that. Replace the diplomacy files by a version that makes the AI really, really like and trust you when you give him your map or gold or whatever. Then give him your map or some gold a couple of times and ask for any treaty you want. After you set everything you needed to set (possibly by repeating this process a couple of times while using a different version of the diplo files every time), replace the diplomacy files with the original ones again.

Generals (5): like others said, check out the Alexander and other scenarios for that. Search all SLIC files for the text 'general' and you should find all general related code (keep in mind though that the existing code still has some unresolved bugs that Harlan and his team (including yours truly) are working on).

Messages (7): Heardie explained that.
[This message has been edited by Locutus (edited January 30, 2001).]

heardie
GGS Co-Webmaster

Aug 1999
posted January 30, 2001 19:20   Click Here to See the Profile for heardieClick Here to Email heardie  send a private message to heardieSend a Message to UIN: 55652350 Visit heardie's Homepage!
Edit/Delete Message    Reply To And Quote This Message
IP: Logged, Admin Access Only
That is much easier. I never knew how the _Mod functions worked, because they arent called in any triggers, so I never bothered to look at them, but tnow I see there use
Alpha Wolf
Settler
Chicago Illinois
Feb 2001
posted January 31, 2001 02:27   Click Here to See the Profile for Alpha WolfClick Here to Email Alpha Wolf  send a private message to Alpha Wolf
Edit/Delete Message    Reply To And Quote This Message
IP: Logged, Admin Access Only
I can code the actual functions but i cant figure out how to trigger them. Your examples make perfect sense to me but WHEN do you call them? The IFs are easy, but I cant ever get anything to actually work so I must not be triggering them right.

------------------
History is written by the victor.

Locutus
Prince
Apolyton Borg Hengelo/Enschede, The Netherlands
Nov 1999
posted January 31, 2001 05:35   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
You don't need to call them, the game calls them automaticly every time the build-window is opened and every time the AI makes a decision on what to build in a certain city. The way to look at these functions is that they overload (or 'overwrite') existing functions of the game engine that are always called to determine what can and can't be built.

If you can't get your code to work you must be doing something else wrong. If you post or email me (an example of) your code, I'll have a look at it and tell you what goes wrong.

Chris B
Warlord
Canton, CT
Oct 2000
posted February 05, 2001 21:35   Click Here to See the Profile for Chris BClick Here to Email Chris B  send a private message to Chris B Visit Chris B's Homepage!
Edit/Delete Message    Reply To And Quote This Message
IP: Logged, Admin Access Only
alright. tonite i tried creting a message for a scenario
i put #include mesage.slc in scenario and made a message in the file as well as a msg_str, but when it loaded it said message.slc was not in an the asset tre. It also said there was a syntax error in scenario.slc

herez what i put in scenario.slc:
// Scenario script for The Communists Have Come

#include "message.slc"

HandleEvent(BeginTurn) 'Show()' pre
{
Message (g.player, 'Intro');
DisableTrigger('ID_EXIT');
}

also, should message be a wordpad doc or a txt dod. i have it as a txt doc.
Thanx 2 anyone who helps.
-CB

ALPHA_WOLF
Warlord
Canton, CT
Oct 2000
posted February 06, 2001 04:02   Click Here to See the Profile for ALPHA_WOLFClick Here to Email ALPHA_WOLF  send a private message to Chris B Visit ALPHA_WOLF's Homepage!
Edit/Delete Message    Reply To And Quote This Message
IP: Logged, Admin Access Only
[quote]Originally posted by Locutus on 01-31-2001 05:35 AM
You don't need to call them, the game calls them automaticly every time the build-window is opened and every time the AI makes a decision on what to build in a certain city. The way to look at these functions is that they overload (or 'overwrite') existing functions of the game engine that are always called to determine what can and can't be built.
quote]

this is good to know. I've been adding more wonders that give buildings and I really dont want to AI to keep building those buildings. Its a waste of prod and support costs. I'd also like for the human player buildings that are redundant due to wonders, to be in another color in the build list or even in the built buildings under the city. Is this possible? Can the AI be told to sell a building? I didnt see that listed under the functions, or maybe I just missed it.

I'm still annoyed my previous SLIC attempts dont work on my new machine, but do work on my old one...grrrrrrrrrrrr I've tried every change I could think of but got screwy results every time.

------------------
History is written by the victor.

Locutus
Prince
Apolyton Borg Hengelo/Enschede, The Netherlands
Nov 1999
posted February 06, 2001 11:37   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
Chris,
I'm getting the impression you didn't understood messages correctly. I think what you're trying to do is the following:

In file scenario.slc:

code:

// Scenario script for The Communists Have Come

#include "message.slc"

HandleEvent(BeginTurn) 'ShowMessage' pre {
Message(g.player, 'Intro');
DisableTrigger('ShowMessage');
}


In file message.slc:

code:

// Scenario messages for The Communists Have Come

Messagebox 'Intro' {
Show();
Text(ID_EXIT);
}


In file msg_str.txt:

code:

EXIT "Put message here"

What this does is show the message "Put message here" to the first player in the first turn and after that this code is never executed again (not sure if the first player is human or barbarian but replacing g.player with 1 will always send the message to player 1, i.e. normally the human player). Is this what you wanted or am I misinterpreting your intentions?

What goes wrong in your current set up is that the file message.slc doesn't even exist. The idea is that you not only put that line in scenario.slc but also actually create the file and put all messagecode in there. Alternatively you could just put all SLIC code (HandleEvent and Messagebox) in 1 file (scenario.slc), nothing wrong with that either. All files in CtP2 are regular text files (txt), Word documents (doc) aren't used by the game.

AW,
I guess I wasn't clear enough about that. The mod_* functions are executed when the AI makes his build orders as well, the AI has an event that's equivilant to the 'human event' of opening the build-manager. So the changes you make in these mod_* functions apply to humans as well as AIs. If you don't want the AI to build certain things, use a condition like IsHumanPlayer. I don't think you can edit the colors in the build manager, but maybe if you dig really deep in the ldl files you might be able to figure out a way (though noone has ever really done that before, so you'd be boldy going where no man has gone before... ). Yes, the AI can be told to sell buildings using SLIC: there's a SellBuilding event that can probably be called with 'Event:SellBuilding();', but I didn't actually try yet.

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.

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