Thread Tools
Old July 22, 2002, 01:07   #1
Oerdin
Deity
 
Oerdin's Avatar
 
Local Time: 21:45
Local Date: October 31, 2010
Join Date: Sep 2001
Location: In a bamboo forest hiding from Dale.
Posts: 17,436
Question
Have you folks seen in Civ3 how a unit's sighting radius increases when the unit stands on top of hills or mountains? I think this is a very interesting feature and I'm wondering if it could be added to CTP2. Has anyone else tried this before?
__________________
Christianity is the belief in a cosmic Jewish zombie who can give us eternal life if we symbolically eat his flesh and blood and telepathically tell him that we accept him as our lord and master so he can remove an evil force present in all humanity because a woman was convinced by a talking snake to eat from an apple tree.
Oerdin is offline  
Old July 22, 2002, 12:11   #2
HuangShang
Call to Power II Democracy GameCTP2 Source Code Project
King
 
HuangShang's Avatar
 
Local Time: 21:45
Local Date: October 31, 2010
Join Date: Jul 2002
Location: Berkeley
Posts: 1,375
Inoticed the fact you can see far...

only play it a couple times... hated it
HuangShang is offline  
Old July 22, 2002, 13:09   #3
child of Thor
Call to Power II Democracy GameCTP2 Source Code Project
Emperor
 
child of Thor's Avatar
 
Local Time: 04:45
Local Date: November 1, 2010
Join Date: Jan 2002
Location: UK
Posts: 3,272
If balanced nicely,say just a one or two extra squares viewing distance, then it would be a good feature to have. Hmmmm, a z dimension in CTP2 terrain? I've no idea, but could be easy to do i guess. Just as units get a bonus defence when on mountains i suppose you could just add a bonus to units view range in the same way?
__________________
'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.
child of Thor is offline  
Old July 22, 2002, 18:16   #4
J Bytheway
Call to Power PBEMCall to Power II Democracy GameCTP2 Source Code Project
Emperor
 
J Bytheway's Avatar
 
Local Time: 05:45
Local Date: November 1, 2010
Join Date: Jul 2001
Location: England
Posts: 3,826
I can't see any way to do that short of adding an additional unit to the square with the longer sight range, which obviously runs into trouble when the square has 12 units in...
J Bytheway is offline  
Old July 23, 2002, 08:17   #5
Locutus
Apolytoners Hall of FameCiv4 SP Democracy GameCiv4 InterSite DG: Apolyton TeamBtS Tri-LeagueC4BtSDG TemplarsC4WDG Team ApolytonCivilization IV CreatorsCTP2 Source Code ProjectPolyCast Team
Deity
 
Locutus's Avatar
 
Local Time: 06:45
Local Date: November 1, 2010
Join Date: Nov 1999
Location: De Hel van Enschede
Posts: 11,702
Well, it's easy to do but a lot of work. In the same fashion that the units in the 7 Samurai scenario get increasing hitpoints, etc, you can increase vision as well. It requires however that you have multiple versions of every unit: one with vision range 1, one with vision range 2, etc. Your Units.txt file (and other related files) would get 2-3 times bigger than it already it (and it's a lot of type/copy-paste work)...
__________________
Administrator of WePlayCiv -- Civ5 Info Centre | Forum | Gallery
Locutus is offline  
Old July 23, 2002, 08:52   #6
Maquiladora
Call to Power II MultiplayerCTP2 Source Code ProjectCall to Power PBEMCall to Power Multiplayer
Emperor
 
Local Time: 05:45
Local Date: November 1, 2010
Join Date: Jun 2001
Posts: 7,665
So it could be done. Would it slow the game down to a crawl with all that extra weight in the Units.txt files etc?
__________________
Call to Power 2: Apolyton Edition - download the latest version (7th June 2010)
CtP2 AE Wiki & Modding Reference
One way to compile the CtP2 Source Code.
Maquiladora is offline  
Old July 23, 2002, 09:12   #7
Locutus
Apolytoners Hall of FameCiv4 SP Democracy GameCiv4 InterSite DG: Apolyton TeamBtS Tri-LeagueC4BtSDG TemplarsC4WDG Team ApolytonCivilization IV CreatorsCTP2 Source Code ProjectPolyCast Team
Deity
 
