示例#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
/* 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;
}
示例#3
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());
}
示例#4
0
/* virtual */ void COrder_TransformInto::Execute(CUnit &unit)
{
	TransformUnitIntoType(unit, *this->Type);
	this->Finished = true;
}
示例#5
0
/**
**  Unit transform into unit.
**
**  @param unit  Pointer to unit.
*/
void HandleActionTransformInto(CUnit &unit)
{
    // What to do if an error occurs ?
    TransformUnitIntoType(unit, *unit.CriticalOrder.Arg1.Type);
    unit.CriticalOrder.Action = UnitActionStill;
}