Пример #1
0
/* virtual */ void COrder_UpgradeTo::Execute(CUnit &unit)
{
	AnimateActionUpgradeTo(unit);
	if (unit.Wait) {
		unit.Wait--;
		return ;
	}
	CPlayer &player = *unit.Player;
	const CUnitType &newtype = *this->Type;
	const CUnitStats &newstats = newtype.Stats[player.Index];

	this->Ticks += player.SpeedUpgrade / SPEEDUP_FACTOR;
	if (this->Ticks < newstats.Costs[TimeCost]) {
		unit.Wait = CYCLES_PER_SECOND / 6;
		return ;
	}

	if (unit.Anim.Unbreakable) {
		this->Ticks = newstats.Costs[TimeCost];
		return ;
	}

	if (TransformUnitIntoType(unit, newtype) == 0) {
		player.Notify(NotifyYellow, unit.tilePos, _("Upgrade to %s canceled"), newtype.Name.c_str());
		this->Finished = true;
		return ;
	}
	player.Notify(NotifyGreen, unit.tilePos, _("Upgrade to %s complete"), unit.Type->Name.c_str());

	//  Warn AI.
	if (player.AiEnabled) {
		AiUpgradeToComplete(unit, newtype);
	}
	this->Finished = true;
}
Пример #2
0
/**
**	Unit upgrades unit!
**
**	@param unit	Pointer to unit.
*/
global void HandleActionUpgradeTo(Unit* unit)
{
    Player* player;
    UnitType* type;
    const UnitStats* stats;

    DebugLevel3Fn(" %d\n" _C_ UnitNumber(unit));

    player=unit->Player;
    if( !unit->SubAction ) {		// first entry
        unit->Data.UpgradeTo.Ticks=0;
        unit->SubAction=1;
    }
    type=unit->Orders[0].Type;
    stats=&type->Stats[player->Player];

    UnitMarkSeen(unit);
    // FIXME: Should count down here
    unit->Data.UpgradeTo.Ticks+=SpeedUpgrade;
    if( unit->Data.UpgradeTo.Ticks>=stats->Costs[TimeCost] ) {

        unit->HP+=stats->HitPoints-unit->Type->Stats[player->Player].HitPoints;
        // don't have such unit now
        player->UnitTypesCount[unit->Type->Type]--;
        unit->Type=type;
        unit->Stats=(UnitStats*)stats;
        // and we have new one...
        player->UnitTypesCount[unit->Type->Type]++;
        UpdateForNewUnit(unit,1);

        NotifyPlayer(player,NotifyGreen,unit->X,unit->Y,
                     "Upgrade to %s complete",unit->Type->Name );
        if( unit->Player->Ai ) {
            AiUpgradeToComplete(unit,type);
        }
        unit->Reset=unit->Wait=1;
        unit->Orders[0].Action=UnitActionStill;
        unit->SubAction=0;

        //
        //	Update possible changed buttons.
        //
        if( IsOnlySelected(unit) ) {
            UpdateButtonPanel();
            MustRedraw|=RedrawPanels;
        } else if( player==ThisPlayer ) {
            UpdateButtonPanel();
            MustRedraw|=RedrawInfoPanel;
        }

        return;
    }

    if( IsOnlySelected(unit) ) {
        MustRedraw|=RedrawInfoPanel;
    }

    unit->Reset=1;
    unit->Wait=CYCLES_PER_SECOND/6;
}
Пример #3
0
/* virtual */ void COrder_UpgradeTo::Execute(CUnit &unit)
{
	AnimateActionUpgradeTo(unit);
	if (unit.Wait) {
		unit.Wait--;
		return ;
	}
	CPlayer &player = *unit.Player;
	const CUnitType &newtype = *this->Type;
	const CUnitStats &newstats = newtype.Stats[player.Index];

	//Wyrmgus start
//	this->Ticks += std::max(1, player.SpeedUpgrade / SPEEDUP_FACTOR);
	this->Ticks += std::max(1, (player.SpeedUpgrade + unit.Variable[TIMEEFFICIENCYBONUS_INDEX].Value) / SPEEDUP_FACTOR);
	//Wyrmgus end
	if (this->Ticks < newstats.Costs[TimeCost]) {
		unit.Wait = CYCLES_PER_SECOND / 6;
		return ;
	}

	if (unit.Anim.Unbreakable) {
		this->Ticks = newstats.Costs[TimeCost];
		return ;
	}

	if (TransformUnitIntoType(unit, newtype) == 0) {
		//Wyrmgus start
		//I think it is too much to notify the player whenever an individual upgrade is cancelled
//		player.Notify(NotifyYellow, unit.tilePos, _("Upgrade to %s canceled"), newtype.Name.c_str());
		//Wyrmgus end
		this->Finished = true;
		return ;
	}
	//Wyrmgus start
	//I think it is too much to notify the player whenever an individual upgrade is completed
//	player.Notify(NotifyGreen, unit.tilePos, _("Upgrade to %s complete"), unit.Type->Name.c_str());
	//Wyrmgus end

	//  Warn AI.
	if (player.AiEnabled) {
		AiUpgradeToComplete(unit, newtype);
	}
	this->Finished = true;
}
Пример #4
0
/**
**  Unit upgrades unit!
**
**  @param unit  Pointer to unit.
*/
void HandleActionUpgradeTo(CUnit &unit)
{
    if (!unit.SubAction) { // first entry
        unit.Data.UpgradeTo.Ticks = 0;
        unit.SubAction = 1;
    }
    unit.Type->Animations->Upgrade ?
    UnitShowAnimation(unit, unit.Type->Animations->Upgrade) :
    UnitShowAnimation(unit, unit.Type->Animations->Still);
    if (unit.Wait) {
        unit.Wait--;
        return;
    }
    CPlayer *player = unit.Player;
    CUnitType &newtype = *unit.CurrentOrder()->Arg1.Type;
    const CUnitStats *newstats = &newtype.Stats[player->Index];

    // FIXME: Should count down here
    unit.Data.UpgradeTo.Ticks += SpeedUpgrade;
    if (unit.Data.UpgradeTo.Ticks < newstats->Costs[TimeCost]) {
        unit.Wait = CYCLES_PER_SECOND / 6;
        return;
    }

    unit.ClearAction();
    unit.State = 0;

    if (TransformUnitIntoType(unit, newtype) == 0) {
        player->Notify(NotifyGreen, unit.tilePos.x, unit.tilePos.y,
                       _("Upgrade to %s canceled"), newtype.Name.c_str());
        return ;
    }
    //  Warn AI.
    if (player->AiEnabled) {
        AiUpgradeToComplete(unit, newtype);
    }
    player->Notify(NotifyGreen, unit.tilePos.x, unit.tilePos.y,
                   _("Upgrade to %s complete"), unit.Type->Name.c_str());
}