Announcement

Collapse
No announcement yet.

Some SLIC I haven't seen before

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

  • Some SLIC I haven't seen before

    Okay, so like I finally got around to pulling this old game out from under a layer of dust and started to look at this huge mod I was working on a couple years ago...

    Anyway, I found this SLIC code I did and thought someone might like to use it, as I haven't really seen anything like it here before. But I haven't been around much, so maybe I missed it?

    This first one deals with unit upgrades. It allows you to pay gold to upgrade one or all of your units when you get the right techs:

    Generic replace function:
    Code:
    messagebox 'msgReplaceUnits'
    {
    	Title(ID_TITLE_upgrade_query);
    	MessageType("TP_QUEUE_EMPTY_AFTER_UNIT"); 
    	MessageClass(789);
    	
    	i = 0;
    	onecost = 0;
    	oldunitcount = 0;
    	while (i < player.totalunits) 
    	{		
    		SetUnitByIndex(1, g.player, i);		
    		if (unit.type == oldunittype) 
    		{			
    			oldunitcount = oldunitcount + 1;
    		}
    		i = i + 1;	
    	}
    
    	if(oldunitcount>0) {		
    		
    		onecost = (newunitcost) - (oldunitcost);
    
    		if (onecost <= player.gold)
    		{
    			KillClass(g.player,987);
    			MessageClass(987);
    
    			privoldunittype=oldunittype;
    			privnewunittype=newunittype;
    			privoldunitcost=oldunitcost;
    			privnewunitcost=newunitcost;
    
    			privtotalcost = (privnewunitcost*oldunitcount) - (privoldunitcost*oldunitcount);
    			privonecost = privnewunitcost - privoldunitcost;
    	
    			if (privtotalcost <= player.gold && oldunitcount>1)
    			{
    				Button(ID_BUTTON_Do_upgrade)
    				{
    					AddGold(player, -privtotalcost);
    					i = 0;	
    					while (i < player.totalunits) 
    					{		
    						SetUnitByIndex(1, player, i);		
    						if (unit.type == privoldunittype) 
    						{			
    							oldunitlocation = unit.location;			
    							
    //							KillUnit(unit.1);			
    							SetOrder(1, 56); 
    							AddOrder(unit, oldunitlocation);
    
    							CreateUnit(player, privnewunittype, oldunitlocation, 0);		
    						}
    						else
    						{		
    							i = i + 1;	
    						}
    					}
    					KillClass(g.player, 987);
    				}
    			}
    			Button(ID_BUTTON_Do_one_upgrade)
    			{
    				AddGold(player, -privonecost);
    				i = 0;	
    				while (i < player.totalunits) 
    				{		
    					SetUnitByIndex(1, g.player, i);		
    					if (unit.type == privoldunittype) 
    					{			
    						oldunitlocation = unit.location;			
    						SetOrder(1, 56); 
    						AddOrder(unit, oldunitlocation);
    						CreateUnit(player, privnewunittype, oldunitlocation, 0);		
    //						KillUnit(unit.1);			
    						KillClass(player, 987);
    						message(g.player,'msgReplaceUnits'); 
    					}
    					else
    					{		
    						i = i + 1;	
    					}
    				}
    			}		
    			Button(ID_BUTTON_LibraryNew)
    			{
    				LibraryUnit(privnewunittype);
    				
    			}
    			Button(ID_BUTTON_LibraryOld)
    			{
    				LibraryUnit(privoldunittype);
    				
    			}
    			if (oldunitcount>1)
    			{
    				Text(ID_TEXT_upgrade_query);
    			}
    			else
    			{
    				Text(ID_TEXT_upgrade_one_query);
    			}
    		}
    		else
    		{
    			Abort();
    		}
    	}
    	else
    	{
    		Abort();
    	}
    }
    example trigger:
    Code:
    trigger 'IronWorking_trigReplaceUnits' when (HasAdvance(g.player, ID_ADVANCE_IRON_WORKING) ) 
    {	
    
    	if(HasAdvance(g.player, ID_ADVANCE_EUROPEAN_CIV)) {
    
    		oldunittype = UnitType("UNIT_WARRIOR");
    		newunittype = UnitType("UNIT_LEGION");	
    		oldunitcost = 100;
    		newunitcost = 300;
    		SetString(0,ID_UNIT_WARRIOR);
    		SetString(1,ID_UNIT_LEGION);
    		message(g.player,'msgReplaceUnits');
    
    		oldunittype = UnitType("UNIT_SWORDSMAN");
    		newunittype = UnitType("UNIT_LEGION");	
    		oldunitcost = 100;
    		newunitcost = 300;
    		SetString(0,ID_UNIT_SWORDSMAN);
    		SetString(1,ID_UNIT_LEGION);
    		message(g.player,'msgReplaceUnits');
    	}
    
    	if(HasAdvance(g.player, ID_ADVANCE_AFRICAN_CIV)) {
    
    		oldunittype = UnitType("UNIT_WARRIOR");
    		newunittype = UnitType("UNIT_LEGION");	
    		oldunitcost = 100;
    		newunitcost = 300;
    		SetString(0,ID_UNIT_WARRIOR);
    		SetString(1,ID_UNIT_LEGION);
    		message(g.player,'msgReplaceUnits');
    
    		oldunittype = UnitType("UNIT_SWORDSMAN");
    		newunittype = UnitType("UNIT_LEGION");	
    		oldunitcost = 100;
    		newunitcost = 300;
    		SetString(0,ID_UNIT_SWORDSMAN);
    		SetString(1,ID_UNIT_LEGION);
    		message(g.player,'msgReplaceUnits');
    	}
    	if(HasAdvance(g.player, ID_ADVANCE_EASTERN_CIV)) {
    
    		oldunittype = UnitType("UNIT_WARRIOR");
    		newunittype = UnitType("UNIT_LEGION");	
    		oldunitcost = 100;
    		newunitcost = 300;
    		SetString(0,ID_UNIT_WARRIOR);
    		SetString(1,ID_UNIT_LEGION);
    		message(g.player,'msgReplaceUnits');
    
    		oldunittype = UnitType("UNIT_SWORDSMAN");
    		newunittype = UnitType("UNIT_LEGION");	
    		oldunitcost = 100;
    		newunitcost = 300;
    		SetString(0,ID_UNIT_SWORDSMAN);
    		SetString(1,ID_UNIT_LEGION);
    		message(g.player,'msgReplaceUnits');
    	}
    	if(HasAdvance(g.player, ID_ADVANCE_NATIVE_CIV)) {
    
    		oldunittype = UnitType("UNIT_WARRIOR");
    		newunittype = UnitType("UNIT_BERSERKER");	
    		oldunitcost = 100;
    		newunitcost = 300;
    		SetString(0,ID_UNIT_WARRIOR);
    		SetString(1,ID_UNIT_BERSERKER);
    		message(g.player,'msgReplaceUnits');
    
    		oldunittype = UnitType("UNIT_SWORDSMAN");
    		newunittype = UnitType("UNIT_BERSERKER");	
    		oldunitcost = 100;
    		newunitcost = 300;
    		SetString(0,ID_UNIT_SWORDSMAN);
    		SetString(1,ID_UNIT_BERSERKER);
    		message(g.player,'msgReplaceUnits');
    	}
    	if(HasAdvance(g.player, ID_ADVANCE_WESTERN_CIV)) {
    
    		oldunittype = UnitType("UNIT_WARRIOR");
    		newunittype = UnitType("UNIT_BERSERKER");	
    		oldunitcost = 100;
    		newunitcost = 300;
    		SetString(0,ID_UNIT_WARRIOR);
    		SetString(1,ID_UNIT_BERSERKER);
    		message(g.player,'msgReplaceUnits');
    
    		oldunittype = UnitType("UNIT_SWORDSMAN");
    		newunittype = UnitType("UNIT_BERSERKER");	
    		oldunitcost = 100;
    		newunitcost = 300;
    		SetString(0,ID_UNIT_SWORDSMAN);
    		SetString(1,ID_UNIT_BERSERKER);
    		message(g.player,'msgReplaceUnits');
    	}
    	if(HasAdvance(g.player, ID_ADVANCE_ASIAN_CIV)) {
    
    		oldunittype = UnitType("UNIT_WARRIOR");
    		newunittype = UnitType("UNIT_SAMURAI");	
    		oldunitcost = 100;
    		newunitcost = 300;
    		SetString(0,ID_UNIT_WARRIOR);
    		SetString(1,ID_UNIT_SAMURAI);
    		message(g.player,'msgReplaceUnits');
    
    		oldunittype = UnitType("UNIT_SWORDSMAN");
    		newunittype = UnitType("UNIT_SAMURAI");	
    		oldunitcost = 100;
    		newunitcost = 300;
    		SetString(0,ID_UNIT_SWORDSMAN);
    		SetString(1,ID_UNIT_SAMURAI);
    		message(g.player,'msgReplaceUnits');
    	}
    
    }
    I can post the whole file if anyone's interested, but it's fairly customized to my mod. I do have a version w/out the different civ types though.

    Let me know if you see any errors I remember there being two issues with this: 1) I can't remember exactly, 2) It only works on the host server pc in multiplayer.

    The next one is really simple. It just adds to the city size when a new one is built after arcologies is discovered:

    Code:
    trigger 'GrowCity' when (city.built)
    {
    	if (HasAdvance(g.player, ID_ADVANCE_ARCOLOGIES) )
    	{
    		if (IsUnderseaCity(city) )
    		{
    			AddPops(city,3);
    		}
    		// terraintype 13 = space - done this way because isspacecity function is broken
    		elseif (TerrainType(city.location) == 13 ) 
    		{
    			AddPops(city,1);
    		}
    		else
    		{
    			AddPops(city,5);
    		}
    	}
    }
    The next script deals with having different units for different types of civilizations (ie: african, european, asian...). What I did here was I created a bunch of different advances to define each civilization type, and assigned them to the actual civs:

    Code:
    trigger 'trigStartUpCiv' when ((g.year == 0) && (IsPlayerAlive(g.player))) {
    	Message(g.player, 'msgStartUpCiv');
    }
    
    messagebox 'msgStartUpCiv'
    {
    
    	//civtype 0 = None - barbarian
    	//civtype 1 = Native Indian - sioux, iroquois
    	//civtype 2 = European - greek, russian, spanish, portugese, roman, phoenician, byzantine, italian
    	//civtype 3 = Western/Eurpoean 2 - american, scottish, english, german, french, dutch, vikings, turkish, celtic, austrian, hungarian, swedish
    	//civtype 4 = Asian - japanese, chinese, thai, polynesian, indonesian, korean, mongolian
    	//civtype 5 = African/South American -  zulu, mayan, incan, aztec, brazilian, mexican, ethiopian, bantu
    	//civtype 6 = Middle Eastern - Arabian, persian, egyptian, hebrew, indian, assyrian
    	nativeciv=177;
    	europeanciv=178;
    	africanciv=179;
    	asianciv=180;
    	easternciv=181;
    	westernciv=182;
    
    	//civtype 0 = None - barbarian
    	if(PlayerCivilization(g.player) == CivilizationIndex("BARBARIAN"))
    	{
    		GrantAdvance(g.player,westernciv);
    		GrantAdvance(g.player,easternciv);
    		GrantAdvance(g.player,asianciv);
    		GrantAdvance(g.player,nativeciv);
    		GrantAdvance(g.player,africanciv);
    		GrantAdvance(g.player,europeanciv);
    	}
    
    	//civtype 1 = Native Indian - sioux, iroquois
    	if(PlayerCivilization(g.player) == CivilizationIndex("SIOUX"))
    	{
    		GrantAdvance(g.player,nativeciv);
    	}
    
    	if(PlayerCivilization(g.player) == CivilizationIndex("IROQUOIS"))
    	{
    		GrantAdvance(g.player,nativeciv);
    	}
    
    
    
    
    
    	//civtype 2 = European - greek, russian, spanish, portugese, roman, phoenician, byzantine, italian
    	if(PlayerCivilization(g.player) == CivilizationIndex("GREEK"))
    	{
    		GrantAdvance(g.player,europeanciv);
    	}
    
    	if(PlayerCivilization(g.player) == CivilizationIndex("RUSSIAN"))
    	{
    		GrantAdvance(g.player,europeanciv);
    	}
    
    	if(PlayerCivilization(g.player) == CivilizationIndex("ITALIAN"))
    	{
    		GrantAdvance(g.player,europeanciv);
    	}
    
    	if(PlayerCivilization(g.player) == CivilizationIndex("ROMAN"))
    	{
    		GrantAdvance(g.player,europeanciv);
    	}
    
    	if(PlayerCivilization(g.player) == CivilizationIndex("PHOENICIAN"))
    	{
    		GrantAdvance(g.player,europeanciv);
    	}
    
    	if(PlayerCivilization(g.player) == CivilizationIndex("BYZANTINE"))
    	{
    		GrantAdvance(g.player,europeanciv);
    	}
    
    	if(PlayerCivilization(g.player) == CivilizationIndex("SPANISH"))
    	{
    		GrantAdvance(g.player,europeanciv);
    	}
    
    	if(PlayerCivilization(g.player) == CivilizationIndex("BYZANTINE"))
    	{
    		GrantAdvance(g.player,europeanciv);
    	}
    
    	if(PlayerCivilization(g.player) == CivilizationIndex("PORTUGUESE"))
    	{
    		GrantAdvance(g.player,europeanciv);
    	}
    
    
    
    	//civtype 3 = Western/Eurpoean 2 - american, scottish, english, german, french, dutch, vikings, turkish, celtic, austrian, hungarian, swedish
    	if(PlayerCivilization(g.player) == CivilizationIndex("AMERICANS"))
    	{
    		GrantAdvance(g.player,westernciv);
    	}
    
    	if(PlayerCivilization(g.player) == CivilizationIndex("SCOTTISH"))
    	{
    		GrantAdvance(g.player,westernciv);
    	}
    
    	if(PlayerCivilization(g.player) == CivilizationIndex("SLAVIC"))
    	{
    		GrantAdvance(g.player,westernciv);
    	}
    
    	if(PlayerCivilization(g.player) == CivilizationIndex("ENGLISH"))
    	{
    		GrantAdvance(g.player,westernciv);
    	}
    
    	if(PlayerCivilization(g.player) == CivilizationIndex("GERMAN"))
    	{
    		GrantAdvance(g.player,westernciv);
    	}
    
    	if(PlayerCivilization(g.player) == CivilizationIndex("FRENCH"))
    	{
    		GrantAdvance(g.player,westernciv);
    	}
    
    	if(PlayerCivilization(g.player) == CivilizationIndex("DUTCH"))
    	{
    		GrantAdvance(g.player,westernciv);
    	}
    
    	if(PlayerCivilization(g.player) == CivilizationIndex("VIKING"))
    	{
    		GrantAdvance(g.player,westernciv);
    	}
    
    	if(PlayerCivilization(g.player) == CivilizationIndex("TURKISH"))
    	{
    		GrantAdvance(g.player,westernciv);
    	}
    
    	if(PlayerCivilization(g.player) == CivilizationIndex("CELTIC"))
    	{
    		GrantAdvance(g.player,westernciv);
    	}
    
    	if(PlayerCivilization(g.player) == CivilizationIndex("AUSTRIAN"))
    	{
    		GrantAdvance(g.player,westernciv);
    	}
    
    	if(PlayerCivilization(g.player) == CivilizationIndex("HUNGARIAN"))
    	{
    		GrantAdvance(g.player,westernciv);
    	}
    
    	if(PlayerCivilization(g.player) == CivilizationIndex("SWEDISH"))
    	{
    		GrantAdvance(g.player,westernciv);
    	}
    
    
    	//civtype 4 = Asian - japanese, chinese, thai, polynesian, indonesian, korean, mongolian
    	if(PlayerCivilization(g.player) == CivilizationIndex("JAPANESE"))
    	{
    		GrantAdvance(g.player,asianciv);
    	}
    
    	if(PlayerCivilization(g.player) == CivilizationIndex("CHINESE"))
    	{
    		GrantAdvance(g.player,asianciv);
    	}
    
    	if(PlayerCivilization(g.player) == CivilizationIndex("THAI"))
    	{
    		GrantAdvance(g.player,asianciv);
    	}
    
    	if(PlayerCivilization(g.player) == CivilizationIndex("POLYNESIAN"))
    	{
    		GrantAdvance(g.player,asianciv);
    	}
    
    	if(PlayerCivilization(g.player) == CivilizationIndex("INDONESIAN"))
    	{
    		GrantAdvance(g.player,asianciv);
    	}
    
    	if(PlayerCivilization(g.player) == CivilizationIndex("KOREAN"))
    	{
    		GrantAdvance(g.player,asianciv);
    	}
    
    	if(PlayerCivilization(g.player) == CivilizationIndex("MONGOL"))
    	{
    		GrantAdvance(g.player,asianciv);
    	}
    
    	//civtype 5 = African/South American -  zulu, mayan, incan, aztec, brazilian, mexican, ethiopian, bantu
    	if(PlayerCivilization(g.player) == CivilizationIndex("ZULU"))
    	{
    		GrantAdvance(g.player,africanciv);
    	}
    
    	if(PlayerCivilization(g.player) == CivilizationIndex("MAYAN"))
    	{
    		GrantAdvance(g.player,africanciv);
    	}
    
    	if(PlayerCivilization(g.player) == CivilizationIndex("INCAN"))
    	{
    		GrantAdvance(g.player,africanciv);
    	}
    
    	if(PlayerCivilization(g.player) == CivilizationIndex("AZTEC"))
    	{
    		GrantAdvance(g.player,africanciv);
    	}
    
    	if(PlayerCivilization(g.player) == CivilizationIndex("BRAZILIAN"))
    	{
    		GrantAdvance(g.player,africanciv);
    	}
    
    	if(PlayerCivilization(g.player) == CivilizationIndex("MEXICAN"))
    	{
    		GrantAdvance(g.player,africanciv);
    	}
    
    	if(PlayerCivilization(g.player) == CivilizationIndex("ETHIOPIAN"))
    	{
    		GrantAdvance(g.player,africanciv);
    	}
    
    	if(PlayerCivilization(g.player) == CivilizationIndex("BANTU"))
    	{
    		GrantAdvance(g.player,africanciv);
    	}
    
    
    
    	//civtype 6 = Middle Eastern - Arabian, persian, egyptian, hebrew, indian, assyrian
    
    	if(PlayerCivilization(g.player) == CivilizationIndex("ARABIAN"))
    	{
    		GrantAdvance(g.player,easternciv);
    	}
    
    	if(PlayerCivilization(g.player) == CivilizationIndex("PERSIAN"))
    	{
    		GrantAdvance(g.player,easternciv);
    	}
    
    	if(PlayerCivilization(g.player) == CivilizationIndex("EGYPTIAN"))
    	{
    		GrantAdvance(g.player,easternciv);
    	}
    
    	if(PlayerCivilization(g.player) == CivilizationIndex("HEBREW"))
    	{
    		GrantAdvance(g.player,easternciv);
    	}
    
    	if(PlayerCivilization(g.player) == CivilizationIndex("INDIAN"))
    	{
    		GrantAdvance(g.player,easternciv);
    	}
    
    	if(PlayerCivilization(g.player) == CivilizationIndex("ASSYRIAN"))
    	{
    		GrantAdvance(g.player,easternciv);
    	}
    
    	//advance #'s
    	zuluspearman=165;
    	zuluwarrior=166;
    	phalanx=167;
    	warrior=168;     
    	swordsman=169;
    	spearman=170;
    	legion=171;
    	samurai=172;
    	berserker=173;
    	espearman=174;
    	slinger=175;
    	archer=176;
    	
    	toolmaking=2;
    	ironworking=11;
    	bronzeworking=5;
    	warriorcode=164;
    
    	//civtype 0 = None - barbarian
    	//civtype 1 = Native Indian - sioux, iroquois
    	//civtype 2 = European - greek, russian, spanish, portugese, roman, phoenician, byzantine, italian
    	//civtype 3 = Western/Eurpoean 2 - american, scottish, english, german, french, dutch, vikings, turkish, celtic, austrian, hungarian, swedish
    	//civtype 4 = Asian - japanese, chinese, thai, polynesian, indonesian, korean, mongolian
    	//civtype 5 = African/South American -  zulu, mayan, incan, aztec, brazilian, mexican, ethiopian, bantu
    	//civtype 6 = Middle Eastern - Arabian, persian, egyptian, hebrew, indian, assyrian
    
    	//0: 	CTP1 warrior, Spearman, Mounted Archer, Archer, Chariot, Elephant, Samurai, Legion, Pikeman, Knight, Crusader, Horse Archer, Cavalry, Musketeers....
    	//1: 	CTP1 warrior, Spearman, Mounted Archer, Archer, Chariot, Elephant, Berserker, Pikeman, Horse Archer
    	//2:	Swordsman, Phalanx, Mounted Archer, Archer, Chariot, Elephant, Legion, Pikeman, Knight
    	//3:	Swordsman, Spearman, Mounted Archer, Archer, Chariot, Elephant, Berserker, Pikeman, Knight
    	//4:	Swordsman, Spearman, Mounted Archer, Archer, Chariot, Elephant, Samurai,  Pikeman, Horse Archer
    	//5:	CTP1 Warrior, Zulu Phalanx, Mounted Archer, Zulu Spearman, Chariot, Elephant, Legion, Pikeman, Light Cavalry
    	//6:	Swordsman, Egyptian Spearman, Mounted Archer, Slinger, Chariot, Elephant, Legion, Pikeman, Light Cavalry
    
    
    	Abort();
    }
    And then you can add certain units to each civ like this:

    Code:
    trigger 'Toolmaking_trigGiveAdvance' when (HasAdvance(g.player, ID_ADVANCE_TOOLMAKING)) 
    {	
    	if(HasAdvance(g.player, ID_ADVANCE_NATIVE_CIV)){	
    		GrantAdvance(g.player, warrior);
    	}
    
    	if(HasAdvance(g.player, ID_ADVANCE_EUROPEAN_CIV)){	
    		GrantAdvance(g.player,swordsman);
    	}
    
    	if(HasAdvance(g.player, ID_ADVANCE_WESTERN_CIV)){	
    		GrantAdvance(g.player,swordsman);
    	}
    
    	if(HasAdvance(g.player, ID_ADVANCE_ASIAN_CIV)){	
    		GrantAdvance(g.player,swordsman);
    	}
    
    	if(HasAdvance(g.player, ID_ADVANCE_AFRICAN_CIV)){	
    		GrantAdvance(g.player,warrior);
    	}
    
    	if(HasAdvance(g.player, ID_ADVANCE_EASTERN_CIV)){	
    		GrantAdvance(g.player,swordsman);
    	}
    }
    All I did was add a new tech for each unit, and only allow it when you have the prerequisite tech. The units are only altered (for now) in appearance in my mod. I just couldn't stand the thought of samurai in England and Hoplites in China.

    Again, let me know if you see any errors/things I could've done better here. The civ type script concept here has just one major problem: The AI likes to trade the civ type techs! So Japan and Turkey will trade and then turkey can build samurai. Bah.

    If I get enough feedback, I could post my mod, but it's fricken huge (like 100+ MB I think), because I added so many new techs, units, improvements (like space/undersea only ones), AI, sprites and library entries, all on top of Celestial Dawn's mod.

    Hope these scripts are some help.

    L8r.

  • #2
    I take it back

    The mod's 120MB, but I can zip it down to 30.7MB. :P

    Comment


    • #3
      Thanks for sharing .

      There was someone in the CTP2 forums looking for CTP1 unit updater code - I'll point him in this direction.

      Code in messageboxes never works properly in MP games - the only way to fix it would be to copy all the messagebox code into the other function.

      If you're short of upload space, then I'm sure there's someone around here who could spare some for a good cause .

      Comment


      • #4
        Hi, Madd_Mugsey

        Long time, no see!

        Did you know that the source code for CTP2 has been released? Some of us are working on it:



        There's a very limited interest in CTP1 creation nowadays.

        Comment


        • #5
          Originally posted by J Bytheway
          Thanks for sharing .

          There was someone in the CTP2 forums looking for CTP1 unit updater code - I'll point him in this direction.
          That's me, thank you J Bytheway.

          Madd_Mugsey, I am very interested by a unit updater for Civ: CtP, as I posted it in the CtP2 forum the lack of updater was the last thing that was preventing me from giving Civ: CtP another chance. Needless to say I am interested by the full file.

          When I have the time I will adapt this Updater to the Apolyton Pack but as I am new (a newbie actually) to Civ: CtP I don't know what I have to do with the code (do I have to copy it in a file or do I have to #include the file in an existing .slc? Where do I have to copy the Trigger and the unit arrays?).
          "Democracy is the worst form of government there is, except for all the others that have been tried." Sir Winston Churchill

          Comment


          • #6
            Wow

            What a response! I wasn't expecting anyone to reply so quickly, I thought things were pretty much dead around here...

            Here goes:

            Code in messageboxes never works properly in MP games - the only way to fix it would be to copy all the messagebox code into the other function.
            Hmmm... It's been like three years since I've looked at this, but if I remember correctly, aren't messageboxes the only way to do functions in SLIC1?

            If you're short of upload space, then I'm sure there's someone around here who could spare some for a good cause .
            That would be sweet. I'm just doing some basic testing of the mod now. It needs a serious playtest and balancing I think though. I'm going to move at least one city improvement to another tech and see if I can make a little notification every time a city starts to riot.

            Did you know that the source code for CTP2 has been released? Some of us are working on it:
            Nice! I didn't know that. I never bought CTP2 though; can I download the whole thing, or should I find somewhere to pick it up?

            When I have the time I will adapt this Updater to the Apolyton Pack but as I am new (a newbie actually) to Civ: CtP I don't know what I have to do with the code (do I have to copy it in a file or do I have to #include the file in an existing .slc? Where do I have to copy the Trigger and the unit arrays?).
            Ooh, this may be more work than you bargained for...

            Okay, I attached both the slic and the string file in a zip file.
            You have to add include lines for both of them.

            Put the Update_scr.slc in the X:\\\\Civ CTP\ctp_data\default\gamedata folder. Edit the script.slc file there, add the line

            #include "Update_scr.slc"

            at the end.

            Put the Update_str.txt in the X:\\\\Civ CTP\ctp_data\english\gamedata folder. Edit the Strings.txt file there, add the line

            import "Update_str.txt"

            at the end.


            You'll need to make some serious alterations to the Update_scr.slc file to get this to work. I have completely redone the tech tree and the units associated with each tech for my mod, and this file reflects those changes. I left out the civ specific stuff, but this is a lot of work already... Here's what you need to do:


            Okay you're going to see a whole bunch of triggers in the file that look like this:

            Code:
            trigger 'Metallurgy_trigReplaceUnits' when (HasAdvance(g.player, ID_ADVANCE_METALLURGY) ) 
            {	
            
            	oldunittype = UnitType("UNIT_PIKEMEN");
            	newunittype = UnitType("UNIT_MUSKETEERS");	
            	oldunitcost = 200;
            	newunitcost = 400;
            	SetString(0,ID_UNIT_PIKEMEN);
            	SetString(1,ID_UNIT_MUSKETEERS);
            
            	message(g.player,'msgReplaceUnits');
            
            	oldunittype = UnitType("UNIT_GREEK_FIRE");
            	newunittype = UnitType("UNIT_MUSKETEERS");	
            	oldunitcost = 200;
            	newunitcost = 400;
            	SetString(0,ID_UNIT_GREEK_FIRE);
            	SetString(1,ID_UNIT_MUSKETEERS);
            
            	message(g.player,'msgReplaceUnits');
            	
            	oldunittype = UnitType("UNIT_HOPLITE");
            	newunittype = UnitType("UNIT_MUSKETEERS");	
            	oldunitcost = 100;
            	newunitcost = 200+400;
            	SetString(0,ID_UNIT_HOPLITE);
            	SetString(1,ID_UNIT_MUSKETEERS);
            	message(g.player,'msgReplaceUnits');
            
            }
            What this does is it calls the big generic function at the top of the file if the player has the old unit type, and prompts him to replace them with the new unit type for the cost of (newunitcost-oldunitcost)*# units.

            Each trigger is called when the player gets a unit giving advance (in this case ID_ADVANCE_METALLURGY). You'll need to make sure that you have triggers corresponding to each of the advances that you're using that give units.

            And then, you'll need to put all the possible upgrades in each trigger, basically by copying and pasting this part:
            Code:
            	oldunittype = UnitType("UNIT_HOPLITE");
            	newunittype = UnitType("UNIT_MUSKETEERS");	
            	oldunitcost = 100;
            	newunitcost = 200+400;
            	SetString(0,ID_UNIT_HOPLITE);
            	SetString(1,ID_UNIT_MUSKETEERS);
            	message(g.player,'msgReplaceUnits');
            and replacing the old unit and new unit in the variable setting lines and the string setting lines, and altering the costs (which if I remember right are the cumulative production costs for the unit). You'll also need to make sure that this code chunk appears in the correct REVERSE order inside each trigger. For example, I have chosen to upgrade in the order of oldest and weakest unit first. So in this trigger, it goes: upgrade hoplite, upgrade archer, upgrade pikemen. I put the hoplites last and they will be upgraded first.

            Okay that's it. Just a few final notes:

            This thing will only upgrade one unit type at a time. Ie: You can't upgrade your warriors on the same turn as your hoplites.

            I coded in "action" keys to turn the messages on/off. You should see them at the top of the slc file. "[" turns on the upgrade messages. "]" turns them off. I did this because I got tired of being harassed to upgrade when I didn't have any gold


            That's it. Let me know if you have any questions.

            L8r.
            Attached Files

            Comment


            • #7
              Re: Wow

              Originally posted by Madd_Mugsy
              What a response! I wasn't expecting anyone to reply so quickly, I thought things were pretty much dead around here...
              You are right, the Civ: CtP creation forum is not very active but many players, including many CtP2 modders, are still playing the game.

              Ooh, this may be more work than you bargained for...
              I have already reworked Peter Triggs' Updater2 for the CtP2 and the Super Apolyton Pack so I know what I am up to.

              Okay, I attached both the slic and the string file in a zip file.
              You have to add include lines for both of them.

              Put the Update_scr.slc in the X:\\\\Civ CTP\ctp_data\default\gamedata folder. Edit the script.slc file there, add the line

              #include "Update_scr.slc"

              at the end.

              Put the Update_str.txt in the X:\\\\Civ CTP\ctp_data\english\gamedata folder. Edit the Strings.txt file there, add the line

              import "Update_str.txt"
              As expected, it seems to work as in CtP2 but I wasn't sure as J Bytheway told me they were big differences between SLIC1 and CtP2's SLIC.

              You'll need to make some serious alterations to the Update_scr.slc file to get this to work. I have completely redone the tech tree and the units associated with each tech for my mod, and this file reflects those changes. I left out the civ specific stuff, but this is a lot of work already... Here's what you need to do...
              Thank you very much for all the explanations, I will design "update paths" and create all the unit arrays, though they are different from those of the CtP2 Updater2 the spirit is the same and it should not be a problem, the main problem will be to find the time to do all the work.

              Thank you very much for your answer.
              "Democracy is the worst form of government there is, except for all the others that have been tried." Sir Winston Churchill

              Comment


              • #8
                Originally posted by Madd_Mugsy
                Hmmm... It's been like three years since I've looked at this, but if I remember correctly, aren't messageboxes the only way to do functions in SLIC1?
                Yep - that's why I said you'd have to copy-paste the code in. A better solution would be to use some kind of macro preprocessor (that's the kind of thing I often find myself putting together for badly-designed scripting languages, but in this case I think you could just copy/paste the messagebox code in at the bottom of the other function and it should work about right.

                That would be sweet. I'm just doing some basic testing of the mod now. It needs a serious playtest and balancing I think though.


                My Mars mod (see my website - link at top of the post) has been in that state for several years now. It's not easy to find playtesters...

                Nice! I didn't know that. I never bought CTP2 though; can I download the whole thing, or should I find somewhere to pick it up?


                You'll have to get hold of a copy somewhere. Second hand via Amazon marketplace, eBay, etc. are the best methods if you can't find it in your local bargain bin.

                Comment


                • #9
                  Re: Wow

                  Originally posted by Madd_Mugsy


                  Hmmm... It's been like three years since I've looked at this, but if I remember correctly, aren't messageboxes the only way to do functions in SLIC1?

                  Actually..I do a small amount of using SLIC and to answer you dont "NEED" a message box..you can add a slic code and then it will wokr..I myself have half a dozen in a few scenario's that work fine

                  Of course.I know what they are and I dont use in MP or PBEM so its not an issue..

                  things like free public works, free units spawning..


                  Ok..Good luck..when I return from Honduras (building a church near Choluteca) in a week and a half i may try some of your inovations

                  Peace

                  Grandpa Troll
                  Attached Files
                  Hi, I'm RAH and I'm a Benaholic.-rah

                  Comment


                  • #10
                    Madd_Mugsy, a question is haunting me: can the AI Civs update their units through the unit updater?

                    I have briefly read the SLIC code(though I know nothing about SLIC coding) and I have only seen references to the Human Player (the "g.player"), if the answer is no is there a way to tell the AI how to use the updater?
                    "Democracy is the worst form of government there is, except for all the others that have been tried." Sir Winston Churchill

                    Comment


                    • #11
                      g.player refers to whoevers turn it is at the moment, not just the human player.

                      Comment


                      • #12
                        Madd_Mugsy, a question is haunting me: can the AI Civs update their units through the unit updater?
                        Theoretically, it has access to the upgrade messages, but it doesn't do anything with them, so no it doesn't upgrade units...

                        BUT

                        I can make a couple quick changes to the SLIC to give the AI automatic upgrades. I'll post again with the changes.

                        Comment


                        • #13
                          Change the main message box function to this:

                          Code:
                          messagebox 'msgReplaceUnits'
                          {
                          	Title(ID_TITLE_upgrade_query);
                          	MessageType("TP_QUEUE_EMPTY_AFTER_UNIT"); 
                          	MessageClass(789);
                          	
                          	i = 0;
                          	onecost = 0;
                          	oldunitcount = 0;
                          	while (i < player.totalunits) 
                          	{		
                          		SetUnitByIndex(1, g.player, i);		
                          		if (unit.type == oldunittype) 
                          		{			
                          			oldunitcount = oldunitcount + 1;
                          		}
                          		i = i + 1;	
                          	}
                          
                          	if(oldunitcount>0) {		
                          
                          		if(IsHumanPlayer(g.player)) {
                          		
                          			onecost = (newunitcost) - (oldunitcost);
                          	
                          			if (onecost <= player.gold)
                          			{
                          				KillClass(g.player,987);
                          				MessageClass(987);
                          	
                          				privoldunittype=oldunittype;
                          				privnewunittype=newunittype;
                          				privoldunitcost=oldunitcost;
                          				privnewunitcost=newunitcost;
                          	
                          				privtotalcost = (privnewunitcost*oldunitcount) - (privoldunitcost*oldunitcount);
                          				privonecost = privnewunitcost - privoldunitcost;
                          		
                          				if (privtotalcost <= player.gold && oldunitcount>1)
                          				{
                          					Button(ID_BUTTON_Do_upgrade)
                          					{
                          						AddGold(player, -privtotalcost);
                          						i = 0;	
                          						while (i < player.totalunits) 
                          						{		
                          							SetUnitByIndex(1, player, i);		
                          							if (unit.type == privoldunittype) 
                          							{			
                          								oldunitlocation = unit.location;			
                          								
                          								SetOrder(1, 56); 
                          								AddOrder(unit, oldunitlocation);
                          	
                          								CreateUnit(player, privnewunittype, oldunitlocation, 0);		
                          							}
                          							else
                          							{		
                          								i = i + 1;	
                          							}
                          						}
                          						KillClass(g.player, 987);
                          					}
                          				}
                          				Button(ID_BUTTON_Do_one_upgrade)
                          				{
                          					AddGold(player, -privonecost);
                          					i = 0;	
                          					while (i < player.totalunits) 
                          					{		
                          						SetUnitByIndex(1, g.player, i);		
                          						if (unit.type == privoldunittype) 
                          						{			
                          							oldunitlocation = unit.location;			
                          							SetOrder(1, 56); 
                          							AddOrder(unit, oldunitlocation);
                          							CreateUnit(player, privnewunittype, oldunitlocation, 0);		
                          							KillClass(player, 987);
                          							message(g.player,'msgReplaceUnits'); 
                          						}
                          						else
                          						{		
                          							i = i + 1;	
                          						}
                          					}
                          				}		
                          				Button(ID_BUTTON_LibraryNew)
                          				{
                          					LibraryUnit(privnewunittype);
                          					
                          				}
                          				Button(ID_BUTTON_LibraryOld)
                          				{
                          					LibraryUnit(privoldunittype);
                          					
                          				}
                          				if (oldunitcount>1)
                          				{
                          					Text(ID_TEXT_upgrade_query);
                          				}
                          				else
                          				{
                          					Text(ID_TEXT_upgrade_one_query);
                          				}
                          			}
                          			else
                          			{
                          				Abort();
                          			}
                          		}
                          		else
                          		{	
                          // AI Player
                          			KillClass(g.player,978);
                          			MessageClass(978);
                          			privoldunittype=oldunittype;
                          			privnewunittype=newunittype;
                          			i = 0;	
                          			while (i < player.totalunits) 
                          			{		
                          				SetUnitByIndex(1, player, i);		
                          				if (unit.type == privoldunittype) 
                          				{			
                          					oldunitlocation = unit.location;			
                          					KillUnit(unit.1);			
                          					CreateUnit(player, privnewunittype, oldunitlocation, 0);		
                          				}
                          				else
                          				{		
                          					i = i + 1;	
                          				}
                          			}
                          			KillClass(g.player, 978);
                          		}
                          	}
                          	else
                          	{
                          		Abort();
                          	}
                          }
                          and the AI will upgrade all its units automatically for free. We can put a gold check in there too, but I think the general consensus is that the ai is too damn easy anyway.

                          I thought this would take less than 5 min to do, but it ended up taking closer to 15. Turns out, you have to kill the AI units you're upgrading instead of disbanding them - otherwise it just sits in the loop forever. But disbanding actually works if you comment out the loop. This stuff is screwy.

                          But hey! It seems to work now

                          Comment


                          • #14


                            Thank you very much Madd_Mugsy... I have already started working on the update path.

                            "Democracy is the worst form of government there is, except for all the others that have been tried." Sir Winston Churchill

                            Comment


                            • #15
                              If you're in the need of space to host the mod let me know.
                              I might be able to host it

                              Comment

                              Working...
                              X