Announcement

Collapse
No announcement yet.

Finish Improvement Order

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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);
    				}
    		}	
    }
    Last edited by Pedrunn; April 28, 2002, 13:11.
    "Kill a man and you are a murder.
    Kill thousands and you are a conquer.
    Kill all and you are a God!"
    -Jean Rostand

  • #2
    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.

    Comment


    • #3
      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

      Comment

      Working...
      X