CTP2 Bureau
The Modding
Knowledgebase
Apolyton CTP2 section
Apolyton CTP2 files
Apolyton CTP2 forums
Source Code Project SVN

Actions

Pages

Recent Changes Search

Create a new page:

AE Modding Wiki : Functions : Plunder

New SLIC function: Pillage(): Well, as far as I am able to interpret the code below it frees the slaves, destroys all the buildings, and gives the PW to the capturing player. Is supposed to work in messages only, where the city is given from the context. Probably it currently doesn't work at all, since it is outcommented in the AE's script.slc.

SFN_ERROR Slic_Plunder::Call(SlicArgList *args)
{
    if (args->Count() > 0)
        return SFN_ERROR_NUM_ARGS;

	Unit city = g_slicEngine->GetContext()->GetCity(0);
	if (!city.IsValid()) 
    {
		return SFN_ERROR_OK;
	}

	sint32 amt;
	if(!args->GetInt(1, amt))
		return SFN_ERROR_TYPE_ARGS;

	sint32 pl;
	if(!args->GetInt(0, pl))
		return SFN_ERROR_TYPE_ARGS;

	if(pl < 0 || pl >= k_MAX_PLAYERS) 
		return SFN_ERROR_OUT_OF_RANGE;

	if(!g_player || !g_player[pl])
		return SFN_ERROR_DEAD_PLAYER;

	if(!city.GetData()->GetCityData()->CapturedThisTurn()) {
		if(g_network.IsClient()) {
			g_network.RequestResync(RESYNC_PROBABLE_CHEATER);
		}
		return SFN_ERROR_OK;
	}

	if(g_network.IsClient()) {
		g_network.SendAction(new NetAction(NET_ACTION_FREE_SLAVES, city.m_id));
	}

	sint32 p = 0;
	uint64 buildings = city->GetCityData()->GetEffectiveBuildings()&(((uint64)1<<(uint64)g_theBuildingDB->NumRecords())-1);
	for(sint32 i=0; buildings!=0; i++,buildings>>=1)
	{

		if ((buildings&0xFF) == 0) {
			buildings>>=8;
			i+=8;
		}

		if (buildings&1)
		{
			p += buildingutil_GetProductionCost(i, city->GetOwner());
			city->GetCityData()->DestroyImprovement(i);
		}
	}

	amt = p / g_theGovernmentDB->Get(g_player[pl]->m_government_type)->GetBuildingRushModifier();

    if(amt >= 0)
		g_player[pl]->m_materialPool->AddMaterials(amt);

    return SFN_ERROR_OK;
}
Page last modified on June 11, 2009, at 02:40 PM
  Administration
AE Modding Wiki built with PmWiki Design: BureauBert
Share this page:  VK Facebook Twitter LiveJournal OK MR Google+ LinkedIn tumblr Pinterest Blogger Digg Evernote