Buildings work as transporters while doing other stuff. Minor fixes.
This commit is contained in:
parent
7df397f398
commit
34b8c6e580
6 changed files with 42 additions and 8 deletions
src
|
@ -604,6 +604,27 @@ global void CommandUnload(Unit* unit, int x, int y, Unit* what, int flush)
|
|||
// Check if unit is still valid? (NETWORK!)
|
||||
//
|
||||
if (!unit->Removed && unit->Orders[0].Action != UnitActionDie) {
|
||||
//
|
||||
// For bunkers, don't go into an action. Just drop everything here and now.
|
||||
//
|
||||
if (unit->Type->Building) {
|
||||
int i;
|
||||
Unit* uins;
|
||||
|
||||
// Unload all units.
|
||||
uins = unit->UnitInside;
|
||||
for (i = unit->InsideCount; i; --i, uins = uins->NextContained) {
|
||||
if (uins->Boarded) {
|
||||
uins->X = unit->X;
|
||||
uins->Y = unit->Y;
|
||||
if (UnloadUnit(uins)) {
|
||||
unit->BoardCount--;
|
||||
}
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(order = GetNextOrder(unit, flush))) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -190,8 +190,8 @@ extern void HandleActionSpellCast(Unit* unit);
|
|||
extern int UnitShowAnimation(Unit* unit,const Animation* animation);
|
||||
/// Handle the actions of all units each game cycle
|
||||
extern void UnitActions(void);
|
||||
/// Handle Cloaked Unit's Visible
|
||||
extern void HandleCloak(void);
|
||||
/// Unload an unit.
|
||||
extern int UnloadUnit(Unit* unit);
|
||||
//@}
|
||||
|
||||
#endif // !__ACTIONS_H__
|
||||
|
|
|
@ -870,10 +870,11 @@ global void DoButtonButtonClicked(int button)
|
|||
switch (CurrentButtons[button].Action) {
|
||||
case ButtonUnload:
|
||||
//
|
||||
// Unload on coast, transporter standing, unload all units.
|
||||
// Unload on coast, transporter standing, unload all units right now.
|
||||
// That or a bunker.
|
||||
//
|
||||
if (NumSelected == 1 && Selected[0]->Orders[0].Action == UnitActionStill &&
|
||||
CoastOnMap(Selected[0]->X, Selected[0]->Y)) {
|
||||
if ((NumSelected == 1 && Selected[0]->Orders[0].Action == UnitActionStill &&
|
||||
CoastOnMap(Selected[0]->X, Selected[0]->Y)) || Selected[0]->Type->Building) {
|
||||
SendCommandUnload(Selected[0],
|
||||
Selected[0]->X, Selected[0]->Y, NoUnitP,
|
||||
!(KeyModifiers & ModifierShift));
|
||||
|
|
|
@ -139,7 +139,8 @@ global void DoRightButton(int sx, int sy)
|
|||
dest = UnitUnderCursor;
|
||||
|
||||
// don't allow stopping enemy transporters!
|
||||
if (dest && dest->Type->Transporter && PlayersTeamed(ThisPlayer->Player, dest->Player->Player)) {
|
||||
if (dest && dest->Type->Transporter && (!dest->Type->Building) &&
|
||||
PlayersTeamed(ThisPlayer->Player, dest->Player->Player)) {
|
||||
// n0b0dy: So we are clicking on a transporter. We have to:
|
||||
// 1) Flush the transporters orders.
|
||||
// 2) Tell the transporter to follow the units. We have to queue all
|
||||
|
@ -188,7 +189,11 @@ global void DoRightButton(int sx, int sy)
|
|||
dest->Blink = 4;
|
||||
DebugLevel0Fn("Board transporter\n");
|
||||
// Let the transporter move to the unit. And QUEUE!!!
|
||||
SendCommandFollow(dest, unit, 0);
|
||||
// Don't do it for buildings.
|
||||
if (!dest->Type->Building) {
|
||||
DebugLevel0Fn("Send command follow");
|
||||
SendCommandFollow(dest, unit, 0);
|
||||
}
|
||||
SendCommandBoard(unit, -1, -1, dest, flush);
|
||||
continue;
|
||||
}
|
||||
|
@ -460,7 +465,8 @@ local void HandleMouseOn(int x, int y)
|
|||
return;
|
||||
}
|
||||
} else {
|
||||
for (i = TheUI.NumTrainingButtons; i >= 0; --i) {
|
||||
i = min(TheUI.NumTrainingButtons, Selected[0]->Data.Train.Count);
|
||||
for (--i; i >= 0; --i) {
|
||||
if (x >= TheUI.TrainingButtons[i].X &&
|
||||
x < TheUI.TrainingButtons[i].X + TheUI.TrainingButtons[i].Width + 7 &&
|
||||
y >= TheUI.TrainingButtons[i].Y &&
|
||||
|
|
|
@ -856,6 +856,9 @@ local int CclUnit(lua_State* l)
|
|||
} else if (!strcmp(value, "moving")) {
|
||||
unit->Moving = 1;
|
||||
--j;
|
||||
} else if (!strcmp(value, "boarded")) {
|
||||
unit->Boarded = 1;
|
||||
--j;
|
||||
} else if (!strcmp(value, "rs")) {
|
||||
unit->Rs = LuaToNumber(l, j + 1);
|
||||
} else if (!strcmp(value, "units-boarded-count")) {
|
||||
|
|
|
@ -3631,6 +3631,9 @@ global void SaveUnit(const Unit* unit, CLFile* file)
|
|||
if (unit->Moving) {
|
||||
CLprintf(file, " \"moving\",");
|
||||
}
|
||||
if (unit->Boarded) {
|
||||
CLprintf(file, " \"boarded\",");
|
||||
}
|
||||
CLprintf(file, " \"rs\", %d,", unit->Rs);
|
||||
CLprintf(file, " \"units-boarded-count\", %d,", unit->BoardCount);
|
||||
CLprintf(file, "\n \"units-contained\", {");
|
||||
|
|
Loading…
Add table
Reference in a new issue