Announcement

Collapse
No announcement yet.

CtP Unit Updater

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

  • #16
    Originally posted by Tamerlin


    By splitting an army do you mean that "unlocking" the units in the same tile is enough?
    Yep, that'll do it

    Comment


    • #17
      Originally posted by Madd_Mugsy

      Yep, that'll do it
      Thanks for your reply...
      "Democracy is the worst form of government there is, except for all the others that have been tried." Sir Winston Churchill

      Comment


      • #18
        Bug

        So I looked into that stupid stacked units all getting scrapped when updated bug.

        Replace the main function with this:

        Code:
        messagebox 'msgReplaceUnits'
        {
        	Title(ID_TITLE_upgrade_query);
        	MessageType("TP_QUEUE_EMPTY_AFTER_UNIT"); 
        	MessageClass(789);
        	
        	i = 0;
        	onecost = 0;
        	oldunitcount = 0;
        	while (i < player.totalunits) 
        	{		
        		SetUnitByIndex(1, g.player, i);		
        		if (unit.type == oldunittype) 
        		{			
        			oldunitcount = oldunitcount + 1;
        		}
        		i = i + 1;	
        	}
        
        	if(oldunitcount>0) {		
        
        		if(IsHumanPlayer(g.player)) {
        		
        			onecost = (newunitcost) - (oldunitcost);
        	
        			if (onecost <= player.gold)
        			{
        				KillClass(g.player,987);
        				MessageClass(987);
        	
        				privoldunittype=oldunittype;
        				privnewunittype=newunittype;
        				privoldunitcost=oldunitcost;
        				privnewunitcost=newunitcost;
        	
        				privtotalcost = (privnewunitcost*oldunitcount) - (privoldunitcost*oldunitcount);
        				privonecost = privnewunitcost - privoldunitcost;
        		
        				if (privtotalcost <= player.gold && oldunitcount>1)
        				{
        					Button(ID_BUTTON_Do_upgrade)
        					{
        						AddGold(player, -privtotalcost);
        						i = 0;	
        						while (i < player.totalunits) 
        						{		
        							SetUnitByIndex(1, player, i);		
        							if (unit.type == privoldunittype) 
        							{			
        								oldunitlocation = unit.location;			
        
        								if(UnitsInCell(oldunitlocation)>1)
        								{
        									SetOrder(1, 13); 
        									AddOrder(unit, oldunitlocation);
        								}								
        
        								SetOrder(1, 56); 
        								AddOrder(unit, oldunitlocation);
        	
        								CreateUnit(player, privnewunittype, oldunitlocation, 0);		
        							}
        							else
        							{		
        								i = i + 1;	
        							}
        						}
        						KillClass(g.player, 987);
        					}
        				}
        				Button(ID_BUTTON_Do_one_upgrade)
        				{
        					AddGold(player, -privonecost);
        					i = 0;	
        					while (i < player.totalunits) 
        					{		
        						SetUnitByIndex(1, g.player, i);		
        						if (unit.type == privoldunittype) 
        						{			
        							oldunitlocation = unit.location;			
        
        							if(UnitsInCell(oldunitlocation)>1)
        							{
        								SetOrder(1, 13); 
        								AddOrder(unit, oldunitlocation);
        							}								
        							SetOrder(1, 56); 
        							AddOrder(unit, oldunitlocation);
        							CreateUnit(player, privnewunittype, oldunitlocation, 0);		
        							KillClass(player, 987);
        							message(g.player,'msgReplaceUnits'); 
        						}
        						else
        						{		
        							i = i + 1;	
        						}
        					}
        				}		
        				Button(ID_BUTTON_LibraryNew)
        				{
        					LibraryUnit(privnewunittype);
        					
        				}
        				Button(ID_BUTTON_LibraryOld)
        				{
        					LibraryUnit(privoldunittype);
        					
        				}
        				if (oldunitcount>1)
        				{
        					Text(ID_TEXT_upgrade_query);
        				}
        				else
        				{
        					Text(ID_TEXT_upgrade_one_query);
        				}
        			}
        			else
        			{
        				Abort();
        			}
        		}
        		else
        		{	
        // AI Player
        			KillClass(g.player,978);
        			MessageClass(978);
        			privoldunittype=oldunittype;
        			privnewunittype=newunittype;
        			i = 0;	
        			while (i < player.totalunits) 
        			{		
        				SetUnitByIndex(1, player, i);		
        				if (unit.type == privoldunittype) 
        				{			
        					oldunitlocation = unit.location;			
        					KillUnit(unit.1);			
        					CreateUnit(player, privnewunittype, oldunitlocation, 0);		
        				}
        				else
        				{		
        					i = i + 1;	
        				}
        			}
        			KillClass(g.player, 978);
        		}
        	}
        	else
        	{
        		Abort();
        	}
        }

        All I did was add a check to see if there were more than 1 unit in the cell and if there were to run the ungroup order before the disband order.

        I'm also trying to come up with a way to make this updater work with a key press on a stack by stack / unit by unit basis, but I can't seem to get the unit context when I use the trigger

        Code:
        trigger 'keytest' when (key.3.pressed && unit.selected) // where key.3 = "U"
        {
        //do stuff
        //in here the unit context is invalid?  but it works if I remove the key.pressed part of the trigger
        }
        Any ideas?

        L8r.

        Comment


        • #19
          Re: Bug

          Originally posted by Madd_Mugsy
          So I looked into that stupid stacked units all getting scrapped when updated bug.

          Replace the main function with this...
          Thanks Madd_Mugsy... I have to start again the game I was playing in order to test the Updater as I forgot to unlock the units in my armies... thus losing 20 units in the process.

          I'm also trying to come up with a way to make this updater work with a key press on a stack by stack / unit by unit basis, but I can't seem to get the unit context when I use the trigger.

          Any ideas?
          Unfortunately I can't help you on this ground as I know nothing about SLIC. You should have a look at Peter Trigg's Updater2 code for the CtP2 Super Apolyton Pack 2. In the APOL_Updater2 the "Sleep" button is used to upgrade the units. Though I know the CtP1 SLIC and the CtP2 SLIC are very different there might be some ideas to borrow...
          "Democracy is the worst form of government there is, except for all the others that have been tried." Sir Winston Churchill

          Comment


          • #20
            Re: Bug

            Originally posted by Madd_Mugsy
            I'm also trying to come up with a way to make this updater work with a key press on a stack by stack / unit by unit basis, but I can't seem to get the unit context when I use the trigger

            Code:
            trigger 'keytest' when (key.3.pressed && unit.selected) // where key.3 = "U"
            {
            //do stuff
            //in here the unit context is invalid?  but it works if I remove the key.pressed part of the trigger
            }
            Any ideas?
            The problem here is due to the slightly bizarre way SLIC triggers work. Based on the conditions you write in the trigger the game guesses which event the trigger should be tied to. Getting it right is something of an art (although there is a list of priorities somewhere).

            With only unit.selected, the trigger will fire when a unit is selected, but with both the other part takes priority and the trigger fires on a keypress and so the only context you get is the key context.

            It's better to trigger on a unit order like sleeping as Tamerlin suggests. I've done this with fortify for adding settlers to cities and it works fine. It also has the advantage that it works in multiplayer whereas code in buttons on messageboxes doesn't (as you discovered).

            Comment


            • #21
              kewl.

              I'll give it a shot.

              thx

              Comment


              • #22
                I got it working with the unit.fortified trigger - but i didn't see a unit.sleeping (or whatever) trigger to catch the sleep button - is there one?

                This is what it looks like (early, early draft):

                Code:
                trigger 'WarriorUpgrade' when (unit.fortified && HasAdvance(g.player, ID_ADVANCE_IRON_WORKING) && unit.type == UnitType("UNIT_WARRIOR"))
                {
                	oldunitlocation = unit.location;			
                	if(UnitsInCell(oldunitlocation)>1)
                	{
                		SetOrder(1, 13); 
                		AddOrder(unit, oldunitlocation);
                	}								
                
                	SetOrder(1, 56); 
                	AddOrder(unit, oldunitlocation);
                	CreateUnit(player, UnitType("UNIT_LEGION"), oldunitlocation, 0);		
                }
                I made a quick modding tool to read and update all the advance & unit text files and GL files, and I'm going to add a function to write the updating script automatically too so there's not so much copy/pasting.

                I can post it when it's closer to being done if you guys want.

                L8r.

                Comment


                • #23
                  PLEASE!!!

                  Thx

                  Grandpa Troll
                  Attached Files
                  Hi, I'm RAH and I'm a Benaholic.-rah

                  Comment


                  • #24
                    Originally posted by Madd_Mugsy
                    I can post it when it's closer to being done if you guys want.

                    L8r.
                    It would be great!

                    Though I am not sure I will be able to figure out by myself how to use such a tool. :-(
                    "Democracy is the worst form of government there is, except for all the others that have been tried." Sir Winston Churchill

                    Comment


                    • #25
                      Originally posted by Tamerlin


                      It would be great!

                      Though I am not sure I will be able to figure out by myself how to use such a tool. :-(
                      Thats why we have this big old community family to help one another out...

                      I mean..4-Real..if the kind folks can teach me how to do some very elementary things..then we can ALL learn here!!
                      Attached Files
                      Hi, I'm RAH and I'm a Benaholic.-rah

                      Comment


                      • #26
                        Originally posted by Grandpa Troll
                        Thats why we have this big old community family to help one another out...

                        I mean..4-Real..if the kind folks can teach me how to do some very elementary things..then we can ALL learn here!!


                        That is true!
                        "Democracy is the worst form of government there is, except for all the others that have been tried." Sir Winston Churchill

                        Comment


                        • #27
                          Hi, I'm more of a tweaker than I am a modder and I'm quite interested in having a unit updater for CTP. Could anyone show me how the files/SLICs above need to be implemented into the game? I'm sure there's quite a bit that you experts consider trivial that is well beyond me. If anyone could post a finished attachment or something to copy&paste, I would be grateful.

                          Edit: Ok, I read the other thread and it has helped although using that format, the game wouldn't load up and it said that "oldunitlocation" was a pre-existing symbol...or some such thing. Anyway, I just renamed it to "oul" for short and it seems to be working. I'll post again if I hit a wall.
                          Last edited by 1096; August 16, 2004, 12:17.

                          Comment

                          Working...
                          X