Announcement

Collapse
No announcement yet.

SLIC questions

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

  • SLIC questions

    I'm trying to get a couple of existing slics to work for Cradle, but with little luck.

    All I am doing is changing existing units with new units.

    Code:
    ////////////////////////////////////////////////////////////////////////////
    //Elite units code by Stan Karpinski, using peices of code from Immortal  //
    // Wombat, Peter Triggs. If a unit is involved in a successful battle,    //
    // there is a 5% chance it will become an elite unit of that type.        //
    // Applies to only certain front line troops and the army must have at    //
    //least 2 units										  //
    ////////////////////////////////////////////////////////////////////////////
    int_t HeroChance;
    int_t HeroChance2;
    int_t HeroChance3;
    int_t HeroChance4;
    
    HandleEvent(VictoryMoveOrder) 'elite' pre {
    	location_t	tmpLoc;
    	int_t 	PromotionChance;
    	tmpArmy = army[0];
    	tmpNum = tmpArmy.size;
    	tmpPlayer = army[0].owner;
    	tmpLoc = army[0].location;
    	int_t tempUnit;
    		if (tmpNum >=2) {
    		for (j = 0; j < GetUnitsAtLocation(tmpLoc); j = j + 1) {
    	  	GetUnitFromCell(tmpLoc, j, tmpUnit);
    			if ((tmpUnit.type == UnitDB(UNIT_WARRIOR))){
    			PromotionChance = random(90);
    			if(PromotionChance <= 5){			
    			message(tmpPlayer, 'Eone');
    			KillUnit(tmpUnit);
    			CreateUnit(army[0].owner, UnitDB(UNIT_WARRIOR_ELITE), tmpLoc,0);
    			Event:GroupOrder(army[0]);
    				}
    			}	
    			elseif ((tmpUnit.type == UnitDB(UNIT_HOPLITE))){
    			PromotionChance = random(90);
    			if(PromotionChance <= 5){			
    			message(tmpPlayer, 'Etwo');
    			KillUnit(tmpUnit);
    			CreateUnit(army[0].owner, UnitDB(UNIT_HOPLITE_ELITE), tmpLoc,0);
    			Event:GroupOrder(army[0]);
    				}
    			}	
    			elseif ((tmpUnit.type == UnitDB(UNIT_HYPASPISTS))){
    			PromotionChance = random(90);
    			if(PromotionChance <= 5){			
    			message(tmpPlayer, 'Ethree');
    			KillUnit(tmpUnit);
    			CreateUnit(army[0].owner, UnitDB(UNIT_HYPASPISTS_ELITE), tmpLoc,0);
    			Event:GroupOrder(army[0]);
    				}
    			}	
    			elseif ((tmpUnit.type == UnitDB(UNIT_LEGION))){
    			PromotionChance = random(90);
    			if(PromotionChance <= 5){			
    			message(tmpPlayer, 'Efour');
    			KillUnit(tmpUnit);
    			CreateUnit(army[0].owner, UnitDB(UNIT_LEGION_ELITE), tmpLoc,0);
    			Event:GroupOrder(army[0]);
    				}
    			}	
    			elseif ((tmpUnit.type == UnitDB(UNIT_SPEARMAN))){
    			PromotionChance = random(90);
    			if(PromotionChance <= 5){			
    			message(tmpPlayer, 'Efive');
    			KillUnit(tmpUnit);
    			CreateUnit(army[0].owner, UnitDB(UNIT_SPEARMAN_ELITE), tmpLoc,0);
    			Event:GroupOrder(army[0]);
    				}
    			}	
    			elseif ((tmpUnit.type == UnitDB(UNIT_PIKEMEN))){
    			PromotionChance = random(90);
    			if(PromotionChance <= 5){			
    			message(tmpPlayer, 'Esix');
    			KillUnit(tmpUnit);
    			CreateUnit(army[0].owner, UnitDB(UNIT_PIKEMEN_ELITE), tmpLoc,0);
    			Event:GroupOrder(army[0]);
    				}
    			}	
    			elseif ((tmpUnit.type == UnitDB(UNIT_ARQUEBUSIER))){
    			PromotionChance = random(90);
    			if(PromotionChance <= 5){			
    			message(tmpPlayer, 'Eseven');
    			KillUnit(tmpUnit);
    			CreateUnit(army[0].owner, UnitDB(UNIT_ARQUEBUSIER_ELITE), tmpLoc,0);
    			Event:GroupOrder(army[0]);
    				}
    			}	
    			elseif ((tmpUnit.type == UnitDB(UNIT_INFANTRYMAN))){
    			PromotionChance = random(90);
    			if(PromotionChance <= 5){			
    			message(tmpPlayer, 'Eeight');
    			KillUnit(tmpUnit);
    			CreateUnit(army[0].owner, UnitDB(UNIT_INFANTRYMAN_ELITE), tmpLoc,0);
    			Event:GroupOrder(army[0]);
    				}
    			}	
    			elseif ((tmpUnit.type == UnitDB(UNIT_MACHINE_GUNNER))){
    			PromotionChance = random(90);
    			if(PromotionChance <= 5){			
    			message(tmpPlayer, 'Enine');
    			KillUnit(tmpUnit);
    			CreateUnit(army[0].owner, UnitDB(UNIT_MACHINE_GUNNER_ELITE), tmpLoc,0);
    			Event:GroupOrder(army[0]);
    				}
    			}	
    			elseif ((tmpUnit.type == UnitDB(UNIT_MAN_AT_ARMS))){
    			PromotionChance = random(90);
    			if(PromotionChance <= 5){			
    			message(tmpPlayer, 'Eten');
    			KillUnit(tmpUnit);
    			CreateUnit(army[0].owner, UnitDB(UNIT_MAN_AT_ARMS_ELITE), tmpLoc,0);
    			Event:GroupOrder(army[0]);
    				}
    			}	
    			elseif ((tmpUnit.type == UnitDB(UNIT_MARINE))){
    			PromotionChance = random(90);
    			if(PromotionChance <= 5){			
    			message(tmpPlayer, 'Eeleven');
    			KillUnit(tmpUnit);
    			CreateUnit(army[0].owner, UnitDB(UNIT_MARINE_ELITE), tmpLoc,0);
    			Event:GroupOrder(army[0]);
    				}
    			}	
    			elseif ((tmpUnit.type == UnitDB(UNIT_HOVER_INFANTRY))){
    			PromotionChance = random(90);
    			if(PromotionChance <= 5){			
    			message(tmpPlayer, 'Etwelve');
    			KillUnit(tmpUnit);
    			CreateUnit(army[0].owner, UnitDB(UNIT_HOVER_INFANTRY_ELITE), tmpLoc,0);
    			Event:GroupOrder(army[0]);
    				}
    			}	
    
    
    		}
    		
    	}
    }	
    
    //////////////////////////////////////////////////////////////////////////////
    // Elite unit code expansion								    //
    //Elite units involved in a successful combat have a 1 in 30 chance of being//
    // promoted to a GENERAL. Army must have at least 2 units			    //
    //////////////////////////////////////////////////////////////////////////////
    
    
    HandleEvent(VictoryMoveOrder) 'General' pre {
    	location_t	tmpLoc;
    	int_t 	PromotionChance;
    	tmpArmy = army[0];
    	tmpNum = tmpArmy.size;
    	tmpPlayer = army[0].owner;
    	tmpLoc = army[0].location;
    	int_t tempUnit;
    		if (tmpNum >=2) {
    		for (j = 0; j < GetUnitsAtLocation(tmpLoc); j = j + 1) {
    	  	GetUnitFromCell(tmpLoc, j, tmpUnit);
    			if ((tmpUnit.type == UnitDB(UNIT_WARRIOR_ELITE))){
    			PromotionChance = random(90);
    			if(PromotionChance <= 2){			
    			message(tmpPlayer, 'Gone');
    			KillUnit(tmpUnit);
    			CreateUnit(army[0].owner, UnitDB(UNIT_HERO), tmpLoc,0);
    			Event:GroupOrder(army[0]);
    				}
    			}		
    			elseif ((tmpUnit.type == UnitDB(UNIT_HOPLITE_ELITE))){
    			PromotionChance = random(90);
    			if(PromotionChance <= 2){			
    			message(tmpPlayer, 'Gtwo');
    			KillUnit(tmpUnit);
    			CreateUnit(army[0].owner, UnitDB(UNIT_HERO), tmpLoc,0);
    			Event:GroupOrder(army[0]);
    				}
    			}	
    			elseif ((tmpUnit.type == UnitDB(UNIT_SPEARMAN_ELITE))){
    			PromotionChance = random(90);
    			if(PromotionChance <= 2){			
    			message(tmpPlayer, 'Gthree');
    			KillUnit(tmpUnit);
    			CreateUnit(army[0].owner, UnitDB(UNIT_HERO), tmpLoc,0);
    			Event:GroupOrder(army[0]);
    				}
    			}	
    			elseif ((tmpUnit.type == UnitDB(UNIT_LEGION_ELITE))){
    			PromotionChance = random(90);
    			if(PromotionChance <= 2){			
    			message(tmpPlayer, 'Gfour');
    			KillUnit(tmpUnit);
    			CreateUnit(army[0].owner, UnitDB(UNIT_HERO), tmpLoc,0);
    			Event:GroupOrder(army[0]);
    				}
    			}	
    			elseif ((tmpUnit.type == UnitDB(UNIT_HYPASPISTS_ELITE))){
    			PromotionChance = random(90);
    			if(PromotionChance <= 2){			
    			message(tmpPlayer, 'Gfive');
    			KillUnit(tmpUnit);
    			CreateUnit(army[0].owner, UnitDB(UNIT_HERO), tmpLoc,0);
    			Event:GroupOrder(army[0]);
    				}
    			}
    			elseif ((tmpUnit.type == UnitDB(UNIT_HERO))){
    			PromotionChance = random(90);
    			if(PromotionChance <= 3){
    				if (HeroChance<9){
    				HeroChance=HeroChance+1;	
    				KillUnit(tmpUnit);
    					if(HeroChance==1){
    					CreateUnit(army[0].owner, UnitDB(UNIT_GREAT_GENERAL), tmpLoc,0);
    					AgeGREAT_GENERAL = 100 + random(50);
    					message(tmpPlayer, 'GREAT_GENERAL');	
    					Event:GroupOrder(army[0]);
    						}
    					}
    				}
    			}	
    
    		}
    		
    	}
    }
    
    
    
    
         /////////////////////////////////////////
        //                                     //
       //    Improved PoW (Now works)         //
      //     by The Immortal Wombat          //
     //					//
    /////////////////////////////////////////
    
      //-------------//
     //  Variables  //
    //-------------//
    
    int_t	POW_TYPE[];
    int_T	POWage;
    int_t	tmpNum;int_t tmpWonder;
    army_t	tmpArmy;
    int_T	tmpNum2;
    int_t	IsThere;
    location_t	tmpLoc;
    location_t	tmpLoc2;
    unit_T	tmpUnit2;
    int_t tmpPlayer;
    int_t	i;
    
      //---------------------//
     //  Begin Game Setup   //
    //---------------------//
    
    HandleEvent(BeginTurn) 'GameStart' pre {
    	POW_TYPE[0] = UnitDB(UNIT_WARRIOR);			//The better the age, the better the unit you get.
    	POW_TYPE[1] = UnitDB(UNIT_SPEARMAN);
    	POW_TYPE[2] = UnitDB(UNIT_HOPLITE);
    	POW_TYPE[3] = UnitDB(UNIT_MAN_AT_ARMS);
    	POW_TYPE[4] = UnitDB(UNIT_INFANTRYMAN);
    	POW_TYPE[5] = UnitDB(UNIT_MACHINE_GUNNER);
    	POW_TYPE[6] = UnitDB(UNIT_HOVER_INFANTRY);
    
    	DisableTrigger('GameStart');			//run once only
    }
    
      //----------------------//
     //   Get Player Age     //
    //----------------------//
    
    
    int_f WOUTER_GetAge(int_t thePlayer) {
    	tmpPlayer = thePlayer;
    
    	if (HasAdvance(tmpPlayer, ID_ADVANCE_PLASMA_WEAPONRY)) {			// if player has Plasma Weaponry,
    		return 6;							
    	} elseif (HasAdvance(tmpPlayer, ID_ADVANCE_ADV_INFANTRY_TACTICS)) {		// etc.
    		return 5;
    	} elseif (HasAdvance(tmpPlayer, ID_ADVANCE_RAILROAD)) {
    		return 4;
    	} elseif (HasAdvance(tmpPlayer, ID_ADVANCE_BANKING)) {
    		return 3;
    	} elseif (HasAdvance(tmpPlayer, ID_ADVANCE_COMPOSITE_BOW)) {
    		return 2;
    	} elseif (HasAdvance(tmpPlayer, ID_ADVANCE_TOOLMAKING)) {
    		return 1;
    	} else {								// if none of above advances present, (should never happen)
    		return 0;							// age is age 0
    	}
    }
    
      //--------------------------------------------//
     //  Capturing event (should be unnecessary)   //
    //--------------------------------------------//
    
    int_f	CaptureUnit(location_t theLocation){				// invented function to create unit depending on age
    	tmpLoc2 = theLocation;
    	POWage = WOUTER_GetAge(tmpPlayer);					//get age
    	Event:CreateUnit(tmpPlayer, tmpLoc2, 0, POW_TYPE[POWage], 1);			//create unit. If in age 1, create POW_TYPE[1]
    	Event:GroupOrder(army[0]);						//This is set up like this because of bugs just using the CreateUnit event
    }
    
    
      //------------------//
     //  Battle event    //
    //------------------//
    
    HandleEvent(VictoryMoveOrder) 'capture' pre {
    	tmpArmy = army[0];
    	tmpNum = tmpArmy.size;
    	tmpPlayer = army[0].owner;
    	tmpLoc = army[0].location;
    	IsThere = 0;
    	for(i = 0; i < tmpNum; i = i + 1) {
    		GetUnitFromArmy(tmpArmy, i, tmpUnit);
    		tmpNum2 = tmpUnit.type;
    		if(tmpNum2 >= 112 && tmpNum <= 117){			// number of units. 107-117 are wonder-units
    			IsThere = 1;				//GOT ONE!!
    		}
    	}
    	if(IsThere == 1){					//If it was there,
    		POWage = WOUTER_GetAge(tmpPlayer);		//get age (for messaging purposes)
    		if(POWage == 6){
    			message(tmpPlayer, 'six');		
    			CaptureUnit(tmpLoc);			//and run the captureunit function
    		}
    		elseif(POWage == 5){
    			message(tmpPlayer, 'five');
    			CaptureUnit(tmpLoc);
    		}
    		elseif(POWage == 4){
    			message(tmpPlayer, 'four');
    			CaptureUnit(tmpLoc);
    		}
    		elseif(POWage == 3){
    			message(tmpPlayer, 'three');
    			CaptureUnit(tmpLoc);
    		}
    		elseif(POWage == 2){
    			message(tmpPlayer, 'two');
    			CaptureUnit(tmpLoc);
    		}
    		elseif(POWage == 1){
    			message(tmpPlayer, 'one');
    			CaptureUnit(tmpLoc);
    		}	
    		
    	}
    }
    Last edited by Martin Gühmann; June 24, 2008, 15:19.
    Yes, let's be optimistic until we have reason to be otherwise...No, let's be pessimistic until we are forced to do otherwise...Maybe, let's be balanced until we are convinced to do otherwise. -- DrSpike, Skanky Burns, Shogun Gunner
    ...aisdhieort...dticcok...

  • #2
    Re: SLIC questions

    Originally posted by hexagonian
    I'm trying to get a couple of existing slics to work for Cradle, but with little luck.

    All I am doing is changing existing units with new units.
    And what is your particular problem? Any error messages?

    -Martin
    Civ2 military advisor: "No complaints, Sir!"

    Comment


    • #3
      CRA_elite

      slc: 16 Symbol tmpArmy undefined
      slc: 16 Symbol tmpArmy used in assignment unknown type

      slc: 17 Symbol tmpArmy not a structure
      slc: 17 Symbol tnpNum undefined:
      slc: 17 Variable tmpNum used in assignment unknown type

      slc: 18 Symbol tmpPlayer undefined
      slc: 18 Variable tmpPlayer used in assignment unknown type

      slc: 22 Symbol j undefined
      slc: 22 Variable j used in assignment unknown type

      slc: 23 Symbol tmpUnit undefined

      slc: 24, 33, 42, 51, 60, 69, 78, 87, 96, 105, 114, 123, 150, 157, 166, 175, 184, 193, 202 Symbol tmpUnit not a structure

      slc: 210 Symbol AgeGREAT_GENERAL undefined
      slc: 210 Variable AgeGREAT_GENERALused in assignment unknown type

      slc: 235 GREAT_GENERAL not string variable


      ++++++++++++++++++++++++++++++++++++
      CRA_pow

      slc:14 Symbol tmpNum already has a type

      slc:15 Symbol tmpArmy already has a type

      slc:21 Symbol tmpPlayer already has a type

      slc: 83 Symbol tmpArmy not a structure

      slc: 89 Symbol tmpUnit not a structure


      ++++++++++++++++++++++++++++++++++++
      In addition, when I activate the above SLICs, I get crashes on the following SLIC, but do not get those crashes when the two above are deactivated

      CRA_wonderunits

      slc:8 Symbol tmpPlayer already has a type

      slc:8 Symbol tmpWonder already has a type

      slc:291 Symbol i already has a type

      slc:292 Symbol j already has a type
      Yes, let's be optimistic until we have reason to be otherwise...No, let's be pessimistic until we are forced to do otherwise...Maybe, let's be balanced until we are convinced to do otherwise. -- DrSpike, Skanky Burns, Shogun Gunner
      ...aisdhieort...dticcok...

      Comment


      • #4
        The code you use has global variables. That is really bad style, unless the variables are really intended to be global, and exchange data across events and function.

        The quick and dirty way to fix it is to change the include order of the slic files: So first CRA_wonderunits.slc, CRA_pow.slc, and then CRA_pow.slc.

        Probably this won't be enough, but it should remove the symbol undefined errors. For the symbol already have a type error, you can outcomment the symbol redefinition.

        slc: 210 Symbol AgeGREAT_GENERAL undefined
        That line doesn't seem to do anything in your script so it can go, or being outcommented.

        slc: 235 GREAT_GENERAL not string variable
        Looks like a message box is missing.

        -Martin
        Civ2 military advisor: "No complaints, Sir!"

        Comment


        • #5
          Rearranging the order in script.slc appears to do the trick. I actually didn't have to outcomment anything. It also explains why the pow.slc file stopped working for me about a week ago, and I hadn't done anything to that file - but I had alphabetized the slics in script.slc for bookkeeping purposes.

          No guarantee that it will hold up, but the only new slic I now have is the elite.slc, and Cradle has been running pretty stable since 2001, so any crashes will probably be trackable to that file.

          Fixed the last two problems too, although I did have the messageboxes in.

          I renamed GREAT_GENERAL to Gsix (following the naming sequence of the other messages I had in the slc file.)

          Thanks
          Yes, let's be optimistic until we have reason to be otherwise...No, let's be pessimistic until we are forced to do otherwise...Maybe, let's be balanced until we are convinced to do otherwise. -- DrSpike, Skanky Burns, Shogun Gunner
          ...aisdhieort...dticcok...

          Comment


          • #6
            Urgh, yes. that'll be all my fault. Sorry.

            It's buggy anyway, the variable names in this line need to agree. (tmpNum2 in this case)
            Code:
            if(tmpNum2 >= 112 && tmpNum <= 117){
            This is better, assuming I haven't introduced any new bugs.

            Code:
            //---------------------------------------
            //    Prisoners of War 1.02
            //    by the Immortal Wombat
            //---------------------------------------
            
            int_t	POW_TYPE[];
            
            //-----------------------
            //  Begin Game Setup
            
            HandleEvent(BeginTurn) 'GameStart' pre {
            	POW_TYPE[0] = UnitDB(UNIT_WARRIOR);	
            	POW_TYPE[1] = UnitDB(UNIT_SPEARMAN);
            	POW_TYPE[2] = UnitDB(UNIT_HOPLITE);
            	POW_TYPE[3] = UnitDB(UNIT_MAN_AT_ARMS);
            	POW_TYPE[4] = UnitDB(UNIT_INFANTRYMAN);
            	POW_TYPE[5] = UnitDB(UNIT_MACHINE_GUNNER);
            	POW_TYPE[6] = UnitDB(UNIT_HOVER_INFANTRY);
            
            	DisableTrigger('GameStart');			//run once only
            }
            
            //----------------------
            //   Get Player Age
            
            
            int_f WOUTER_GetAge(int_t thePlayer) {
            	int_t tmpPlayer;
            	tmpPlayer = thePlayer;
            
            	if (HasAdvance(tmpPlayer, ID_ADVANCE_PLASMA_WEAPONRY)) {
            		return 6;							
            	} elseif (HasAdvance(tmpPlayer, ID_ADVANCE_ADV_INFANTRY_TACTICS)) {
            		return 5;
            	} elseif (HasAdvance(tmpPlayer, ID_ADVANCE_RAILROAD)) {
            		return 4;
            	} elseif (HasAdvance(tmpPlayer, ID_ADVANCE_BANKING)) {
            		return 3;
            	} elseif (HasAdvance(tmpPlayer, ID_ADVANCE_COMPOSITE_BOW)) {
            		return 2;
            	} elseif (HasAdvance(tmpPlayer, ID_ADVANCE_TOOLMAKING)) {
            		return 1;
            	} else {	
            		return 0;
            	}
            }
            
             //--------------------------------------------
            //  Capturing event
            
            void_f	CaptureUnit(location_t theLocation, int_t thePlayer){	
            	location_t tmpLoc;
            	int_t POWage;
            	int_t tmpPlayer;
            	tmpPlayer = thePlayer;
            	tmpLoc = theLocation;
            	POWage = WOUTER_GetAge(tmpPlayer);
            	Event:CreateUnit(tmpPlayer, tmpLoc, 0, POW_TYPE[POWage], 1);
            	Event:GroupOrder(army[0]);
            }
            
            
             //------------------
            //  Battle event
            
            
            HandleEvent(VictoryMoveOrder) 'capture' pre {
            	location_t tmpLoc;
            	army_t tmpArmy;
            	unit_t tmpUnit;
            	int_t tmpNum;
            	int_t tmpNum2;
            	int_t tmpPlayer;
            	int_t POWage;
            	int_t IsThere;
            	int_t i;
            	
            	tmpArmy = army[0];
            	tmpNum = tmpArmy.size;
            	tmpPlayer = army[0].owner;
            	tmpLoc = army[0].location;
            	IsThere = 0;
            
            	for(i = 0; i < tmpNum; i = i + 1) {
            		GetUnitFromArmy(tmpArmy, i, tmpUnit);
            		tmpNum2 = tmpUnit.type;
            		if(tmpNum2 >= 112 && tmpNum2 <= 117){			// ID of chosen units
            			IsThere = 1;
            		}
            	}
            	if(IsThere == 1){	
            		POWage = WOUTER_GetAge(tmpPlayer);		//get age (for messaging purposes)
            		if(POWage == 6){
            			message(tmpPlayer, 'six');		
            			CaptureUnit(tmpLoc, tmpPlayer);			//and run the captureunit function
            		}
            		elseif(POWage == 5){
            			message(tmpPlayer, 'five');
            			CaptureUnit(tmpLoc, tmpPlayer);
            		}
            		elseif(POWage == 4){
            			message(tmpPlayer, 'four');
            			CaptureUnit(tmpLoc, tmpPlayer);
            		}
            		elseif(POWage == 3){
            			message(tmpPlayer, 'three');
            			CaptureUnit(tmpLoc, tmpPlayer);
            		}
            		elseif(POWage == 2){
            			message(tmpPlayer, 'two');
            			CaptureUnit(tmpLoc, tmpPlayer);
            		}
            		elseif(POWage == 1){
            			message(tmpPlayer, 'one');
            			CaptureUnit(tmpLoc, tmpPlayer);
            		}	
            	}
            }
            Concrete, Abstract, or Squoingy?
            "I don't believe in giving scripting languages because the only additional power they give users is the power to create bugs." - Mike Breitkreutz, Firaxis

            Comment

            Working...
            X