Locutus's Avatar
 
Local Time: 06:45
Local Date: November 1, 2010
Join Date: Nov 1999
Location: De Hel van Enschede
Posts: 11,702
I don't think so, not significantly anyway. But then again, noone ever tried tripling the total number of units in the game (and don't forget that in some mods we already almost doubled the number of units compared to the original game)
__________________
Administrator of WePlayCiv -- Civ5 Info Centre | Forum | Gallery
Locutus is offline  
Old July 23, 2002, 19:55   #8
J Bytheway
Call to Power PBEMCall to Power II Democracy GameCTP2 Source Code Project
Emperor
 
J Bytheway's Avatar
 
Local Time: 05:45
Local Date: November 1, 2010
Join Date: Jul 2001
Location: England
Posts: 3,826
What would slow the game down (if anything) would be the constant SLIC execution whenever a unit moved. I doubt my P200 could plough through the AI turns very quickly. Perhaps give the AI the long-sight versions everywhere to speed things up.
J Bytheway is offline  
Old July 23, 2002, 20:19   #9
Locutus
Apolytoners Hall of FameCiv4 SP Democracy GameCiv4 InterSite DG: Apolyton TeamBtS Tri-LeagueC4BtSDG TemplarsC4WDG Team ApolytonCivilization IV CreatorsCTP2 Source Code ProjectPolyCast Team
Deity
 
Locutus's Avatar
 
Local Time: 06:45
Local Date: November 1, 2010
Join Date: Nov 1999
Location: De Hel van Enschede
Posts: 11,702
You'd be surprised. The Alexander scenario has dozens of UnitMove events, doesn't hurt all that much (yes, it's very slow on a P200 but experience shows that that's mostly because of the huge map and loads of cities & units).
__________________
Administrator of WePlayCiv -- Civ5 Info Centre | Forum | Gallery
Locutus is offline  
Old July 23, 2002, 23:09   #10
Pedrunn
Call to Power II Democracy Game
King
 
Pedrunn's Avatar
 
Local Time: 01:45
Local Date: November 1, 2010
Join Date: Jul 2001
Location: of Natal, Brazil
Posts: 2,555
I think you guy are going the harder way.
The easiest thing to do is to create a invisible improvement under the unit. if unit has vision range 1 it creates a vision 2 imp, if hs vision 2 creates a imp with 3. When the unit move out the tile the imp is destroyed.
__________________
"Kill a man and you are a murder.
Kill thousands and you are a conquer.
Kill all and you are a God!"
-Jean Rostand
Pedrunn is offline  
Old July 24, 2002, 07:38   #11
Martin Gühmann
staff
Call to Power II Democracy GameCall to Power Democracy GameCTP2 Source Code Project
Super Moderator
 
Martin Gühmann's Avatar
 
Local Time: 06:45
Local Date: November 1, 2010
Join Date: Mar 2001
Location: Tübingen, Germany
Posts: 6,206
Quote:
Originally posted by Pedrunn
I think you guy are going the harder way.
The easiest thing to do is to create a invisible improvement under the unit. if unit has vision range 1 it creates a vision 2 imp, if hs vision 2 creates a imp with 3. When the unit move out the tile the imp is destroyed.
Actual this is the harder way, first you have to create the tile improvement, but then it isn't finished so you need a second event to finish it, until tehn the unit left the mountain. Then you can only build a tile improvement on land with an owner so you would have to give the land to the civ to which the units belongs. So it would only effective to use the test tile improvement of GoodMod for it. You couldn't pillage without huge problems the tile improvement afterwards. And if you pillage the location you will remove all the tile improvements at that place. So I would say it is possible to do it this way but the price is too high.

-Martin
__________________
Civ2 military advisor: "No complaints, Sir!"
Martin Gühmann is offline  
Old July 24, 2002, 12:23   #12
ahenobarb
Prince
 
