 |
|
Maquiladora
|
|
You lose one caravan each time you cancel a route so its probably better to defend the route instead of cancelling any.
edit: got it right this time 
Last edited by Maquiladora on 28-12-2002 at 21:23
|
|
|  |
 |
|
Maquiladora
|
|
Yeah it doesnt make much real life sense, but in gameplay terms it makes you defend a trade route from pirates. Also the more caravans a trade route uses the less harm it does to cancel it, obviously, so dont cancel a 1 caravan trade route because you wont get any caravans from it.
|
|
|  |
 |
|
Martin Gühmann
|
 |
Berlin, Germany
Mar 2001 time: 06:24
|
|
That should give the lost trader back.
code:
HandleEvent(KillTradeRoute)'MG_GiveTradeUnitBack'p
ost{
city_t MGCity;
unit_t MGUnit;
location_t MGLoc;
GetCityByIndex(g.player, 0, MGCity);
if(HasAdvance(g.player, ID_ADVANCE_TRADE))
if(CityIsValid(MGCity)){//Creates an additional Caravan unit near your first city
CreateUnit(g.player, UnitDB(UNIT_CARAVAN), MGCity.location, 2, MGUnit);
}
else{//Creates the Caravan unit somewhere else
CreateUnit(g.player, UnitDB(UNIT_CARAVAN), MGLoc, 2, MGUnit);
}
}
elseif(g.player, ID_ADVANCE_GLOBAL_ECONOMICS)){
if(CityIsValid(MGCity)){//Creates an additional Z-Freight unit near your first city
CreateUnit(g.player, UnitDB(UNIT_Z_FREIGHT_TRANSPORT), MGCity.location, 2, MGUnit);
}
else{//Creates the Z-Freight unit somewhere else
CreateUnit(g.player, UnitDB(UNIT_Z_FREIGHT_TRANSPORT), MGLoc, 2, MGUnit);
}
}
}
Disclaimer: Untestested, untried, maybe buggy.
You can find this code in the attachment of this post. Just download the attachment unzip it into your ..\ctp2_data\default\gamedata\ folder and open there the file GM1_APOL_script.slc and add this line to the end of the file:
#include "GiveTraderBack.slc"
And make shure that the file ends with a blanc line.
-Martin
Attachment: givetraderback.zip
This has been downloaded 1 time(s).
|
|
|  |
 |
|
Martin Gühmann
|
 |
Berlin, Germany
Mar 2001 time: 06:24
|
|
The event handler is called but are you shure that the if else statements will ever be true?
To determine if the if statement is true you could insert a piece of code like this:
PlaySound("SOUND_ID_ELEPHANT");
The sound id must be a valid sound from the sound.txt otherwise - silence.
I hope you played with the /reloadslic ceremony, that will make things easier as you don't have to reload CTP2 every time you want to test another piece of code.
For the rest of the code you could replace CreateUnit function by the CreateUnit event. So just replace the line with the CreateUnit function with.
Event:CreateUnit(g.player, MGCity.location, MGCity, UnitDB(UNIT_CARAVAN), 1);
In the else statement it should be:
Event:CreateUnit(g.player, MGLoc, 0, UnitDB(UNIT_CARAVAN), 1);
If this doesn't work I will take a look on this tommorow. I hope this is not as difficuilt as teaching slaves to uprise properly.
If you are searching for more slic stuff you could take a look into the Apolyton CTP2 Modification Section.
-Martin
|
|
|  |
 |
|
Martin the Dane
|
 |
Aarhus, Denmark
Feb 2000 time: 06:24
|
|
Update
After posting the above I had an idea: what if I passed g.player as an int_t? I modified the code a bit, and now it works.
The code is as follows:
code: HandleEvent(KillTradeRoute) 'MG_GiveTradeUnitBack' post{
city_t MGCity;
unit_t MGUnit;
location_t MGLoc;
int_t MGplay; // g.palyer must be passed to the event as an int_t
MGPlay = g.player;
GetCityByIndex(g.player, 0, MGCity);
if(HasAdvance(g.player, ID_ADVANCE_TRADE)){
if(CityIsValid(MGCity)){//Creates an additional Caravan unit near your first city
Event:CreateUnit(MGPlay, MGCity.location, MGCity, UnitDB(UNIT_CARAVAN), 1);
}
else{//Creates the Caravan unit somewhere else
Event:CreateUnit(MGPlay, MGLoc, 0, UnitDB(UNIT_CARAVAN), 1);
}
}
}
|
|
|  |
 |
|
Martin the Dane
|
 |
Aarhus, Denmark
Feb 2000 time: 06:24
|
|
Ok here is the updated version of GiveTraderBack.slc as a .zip file with explanations etc.
Edited to remove the attachent, just grab the one two posts down.
Last edited by Martin the Dane on 29-12-2002 at 21:39
|
|
|  |
 |
|  |
 |
|
Martin the Dane
|
 |
Aarhus, Denmark
Feb 2000 time: 06:24
|
|
Well the trouble is that the number of lost trade points depends on wheter they are from Caravans or Freight Transports, so unless we can determin that, giving back TF's after inventing them could create additional tradepoints, and that's worse than losing some. 
If you have a mix, and you most likely have if you have built any FT's, there is no way of telling which is used for any given trade route. It seems like it is most likely that caravans will be used for routes requring less than 3 points, but this is not a fixed rule.
I gave myself 5 FT's created some trade routes and broke them again, this resulted in the loss of 2 points/route (one returned from the function). Now I had a mix, so I repeated the create-break. This time I sometimes lost 2 point/route sometimes not, and usually not if the route used less than 3 point.
So I guess the good old German word "schade" is apropriate here.
|
|
|  |
 |
|
Martin Gühmann
|
 |
Berlin, Germany
Mar 2001 time: 06:24
|
|
quote: Originally posted by Martin the Dane
I just checked the slic section, there is a function INT TradePoints(player) that acording to the list gives the number of caravans the player has, but it could be the number of tradepoints available. |
I wonder why I can't find it in the function reference here on Apolyton, maybe because the code of that shtml file is c****y. But I hope it will indeed return the number of total tradepoints. So the code should look like this:
PHP:
int_t MGGlobalTraders;
HandleEvent(KillTradeRoute)'MG_CountTrader'pre{
MGGlobalTraders = TradePoints(g.player);
}
HandleEvent(KillTradeRoute)'MG_GiveTraderBack'post {
location_t MGLoc;
int_t MGTraders;
int_t MGplay; // g.player must be passed as a int_t
int_t i;
MGTraders = MGGlobalTraders - TradePoints(g.player);
MGPlay = g.player;
for(i=0; i<MGTraders; i=i+1){
Event:CreateUnit(MGPlay, MGLoc, 0, UnitDB(UNIT_CARAVAN), 1);
}
}
Disclaimer: Untried, untested, maybe buggy.
quote: Originally posted by Martin the Dane
Unfortunately I don't know how to test this, but I'll try to find out. I would like to popup a message saying "you have # tradepoints" or something similar. |
Yes it is possible to put it into a message box, but I think this has to wait until, tommorw.
-Martin
Attachment: givetradeback.zip
This has been downloaded 1 time(s).
|
|
|  |
All times are GMT. The time now is 05:24. Apolyton Time is 00:24. |
top of page
|
| archivepost |
|
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
|
|
|
|
|
|