Announcement

Collapse
No announcement yet.

CTP1: SLIC 1.1 EXTRAS

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • CTP1: SLIC 1.1 EXTRAS

    By Winnie Lee
    June 4, 1999

    Note: This is the Developer's Corner, a part of the C:CTP section of Apolyton, where members of the C:CTP development team express their views on ctp-related topics.

    It's a wee bit lonely out here, since more than half the team's away on holidays, so I thought I'd sneak in a little bit more information on SLIC. Mind you, this is not aimed at programmers and programmer-type people - this is just a little bit of random easy stuff. It's for those who may not necessarily want to go through the whole rigmarole of writing a scenario, but would like a couple of little cool SLIC things in their games. So advanced users, don't flame me for the simplicity - this isn't for you!

    Right off the bat, I usually start by modifying the text files in ctp_data/default/gamedata. There is some documentation on how to modify text files, so I won't go into that here. Generally, the things that get changed are enabling and obsoleting advances, costs, unit movement, restrictions, government modifiers, terrain values, improvement effects, wonder effects, and a whole lot of text strings. These changes are pretty easy - as long as you keep quotes around text and keep the lines in order, these are relatively harmless changes. The only general guideline is to avoid really huge numbers (like when an order of magnitude becomes trivial), and negative numbers (unless you see other negative numbers being used).

    It's the stuff that SLIC can do that makes it a little risky. You can control almost everything in the game through SLIC, either directly or with some kind of work-around (my favourite method). MrOgre (Joe Rumsey), our illustrious programmer and SLIC guru, has posted some great documentation on using SLIC. He has also posted a lot of examples that people have asked for in the forum. I hope that this will be useful to someone out there, but more importantly, that it will generate more suggestions for things that we can add to SLIC. At the very worst, it's kind of fun to play with this stuff.

    TERRAIN

    Here's something that Joe didn't put in the SLIC documentation (ha ha, Joe, you owe me a Coke):

    Code:
     0 TERRAIN_TYPE_FOREST
     1 TERRAIN_TYPE_PLAINS
     2 TERRAIN_TYPE_TUNDRA
     3 TERRAIN_TYPE_GLACIER
     4 TERRAIN_TYPE_GRASSLAND
     5 TERRAIN_TYPE_DESERT
     6 TERRAIN_TYPE_SWAMP
     7 TERRAIN_TYPE_JUNGLE
     8 TERRAIN_TYPE_MOUNTAIN
     9 TERRAIN_TYPE_HILL
    10 TERRAIN_TYPE_WATER_SHALLOW
    11 TERRAIN_TYPE_WATER_DEEP
    12 TERRAIN_TYPE_WATER_VOLCANO
    13 TERRAIN_TYPE_SPACE
    14 TERRAIN_TYPE_WATER_BEACH
    15 TERRAIN_TYPE_WATER_SHELF
    16 TERRAIN_TYPE_WATER_TRENCH
    17 TERRAIN_TYPE_WATER_RIFT
    18 TERRAIN_TYPE_DEAD
    19 TERRAIN_TYPE_BROWN_HILL
    20 TERRAIN_TYPE_BROWN_MOUNTAIN
    21 TERRAIN_TYPE_WHITE_HILL
    22 TERRAIN_TYPE_WHITE_MOUNTAIN
    23 TERRAIN_TYPE_DEAD_HILL

    The number preceding each terrain type is the terrain index. The terrain index can be used for nifty little tricks like this:

    Code:
    Trigger 'ChangeTerrainToGlacier' when (unit.moved && unit.type == UnitType("UNIT_ABOLITIONIST")) {
    	Terraform(unit.location, 3);
    	//terrain index 3 is glacier
    }

    The abolitionist, being the frosty female that she is, will turn every tile she steps on into glacier. You can use the Terraform(location, terrain_index) function with the PlantGood(location) function too - for example, if you want to make the Cyber Ninja a fertility goddess instead of the Ice Queen, -

    Code:
    Trigger 'ChangeTerrainAndAddGoods' when (unit.moved && unit.type == UnitType("UNIT_CYBER_NINJA")) {
    	Terrform(unit.location, 4);
    	//terrain index 4 is grassland	
    	PlantGood(unit.location);
    	//after the terrain has terraformed, plant a good there
    }

    - Which will turn every tile the Cyber Ninja steps on into grassland, and then plant tobacco or poppies on the same tile.

    Here's another thing you can do:

    Code:
    TypeLocation last_tile_unit_was_on;
    Trigger 'GetLastLocation' when (g.player == 1 && unit.moved && unit.type == UnitType("UNIT_SETTLER")) {
    	DisableTrigger('GetLastLocation');
    	//only run this trigger once
    	ExtractLocation(unit.location, last_tile_unit_was_on);
    	//get the very first tile that the settler moved to
    	year_start = 1;
    	//start counting turns
    }
    Code:
    Trigger 'InitTurn' when (g.player == 1) {
    	If(year_start) {
    		Year_start = year_start + 1;
    		//when the unit moves, start incrementing the turns
    	}
    	If(year_start == 6) {
    		Terraform(last_tile_unit_was_on, 3);
    		//when 5 turns have passed, turn that tile into glacier	
    	}
    }

    So the very first tile that the settler moves to is saved as last_tile_unit_was_on. Five turns later, that tile turns into glacier.

    BTW, if you just want to see these triggers work, cut and paste them into script.slc (make a backup copy before doing so!!!), start a new game, and cheat yourself an Abolitionist or a Cyber Ninja, then move them around. However, this is my little cheaty way to see things in a hurry. The right way to do this is to put the triggers in a file called scenario.slc, and place it in the directory with the saved game like this:

    ctp_program/ctp/save/game/folder_with_saved_game/default/gamedata/scenario.slc

    That way, it will only happen when you load a saved game from that folder. Otherwise, if you leave the triggers in script.slc, it will happen in every game.

    You may want to think twice about changing land into water or vice versa, because it may not work the way you thought it would. Why? Well, let's say you have a single tile island. Eight beach tiles surround that single tile. Those 8 beach tiles are themselves surrounded by 16 trench or shelf tiles. Trench and rift tiles are surrounded by deep water - 24, to be exact. Changing any of these tiles to land requires that you also change its surrounding tiles for a smooth transition.

    One more thing: TERRAIN_TYPE_DEAD_HILL doesn't exist, so don't use 23 as the terrain index - it'll give you a black hole that can be traveled like any other tile, but like dead tiles, has no production, food, or gold. Of course, you can change all this in terrain.txt, which would allow you to have a black tile with whatever gold, production, food, or movement that you choose. [Just thought I'd let you know.]

    CUSTOMISING C:CTP

    Here are a couple of ways to customise the way the game works. Let's say you want to have the diplomacy screen open when you click on a foreign unit. You could do:

    Code:
    Trigger 'OpenDiplomacyScreen' when (g.player == 1 && clicked.unit && unit.owner != 1) {
    	OpenDiplomacy();
    }

    This is only useful in single player games, where the human player is player 1. I like this option, but only when I'm not playing bloodlust on.

    You could also use a sound cue to tell you which units are yours and which ones are not:

    Code:
    Trigger 'PlayUnitSound' when (g.player == 1 && clicked.unit) {
    	If(unit.owner != 1) {
    		PlaySound("SOUND_ID_GIANT_SQUID");
    	}
    }

    If you click on units that are not yours, you will hear the squid sound. You can also add sounds of your own (units that are not mine say, "Bite me"). To do this, you need to do 2 things: first, copy the .wav files into ctp_data/default/sound, then open up sounds.txt located in ctp_data/default/gamedata. There is the number "1048" at the top - the total number of sounds. If you're adding one new sound, change the number to "1049". Give the sound an ID - like "SOUND_ID_BITE_ME". In quotes, put the .wav file name: "bite_me.wav". So your sounds.txt file should look something like this:

    Code:
    #sounds.txt (SoundDB)
    1049
    #
    SOUND_ID_BITE_ME		"bite_me.wav"
    #
    SOUND_ID_NONE			" "
    Etc.

    Again, and I can not stress this enough, MAKE A BACKUP COPY OF ALL THE FILES YOU PLAN TO CHANGE BEFORE CHANGING ANYTHING!

    Last edited by Martin Gühmann; April 23, 2012, 17:02.
    Civ2 military advisor: "No complaints, Sir!"
Working...
X