ahenobarb's Avatar
 
Local Time: 04:45
Local Date: November 1, 2010
Join Date: Nov 2001
Posts: 437
Quote:
Originally posted by Martin Gühmann


Actual this is the harder way, first you have to create the tile improvement, but then it isn't finished so you need a second event to finish it, until tehn the unit left the mountain. Then you can only build a tile improvement on land with an owner so you would have to give the land to the civ to which the units belongs. So it would only effective to use the test tile improvement of GoodMod for it. You couldn't pillage without huge problems the tile improvement afterwards. And if you pillage the location you will remove all the tile improvements at that place. So I would say it is possible to do it this way but the price is too high.

-Martin
Couldn't you just reach into the structure of each unit to the visionrage through a .slc? it seems that all you would need to do (And I haven't fully undertaken learning all the .slc variables) is write a .slc that says in essence:

While terrain = mountain or hills (In another .slc project I was reading about the land was being checked to see who was the owner in order to influence the movement rate, so it seems this could be done),

UNIT_[TYPE or whatever the varible should be].visionrage = UNIT_TYPE.visionrange + 1

Last edited by ahenobarb; July 24, 2002 at 12:37.
ahenobarb is offline  
Old July 24, 2002, 13:48   #13
Martin Gühmann
staff
Call to Power II Democracy GameCall to Power Democracy GameCTP2 Source Code Project
Super Moderator
 
Martin Gühmann's Avatar
 
Local Time: 06:45
Local Date: November 1, 2010
Join Date: Mar 2001
Location: Tübingen, Germany
Posts: 6,206
Quote:
Originally posted by ahenobarb
Couldn't you just reach into the structure of each unit to the visionrage through a .slc? it seems that all you would need to do (And I haven't fully undertaken learning all the .slc variables) is write a .slc that says in essence:

While terrain = mountain or hills (In another .slc project I was reading about the land was being checked to see who was the owner in order to influence the movement rate, so it seems this could be done),

UNIT_[TYPE or whatever the varible should be].visionrage = UNIT_TYPE.visionrange + 1
The problem here is there is no slic function that allows us to increase the vision range of an unit. I can damage it and I can add/remove move points, unfortunatly nothing more.

-Martin
__________________
Civ2 military advisor: "No complaints, Sir!"
Martin Gühmann is offline  
Old July 24, 2002, 14:05   #14
ahenobarb
Prince
 
ahenobarb's Avatar
 
Local Time: 04:45
Local Date: November 1, 2010
Join Date: Nov 2001
Posts: 437
Quote:
Originally posted by Martin Gühmann


The problem here is there is no slic function that allows us to increase the vision range of an unit. I can damage it and I can add/remove move points, unfortunatly nothing more.

-Martin
You guys are the experts in this, but in looking at the units.txt file, all the units are set up as C structures. As you know any C structure element can be access by referencing the structure name adding the structure member operator (i.e. '.' ) and the name of the structure element you want to access (in this case, for example "UNIT_ARCHER.visionrange" Visionrange is one of the elments in a unit structure listed in units.txt). Once you have refenced the specific element you want, you should be able to change it.

What I don't know is whether you can do this with .slc
I'm not certain if .slc only let's you use the variables that are named in the modification section of the CTP2 portion of this site. Or, if once you know a structure name, you can access that structure just like a C strucutre through the .slc file.

Since I haven't learned enough about .slc to try to write some code yet (I'm still in the middle of my first real game), I'm passing it along in case one of the experts wants to try their hand at it.
ahenobarb is offline  
Old July 24, 2002, 17:50   #15
Martin Gühmann
staff
Call to Power II Democracy GameCall to Power Democracy GameCTP2 Source Code Project
Super Moderator
 
Martin Gühmann's Avatar
 
