Announcement

Collapse
No announcement yet.

E's Source Code attempts

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

  • I went through the A star and I think its goingto take me awhile to digest how to utilize it...

    but something struck as to implementing the food cost to units. There is home city recording when creating a unit, how can I access that or use it to subtract food from a city or harvest food from a square?

    Code:
    STDEHANDLER(CityCreateUnitEvent)
    {
    	Unit homeCity;
    	if(!args->GetCity(0, homeCity)) {
    		
    		return GEV_HD_Continue;
    	}
    Formerly known as "E" on Apolyton

    See me at Civfanatics.com

    Comment


    • I don't think that code implies that the home city is being recorded. It's simply checking that the city still exists.

      Comment


      • Originally posted by J Bytheway
        I don't know anything about A* in particular, but I can imagine some algorithms would work better if you used a small positive finite cost for the road tiles, rather than a 0 cost.
        Well, we had already a trade astar that used entry costs of 0. However I think it is irrelevant for this astar what the entry costs are, as long as they are not k_ASTAR_BIG. In fact this astar should only figure out, whether there is a connection, and shouldn't return an optimal path.

        Well but if I consider it more then it might be a good idea to give it a cost bigger than 0 like 1.

        Originally posted by E
        I went through the A star and I think its goingto take me awhile to digest how to utilize it...
        What is so difficuilt about it? All you have to understand is what this EntryCost method does. It determines which path is the cheapest, which tiles are allowed to use. All you have to do is to copy the TradeAstar and costumize the entry function, so that it returns k_ASTAR_BIG and ASTAR_BLOCKED if there is no road. Otherwise costs are 1.0.

        Originally posted by E
        but something struck as to implementing the food cost to units. There is home city recording when creating a unit, how can I access that or use it to subtract food from a city or harvest food from a square?
        As far as I can see it, it doesn't help you. It is just a name for a variable in this event. In fact in CTP2 units aren't owned by cities that is an ancient concept from Civ2. And by the way this is a little bit more difficuilt to implement than the astar.

        -Martin
        Civ2 military advisor: "No complaints, Sir!"

        Comment


        • Originally posted by Martin Gühmann


          Well, we had already a trade astar that used entry costs of 0. However I think it is irrelevant for this astar what the entry costs are, as long as they are not k_ASTAR_BIG. In fact this astar should only figure out, whether there is a connection, and shouldn't return an optimal path.

          Well but if I consider it more then it might be a good idea to give it a cost bigger than 0 like 1.



          What is so difficuilt about it? All you have to understand is what this EntryCost method does. It determines which path is the cheapest, which tiles are allowed to use. All you have to do is to copy the TradeAstar and costumize the entry function, so that it returns k_ASTAR_BIG and ASTAR_BLOCKED if there is no road. Otherwise costs are 1.0.

          -Martin
          I did look at it and I have to figure a few things out like how do I tell it which cities or which improvement are connected. I think thats a new function but I have to mess with te getnearestcity code to see how that was used. Really I think not having a compilable version of the code right now is holding me back from learning. thanks for the help once I get the code going I'm sure I'll have more questions.
          Formerly known as "E" on Apolyton

          See me at Civfanatics.com

          Comment


          • Originally posted by E
            Really I think not having a compilable version of the code right now is holding me back from learning.
            Well I just was able to update by source code working copy to Revision 494. But I think the accessibilty is still not as good as it should be.

            -Martin
            Civ2 military advisor: "No complaints, Sir!"

            Comment


            • Thanks Martin,

              i just got my update. Are you still working on any code? Diplomacy still needs work (atleast the interface) and I'm still willing to do graphics for it and willing to take your guideance

              But can I make a request, I hope it simple. Add at the top bar where the buttons are and where the gold, PW is etc. A bar that says what you are researching and how many turns. Thats a nice touch from civ4
              Formerly known as "E" on Apolyton

              See me at Civfanatics.com

              Comment


              • Martin,
                since there isnt a working group of the code b/c Fromafar is doing some extensive fixes. Any chance you can look over my code here? I'm beefing up my addresource code I did before but I'm trying to add 3 checks:

                1) if a city has a good that the city needs to build thebuilding before the good it enables is available

                2) attempt to create "appearing" resources by not letting a good be added until an advance is available (this will also allow for "bonus" goods that cant be traded if you do subneural ads)

                3) then trying to make them "vanish" by if a player has a tech the resource is no longer available.

                thanks,


                Code:
                // Add if city has building GetEnablesGood >0 then that good will be dded to the city for trade
                    sint32 good; 
                	for(sint32 b = 0; b < g_theBuildingDB->NumRecords(); b++) {
                		if(m_built_improvements & ((uint64)1 << b)) {
                			const BuildingRecord *rec = g_theBuildingDB->Get(b, g_player[m_owner]->GetGovernmentType());
                //      Check If needsGood for the building a make bonuses dependent on having that good for further bonus
                //			if(rec->GetNumNeedsCityGoodAll() > 0) {
                //			sint32 g;
                //				for(g = 0; g < rec->GetNumNeedsCityGoodAll(); g++) {
                //					if((m_buyingResources[rec->GetNeedsCityGoodAllIndex(g)] + m_collectingResources[rec->GetNeedsCityGoodAllIndex(g)]) == 0)
                //		}
                //	}
                			if (rec->GetNumEnablesGood() > 0){
                				for(good = 0; good < rec->GetNumEnablesGood(); good++) {
                // new check to see if a resource needs an adavance to be collected
                					const ResourceRecord *grec = g_theResourceDB->Get(good);
                						if(!g_player[m_owner]->HasAdvance(grec->GetAvailableAdvanceIndex()) && grec->GetAvailableAdvanceIndex() >= 0) {
                							return;}
                						else if(g_player[m_owner]->HasAdvance(grec->GetVanishAdvanceIndex()) && grec->GetVanishAdvanceIndex() >= 0) {
                							return;}						
                //end new code					
                						else {
                							m_collectingResources.AddResource(rec->GetEnablesGoodIndex(good));
                						}
                				}
                			}
                		}
                	}
                
                // end building enables good
                Formerly known as "E" on Apolyton

                See me at Civfanatics.com

                Comment


                • Originally posted by E
                  Martin,
                  since there isnt a working group of the code b/c Fromafar is doing some extensive fixes. Any chance you can look over my code here? I'm beefing up my addresource code I did before but I'm trying to add 3 checks:

                  1) if a city has a good that the city needs to build thebuilding before the good it enables is available

                  2) attempt to create "appearing" resources by not letting a good be added until an advance is available (this will also allow for "bonus" goods that cant be traded if you do subneural ads)

                  3) then trying to make them "vanish" by if a player has a tech the resource is no longer available.
                  The most important thing at first: Get the indention right! Otherwise I don't look at your code. As it is harder to read.

                  So far I don't know whether you want a visible good on the map or just one extra good in the trade menu. For just the extra good in the trade menu you can use the collect resource routine. If you want to add a good on the map you have to do some good planting.

                  Of course in both cases you have the conditions have to be met. Maybe it helps you if you write the idea of your algorithm down on a piece of paper in pseudo code.

                  -Martin
                  Civ2 military advisor: "No complaints, Sir!"

                  Comment


                  • thanks Martin,
                    Fromafar's fixes should yeild a compilable ctp2 tonight so I'll give it a shot, I think I know what I need to do. (and will fix indentations, its easier once my notes are removed)

                    Are you still interested in updating the diplomacy interface? I looked at diplomacywindow.cpp last night and tried to map references to graphics and sizes and couldnt really pin it down.

                    Did you find a way to increase the size of the diplomacy window to allow for leaderheads? And how to move the "offers" tab to a separate section on the right side so it would look more like the civ3/civ4 interface?

                    Those two things I'm willing to help with and can whip out some graphics for testing fast. I tried to add a civ3 picture with a 200 pixel height on top of the parchment just to see the effect. Of course it just cut off the graphic, but if I lad a larger window and was able to have the discussion text lowered I would of had a leaderhead graphic.


                    thanks,
                    Formerly known as "E" on Apolyton

                    See me at Civfanatics.com

                    Comment


                    • Originally posted by E
                      Are you still interested in updating the diplomacy interface?
                      Well for me that has low priority.

                      Originally posted by E
                      Did you find a way to increase the size of the diplomacy window to allow for leaderheads? I looked at diplomacywindow.cpp last night and tried to map references to graphics and sizes and couldnt really pin it down.
                      That's one of the easiest things, you just have to edit the right *.ldl file. If those tiny leader icons showed up in the original version we would already have a diplomanager with bigger photos.

                      Originally posted by E
                      And how to move the "offers" tab to a separate section on the right side so it would look more like the civ3/civ4 interface?
                      That's a thing you have to do in the code but that should be rather some copy 'n' paste 'n' modify work.

                      The only question is what do you do with the treaties, do you put them on both sides.

                      -Martin
                      Civ2 military advisor: "No complaints, Sir!"

                      Comment


                      • Originally posted by E
                        Did you find a way to increase the size of the diplomacy window to allow for leaderheads? I looked at diplomacywindow.cpp last night and tried to map references to graphics and sizes and couldnt really pin it down.


                        That's one of the easiest things, you just have to edit the right *.ldl file. If those tiny leader icons showed up in the original version we would already have a diplomanager with bigger photos.

                        ldl, no kidding? is that ldl in the code or with the normal game files?


                        Originally posted by E
                        And how to move the "offers" tab to a separate section on the right side so it would look more like the civ3/civ4 interface?


                        That's a thing you have to do in the code but that should be rather some copy 'n' paste 'n' modify work.

                        The only question is what do you do with the treaties, do you put them on both sides.
                        Both sides is what I thought would be easiest, but would it them select both at the same time?


                        Are you still interested in updating the diplomacy interface?

                        posted by Martin:
                        Well for me that has low priority
                        ack! civ4 got to you
                        Formerly known as "E" on Apolyton

                        See me at Civfanatics.com

                        Comment


                        • Originally posted by E
                          ldl, no kidding? is that ldl in the code or with the normal game files?
                          What you want to tell me that you never heard of the files with the ldl extension (probably stands for layout description language at least that's what these files do). You can look on the revision in which I changed the layout of some windows, and all these files have modified *.ldl files. Look for the folder ..\ctp2_data\english\uidata\layouts\.

                          Originally posted by E
                          Both sides is what I thought would be easiest, but would it them select both at the same time?
                          It would do what you want, so you can make it so that you click on one at one side and then it disappears in both list boxes, that is how it is done with the open border agreement in Civ4.

                          Originally posted by E
                          ack! civ4 got to you
                          It's rather my university, it was already not too high on my priority list. There is rather something like adding multiple string import files so that AOM doesn't prevent me from string synchronisation and file cleanups.

                          Then we have the conversion and franchise info that should go into the Diplomanager somewhere. Currently you only know what you lose but not what you gain. Then some UI inprovements, make sure that you can't end turn if a city as an empty build queue.

                          For Civ4 I am currently waiting for a patch, there are so many problems that you should see if you play one entire game. You should see that memory eating behavior, the performance issures, the graphical bugs (missing hammers, incomplete option screen). But most priority is fixing the memory leaks, if I set my virtual working space to 512 (twice of my physical working space) and after some time the game crashes, because of missing memory then there is something wrong. So I wait before I buy some addition RAM.

                          -Martin
                          Civ2 military advisor: "No complaints, Sir!"

                          Comment


                          • good stuff Martin. Thanks for the help. I wish I figured out the LDL stuff sooner now I have to dig them and figure what goes where so far it looks like Exchange in the Diplomacy.ldl might be what I'm looking for.

                            I'm happy I finally got hidden nationality working, something I wanted in ctp2 since the code came out. But I might have to ask you where to go to make the tile info say barbarian nstead of the nation, and change the color except if its the player. But o far atleast it works.

                            Setting up the diplomacy screento look like the Civ3/Civ4 table i something I waned for awhile so thats what I'll dig into next in the code. UI is brand new for me so I might get annoying with questions...
                            Formerly known as "E" on Apolyton

                            See me at Civfanatics.com

                            Comment


                            • Originally posted by E
                              I'm happy I finally got hidden nationality working, something I wanted in ctp2 since the code came out. But I might have to ask you where to go to make the tile info say barbarian nstead of the nation, and change the color except if its the player. But o far atleast it works.
                              Probably in one of the Maputils files in the gfx subfolders. (I hope they are there otherwise they are somewhere else.) And of course this should only apply if are not a Barbarian and there are other units on the same tile without hidden nationality.

                              Originally posted by E
                              Setting up the diplomacy screento look like the Civ3/Civ4 table i something I waned for awhile so thats what I'll dig into next in the code. UI is brand new for me so I might get annoying with questions...
                              Actually it isn't so difficuilt, you just need to put some buildin blocks together and vola you are there. Fortunately someone else did all the work for UI classes. Of course the only thing you have to do is to fill the building blocks with life.

                              -Martin
                              Civ2 military advisor: "No complaints, Sir!"

                              Comment


                              • Thanks Martin,

                                I'll dive into it especially this weekend. I did try to resize the box and it made the diplomacy manager where it doesnt close so I got to real try to figure itout.


                                I've been having problems with the regardevent.cpp hiddennationality code though
                                Code:
                                STDEHANDLER(BattleAftermathRegardEvent)
                                {
                                	Army army;
                                	MapPoint pos;
                                	Unit ta;
                                	Unit td;
                                	sint32 attack_owner, defense_owner;
                                
                                	
                                	args->GetArmy(0, army);
                                
                                	if(!args->GetPos(0, pos))
                                		return GEV_HD_Continue;
                                
                                	args->GetUnit(0, ta);
                                	args->GetUnit(1, td);
                                
                                	if(!args->GetPlayer(0, attack_owner))
                                		return GEV_HD_Continue;
                                
                                	if(!args->GetPlayer(1, defense_owner))
                                		return GEV_HD_Continue;
                                
                                // EMOD - Hidden Nationality check added by E 18 Nov 2005 - if unit is not Hidden Nationality then Regard Event is Logged 
                                	if(!(ta.GetDBRec()->GetHiddenNationality() == true)) {
                                
                                //original code
                                		Diplomat & defending_diplomat = Diplomat::GetDiplomat(defense_owner);
                                		defending_diplomat.LogViolationEvent(attack_owner, PROPOSAL_TREATY_CEASEFIRE);
                                	}
                                
                                
                                //end EMOD
                                
                                	
                                	return GEV_HD_Continue;
                                }
                                its mainly that the game cant handle stacks. if its a hiddenNationality(HN) or non-HN it crashes or 2 or more non-HN, but a HN vs a non HN it works fine
                                Formerly known as "E" on Apolyton

                                See me at Civfanatics.com

                                Comment

                                Working...
                                X