Announcement

Collapse
No announcement yet.

PROJECT: ShowOnMap

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

  • PROJECT: ShowOnMap

    Ok, my other project I want to do is add a flag for wonders (later buildings too) that will tell the program to create a wonderimprovement once a wonder is built. Yes, it is based on the visible wonders mod, but wouldn't it be nice to just add a flag ShowOnMap () and put the index number and the game will place it. I think so. So I'm looking at where to put the code first, and I think I'll relook the slic and then try to code it from there. I'm thinking the code might have to go in some of the code found in WonderTracker.cpp


    Code:
    BOOL WonderTracker::HasWonderBeenBuilt(sint32 which)
    {
    	return (m_builtWonders & ((uint64)1 << (uint64)which)) != 0;
    }
    
    void WonderTracker::AddBuilt(sint32 which)
    {
    	m_builtWonders |= (uint64)1 << (uint64)which;
    	if(g_network.IsHost()) {
    		g_network.Enqueue(new NetInfo(NET_INFO_CODE_BUILT_WONDERS,
    									  (uint32)(m_builtWonders & 0xffffffff),
    									  (uint32)(m_builtWonders >> (uint64)32)));
    	}
    }
    
    BOOL WonderTracker::GetCityWithWonder(sint32 which, Unit &city)
    {
    	sint32 p;
    	for(p = 0; p < k_MAX_PLAYERS; p++) {
    		if(!g_player[p])
    			continue;
    		sint32 c;
    		for(c = g_player[p]->m_all_cities->Num() - 1; c >= 0; c--) {
    			if(g_player[p]->m_all_cities->Access(c).GetData()->GetCityData()->GetBuiltWonders() & ((uint64)1 << which)) {
    
    				city = g_player[p]->m_all_cities->Access(c);
    				return TRUE;
    			}
    		}
    	}
    	return FALSE;

    OR in CityEvent.cpp


    Code:
    STDEHANDLER(CityBuildWonderEvent)
    {
    	Unit city;
    	sint32 type;
    	if(!args->GetCity(0, city)) return GEV_HD_Continue;
    	if(!args->GetInt(0, type)) return GEV_HD_Continue;
    
    	city.BuildWonder(type);
    	return GEV_HD_Continue;
    }
    Formerly known as "E" on Apolyton

    See me at Civfanatics.com

  • #2
    Martin,
    I saw that Actor uses the draw forcefield and drawWalls funcion to place it on the map when built. Would you recommend using the Draw features but have it search for tiles or to create it as an event?
    Formerly known as "E" on Apolyton

    See me at Civfanatics.com

    Comment


    • #3
      Well the little problem is that you have to store the location of the wonder tile somewhere. One possible way would be to use the tile object list. However I would put or call the placement from the City::BuildWonder function. But maybe you should take a close lock on your good improvements first.

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

      Comment


      • #4
        I'll stick to finishing my goods first, but I was thinking of making it a flag in the wonder/building.txt something like ShowOnMap 42, using the integer as the index number. I saw that the forcefield code had a default value that you ended up putting in your citystyle.txt IIRC.

        So I'm thinking I'd have to do something similar but copy the searching tile code IW did in the SLIC and then having the DrawActor trigger it in the CityEvent code...

        the follow on to this might also be to add a flag in the advances.txt that is EnableCitySprawl 44, and if a player has the advance and the city grows than it does city sprawl. Having it as flags in the txt also allows it to be a modder option and not change the original game.

        Of course adding Unit updater and the kill city options are also on my list but I will stay focused on my good improvements first.
        Formerly known as "E" on Apolyton

        See me at Civfanatics.com

        Comment


        • #5
          It is not so easy:

          1. You have to figure out where you put the graphic on the map.
          2. That must be stored, so that you don't put it at another place each time you call the draw function.
          3. What about the Great Wall, in Ben's version it is a set of tile improvements, in which order in how must they arranged on the map.
          4. How do you store this bit of information in the save game file so that it is compatible with old savegames.

          And I think that are just some questions you have to answer and implement finally.

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

          Comment


          • #6
            If it's done, then limiting it to one-tile wonders would be far easier than kludging the Great Wall in.
            Concrete, Abstract, or Squoingy?
            "I don't believe in giving scripting languages because the only additional power they give users is the power to create bugs." - Mike Breitkreutz, Firaxis

            Comment


            • #7
              Originally posted by Martin Gühmann
              It is not so easy:

              1. You have to figure out where you put the graphic on the map.
              I can't just use a search tile function like in IW's slic? I'm thinking I may to make it an event where a tileimp is built as opposed to "draw" which I think just places a graphic.

              2. That must be stored, so that you don't put it at another place each time you call the draw function.
              Will making it a tileimp thats placed at an event solve this?

              3. What about the Great Wall, in Ben's version it is a set of tile improvements, in which order in how must they arranged on the map.
              Ben said it can be just one tile, and I think that is best.

              4. How do you store this bit of information in the save game file so that it is compatible with old savegames.
              You got me on that one. Does forcefield have a problem with that/ Or citywalls? Would making it an event solve it?



              PS Immortal Wombat, you've done great stuff with SLIC have you ever tried helping with the source code? We could use the help here.
              Formerly known as "E" on Apolyton

              See me at Civfanatics.com

              Comment


              • #8
                CityEvent.cpp

                Code:
                STDEHANDLER(CreateWonderEvent)
                {
                	Unit c;
                	sint32 wonder;
                	if(!args->GetCity(0, c)) return GEV_HD_Continue;
                	if(!args->GetInt(0, wonder)) return GEV_HD_Continue;
                
                	c.CD()->SetWonders(c.CD()->GetBuiltWonders() | ((uint64)1 << (uint64)wonder));
                	wonderutil_AddBuilt(wonder);
                	g_player[c->GetOwner()]->AddWonder(wonder, c);
                	g_player[c->GetOwner()]->RegisterCreateWonder(c, wonder);
                
                	
                	if (c->GetOwner() == g_selected_item->GetVisiblePlayer() &&
                		!Player::IsThisPlayerARobot(c->GetOwner())) {
                		
                		if ( g_theProfileDB->IsWonderMovies() ) {
                			if (g_director) {
                				g_director->AddPlayWonderMovie(c.CD()->GetBuildQueue()->GetHead()->m_type);
                			}
                		}
                		
                	}
                	if(g_network.IsHost()) {
                		g_network.Block(c.GetOwner());
                		g_network.Enqueue(new NetInfo(NET_INFO_CODE_WONDER_BUILT,
                									  c.CD()->GetBuildQueue()->GetHead()->m_type, (uint32)c.m_id));
                		g_network.Unblock(c.GetOwner());
                	}
                
                	Unit u;
                	c.CD()->GetBuildQueue()->FinishBuildFront(u);
                	SlicObject *so;
                	if(wonder == wonderutil_GetFobCityIndex()) {
                		so = new SlicObject("911ForbiddenCityPeace");
                		so->AddRecipient(c.GetOwner());
                		so->AddCity(c);
                		g_slicEngine->Execute(so);
                	}
                
                	if(wonder == wonderutil_GetGaiaIndex()) {
                #if defined(ACTIVISION_ORIGINAL)	// have to make a new object for each player
                		so = new SlicObject("GCMustDiscoverGaiaController");
                		for(sint32 i = 1; i < g_theProfileDB->GetMaxPlayers(); i++) {
                			if(g_player[i] && i != c->GetOwner()) {
                #else
                		// Notify the other players that they have to hurry to win.
                		// Starting at 1: the Barbarians do not have to be notified.
                		for (sint32 i = 1; i < k_MAX_PLAYERS; ++i)
                		{
                			if (g_player[i] && !g_player[i]->IsDead() && (i != c.GetOwner()))
                			{
                				SlicObject * so	= new SlicObject("GCMustDiscoverGaiaController");
                #endif
                				so->AddRecipient(i);
                				so->AddPlayer(i);
                				so->AddPlayer(c.GetOwner());
                				g_slicEngine->Execute(so);	// will delete so after handling
                			}
                		}
                	}
                
                	return GEV_HD_Continue;
                }
                Formerly known as "E" on Apolyton

                See me at Civfanatics.com

                Comment


                • #9
                  Originally posted by E
                  You got me on that one. Does forcefield have a problem with that/ Or citywalls? Would making it an event solve it?
                  No forcefoelds and citywalls are place on the same tile as the city itsself, but visible wonders are placed outside of the city. But if you turn them into a tileimprovements than you shouldn't have a problem, but then I suggest to use real tileimprovements stored in tileimp.txt.

                  To place them you have to use the create wonder event posted above. Another thing is that you should add then a CantPillaged flag to tileimp.txt.

                  And finally you have to consider a way to remove them from the map if the wonder is destroyed.

                  For placing them you should find in the source code a search function.

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

                  Comment


                  • #10
                    I'll go with the tileimp and use IW's as a default to add to the code.

                    I'll look for the searc function in a bit, but cant I use something similar to IW's Slic? just get city pos check for an imp and if they are all imps then cut one. I think I may also have to add a check in can build if its an island etc...


                    for CantPillage I think I need to add the check here in OA_Pillage.cpp
                    Code:
                         if (ai->m_world->GetNumImprovements(pos) > 0) {
                    			start_owner = ai->m_world->GetCellOwner(&pos);
                            
                                if ((0 <= start_owner) && (start_owner <= k_MAX_PLAYERS)) { 
                                    if (ai->m_foreigner[start_owner]) { 
                                        if (start_owner != ai->m_my_player_id) { 
                                            if (ai->m_foreigner[start_owner]->IsAtHotWar()) { 
                                                if (ai->m_player->CanPillage(nth_army->m_id.GetVal(), &is_unknown_id, &pos)) { 
                                                    ai->m_player->Pillage(nth_army->m_id.GetVal(), &is_unknown_id, &pos);
                                                }
                                            } 
                                        } 
                                    }
                                }
                            } 
                        } 
                    }
                    Formerly known as "E" on Apolyton

                    See me at Civfanatics.com

                    Comment


                    • #11
                      Originally posted by E
                      PS Immortal Wombat, you've done great stuff with SLIC have you ever tried helping with the source code? We could use the help here.
                      I plan to get involved at some point, but that point is not here yet
                      Concrete, Abstract, or Squoingy?
                      "I don't believe in giving scripting languages because the only additional power they give users is the power to create bugs." - Mike Breitkreutz, Firaxis

                      Comment


                      • #12
                        Originally posted by E
                        I'll look for the searc function in a bit, but cant I use something similar to IW's Slic?
                        Of course you can reprogram it, but first that is an unnecessary code duplication. Second if you duplicate code you can do errors. Third why writing code again if someone else already has written it. And fourth that isn't a very good style of programming.

                        Originally posted by E
                        just get city pos check for an imp and if they are all imps then cut one. I think I may also have to add a check in can build if its an island etc...
                        Why cutting one? The tileimp records have already an exclusion flag that does this automaticly for you, you may just need to add some new.

                        Originally posted by E
                        for CantPillage I think I need to add the check here in OA_Pillage.cpp
                        From a glipse at it, it seems that it is just related to the AI, however it must know which it can pillage and which not, but it would prevent a human player from pillaging the tileimps.

                        By the way I think we should make it so that if a location contains an unpillagable tileimp that the rest of the tileimps at that location can be pillaged, if they are pillagble.

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

                        Comment


                        • #13
                          Martin,

                          I've been hunting for a search function and found something in governor.cpp but I don't think the AI is the way to go. I didn't see much in gs. Could you point in the right direction or may be point out what I miss?

                          I searched on SEARCH...and Search tile, etc.
                          Formerly known as "E" on Apolyton

                          See me at Civfanatics.com

                          Comment


                          • #14
                            You are looking for a function that scans through all tiles under the city influence. For instance an iterator does something like this. And in fact you find something like this in the governor.cpp.

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

                            Comment


                            • #15
                              great. so I was close, and in the right place, but couldnt find what I was looking for
                              Formerly known as "E" on Apolyton

                              See me at Civfanatics.com

                              Comment

                              Working...
                              X