Local Time: 06:45
Local Date: November 1, 2010
Join Date: Mar 2001
Location: Tübingen, Germany
Posts: 6,206
Quote:
Originally posted by ahenobarb
You guys are the experts in this, but in looking at the units.txt file, all the units are set up as C structures. As you know any C structure element can be access by referencing the structure name adding the structure member operator (i.e. '.' ) and the name of the structure element you want to access (in this case, for example "UNIT_ARCHER.visionrange" Visionrange is one of the elments in a unit structure listed in units.txt). Once you have refenced the specific element you want, you should be able to change it.

What I don't know is whether you can do this with .slc I'm not certain if .slc only let's you use the variables that are named in the modification section of the CTP2 portion of this site. Or, if once you know a structure name, you can access that structure just like a C strucutre through the .slc file.
Would it is such easy then you have to answer me this question: Why we need such a function to add additional movement points:

AddMovement

Another question would be what do you exactly change if you use the dot operator, do you change just the vision range of one particular unit or would it rather change the vision range of all the units of the same type. Of course I didn't tryed it, so at least I will try it afterwards I finished my GOTM, finished GoodMod1 v.1.0 and started with GoodMod2, there such a thing would be very helpfull if it work.

-Martin
__________________
Civ2 military advisor: "No complaints, Sir!"
Martin Gühmann is offline  
Old July 24, 2002, 19:14   #16
Peter Triggs
CTP2 Source Code ProjectCivilization IV Creators
King
 
Local Time: 04:45
Local Date: November 1, 2010
Join Date: Jan 2000
Location: Gone Fishin, Canada
Posts: 1,059
Here's the problem:

Quote:
SLIC provides direct read-only access to much of the data contained in the game databases.
Also, although it's written that you can access many fields from the databases (using dot notation) this only seems to work for the UnitDB. Every time I've tried a different one (even using the examples that were given in the documentation), I get a syntax error. So it looks to me that this was something that was intended to be included but didn't get finished. It's a pity, being able to access the fields in strategies.txt and diplomacy.txt would be very useful.
Peter Triggs is offline  
Old July 25, 2002, 09:05   #17
ahenobarb
Prince
 
ahenobarb's Avatar
 
Local Time: 04:45
Local Date: November 1, 2010
Join Date: Nov 2001
Posts: 437
Quote:
Originally posted by Peter Triggs
Here's the problem:



Also, although it's written that you can access many fields from the databases (using dot notation) this only seems to work for the UnitDB. Every time I've tried a different one (even using the examples that were given in the documentation), I get a syntax error. So it looks to me that this was something that was intended to be included but didn't get finished. It's a pity, being able to access the fields in strategies.txt and diplomacy.txt would be very useful.
I read through the SLIC documentation yesterday and saw that same passage. However, in the 10 minutes I had free last night, I tried my hand at it. I expected that I would get an error, but it should point me to the proper solution.

However, that one part I thought wasn't in error apparantly was. The error message said: "No TERRAIN_HILL in the TerrainDB" "No TERRAIN_MOUNTAIN in the TerrainDB" (I had referenced both with TerrainDB(TERRAIN_XXXX))

I haven't had anytime to look at it again, but that struck me as odd. Unless the Terrain.txt is not considered the TerrainDB, I don't know what is wrong.

Any ideas?
ahenobarb is offline  
Old July 25, 2002, 12:18   #18
HuangShang
Call to Power II Democracy GameCTP2 Source Code Project
King
 
HuangShang's Avatar
 
Local Time: 21:45
Local Date: October 31, 2010
Join Date: Jul 2002
Location: Berkeley
Posts: 1,375
God... i never remember what this thread is for in the morning
HuangShang is offline  
Old July 25, 2002, 17:30   #19
Locutus
Apolytoners Hall of FameCiv4 SP Democracy GameCiv4 InterSite DG: Apolyton TeamBtS Tri-LeagueC4BtSDG TemplarsC4WDG Team ApolytonCivilization IV CreatorsCTP2 Source Code ProjectPolyCast Team
Deity
 
Locutus's Avatar
 
Local Time: 06:45
Local Date: November 1, 2010
Join Date: Nov 1999
Location: De Hel van Enschede
Posts: 11,702
That's odd, ahenobarb, I did the same thing just now and got a syntax error, just like Peter. Are you sure you didn't make any typos or anything silly like that? If not, could you post your code, so others can see they can reproduce and explain it?

