コード例 #1
0
ファイル: C4InfoCore.cpp プロジェクト: lluchs/clonk-rage
void C4PhysicalInfo::PromotionUpdate(int32_t iRank, bool fUpdateTrainablePhysicals, C4Def *pTrainDef)
	{
#ifdef C4ENGINE
	if (iRank>=0) { CanDig=1; CanChop=1; CanConstruct=1; }
	if (iRank>=0) { CanScale=1; }
	if (iRank>=0) { CanHangle=1; }
	Energy= Max<int32_t>( Energy, (50+5*BoundBy<int32_t>(iRank,0,10)) *C4MaxPhysical/100 );
	if (fUpdateTrainablePhysicals && pTrainDef)
		{
		// do standard training: Expect everything to be trained fully at rank 20
		int32_t iTrainRank = BoundBy<int32_t>(iRank, 0,20);
		Scale = pTrainDef->Physical.Scale + (C4MaxPhysical - pTrainDef->Physical.Scale) * iTrainRank / 20;
		Hangle = pTrainDef->Physical.Hangle + (C4MaxPhysical - pTrainDef->Physical.Hangle) * iTrainRank / 20;
		Swim = pTrainDef->Physical.Swim + (C4MaxPhysical - pTrainDef->Physical.Swim) * iTrainRank / 20;
		Fight = pTrainDef->Physical.Fight + (C4MaxPhysical - pTrainDef->Physical.Fight) * iTrainRank / 20;
		// do script updates for any physicals as required (this will train stuff like magic)
		const char *szPhysName; C4PhysicalInfo::Offset PhysOff;
		for (int32_t iPhysIdx=0; szPhysName = GetNameByIndex(iPhysIdx, &PhysOff); ++iPhysIdx)
			{
			C4Value PhysVal(this->*PhysOff, C4V_Int);
			C4AulParSet Pars(C4VString(szPhysName), C4VInt(iRank), C4VRef(&PhysVal));
			if (!!pTrainDef->Script.Call(PSF_GetFairCrewPhysical, &Pars))
				{
				this->*PhysOff = PhysVal.getInt();
				}
			}
		}
#endif
	}
コード例 #2
0
ファイル: C4MapScript.cpp プロジェクト: farad91/openclonk
bool C4MapScriptHost::InitializeMap(C4SLandscape *pLandscape, C4TextureMap *pTexMap, C4MaterialMap *pMatMap, uint32_t iPlayerCount, std::unique_ptr<CSurface8> *pmap_fg_surface, std::unique_ptr <CSurface8>* pmap_bg_surface)
{
	// Init scripted map by calling InitializeMap in the proper scripts. If *pmap_surface is given, it will pass the existing map to be modified by script.
	assert(pmap_fg_surface);
	assert(pmap_bg_surface);

	this->pTexMap = pTexMap;
	this->pMatMap = pMatMap;
	// Don't bother creating surfaces if the functions aren't defined
	if (!LayerPrototype->GetFunc(PSF_InitializeMap))
	{
		C4PropList *scen_proplist = ::GameScript.ScenPropList._getPropList();
		if (!scen_proplist || !scen_proplist->GetFunc(PSF_InitializeMap)) return false;
	}
	// Create proplist as script context
	std::unique_ptr<C4MapScriptMap> map(CreateMap());

	// Drawing on existing map or create new?
	if (*pmap_fg_surface && *pmap_bg_surface)
	{
		// Existing map
		map->SetSurfaces(std::move(*pmap_fg_surface), std::move(*pmap_bg_surface));
	}
	else
	{
		assert(!*pmap_fg_surface && !*pmap_bg_surface);
		// No existing map. Create new.
		int32_t map_wdt,map_hgt;
		pLandscape->GetMapSize(map_wdt, map_hgt, iPlayerCount);
		if (!map->CreateSurface(map_wdt, map_hgt)) return false;
	}
	C4AulParSet Pars(C4VPropList(map.get()));
	C4Value result = map->Call(PSF_InitializeMap, &Pars);
	if (!result) result = ::GameScript.Call(PSF_InitializeMap, &Pars);
	// Map creation done.
	if (result)
	{
		map->ConvertSkyToTransparent();
	}
	std::tie(*pmap_fg_surface, *pmap_bg_surface) = map->ReleaseSurfaces();
	return !!result;
}