Skip to content

Commit

Permalink
Fixed GadgetModifierEW and modifier QuantumHiggsNet.
Browse files Browse the repository at this point in the history
  • Loading branch information
Noodlefu committed Apr 8, 2018
1 parent 668071d commit d7e651c
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 32 deletions.
15 changes: 6 additions & 9 deletions DarkSpace/GadgetModifierEW.cpp
Expand Up @@ -47,9 +47,6 @@ bool GadgetModifierEW::usable(Noun * pTarget, bool shift) const
if (((NounShip *)pTarget)->isDestroyed())
return false;

if (!isEnemy(pTargetShip))
return false;

if (pTargetShip->testFlags( NounShip::FLAG_CLOAKED|NounShip::FLAG_IN_SAFE_ZONE ) )
return false;

Expand All @@ -73,8 +70,8 @@ void GadgetModifierEW::use(dword when, Noun * pTarget, bool shift)
if (active() && m_Target.valid())
{
NounGadget::use(when, pTarget, shift);
for (std::vector<ModifierType>::iterator iList = modifiersType().begin(); iList != modifiersType().end(); ++iList)
m_Target->addModifier(*iList, strength());
for (int i=0; i<m_Modifiers.size(); ++i)
m_Target->subtractModifier(m_Modifiers[i], strength());

if (isServer())
{
Expand All @@ -90,8 +87,8 @@ void GadgetModifierEW::use(dword when, Noun * pTarget, bool shift)
{
m_Target = pShipTarget;

for (std::vector<ModifierType>::iterator iList = modifiersType().begin(); iList != modifiersType().end(); ++iList)
m_Target->subtractModifier(*iList, strength());
for (int i = 0; i<m_Modifiers.size(); ++i)
m_Target->addModifier(m_Modifiers[i], strength());

if (isServer())
{
Expand Down Expand Up @@ -136,8 +133,8 @@ void GadgetModifierEW::release()

if(m_Target.valid())
{
for (std::vector<ModifierType>::iterator iList = modifiersType().begin(); iList != modifiersType().end(); ++iList)
m_Target->addModifier(*iList, strength());
for (int i = 0; i<m_Modifiers.size(); ++i)
m_Target->subtractModifier(m_Modifiers[i], strength());

m_Target = NULL;
}
Expand Down
2 changes: 1 addition & 1 deletion DarkSpace/GadgetModifierEW.h
Expand Up @@ -26,13 +26,13 @@ class DLL GadgetModifierEW : public NounGadget
virtual int energyCost() const = 0;
virtual float strength() const = 0;
virtual float range() const = 0;
virtual std::vector<ModifierType> modifiersType() const = 0;

void release();
bool active() const;

protected:
NounShip::wRef m_Target;
Array< ModifierType > m_Modifiers;
};

inline bool GadgetModifierEW::active() const {
Expand Down
22 changes: 11 additions & 11 deletions DarkSpaceClient/DarkSpaceClient.cpp
Expand Up @@ -114,24 +114,24 @@ void CClientApp::RunGame( InterfaceContext * pInterface )
#ifndef _DEBUG
__try {
#endif
float fSVolume, fMVolume = 0.0f;
HWND hwnd = NULL;
GameDocument * pDoc = WidgetCast<GameDocument>(pInterface->document());
float fSVolume = 0.0f;
int fMVolume = 0;
HWND hWnd = NULL;
// THE MAIN GAME LOOP
while (pInterface->render())
{
if (hwnd == NULL )
hwnd = GetForegroundWindow();
{
// get our main window
hWnd = FindWindowA("DarkSpace",NULL);

// track any changes in volume so we can return back to them
if (fSVolume != pInterface->audio()->volume() && pInterface->audio()->volume() > 0.0)
// update our saved values if the volume is changed
if (pInterface->audio()->volume() > 0)
fSVolume = pInterface->audio()->volume();

GameDocument * pDoc = WidgetCast<GameDocument>(pInterface->document());
if (fMVolume != pDoc->jukeBox()->volume() && pDoc->jukeBox()->volume() > 0.0)
if (pDoc->jukeBox()->volume() > 0)
fMVolume = pDoc->jukeBox()->volume();

// mute our device if we lose focus
if (hwnd != GetForegroundWindow())
if (hWnd != GetForegroundWindow())
{
pInterface->audio()->setVolume(0.0f);
pDoc->jukeBox()->setVolume(0.0f);
Expand Down
1 change: 1 addition & 0 deletions Gadgets/Gadgets.vcxproj
Expand Up @@ -369,6 +369,7 @@
<ClInclude Include="PlatformSensor.h" />
<ClInclude Include="PlatformSupply.h" />
<ClInclude Include="PulseShield.h" />
<ClInclude Include="QuantumHiggsNet.h" />
<ClInclude Include="Reactor1000.h" />
<ClInclude Include="Reactor1500.h" />
<ClInclude Include="Reactor500.h" />
Expand Down
3 changes: 3 additions & 0 deletions Gadgets/Gadgets.vcxproj.filters
Expand Up @@ -752,6 +752,9 @@
<ClInclude Include="PlanetArena.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="QuantumHiggsNet.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="makefile" />
Expand Down
10 changes: 5 additions & 5 deletions Gadgets/QuantumHiggsNet.h
Expand Up @@ -9,6 +9,10 @@ class QuantumHiggsNet : public GadgetModifierEW
{
public:
DECLARE_WIDGET_CLASS();
QuantumHiggsNet()
{
m_Modifiers.push(MT_MASS);
}
Type type() const
{
return SPECIAL_OFFENSIVE;
Expand Down Expand Up @@ -39,7 +43,7 @@ class QuantumHiggsNet : public GadgetModifierEW
}
float strength() const
{
return 100.0f;
return -100.0f;
}
float range() const
{
Expand All @@ -49,10 +53,6 @@ class QuantumHiggsNet : public GadgetModifierEW
{
return TICKS_PER_SECOND * 30;
}
ModifierType modifierType() const
{
return MT_MASS;
}
};

//----------------------------------------------------------------------------
Expand Down
12 changes: 6 additions & 6 deletions Gadgets/ReduceWeaponRange.h
Expand Up @@ -9,6 +9,11 @@ class ReduceWeaponRange : public GadgetModifierEW
{
public:
DECLARE_WIDGET_CLASS();
ReduceWeaponRange()
{
m_Modifiers.push(MT_WEAPON_RANGE);
m_Modifiers.push(MT_BEAM_RANGE);
}
Type type() const
{
return SPECIAL_OFFENSIVE;
Expand Down Expand Up @@ -39,7 +44,7 @@ class ReduceWeaponRange : public GadgetModifierEW
}
float strength() const
{
return 10.0f;
return -10.0f;
}
float range() const
{
Expand All @@ -49,11 +54,6 @@ class ReduceWeaponRange : public GadgetModifierEW
{
return TICKS_PER_SECOND * 30;
}
std::vector<ModifierType> modifiersType() const
{
std::vector<ModifierType> modifiers = { MT_WEAPON_RANGE, MT_BEAM_RANGE };
return modifiers;
}
};

//----------------------------------------------------------------------------
Expand Down

0 comments on commit d7e651c

Please sign in to comment.