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.
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);
}
}
}
Comment