Aside from that, it's good to know we have an experienced programmer looking into SLIC again. We desperately need people like you
__________________
Administrator of WePlayCiv -- Civ5 Info Centre | Forum | Gallery
Locutus is offline  
Old July 25, 2002, 22:07   #20
ahenobarb
Prince
 
ahenobarb's Avatar
 
Local Time: 04:45
Local Date: November 1, 2010
Join Date: Nov 2001
Posts: 437
Quote:
Originally posted by Locutus
That's odd, ahenobarb, I did the same thing just now and got a syntax error, just like Peter. Are you sure you didn't make any typos or anything silly like that? If not, could you post your code, so others can see they can reproduce and explain it?

Aside from that, it's good to know we have an experienced programmer looking into SLIC again. We desperately need people like you
It was a case-sensitivity issue. i was rushing out the door and didn't get time to fool around to check it.

Anyway, here's the SLIC I did for this:

HandleEvent(MoveUnits) 'IncreaseVision' post {
unit_t tmpUnit;

While(tmpUnit.location == 8 ||
tmpUnit.location == 9 ||
tmpUnit.location == 18 ||
tmpUnit.location == 19 ||
tmpUnit.location == 20 ||
tmpUnit.location == 21 )
{
tmpUnit.visionrange = tmpUnit.visionrange + 1;
}
}
}


However, when I load it up, CTP2 tells me "Visionrange is not a member of tmpUnit".

So from this I believe I have learned the only parts of the unit array that can be used are:

unit.owner - the unit's owner
unit.location - the unit's location
unit.type - the unit's database index
unit.hp - the unit's remaining hit points
unit.valid - true if the unit still exists, false otherwise
unit.name - the unit's name, only useful in string replacements
ahenobarb is offline  
Old July 26, 2002, 12:24   #21
Martin Gühmann
staff
Call to Power II Democracy GameCall to Power Democracy GameCTP2 Source Code Project
Super Moderator
 
Martin Gühmann's Avatar
 
Local Time: 06:45
Local Date: November 1, 2010
Join Date: Mar 2001
Location: Tübingen, Germany
Posts: 6,206
Quote:
Originally posted by ahenobarb
It was a case-sensitivity issue. i was rushing out the door and didn't get time to fool around to check it.

Anyway, here's the SLIC I did for this:

HandleEvent(MoveUnits) 'IncreaseVision' post {
unit_t tmpUnit;

While(tmpUnit.location == 8 ||
tmpUnit.location == 9 ||
tmpUnit.location == 18 ||
tmpUnit.location == 19 ||
tmpUnit.location == 20 ||
tmpUnit.location == 21 )
{
tmpUnit.visionrange = tmpUnit.visionrange + 1;
}
}
}


However, when I load it up, CTP2 tells me "Visionrange is not a member of tmpUnit".

Some notes about the code, the MoveUnits event has two location variables and an army variable in its context. You can take access with army[0] on the army variable. (See the slic documentation which variables are in the context) If you now want to take access on the units of the army you have to use the GetUnitByIndex function within a for loop. It is also possible to get the army size, the best thing here is to consult the various slic files and the slic documentation for examples. So your temporary unit variable actual contains nothing.

Another problem I see in your code is the while loop: As your handler is a post handler the code will be executed after the move event was done. The event is called everytime a unit moves from one tile to its adjacent tile. Once the army is on the hill for instance the condition in the while loop is true and the while loop will be executed until the army leaves the hill. But the next MoveUnits event want be called until the your code was be executed. So once the condition in the while loop is true it will be always true. And the loop turned in an endless loop.

Quote:
Originally posted by ahenobarb
So from this I believe I have learned the only parts of the unit array that can be used are:

unit.owner - the unit's owner
unit.location - the unit's location
unit.type - the unit's database index
unit.hp - the unit's remaining hit points
unit.valid - true if the unit still exists, false otherwise
unit.name - the unit's name, only useful in string replacements
These ones does work with the unit array, for the other ones you have to use the unitrecord array. See the Great Library for some example code about this although I think the GL is not the best place to find examples.

