Ejemplo n.º 1
0
// ////////////////////////////////////////////////////////////////////////////
// give Power
void giftPower(uint8_t from, uint8_t to, BOOL send)
{
	UDWORD gifval;
	uint32_t dummy = 0;

	if (from == ANYPLAYER)
	{
		gifval = OILDRUM_POWER;
	}
	else
	{
		// Give 1/3 of our power away
		gifval = getPower(from) / 3;
		usePower(from, gifval);
	}

	addPower(to, gifval);

	if (send)
	{
		uint8_t giftType = POWER_GIFT;

		NETbeginEncode(NET_GIFT, NET_ALL_PLAYERS);
			NETuint8_t(&giftType);
			NETuint8_t(&from);
			NETuint8_t(&to);
			NETuint32_t(&dummy);
		NETend();
	}
	else if (to == selectedPlayer)
	{
		CONPRINTF(ConsoleString,(ConsoleString,_("%s Gives You %u Power"),getPlayerName(from),gifval));
	}
}
void DroidObjectImplementation::runModulePowerDrain() {
	for( int i=0; i<modules.size(); i++){
		BaseDroidModuleComponent* module = modules.get(i);
		int drain = module->getBatteryDrain();
		if(drain > 0)
			usePower(drain);
	}
}
Ejemplo n.º 3
0
// ////////////////////////////////////////////////////////////////////////////
// give Power
void giftPower(uint8_t from, uint8_t to, uint32_t amount, bool send)
{
	if (send)
	{
		uint8_t giftType = POWER_GIFT;

		NETbeginEncode(NETgameQueue(selectedPlayer), GAME_GIFT);
		NETuint8_t(&giftType);
		NETuint8_t(&from);
		NETuint8_t(&to);
		NETuint32_t(&amount);
		NETend();
	}
	else
	{
		int value = 0;

		if (from == ANYPLAYER && !NetPlay.bComms)
		{
			// basically cheating power, so we check that we are not in multiplayer
			addPower(to, amount);
		}
		else if (from == ANYPLAYER && NetPlay.bComms)
		{
			debug(LOG_WARNING, "Someone tried to cheat power in multiplayer - ignored!");
		}
		else if (amount == 0) // the GUI option
		{
			value = getPower(from) / 3;
			usePower(from, value);
			addPower(to, value);
		}
		else // for scripts etc that can give precise amounts
		{
			value = MIN(getPower(from), amount);
			usePower(from, value);
			addPower(to, value);
		}
		if (from != ANYPLAYER && to == selectedPlayer)
		{
			CONPRINTF(ConsoleString, (ConsoleString, _("%s Gives You %d Power"), getPlayerName(from), value));
		}
	}
}
Ejemplo n.º 4
0
// ********************************************************************************************
BOOL scrSkDifficultyModifier(void)
{
	SDWORD              amount,player;
	RESEARCH_FACILITY	*psResFacility;
	STRUCTURE           *psStr;
    PLAYER_RESEARCH		*pPlayerRes;

	if (!stackPopParams(1,VAL_INT, &player ))
	{
		return FALSE;
	}

	// power modifier
	amount = game.skDiff[player]*40;		//(0-20)*25			
	if(amount > 0)
	{
		addPower(player,amount);
	}
	else
	{
		usePower(player,(0-amount));
	}

	//research modifier.??
	for(psStr=apsStructLists[player];psStr;psStr=psStr->psNext)
	{

//		subtract 0 - 60% off the time to research.
		if(psStr->pStructureType->type == REF_RESEARCH)
		{
			psResFacility =	(RESEARCH_FACILITY*)psStr->pFunctionality;

			/*if(psResFacility->timeToResearch )
			{
				amount = psResFacility->timeToResearch;
				psResFacility->timeToResearch  = amount - ( (amount*3*game.skDiff[player])/100);
			}*/
            //this is not appropriate now the timeToResearch is not used - 10/06/99 so...
            //add 0-60% to the amount required to research
            if (psResFacility->psSubject)
            {
                pPlayerRes = asPlayerResList[player] + 
                    (((RESEARCH *)psResFacility->psSubject)->ref - REF_RESEARCH_START);
                pPlayerRes->currentPoints += ((((RESEARCH *)psResFacility->psSubject)->
                    researchPoints * 3 * game.skDiff[player])/100);
            }
		}

	}

	//free stuff??
		

	return TRUE;
}
Ejemplo n.º 5
0
// ////////////////////////////////////////////////////////////////////////////
// give Power
void giftPower(uint8_t from, uint8_t to, uint32_t amount, bool send)
{
	if (send)
	{
		uint8_t giftType = POWER_GIFT;

		NETbeginEncode(NETgameQueue(selectedPlayer), GAME_GIFT);
			NETuint8_t(&giftType);
			NETuint8_t(&from);
			NETuint8_t(&to);
			NETuint32_t(&amount);
		NETend();
	}
	else
	{
		uint32_t gifval;

		if (from == ANYPLAYER || amount != 0)
		{
			gifval = amount;
		}
		else
		{
			// Give 1/3 of our power away
			gifval = getPower(from) / 3;
			usePower(from, gifval);
		}

		addPower(to, gifval);

		if (from != ANYPLAYER && to == selectedPlayer)
		{
			CONPRINTF(ConsoleString,(ConsoleString,_("%s Gives You %u Power"),getPlayerName(from),gifval));
		}
	}
}
void DroidObjectImplementation::rechargeOtherDroid(DroidObject* otherDroid){

	otherDroid->rechargeFromDroid();
	usePower(100);

}