December 28, 2002, 11:56
|
#1
|
Prince
Local Time: 14:22
Local Date: November 1, 2010
Join Date: Feb 2000
Location: Aarhus, Denmark
Posts: 550
|
Loosing Trade routes
I am playing the Apolyton Pack with GoodMod on gigantic map.
I have noted something strange with the trade-routes. I wanted to change a route to a more profitable one. But when I canceld the trade-route the caravan was lost. Just as if they had been pirated in good old CTP1.
Acording to the manual you should be able to reuse caravans.
Quote:
|
You can always cancel a current trade route to free up caravans if you want to initiate a route somewhere else. To do this, simply select the route and
click the Break Route Button.
|
When I do this my caravan count simply decreases.
__________________
Visit my CTP-page and get TileEdit and a few other CTP related programs.
Download and test SpriteEdit development build.
|
|
|
|
December 28, 2002, 12:10
|
#2
|
Emperor
Local Time: 14:22
Local Date: November 1, 2010
Join Date: Jun 2001
Posts: 7,665
|
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; December 28, 2002 at 12:23.
|
|
|
|
December 28, 2002, 12:28
|
#3
|
Prince
Local Time: 14:22
Local Date: November 1, 2010
Join Date: Feb 2000
Location: Aarhus, Denmark
Posts: 550
|
__________________
Visit my CTP-page and get TileEdit and a few other CTP related programs.
Download and test SpriteEdit development build.
|
|
|
|
December 28, 2002, 12:31
|
#4
|
Emperor
Local Time: 14:22
Local Date: November 1, 2010
Join Date: Jun 2001
Posts: 7,665
|
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.
|
|
|
|
December 28, 2002, 12:50
|
#5
|
Prince
Local Time: 14:22
Local Date: November 1, 2010
Join Date: Feb 2000
Location: Aarhus, Denmark
Posts: 550
|
Peronally I'd prefere a system where there was a certain chance of loosin a caravan when the route is pirated. This way youd still want to defend the traderoute, especially if the chance was cumulative.
Furthermore if it was impossible to break a traderoute being pirated, or carried a penalty in lost caravans, you'd have even more incentive to defend your caravans.
But I guess I'll just have to live with it, as I have no slic-knowledge.
__________________
Visit my CTP-page and get TileEdit and a few other CTP related programs.
Download and test SpriteEdit development build.
|
|
|
|
December 28, 2002, 13:35
|
#6
|
Super Moderator
Local Time: 15:22
Local Date: November 1, 2010
Join Date: Mar 2001
Location: Tübingen, Germany
Posts: 6,206
|
That should give the lost trader back.
Code:
|
HandleEvent(KillTradeRoute)'MG_GiveTradeUnitBack'post{
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
__________________
Civ2 military advisor: "No complaints, Sir!"
|
|
|
|
December 28, 2002, 18:14
|
#7
|
Prince
Local Time: 14:22
Local Date: November 1, 2010
Join Date: Feb 2000
Location: Aarhus, Denmark
Posts: 550
|
Thanks Martin,
I tried your code, (there were two minor errors) but unfortunately it does not work.
I have experimented a bit with it, and the function is called whenever a trade unit is destroyd, but the new trade unit is not created.
Btw. It should create caravans regardless of tradelevel as they are single route units.
__________________
Visit my CTP-page and get TileEdit and a few other CTP related programs.
Download and test SpriteEdit development build.
|
|
|
|
December 28, 2002, 19:24
|
#8
|
Super Moderator
Local Time: 15:22
Local Date: November 1, 2010
Join Date: Mar 2001
Location: Tübingen, Germany
Posts: 6,206
|
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
__________________
Civ2 military advisor: "No complaints, Sir!"
|
|
|
|
December 29, 2002, 05:53
|
#9
|
Emperor
Local Time: 13:22
Local Date: November 1, 2010
Join Date: Jan 2002
Location: UK
Posts: 3,272
|
Martin the Dane,
I often change trade routes to take advantage of new diplomatic situations and to get the most profitable trade routes i can. Unfortunately it will always cost you one caravan to do so, so i make sure i have one of my cities building any extra i need before i make the change to the better trade route - a bit annoying i know, but you can plan for it atleast.
I think the most annoying thing is the way your routes are automatically plotted and how DUMB those routes are sometimes(like right through enemy territory ). I don't think that can be Slic-ed, unfortunately.
__________________
'The very basis of the liberal idea – the belief of individual freedom is what causes the chaos' - William Kristol, son of the founder of neo-conservitivism, talking about neo-con ideology and its agenda for you. info here. prove me wrong.
Bush's Republican=Neo-con for all intent and purpose. be afraid.
|
|
|
|
December 29, 2002, 07:07
|
#10
|
Prince
Local Time: 14:22
Local Date: November 1, 2010
Join Date: Feb 2000
Location: Aarhus, Denmark
Posts: 550
|
child of Thor:
Thanks for the tip, I guess that that's the only way.
Martin:
I have tested your slic quite extensively. From a programmers perspective I can't se why it's not working.
If I replace UNIT_CARAVAN with UNIT_HOPLITE a hoplite is created whenever I cancel a traderoute, so the "CreateUnit" function get's executed.
I have also tried to replace the function with the event, but here I get an "int_t expected" error, and a crash (I think it was parameter 1).
__________________
Visit my CTP-page and get TileEdit and a few other CTP related programs.
Download and test SpriteEdit development build.
|
|
|
|
December 29, 2002, 07:20
|
#11
|
Prince
Local Time: 14:22
Local Date: November 1, 2010
Join Date: Feb 2000
Location: Aarhus, Denmark
Posts: 550
|
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);
}
}
} |
__________________
Visit my CTP-page and get TileEdit and a few other CTP related programs.
Download and test SpriteEdit development build.
|
|
|
|
December 29, 2002, 10:51
|
#12
|
Prince
Local Time: 14:22
Local Date: November 1, 2010
Join Date: Feb 2000
Location: Aarhus, Denmark
Posts: 550
|
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.
__________________
Visit my CTP-page and get TileEdit and a few other CTP related programs.
Download and test SpriteEdit development build.
Last edited by Martin the Dane; December 29, 2002 at 12:39.
|
|
|
|
December 29, 2002, 11:19
|
#13
|
Super Moderator
Local Time: 15:22
Local Date: November 1, 2010
Join Date: Mar 2001
Location: Tübingen, Germany
Posts: 6,206
|
Quote:
|
Originally posted by Martin the Dane
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.
|
Yeah I thought players are just ints but I just saw this in the slic documentaion:
player.owner - An integer version of the player.
This means int != player.
Glad to hear that it works now.
-Martin
__________________
Civ2 military advisor: "No complaints, Sir!"
|
|
|
|
December 29, 2002, 12:37
|
#14
|
Prince
Local Time: 14:22
Local Date: November 1, 2010
Join Date: Feb 2000
Location: Aarhus, Denmark
Posts: 550
|
Oops! guess I was a bit premature with declaring that it worked. I found out that it caused the capital not to produce any thing in the turn where the traderoute was canceled.
Luckely this was easily corrected, I just renoved the inermost if sentences and acociated variables, so now the whole stuff is as follows:
Code:
|
HandleEvent(KillTradeRoute) 'MG_GiveTradeUnitBack' post{
location_t MGLoc;
int_t MGplay; // g.player must be passed as a int_t
MGPlay = g.player;
if(HasAdvance(g.player, ID_ADVANCE_TRADE)){
Event:CreateUnit(MGPlay, MGLoc, 0, UnitDB(UNIT_CARAVAN), 1);
}
} |
Disclaimer: This has not been tested for unforseen bugs, but it does give back the lost trader
__________________
Visit my CTP-page and get TileEdit and a few other CTP related programs.
Download and test SpriteEdit development build.
|
|
|
|
December 29, 2002, 16:03
|
#15
|
King
Local Time: 06:22
Local Date: November 1, 2010
Join Date: Jul 2002
Location: Berkeley
Posts: 1,375
|
u know, i think it adds to the gameplay to lose caravans when routes r broken,
it also is like a merchant losing his job (or not)
|
|
|
|
December 29, 2002, 19:36
|
#16
|
Prince
Local Time: 14:22
Local Date: November 1, 2010
Join Date: Feb 2000
Location: Aarhus, Denmark
Posts: 550
|
Well with the way the trade system is set up you loose anyway, the profit from a given route dekreases over time, so at some point you'll have to break the route.
In real life trade-companies would find new markets and move there.
A more natural way would be to have a certain chance each turn for a given trade-route to "crash" with the loss of some of it's capacity. Make this relative to the time the route has been in effect.
Plus pirating a route should result in loss of more than the cargo, some limit to the number of times a route can be pirated befor it looses one of the caravans and breaks.
Something like 10%-20% chance each time of loosing a caravan, and if the route is stil there after the tenth pirating it breaks and looses a caravan.
I think it's stupid that pirating never results in loss of a caravan.
__________________
Visit my CTP-page and get TileEdit and a few other CTP related programs.
Download and test SpriteEdit development build.
|
|
|
|
December 29, 2002, 20:23
|
#17
|
King
Local Time: 06:22
Local Date: November 1, 2010
Join Date: Jul 2002
Location: Berkeley
Posts: 1,375
|
hmmm, losing caravan only under piracy is a great idea
|
|
|
|
December 30, 2002, 13:54
|
#18
|
Super Moderator
Local Time: 15:22
Local Date: November 1, 2010
Join Date: Mar 2001
Location: Tübingen, Germany
Posts: 6,206
|
There is a Event KillTradeRoute, but unfortunatly it needs an invalid slic argument so it can be triggered. So far I don't know a way so it can be used.
Another question Martin: If I remember correctly a trade route that was created with the Freight Transport should remove 3 trade points if it was canceled, did you test this?
-Martin
__________________
Civ2 military advisor: "No complaints, Sir!"
|
|
|
|
December 30, 2002, 14:20
|
#19
|
Prince
Local Time: 14:22
Local Date: November 1, 2010
Join Date: Feb 2000
Location: Aarhus, Denmark
Posts: 550
|
Martin:
No I only tested using caravans, guess I'll have to test a bit more.
I was looking at the slic pages, but never found anything there that could make the pirating stuff work as I would like it to. But then again I'm not much of a slic-programer, the only modding I ever made was to the gui and terrain files in ctp1.
Now that I have finaly bought ctp2 I'll have more of a chance to get into modding, but I think I'll just stik to what I do best: gui and tools for modders, but at least I kan now test them myself, befor shipping them.
__________________
Visit my CTP-page and get TileEdit and a few other CTP related programs.
Download and test SpriteEdit development build.
|
|
|
|
December 30, 2002, 14:46
|
#20
|
Super Moderator
Local Time: 15:22
Local Date: November 1, 2010
Join Date: Mar 2001
Location: Tübingen, Germany
Posts: 6,206
|
Quote:
|
Originally posted by Martin the Dane
I was looking at the slic pages, but never found anything there that could make the pirating stuff work as I would like it to. But then again I'm not much of a slic-programer, the only modding I ever made was to the gui and terrain files in ctp1.
|
The slic code should be something like this:
Code:
|
HandleEvent(SetPiratingArmy)'MG_KillTradeRoute'post{
Event:KillTradeRoute(traderoute[0],0);
} |
If this code works then it will kill a trade route if it is priated but I doubt that it will work. If you try it I guess you will get an error message, that the first argument of the KillTradeRouteEvent should be of type traderoute_t. If you try to initialize something like this you will get an error message. But I think there is also another way to achieve this you want. But I need some time to work this out.
-Martin
__________________
Civ2 military advisor: "No complaints, Sir!"
|
|
|
|
December 30, 2002, 15:17
|
#21
|
Prince
Local Time: 14:22
Local Date: November 1, 2010
Join Date: Feb 2000
Location: Aarhus, Denmark
Posts: 550
|
Well two things Martin:
1. Yes trade routes created using Freight Transporst do loose 3 trade points when canceled.
2. I get a traderoute unknown error when trying your pirating code
__________________
Visit my CTP-page and get TileEdit and a few other CTP related programs.
Download and test SpriteEdit development build.
|
|
|
|
December 30, 2002, 16:24
|
#22
|
Super Moderator
Local Time: 15:22
Local Date: November 1, 2010
Join Date: Mar 2001
Location: Tübingen, Germany
Posts: 6,206
|
Quote:
|
Originally posted by Martin the Dane
1. Yes trade routes created using Freight Transporst do loose 3 trade points when canceled.
|
I guess in that case you know what to do, just using some part of my first code. Or will every trade route canceled after the invention of Freight Transporsts loose three trade points. However there is only a function that checks how many trade points are in use and no one that gives me the total number of trade points.
Quote:
|
Originally posted by Martin the Dane
2. I get a traderoute unknown error when trying your pirating code
|
That looks like there is no traderoute array, even if there is a improvement array that you actual can't use. The odd think of this event is that I can use everything as first argument I don't get any error message, the second argument must be an int but I have no idea what the int should be. Unfortunatly my other idea didn't work.
-Martin
__________________
Civ2 military advisor: "No complaints, Sir!"
|
|
|
|
December 30, 2002, 18:28
|
#23
|
Prince
Local Time: 14:22
Local Date: November 1, 2010
Join Date: Feb 2000
Location: Aarhus, Denmark
Posts: 550
|
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.
__________________
Visit my CTP-page and get TileEdit and a few other CTP related programs.
Download and test SpriteEdit development build.
|
|
|
|
December 30, 2002, 18:48
|
#24
|
Prince
Local Time: 14:22
Local Date: November 1, 2010
Join Date: Feb 2000
Location: Aarhus, Denmark
Posts: 550
|
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.
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.
__________________
Visit my CTP-page and get TileEdit and a few other CTP related programs.
Download and test SpriteEdit development build.
|
|
|
|
December 30, 2002, 19:35
|
#25
|
Super Moderator
Local Time: 15:22
Local Date: November 1, 2010
Join Date: Mar 2001
Location: Tübingen, Germany
Posts: 6,206
|
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 Code:
|
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
__________________
Civ2 military advisor: "No complaints, Sir!"
|
|
|
|
December 30, 2002, 20:10
|
#26
|
Prince
Local Time: 14:22
Local Date: November 1, 2010
Join Date: Feb 2000
Location: Aarhus, Denmark
Posts: 550
|
It works, I havn't played with it, but I did a cheat test.
No matter what combination I used I ended up with the same amount of trade routes.
So now we just have to figure out how to make that pirating stuff work.
What about just make it at chance for the player to loose a trade point, if that's acheaveable.
I'll look into it
__________________
Visit my CTP-page and get TileEdit and a few other CTP related programs.
Download and test SpriteEdit development build.
|
|
|
|
December 30, 2002, 21:10
|
#27
|
King
Local Time: 13:22
Local Date: November 1, 2010
Join Date: Jan 2000
Location: Gone Fishin, Canada
Posts: 1,059
|
Quote:
|
2. I get a traderoute unknown error when trying your pirating code
|
Martin G, where'd the traderoute array come from. I don't think I've ever seen it before. Do you know what members it has, if any?
|
|
|
|
December 30, 2002, 23:32
|
#28
|
King
Local Time: 10:22
Local Date: November 1, 2010
Join Date: Jul 2001
Location: of Natal, Brazil
Posts: 2,555
|
Welcome to modding Martin the Dane. You started the modification of the features you dislike
Like the rest of us modders
__________________
"Kill a man and you are a murder.
Kill thousands and you are a conquer.
Kill all and you are a God!"
-Jean Rostand
|
|
|
|
December 31, 2002, 07:18
|
#29
|
Prince
Local Time: 14:22
Local Date: November 1, 2010
Join Date: Feb 2000
Location: Aarhus, Denmark
Posts: 550
|
Thanks for the welcome Pedrunn,
I have a simple question for you and other seasoned slic'ers: Is there an arguments array for functions and events that can be accessed from within the function/handler?
__________________
Visit my CTP-page and get TileEdit and a few other CTP related programs.
Download and test SpriteEdit development build.
|
|
|
|
December 31, 2002, 08:01
|
#30
|
Deity
Local Time: 15:22
Local Date: November 1, 2010
Join Date: Nov 1999
Location: De Hel van Enschede
Posts: 11,702
|
You mean something like this or this?
|
|
|
|
Posting 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
|
|
|
All times are GMT -4. The time now is 09:22.
|
|