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
  Question to SLIC writers

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:   Question to SLIC writers Format for Better Printing
Dale
Warlord
Melbourne, Australia
Dec 2000
posted February 07, 2001 21:37   Click Here to See the Profile for DaleClick Here to Email Dale  send a private message to Dale
Edit/Delete Message    Reply To And Quote This Message
IP: Logged, Admin Access Only
I've been thinking about how to teleport units around the map. The question comes up because event TELEPORT can cause some weird results, and just disbanding a unit and creating a new one at the new location won't take across any veteran status. So I've had this idea and wondered if it would work in SLIC. Maybe Locutus can shed some light?

Here's the basics of the code anyways:

code:

location_t tmploc;
unit_t tmpunit;

tmpunit = (unit you want to 'teleport');
// Define desired unit to 'teleport'.
//
// Routine to find desired location to 'teleport' to.
// In withdraw mod I use a 50 loop RandomNeighbor loop
// to find a desired spot.
// Define desired spot as tmploc
//
tmpunit.location = tmploc;
// Define location of unit to desired location.
//
// End with whatever the command is to refresh the screen.


By my thoughts, this should work because all you are doing is redefining the units location property to what you want and then refreshing the screen so the unit icon pops up in it's new location. Can anyone see any problems with this theory?

------------------
Author of Diplomod. The mod to fix diplomacy.

Rommell to a sub-commander outside Tobruk: "Those Australians are in there somewhere. But where? Let's advance and wait till they shoot, then shoot back."
[This message has been edited by Dale (edited February 07, 2001).]

Jerk
Chieftain
Green Bay, WI USA
Nov 2000
posted February 08, 2001 02:56   Click Here to See the Profile for JerkClick Here to Email Jerk  send a private message to Jerk
Edit/Delete Message    Reply To And Quote This Message
IP: Logged, Admin Access Only

I haven't done any testing but I doubt it works like that. Using unit.location extracts the location but probably doesn't set the location. I could be wrong though. You can actually kill the unit and then create it at a different location. Just use IsVeteran() to see if the unit is a veteran, create the unit, then ToggleVeteran() to set it to the right status. You can do similar with hit points as well using unit.hp and DamageUnit().
heardie
GGS Co-Webmaster

Aug 1999
posted February 08, 2001 03:55   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
Heres a function from the Alexander scenario. I presume you know how to use, include it, etc.
code:

// Teleports units from a given location to a given location
void_f TeleportUnits (location_t tmpLoc, location_t tmpDest, int_t tmpPlayer)
{
int_t unitTypes[12];
int_t tmpNum;
int_t playerNum;
int_t i;
location_t tmpLoc2;
location_t tmpDest2;
unit_t tmpUnit;

playerNum = tmpPlayer;
tmpLoc2 = tmpLoc;
tmpDest2 = tmpDest;
tmpNum = GetUnitsAtLocation(tmpDest2);
if (tmpNum > 0) {
for (i = 0; i < tmpNum; i = i + 1) {
GetUnitFromCell(tmpLoc2, i, tmpUnit);
if (tmpUnit.owner != playerNum) {
Event:KillUnit(tmpUnit, 0, playerNum); // Kill units in the destination square not belonging to teleporting units
}
}
}
tmpNum = GetUnitsAtLocation(tmpLoc2);
if (tmpNum > 0) {
for (i = 0; i < tmpNum; i = i + 1) {
GetUnitFromCell(tmpLoc2, i, tmpUnit);
unitTypes[i] = tmpUnit.type;
}
for (i = 0; i < tmpNum; i = i + 1) {
if (unitTypes[i] != 0) {
CreateUnit(playerNum, unitTypes[i], tmpDest2, 0); // 'Teleport' new unit
}
}
for (i = 0; i < tmpNum; i = i + 1) {
GetUnitFromCell(tmpLoc2, i, tmpUnit);
Event:KillUnit(tmpUnit, 0, playerNum); // Kill old unit
}
}
}


Locutus
Prince
Apolyton Borg Hengelo/Enschede, The Netherlands
Nov 1999
posted February 08, 2001 15:00   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
Here's another piece of code from the Alexander scenario (though this wasn't in the original game, something like this will be added to the improved version). It gives you an example of how to store veteran and health status. Combine this with the code above and you'll have a perfect replacement for the Teleport function.

code:

