Thread Tools
Old April 28, 2002, 12:56   #1
Pedrunn
Call to Power II Democracy Game
King
 
Pedrunn's Avatar
 
Local Time: 20:43
Local Date: October 31, 2010
Join Date: Jul 2001
Location: of Natal, Brazil
Posts: 2,555
Finish Improvement Order
I am giving a try in Slic writting. My first slic was to add the rush improvements using Entrench order for a new kind of Special Unit: The Worker.
I want to know if its correct and bug free.

Code:
HandleEvent(EntrenchOrder) 'FinishImprovementsOrder' pre {
         unit_t  tmpUnit;
               GetUnitFromArmy(army[0], i, tmpUnit);
                            unit[0] = tmpUnit;
                            if ((unit[0].type == UnitDB(UNIT_WORKER))) {
							FinishImprovements(unit[0].location);
       				 }
}
My biggest problemcomes when i wanted to make the AI to knows how to use it. But the best i could do was make the unit finish improvent as it goes over tiles for the AI.
There is some function to trigger the code if the tile has an unfinished imp? Can someone help me with this issue?
I want to make the AI always entrench if this units pass by an tile with unfinished imp.
Code:
HandleEvent(MoveToOrder) 'AIUsingFinishImprovement' post {
         unit_t  tmpUnit;
		if(!=IsHumanPlayer(player[0])){
		GetUnitFromArmy(army[0], i, tmpUnit);
      			unit[0] = tmpUnit;
      			if ((unit[0].type == UnitDB(UNIT_WORKER))) {
						FinishImprovements(unit[0].location);
				}
		}	
}
__________________
"Kill a man and you are a murder.
Kill thousands and you are a conquer.
Kill all and you are a God!"
-Jean Rostand

Last edited by Pedrunn; April 28, 2002 at 13:11.
Pedrunn is offline  
Old April 28, 2002, 15:13   #2
Peter Triggs
CTP2 Source Code ProjectCivilization IV Creators
King
 
Local Time: 23:43
Local Date: October 31, 2010
Join Date: Jan 2000
Location: Gone Fishin, Canada
Posts: 1,059
I'd suggest using the MoveOrder event:

Code:
HandleEvent(MoveOrder) 'FinishImprovementsOrder' post {

    unit_t  tmpUnit;
    int_t i;

    for (i=0;i < army[0].size;i=i+1 ){   
         GetUnitFromArmy(army[0], i, tmpUnit);
         if (tmpUnit.type == UnitDB(UNIT_WORKER)) {
	      FinishImprovements(tmpUnit.location);
         }
    }
}
You put the improvement down as normal and then move your Worker (whose on an adjacent tile) on to it. The next turn, you move the Worker off the tile and, presto, there's the improvement. (I tried it using a Hoplite to stand in for your Worker.) This works fine for the Human and it should 'work' for the AI, too, in the way you described. To get the AI to actually try to do this would be much more difficult, if possible at all.

Note: You don't need "unit[0]=tmpUnit". Once you've declared "tmpUnit" to be a unit type variable you can access the members of the unit array in the same way as with a builtin variable.
Peter Triggs is offline  
Old May 1, 2002, 05:19   #3
The Big Mc
CTP2 Source Code Project
King
 
The Big Mc's Avatar
 
Local Time: 23:43
Local Date: October 31, 2010
Join Date: Oct 2001
Location: Of the universe / England
Posts: 2,061
you tried picking up the slic files on the apolyton ctp2 page
__________________
"Every time I learn something new it pushes some old stuff out of my brain" Homer Jay Simpson
The BIG MC making ctp2 a much unsafer place.
Visit the big mc’s website
The Big Mc 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 19:43.


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