Even if it takes some time to learn slic, don't give up keep on trying.

-Martin
__________________
Civ2 military advisor: "No complaints, Sir!"
Martin Gühmann is offline  
Old July 26, 2002, 12:45   #22
ahenobarb
Prince
 
ahenobarb's Avatar
 
Local Time: 04:45
Local Date: November 1, 2010
Join Date: Nov 2001
Posts: 437
Quote:
Originally posted by Martin Gühmann



If you now want to take access on the units of the army you have to use the GetUnitByIndex function within a for loop. It is also possible to get the army size, the best thing here is to consult the various slic files and the slic documentation for examples. So your temporary unit variable actual contains nothing.

Another problem I see in your code is the while loop: .... the loop turned in an endless loop.



These ones does work with the unit array, for the other ones you have to use the unitrecord array. See the Great Library for some example code about this although I think the GL is not the best place to find examples.

Even if it takes some time to learn slic, don't give up keep on trying.

-Martin
Thanks, Martin. I dumped the GetUnitsByIndex even though I saw an example using that. I figured, if I really needed it, CTP2 would say something when I started the game and it spat out its error messages. It didn't say anything when I dropped it, so I figured I didn't need it. Guess I was wrong.

While loop: I thought that might be the case, but figured I'd cross that bridge when/if I ever saw the visionrange actually increase.

I'll check the GL. Thanks again.
ahenobarb is offline  
Old July 26, 2002, 18:49   #23
J Bytheway
Call to Power PBEMCall to Power II Democracy GameCTP2 Source Code Project
Emperor
 
J Bytheway's Avatar
 
Local Time: 05:45
Local Date: November 1, 2010
Join Date: Jul 2001
Location: England
Posts: 3,826
Quote:
Originally posted by Martin Gühmann
Would it is such easy then you have to answer me this question: Why we need such a function to add additional movement points:

AddMovement
Even if such modification did work (which it apparently doesn't) you would still need the AddMovement function since this affects the units current available movement, not the MaxMovePoints. Similarly for the hp.
J Bytheway is offline  
Old July 27, 2002, 11:42   #24
Martin Gühmann
staff
Call to Power II Democracy GameCall to Power Democracy GameCTP2 Source Code Project
Super Moderator
 
Martin Gühmann's Avatar
 
Local Time: 06:45
Local Date: November 1, 2010
Join Date: Mar 2001
Location: Tübingen, Germany
Posts: 6,206
Quote:
Originally posted by ahenobarb
Thanks, Martin. I dumped the GetUnitsByIndex even though I saw an example using that. I figured, if I really needed it, CTP2 would say something when I started the game and it spat out its error messages. It didn't say anything when I dropped it, so I figured I didn't need it. Guess I was wrong.

While loop: I thought that might be the case, but figured I'd cross that bridge when/if I ever saw the visionrange actually increase.

I'll check the GL. Thanks again.
There are two kinds of errors that can you code contain. On the one hand syntax errors on the other hand semantic errors. The syntax errors are the easier ones, because you will get an error message, even if slic error messages could give you more pieces of information. But the semantic errors are the ones that are much harder to detect, because the syntax is ok but the content is the problem. The only symptom that you notice is that your code doesn't do the stuff that it is supposed to do, and now you have to search why.

Here is an example in English:

Code:
The only symptom code is that doesn't do the stuff that it is supposed and now have why.
You see I just deleted some words of my last sentece and you don't get the content, but nevertheless all the words I used are valid English words and also the form should be correct, capital letter on the beginning a dot at the end, and the grammer is ok more or (rather) less correct.

-Martin
__________________
Civ2 military advisor: "No complaints, Sir!"
Martin Gühmann is offline  
 

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT -4. The time now is 00:45.


Design by Vjacheslav Trushkin, color scheme by ColorizeIt!.
Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Apolyton Civilization Site | Copyright © The Apolyton Team