 |
|  |
 |
|
E
|
 |
July 24,2005 Ctp2 Tiles in sig!
May 1999 time: 21:24
|
|
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;
}
|
|
|  |
 |
|
E
|
 |
July 24,2005 Ctp2 Tiles in sig!
May 1999 time: 21:24
|
|
Okay this isnt a real attempt at the code (yet) but I'm trying to gather exactly what I'll need to do.
1) it has to go in the citywonderevent, no prob.
2) first it has to check the radius for terrain andimprovements
3) then it has to get the wonder imp properties Cantbuildon and excludes
4) it has to check if the wonder can be built on terrain or the improvements
5) then it has to build the wonder
I know I'm going to need help on the iterator, havent done anything like that before, but I think I found something similar in the jumble of code I pasted there. Questions though:
1) do I have to copy the checks that createtile (like Cantbuildon etc) or is there some whay I can just do Get terrainutil_CanPlayerBuildAt?
2)How do I tell it to create the tile?
3) should I make it do a check n the build ques to see if the wonder can be shown on the map so it doesn't cause a problem afterwards?
thanks
code:
////
sint32 w;
const WonderRecord *rec = g_theWonderDB->Get(wonder_type);
sint32 t = rec->GetTerrutilIndex();
sint32 wonderimp = rec->GetShowOnMapIndex();
if (t < 0) {
return FALSE;
for(i = 0; i < rec->GetNumCanSettleOn(); i++) {
if(rec->GetCanSettleOnIndex(i) == cell->GetTerrain()) {
return TRUE;
}
}
if(cell->GetOwner() == -1) {
if(rec->GetIntBorderRadius()) {
if(!g_player[pl]->IsVisible(pos)) {
return false;
}
} else {
return false;
}
}
for(i = 0; i < rec->GetNumCantBuildOn(); i++) {
if(rec->GetCantBuildOnIndex(i) == cell->GetTerrain()) {
return FALSE;
}
}
}
g_gevManager->AddEvent(GEV_INSERT_Tail,
GEV_CreateImprovement,
GEA_Player, m_playerId,
GEA_MapPoint, iter->pos,
GEA_Int, iter->type,
GEA_Int, 0,
GEA_End);
|
|
|  |
 |
|
E
|
 |
July 24,2005 Ctp2 Tiles in sig!
May 1999 time: 21:24
|
|
Just some left over notes and stuff to clean up after I finish NeedsCityGood. the stuff in bold I'll need to walk through though...
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);
}
//begin E code from Governor.cpp PlaceTileImprovements
Player *player_ptr;
CityData *city;
Unit unit;
Cell *cell;
TiGoal ti_goal;
MapPoint pos;
CityInfluenceIterator it(unit.RetPos(), city->GetSizeIndex());
for(it.Start(); !it.End(); it.Next()) {
if (unit.RetPos() == it.Pos())
continue;
cell = g_theWorld->GetCell(it.Pos());
if (!(cell->GetCityOwner() == unit))
continue;
if (cell->GetNumImprovements() > 0)
continue;
if ( terrutil_PlayerCanBuildAt(it.Pos(), imp) )
g_gevManager->AddEvent(GEV_INSERT_Tail, GEV_CreateImprovement,
GEA_Player, m_playerId,
GEA_MapPoint, iter->pos,
GEA_Int, iter->type,
GEA_Int, 0,
//end E code
if(wonder == wonderutil_GetGaiaIndex()) {
// 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");
so->AddRecipient(i);
so->AddPlayer(i);
so->AddPlayer(c.GetOwner());
g_slicEngine->Execute(so); // will delete so after handling
}
}
}
return GEV_HD_Continue;
}
|
|
|  |
 |
|  |
All times are GMT. The time now is 05:24. Apolyton Time is 00:24. |
top of page
|
|
|
Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is ON
vB code is ON
Smilies are ON
[IMG] code is ON
|
|
|
|
|
|