Apolyton Archive  |  Preserved copy of the Apolyton Civilization Site and its forums as they stood in September 2005. Read-only; nothing here can be posted to or replied to.  |  Forum index |  About this archive |  The 1998–2001 UBB forums
Today on Apolyton WARDELL INTERVIEW PROMO A.C.S. HISTORY CHAPTER 4 GET CIV4 /w FREE PLUS! A.C.S. PHOTO GALLERY GET A.O.M. V1.1
Apolyton Civilization Forums
main| civ2| civ3| civ4| smac| ctp2| ron| moo3| galciv| galciv2| alt| about|
ApolytonPLUS | register | search | faq | new posts | pm (-/-) | upload | members
hall of fame new! | civgroups | civgroups news | interviews | the column | radio | chat | directory | news | store | PLUS
Apolyton Civilization Forums : Powered by vBulletin version 2.0.3 Apolyton Civilization Forums > Miscellaneous > Archive > CtP2-Creation/AI/Mods/Scenarios-Archive > Question to SLIC writers
Show a Printable Version | Email This Page to Someone! | Receive updates to this thread | Report this to Apolyton news!

bottom of page
  
Author
Thread    < Last Thread     Next Thread > Post New Thread     Post A Reply
Dale is offline Dale
King
Sir! Why do you keep clicking on me?
Dec 2000
time: 15:14
Post  Old Post 08-02-2001 07:37
Edit/Delete Message Reply w/Quote
#1 Report this post to a moderator
Question to SLIC writers Support Apolyton

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 is offline Jerk
Chieftain
Green Bay, WI USA
Nov 2000
time: 23:14
Post  Old Post 08-02-2001 12:56
Edit/Delete Message Reply w/Quote
#2 Report this post to a moderator
Tired of ads?


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 is offline heardie
Prince

Aug 1999
time: 15:14
Post  Old Post 08-02-2001 13:55
Edit/Delete Message Reply w/Quote
#3 Report this post to a moderator
Support Apolyton or Terrorists Win

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 is offline Locutus
ACS CTP1/2 Manager & Civ4 Co-Manager
Hengelo, The Netherlands
Nov 1999
time: 06:14
Post  Old Post 09-02-2001 01:00 Visit Locutus<br><img src=/forums/images/staff-icon.gif>'s homepage!
Edit/Delete Message Reply w/Quote
#4 Report this post to a moderator
Support Apolyton

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 is offline Dale
King
Sir! Why do you keep clicking on me?
Dec 2000
time: 15:14
Post  Old Post 09-02-2001 02:49
Edit/Delete Message Reply w/Quote
#5 Report this post to a moderator
Support Apolyton, buy Call to Power 2

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 is offline Alpha Wolf
Chieftain
Prince of the Barbarians
Feb 2001
time: 05:14
Post  Old Post 09-02-2001 09:47 Visit Alpha Wolf's homepage!
Edit/Delete Message Reply w/Quote
#6 Report this post to a moderator
Avatar Enlargement: We've got the solution

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 is offline Locutus
ACS CTP1/2 Manager & Civ4 Co-Manager
Hengelo, The Netherlands
Nov 1999
time: 06:14
Post  Old Post 09-02-2001 12:32 Visit Locutus<br><img src=/forums/images/staff-icon.gif>'s homepage!
Edit/Delete Message Reply w/Quote
#7 Report this post to a moderator
Support Apolyton buy from Amazon

AW,
This already happens automaticly. Right before a city is given away, all units in that city are teleported to nearby cities.

Colonel Kraken is offline Colonel Kraken
Warlord
Grand Rapids, MI
Nov 2000
time: 00:14
Post  Old Post 09-02-2001 21:07
Edit/Delete Message Reply w/Quote
#8 Report this post to a moderator
Increase the size of your Attachments

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 is offline Alpha Wolf
Chieftain
Prince of the Barbarians
Feb 2001
time: 05:14
Post  Old Post 10-02-2001 07:55 Visit Alpha Wolf's homepage!
Edit/Delete Message Reply w/Quote
#9 Report this post to a moderator
Support Apolyton, buy Call to Power 2

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 is offline XMon
Warlord
Tampa, Florida
Sep 2000
time: 00:14
Talking  Old Post 11-02-2001 10:23
Edit/Delete Message Reply w/Quote
#10 Report this post to a moderator
Support Apolyton or Terrorists Win

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.

  < Last Thread     Next Thread > Post New Thread     Post A Reply
All times are GMT. The time now is 05:14.
Apolyton Time is 00:14.
    top of page
Rate This Thread:
archivepost
Forum Jump:
Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is ON
vB code is ON
Smilies are ON
[IMG] code is ON
 




Contact Us - Apolyton Civilization Site - Support Us!

Building a better Apolyton through better information. Click here and take our poll!
Non-US visitors, click here!

Powered by: vBulletin Version 2.0.3
Copyright ©2000, 2001, Jelsoft Enterprises Limited.

Page generated in 0.0399 seconds (89.04% PHP - 10.96% MySQL) with 31 queries
Page Loading Time:

Support Apolyton: Amazon USA | Amazon UK | Amazon DE | Amazon FR |
Support Apolyton and get FREE PLUS, Buy from Chips&Bits: Galactic Civilizations | Galactic Civilizations: Deluxe Edition | Call to Power 2 | Civilization: The Boardgame | GURPS/ Alpha Centauri | Alpha Centauri | Civilization IV | Civilization III: Complete |


Front Page | Civilization IV | Civilization III | Civilization II | Call to Power II | Alpha Centauri | Master of Orion III
Rise of Nations | Galactic Civilizations | Galactic Civilizations II | Misc
Alt.Civs | Civ I | C:CtP I | About | News | Directory | Apolyton Store | Forums | Chat | Columns | Interviews | Newsletter
Scenario League | CSC | Clash of Civs | Spanish Site | CtP Maps | Cradle of Civ | WesW's Ctp1/2 Site | Civ3 Haven

apolyton.net | apolyton.com | civilization2.net | civilization3.net | civilization4.net | civilizationiv.info | calltopower.net | galciv.net | galciv2.net | moo3.net