int_f SwapCityW (city_t swCity, int_t swPlayer, int_t killUnits) {
int_t i;
int_t tmpPlayer;
int_t tmpNum;
int_t numUnits;
int_t noSwap;
int_t tmpUnitTypesW[12]; // -> changed from tmpUnitTypes (CR 2001-01-16)
int_t tmpHp[12];
int_t tmpHealth[12];
int_t tmpDamage;
unit_t tmpUnit;
city_t tmpCity;
location_t tmpLoc;

tmpCity = swCity;
if (CityIsValid(tmpCity)) {
tmpPlayer = swPlayer;
numUnits = GetUnitsAtLocation(tmpCity.location);
tmpLoc = tmpCity.location;
for (i = 0; i < numUnits; i = i + 1) { // Check for special units
GetUnitFromCell(tmpLoc, i, tmpUnit);
tmpNum = tmpUnit.type;
if (tmpNum >= 72 && tmpNum <= 88) {
noSwap = 1;
}
}
if (noSwap == 0) {
if (killUnits == 1) {
for (i = 0; i < numUnits; i = i + 1) {
GetUnitFromCell(tmpLoc, i, tmpUnit);
Event: KillUnit(tmpUnit, 0, tmpUnit.owner);
}
} elseif (killUnits == 0) {
for (i = 0; i < numUnits; i = i + 1) { // -> added (CR 2001-01-16)
// while (GetUnitsAtLocation(tmpLoc) > 0) {
GetUnitFromCell(tmpLoc, 0, tmpUnit);
tmpUnitTypesW[i] = tmpUnit.type; // -> changed from tmpUnitTypes (CR 2001-01-16)
tmpHealth[i] = tmpUnit.hp;
if (IsVeteran(tmpUnit)) {
tmpHp[i] = 1; // -> changed from tmpUnitHp (CR 2001-01-16)
} else {
tmpHp[i] = 0; // -> changed from tmpUnitHp (CR 2001-01-16)
}
Event: KillUnit(tmpUnit, 0, tmpUnit.owner);
// i = i + 1;
}
}
Event:GiveCity(tmpCity, tmpPlayer);
for (i = 0; i < numUnits; i = i + 1) {
CreateUnit(tmpPlayer, tmpUnitTypesW[i], tmpLoc, 0); // -> changed from tmpUnitTypes (CR 2001-01-16)
if (tmpHp[i] == 1) {
ToggleVeteran(tmpUnit, 1);
}
tmpDamage = UnitDB(tmpUnitTypesW[i]).MaxHP - tmpHealth[i]; // -> changed from tmpUnitTypes (CR 2001-01-16)
DamageUnit(tmpUnit, tmpDamage);
}
} else {
return -1; // Can't swap due to Special unit
}
} else {
return -2; // Can't swap due to invalid city
}
}



[This message has been edited by Locutus (edited February 08, 2001).]
Dale
Warlord
Melbourne, Australia
Dec 2000
posted February 08, 2001 16:49   Click Here to See the Profile for DaleClick Here to Email Dale  send a private message to Dale
Edit/Delete Message    Reply To And Quote This Message
IP: Logged, Admin Access Only
Thanks guys! You're champs! I'll look through it all this weekend.

Now I know why I bow to the SLIC wisdom of others, cuz I'm crap!

------------------
Author of Diplomod. The mod to fix diplomacy.

Rommell to a sub-commander outside Tobruk: "Those Australians are in there somewhere. But where? Let's advance and wait till they shoot, then shoot back."

Alpha Wolf
Settler
Prince of the Barbarians
Feb 2001
posted February 08, 2001 23:47   Click Here to See the Profile for Alpha WolfClick Here to Email Alpha Wolf  send a private message to Alpha Wolf Visit Alpha Wolf's Homepage!
Edit/Delete Message    Reply To And Quote This Message
IP: Logged, Admin Access Only
Dear SLIC Lords,
Can transport be triggered before the AI gives away a city in order to salvage the garrison?

GiveCity 'savearmy' pre {
transport garrison logic
}

????????

Sincerely,
Prince of the Barbarians

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

Locutus
Prince
Apolyton Borg Hengelo/Enschede, The Netherlands
Nov 1999
posted February 09, 2001 02:32   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
AW,
This already happens automaticly. Right before a city is given away, all units in that city are teleported to nearby cities.
Colonel Kraken
Chieftain
Grand Rapids, MI
Nov 2000
posted February 09, 2001 11:07   Click Here to See the Profile for Colonel KrakenClick Here to Email Colonel Kraken  send a private message to Colonel Kraken
Edit/Delete Message    Reply To And Quote This Message
IP: Logged, Admin Access Only
In my experience in giving cities away to AI players (just to try it out), units in the city were destroyed. (I had wanted to see if the units would revert to control of the new player). The units definitely were NOT teleported back to my nearest city, but perhaps it works differently if the AI gives YOU a city.
Alpha Wolf
Settler
Prince of the Barbarians
Feb 2001
posted February 09, 2001 21:55   Click Here to See the Profile for Alpha WolfClick Here to Email Alpha Wolf  send a private message to Alpha Wolf Visit Alpha Wolf's Homepage!
Edit/Delete Message    Reply To And Quote This Message
IP: Logged, Admin Access Only
I've seen them die many times. But you can also hear them die. i once bought an AIs second to last city then a few turns later attacked the already surrounded capital. I heard/saw eight units die after I bought the city and the capitol only had a couple of units in it when I attacked, and there was no way those units could have escaped the capitol.

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

XMon
Chieftain
Tampa, Florida
Sep 2000
posted February 11, 2001 00:23   Click Here to See the Profile for XMonClick Here to Email XMon  send a private message to XMon
Edit/Delete Message    Reply To And Quote This Message
IP: Logged, Admin Access Only
I've given cities to other civs (I just can't resist Sheherazade!) and my units were teleported to my nearest city. If your's died then perhaps (just a guess) your cities were full of defenders or you were out of support shields. Dunno.
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.

AltaVista Type or paste text or Web address (beginning with http://) here:
Powered
by Systran
Translate from: 

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