CancelDrag, StartDrag: update interface panel to change drag icon status.

DrawTraitRadius uses usColour.
Allow to start dragging from any stance, soldier will crouch automatically.
Show draggable objects when drag skill menu is active.
Press [\] key to start dragging object/solder/corpse in front of merc.

git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@9369 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
Sevenfm
2022-04-24 18:21:44 +00:00
parent cdc605d5ab
commit 904fae7a96
11 changed files with 345 additions and 82 deletions
+110 -12
View File
@@ -38,6 +38,7 @@
#include "CampaignStats.h" // added by Flugente
#include "Points.h" // added by Flugente
#include "Interface Control.h" // added by Flugente for DrawExplosionWarning(...)
#include "SkillMenu.h"
#endif
#include "Soldier Macros.h"
@@ -4327,6 +4328,8 @@ void HandleExplosionQueue( void )
}
}
extern DragSelection gDragSelection;
// Flugente: show warnings around armed timebombs both in map and inventories
void HandleExplosionWarningAnimations( )
{
@@ -4379,28 +4382,123 @@ void HandleExplosionWarningAnimations( )
}
}
UINT16 usBlue = Get16BPPColor(FROMRGB(0, 0, 255));
UINT16 usColor;
INT32 sRadius;
// show focus area if skill is active
if ( gusSelectedSoldier != NOBODY )
{
SOLDIERTYPE* pSoldier = MercPtrs[gusSelectedSoldier];
if ( pSoldier->bActive && pSoldier->bInSector && (pSoldier->usSoldierFlagMask2 & SOLDIER_TRAIT_FOCUS) )
if ( pSoldier->bActive && pSoldier->bInSector)
{
// checking whether this skill is active is relatively cheap. If it fails, deactivate skill properly
// we cannot use CanUseSkill(...) again though, as this would fail upon opening the menu
if ( pSoldier->CanUseSkill( SKILLS_FOCUS, FALSE, pSoldier->sFocusGridNo ) )
if (pSoldier->usSoldierFlagMask2 & SOLDIER_TRAIT_FOCUS)
{
// radius depends on range
INT16 range = PythSpacesAway(pSoldier->sFocusGridNo, pSoldier->sGridNo);
INT16 radius = gSkillTraitValues.ubSNFocusRadius * range / 20;
// checking whether this skill is active is relatively cheap. If it fails, deactivate skill properly
// we cannot use CanUseSkill(...) again though, as this would fail upon opening the menu
if (pSoldier->CanUseSkill(SKILLS_FOCUS, FALSE, pSoldier->sFocusGridNo))
{
// radius depends on range
INT16 range = PythSpacesAway(pSoldier->sFocusGridNo, pSoldier->sGridNo);
INT16 radius = gSkillTraitValues.ubSNFocusRadius * range / 20;
DrawTraitRadius( pSoldier->sFocusGridNo, pSoldier->pathing.bLevel, sqrt( 0.5 ) * (20 + 40 * radius), 8, 0 );
DrawTraitRadius(pSoldier->sFocusGridNo, pSoldier->pathing.bLevel, sqrt(0.5) * (20 + 40 * radius), 8, usBlue);
}
else
{
// if conditions don't apply, deactivate skill. This will cause it to update to status changes very fast
pSoldier->usSoldierFlagMask2 &= ~SOLDIER_TRAIT_FOCUS;
pSoldier->sFocusGridNo = NOWHERE;
}
}
else
// sevenfm: show draggable objects
if (gDragSelection.Active()) // || gCurrentUIMode == HANDCURSOR_MODE)
{
// if conditions don't apply, deactivate skill. This will cause it to update to status changes very fast
pSoldier->usSoldierFlagMask2 &= ~SOLDIER_TRAIT_FOCUS;
pSoldier->sFocusGridNo = NOWHERE;
// check all tiles on screen
UINT32 tiletype;
UINT16 structurenumber;
UINT8 hitpoints;
UINT8 decalflag;
INT8 bLevel = pSoldier->pathing.bLevel;
UINT16 usRoomNo;
for (INT32 sSpot = 0; sSpot < WORLD_MAX; sSpot++)
{
if (!TileIsOutOfBounds(sSpot) &&
GridNoOnVisibleWorldTile(sSpot) &&
GridNoOnScreen(sSpot) &&
!TERRAIN_IS_HIGH_WATER(sSpot) &&
!InAHiddenRoom(sSpot, &usRoomNo))
{
BOOLEAN fShow = FALSE;
if (IsDragStructurePresent(sSpot, bLevel, tiletype, structurenumber, hitpoints, decalflag) &&
!Water(sSpot, bLevel) &&
FindNotWaterNearby(sSpot, bLevel))
{
fShow = TRUE;
}
// soldiers
if (!fShow)
{
for (UINT32 ubID = gTacticalStatus.Team[OUR_TEAM].bFirstID; ubID <= gTacticalStatus.Team[CIV_TEAM].bLastID; ++ubID)
{
if (ubID != pSoldier->ubID &&
MercPtrs[ubID] &&
MercPtrs[ubID]->sGridNo == sSpot &&
MercPtrs[ubID]->bVisible == TRUE &&
MercPtrs[ubID]->pathing.bLevel == bLevel &&
gAnimControl[MercPtrs[ubID]->usAnimState].ubEndHeight == ANIM_PRONE &&
!Water(MercPtrs[ubID]->sGridNo, MercPtrs[ubID]->pathing.bLevel) &&
pSoldier->ubBodyType <= REGFEMALE &&
(MercPtrs[ubID]->bTeam == pSoldier->bTeam || MercPtrs[ubID]->IsUnconscious() || MercPtrs[ubID]->stats.bLife < OKLIFE))
{
fShow = TRUE;
}
}
}
// corpses
if (!fShow)
{
ROTTING_CORPSE* pCorpse;
for (INT32 sCorpseID = 0; sCorpseID < giNumRottingCorpse; ++sCorpseID)
{
pCorpse = &(gRottingCorpse[sCorpseID]);
if (pCorpse &&
pCorpse->fActivated &&
pCorpse->def.bLevel == pSoldier->pathing.bLevel &&
pCorpse->def.bVisible == TRUE &&
sSpot == pCorpse->def.sGridNo &&
pCorpse->def.ubBodyType < COW &&
pCorpse->def.ubBodyType != QUEENMONSTER)
{
fShow = TRUE;
}
}
}
if (fShow)
{
usColor = Get16BPPColor(FROMRGB(64, 0, 96));
sRadius = (INT32)(sqrt(0.5) * (20));
if (bLevel > 0)
{
DrawTraitRadius(sSpot, bLevel, sRadius, 2, usColor);
DrawTraitRadius(sSpot, bLevel, sRadius + 4, 2, usColor);
}
else
{
DrawTraitRadius(sSpot, bLevel, sRadius, 2, usColor);
}
}
}
}
}
}
}