Example #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));
	}
}
bool InstallationObjectImplementation::updateMaintenance(Time& workingTime) {

	Time now;
	
	int currentTime = time(0);
	int lastTime = lastMaintenanceTime.getTime();

	int elapsedTime = currentTime - lastTime;
	int workTimePermitted = elapsedTime;

	float payAmount = ((float)elapsedTime / 3600.0f) * getMaintenanceRate();

	bool shutdownWork = false;


	if (payAmount > surplusMaintenance) {

		workTimePermitted = surplusMaintenance / getMaintenanceRate() * 3600;

		Time workTill(lastMaintenanceTime.getTime() + (int) workTimePermitted);
		workingTime = workTill;

		shutdownWork = true;
	}

	if (workTimePermitted > 0) {
		elapsedTime = workTimePermitted;
	}

	addMaintenance(-1.0f * payAmount);

	int basePowerRate = getBasePowerRate();

	if (isOperating() && basePowerRate != 0) {
		float energyAmount = (elapsedTime / 3600.0) * basePowerRate;

		if (energyAmount > surplusPower) {
			energyAmount = surplusPower;

			float workPowerPermitted = (surplusPower / basePowerRate) * 3600;

			if (workPowerPermitted < elapsedTime) {
				Time workTill(lastMaintenanceTime.getTime() + (int) workPowerPermitted);
				workingTime = workTill;
			}

			shutdownWork = true;
		}

		addPower(-1.0f * energyAmount);

	}

	lastMaintenanceTime.updateToCurrentTime();

	return shutdownWork;
}
Example #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));
		}
	}
}
Example #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;
}
Example #5
0
 void Player::collideHeart(GameObject& o)
 {
    o.removeTag("heart");
    if(m_lives < 4)
    {
       m_lives++;
       m_heartSound.play();
    }
    else
    {
       addPower(1);
       m_heartPtsSound.play();
    }
 }
void dogDrawSelf(CatLoveDog_InGame *myself)
{
	if(!myself->isPause)
	{
		addPower(myself);
		boneRun(myself);
		boneMove(myself);
		boneHit2(myself);
		boneOut(myself);
		if(!myself->bombShow)
			boneAI(myself);
	  }

}
Example #7
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));
		}
	}
}
Example #8
0
 void Player::collideYoungling(GameObject& o)
 {
    o.removeTag("youngling");
    addPower(5);
 }