Skip to content
This repository was archived by the owner on Jan 5, 2024. It is now read-only.

Commit 8c44bb0

Browse files
committed
Added fresh player-requested features
1 parent 20a0731 commit 8c44bb0

39 files changed

+1427
-159
lines changed

Entities/AEmitter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -660,7 +660,7 @@ void AEmitter::Draw(BITMAP *pTargetBitmap,
660660
emitPos.RadRotate(m_HFlipped ? PI + m_Rotation.GetRadAngle() - m_EmitAngle.GetRadAngle() : m_Rotation.GetRadAngle() + m_EmitAngle.GetRadAngle());
661661
emitPos = m_Pos + RotateOffset(m_EmissionOffset) + emitPos;
662662
if(!g_SceneMan.ObscuredPoint(emitPos))
663-
g_SceneMan.RegisterPostEffect(emitPos, m_pFlash->GetScreenEffect(), m_pFlash->GetScreenEffectHash(), 55 + 200 * PosRand());
663+
g_SceneMan.RegisterPostEffect(emitPos, m_pFlash->GetScreenEffect(), m_pFlash->GetScreenEffectHash(), 55 + 200 * PosRand(), m_pFlash->GetEffectRotAngle());
664664
// g_SceneMan.RegisterPostEffect(emitPos, m_pFlash->GetScreenEffect(), 55 + (200 * PosRand() * ((float)1 - ((float)m_AgeTimer.GetElapsedSimTimeMS() / (float)m_Lifetime))));
665665
}
666666
}

Entities/AHuman.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3165,6 +3165,21 @@ void AHuman::UpdateAI()
31653165
}
31663166
}
31673167

3168+
//////////////////////////////////////////////////////////////////////////////////////////
3169+
// Virtual method: OnPieMenu
3170+
//////////////////////////////////////////////////////////////////////////////////////////
3171+
// Description: Executes the Lua-defined OnPieMenu event handler.
3172+
3173+
int AHuman::OnPieMenu(Actor * pActor)
3174+
{
3175+
int error = Actor::OnPieMenu(pActor);
3176+
3177+
// Call OnPieMenu handlers for a currently held device if any
3178+
if (m_pFGArm && m_pFGArm->IsAttached() && m_pFGArm->HoldsDevice())
3179+
return m_pFGArm->GetHeldDevice()->OnPieMenu(pActor);
3180+
3181+
return 0;
3182+
}
31683183

31693184
//////////////////////////////////////////////////////////////////////////////////////////
31703185
// Virtual method: Update

Entities/AHuman.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -903,6 +903,17 @@ ENTITYALLOCATION(AHuman)
903903
virtual void Update();
904904

905905

906+
//////////////////////////////////////////////////////////////////////////////////////////
907+
// Virtual method: OnPieMenu
908+
//////////////////////////////////////////////////////////////////////////////////////////
909+
// Description: Executes the Lua-defined OnPieMenu event handler.
910+
// Arguments: Actor which triggered the pie menu event
911+
// Return value: An error return value signaling sucess or any particular failure.
912+
// Anything below 0 is an error signal.
913+
914+
virtual int OnPieMenu(Actor * pActor);
915+
916+
906917
//////////////////////////////////////////////////////////////////////////////////////////
907918
// Virtual method: Draw
908919
//////////////////////////////////////////////////////////////////////////////////////////

Entities/Actor.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,7 @@ int Actor::ReadProperty(std::string propName, Reader &reader)
387387
PieMenuGUI::Slice newSlice;
388388
reader >> newSlice;
389389
m_PieSlices.push_back(newSlice);
390+
PieMenuGUI::AddAvailableSlice(newSlice);
390391
}
391392
else if (propName == "AIMode")
392393
{

Entities/Entity.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,8 @@ void Entity::Clear()
214214
m_Groups.clear();
215215
m_LastGroupSearch.clear();
216216
m_LastGroupResult = false;
217+
218+
m_RandomWeight = 1;
217219
}
218220

219221

@@ -246,6 +248,8 @@ int Entity::Create(const Entity &reference)
246248
for (list<string>::const_iterator itr = reference.m_Groups.begin(); itr != reference.m_Groups.end(); ++itr)
247249
m_Groups.push_back(*itr);
248250

251+
m_RandomWeight = reference.m_RandomWeight;
252+
249253
return 0;
250254
}
251255

@@ -318,6 +322,14 @@ int Entity::ReadProperty(std::string propName, Reader &reader)
318322
}
319323
else if (propName == "Description")
320324
reader >> m_PresetDescription;
325+
else if (propName == "RandomWeight")
326+
{
327+
reader >> m_RandomWeight;
328+
if (m_RandomWeight < 0)
329+
m_RandomWeight = 0;
330+
if (m_RandomWeight > 100)
331+
m_RandomWeight = 100;
332+
}
321333
else if (propName == "AddToGroup")
322334
{
323335
string newGroup;

Entities/Entity.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -669,6 +669,17 @@ class Entity:
669669
friend Reader & operator>>(Reader &reader, Entity *operand);
670670

671671

672+
//////////////////////////////////////////////////////////////////////////////////////////
673+
// Friend operator: GetRandomWeight
674+
//////////////////////////////////////////////////////////////////////////////////////////
675+
// Description: Returns random weight used in PresetMan::GetRandomBuyableOfGroupFromTech
676+
// Arguments: None.
677+
// Return value: This item's random weight from 0 to 100
678+
679+
int GetRandomWeight() const { return m_RandomWeight; }
680+
681+
682+
672683
//////////////////////////////////////////////////////////////////////////////////////////
673684
// Protected member variable and method declarations
674685

@@ -695,6 +706,9 @@ class Entity:
695706
std::string m_LastGroupSearch;
696707
// Last group search result, for more efficient response on multiple tries for the same group name
697708
bool m_LastGroupResult;
709+
// Random weight used when picking item using PresetMan::GetRandomBuyableOfGroupFromTech.
710+
// From 0 to 100. 0 means item won't be ever picked.
711+
int m_RandomWeight;
698712

699713

700714
//////////////////////////////////////////////////////////////////////////////////////////

Entities/GAScripted.cpp

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,13 @@ int GAScripted::ReadProperty(std::string propName, Reader &reader)
126126
reader >> m_ScriptPath;
127127
else if (propName == "LuaClassName")
128128
reader >> m_LuaClassName;
129-
else
129+
else if (propName == "AddPieSlice")
130+
{
131+
PieMenuGUI::Slice newSlice;
132+
reader >> newSlice;
133+
PieMenuGUI::AddAvailableSlice(newSlice);
134+
}
135+
else
130136
// See if the base class(es) can find a match instead
131137
return GameActivity::ReadProperty(propName, reader);
132138

@@ -295,6 +301,25 @@ void GAScripted::EnteredOrbit(Actor *pActor)
295301
m_pOrbitedCraft = 0;
296302
}
297303

304+
void GAScripted::OnPieMenu(Actor *pActor)
305+
{
306+
m_pPieMenuActor = pActor;
307+
if (pActor && g_MovableMan.IsActor(pActor))
308+
{
309+
m_pPieMenuActor->OnPieMenu(pActor);
310+
311+
g_MovableMan.OnPieMenu(pActor);
312+
313+
// Call the defined function, but only after first checking if it exists
314+
g_LuaMan.RunScriptString("if " + m_LuaClassName + ".OnPieMenu then " + m_LuaClassName + ":OnPieMenu(); end");
315+
316+
// Trigger pie menu for all global scripts
317+
for (std::vector<GlobalScript *>::iterator sItr = m_GlobalScriptsList.begin(); sItr < m_GlobalScriptsList.end(); ++sItr)
318+
if ((*sItr)->IsActive())
319+
(*sItr)->OnPieMenu(m_pPieMenuActor);
320+
}
321+
322+
}
298323

299324
//////////////////////////////////////////////////////////////////////////////////////////
300325
// Virtual method: Start

Entities/GAScripted.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,16 @@ ENTITYALLOCATION(GAScripted)
296296
virtual void UpdateGlobalScripts(bool lateUpdate);
297297

298298

299+
//////////////////////////////////////////////////////////////////////////////////////////
300+
// Method: OnPieMenu
301+
//////////////////////////////////////////////////////////////////////////////////////////
302+
// Description: Calls this to be processed by derived classes to enable pie-menu dynamic change
303+
// Arguments: None.
304+
// Return value: None.
305+
306+
virtual void OnPieMenu(Actor *pActor);
307+
308+
299309
//////////////////////////////////////////////////////////////////////////////////////////
300310
// Virtual method: DrawGUI
301311
//////////////////////////////////////////////////////////////////////////////////////////

Entities/GameActivity.cpp

Lines changed: 90 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ void GameActivity::Clear()
125125
m_GameOverPeriod = 5000;
126126
m_WinnerTeam = -1;
127127
m_pOrbitedCraft = 0;
128+
m_pPieMenuActor = 0;
128129
m_DemoTimer.Reset();
129130
m_PausedDemoTime = 0;
130131
}
@@ -710,7 +711,23 @@ bool GameActivity::CreateDelivery(int player, int mode, Vector &waypoint, Actor
710711
nativeCostMult = pMetaPlayer->GetNativeCostMultiplier();
711712
}
712713
// Start with counting the craft
713-
float totalCost = pDeliveryCraft->GetGoldValue(nativeModule, foreignCostMult, nativeCostMult);
714+
float totalCost = 0;
715+
716+
if (m_pBuyGUI[player]->GetOnlyShowOwnedItems())
717+
{
718+
if (!m_pBuyGUI[player]->CommitPurchase(pDeliveryCraft->GetModuleAndPresetName()))
719+
{
720+
if (m_pBuyGUI[player]->IsAlwaysAllowedItem(pDeliveryCraft->GetModuleAndPresetName()))
721+
totalCost = pDeliveryCraft->GetGoldValue(nativeModule, foreignCostMult, nativeCostMult);
722+
else
723+
return false;
724+
}
725+
}
726+
else
727+
{
728+
if (!m_pBuyGUI[player]->CommitPurchase(pDeliveryCraft->GetModuleAndPresetName()))
729+
totalCost = pDeliveryCraft->GetGoldValue(nativeModule, foreignCostMult, nativeCostMult);
730+
}
714731

715732
// Go through the list of things ordered, and give any actors all the items that is present after them,
716733
// until the next actor. Also, the first actor gets all stuff in the list above him.
@@ -734,53 +751,73 @@ bool GameActivity::CreateDelivery(int player, int mode, Vector &waypoint, Actor
734751
crabCount = -1;
735752
}
736753

754+
bool purchaseItem = true;
755+
737756
// Add to the total cost tally
738-
totalCost += (*itr)->GetGoldValue(nativeModule, foreignCostMult, nativeCostMult);
739-
// Make copy of the preset instance in the list
740-
pInventoryObject = dynamic_cast<MovableObject *>((*itr)->Clone());
741-
// See if it's actually a passenger, as opposed to a regular item
742-
pPassenger = dynamic_cast<Actor *>(pInventoryObject);
743-
// If it's an actor, then set its team and add it to the Craft's inventory!
744-
if (pPassenger)
745-
{
746-
// If this is the first passenger, then give him all the shit found in the list before him
747-
if (!pLastPassenger)
748-
{
749-
for (list<MovableObject *>::iterator iItr = cargoItems.begin(); iItr != cargoItems.end(); ++iItr)
750-
pPassenger->AddInventoryItem(*iItr);
751-
}
752-
// This isn't the first passenger, so give the previous guy all the stuff that was found since processing him
753-
else
754-
{
755-
for (list<MovableObject *>::iterator iItr = cargoItems.begin(); iItr != cargoItems.end(); ++iItr)
756-
pLastPassenger->AddInventoryItem(*iItr);
757-
}
758-
// Clear out the temporary cargo list since we've assign all the stuff in it to a passenger
759-
cargoItems.clear();
757+
if (m_pBuyGUI[player]->GetOnlyShowOwnedItems())
758+
{
759+
if (!m_pBuyGUI[player]->CommitPurchase((*itr)->GetModuleAndPresetName()))
760+
{
761+
if (m_pBuyGUI[player]->IsAlwaysAllowedItem((*itr)->GetModuleAndPresetName()))
762+
totalCost += (*itr)->GetGoldValue(nativeModule, foreignCostMult, nativeCostMult);
763+
else
764+
purchaseItem = false;
765+
}
766+
}
767+
else
768+
{
769+
if (!m_pBuyGUI[player]->CommitPurchase((*itr)->GetModuleAndPresetName()))
770+
totalCost += (*itr)->GetGoldValue(nativeModule, foreignCostMult, nativeCostMult);
771+
}
760772

761-
// Now set the current passenger as the 'last passenger' so he'll eventually get everything found after him.
762-
pLastPassenger = pPassenger;
763-
// Set the team etc for the current passenger and stuff him into the craft
764-
pPassenger->SetTeam(team);
765-
pPassenger->SetControllerMode(Controller::CIM_AI);
766-
pPassenger->SetAIMode((Actor::AIMode)mode);
773+
if (purchaseItem)
774+
{
775+
// Make copy of the preset instance in the list
776+
pInventoryObject = dynamic_cast<MovableObject *>((*itr)->Clone());
777+
// See if it's actually a passenger, as opposed to a regular item
778+
pPassenger = dynamic_cast<Actor *>(pInventoryObject);
779+
// If it's an actor, then set its team and add it to the Craft's inventory!
780+
if (pPassenger)
781+
{
782+
// If this is the first passenger, then give him all the shit found in the list before him
783+
if (!pLastPassenger)
784+
{
785+
for (list<MovableObject *>::iterator iItr = cargoItems.begin(); iItr != cargoItems.end(); ++iItr)
786+
pPassenger->AddInventoryItem(*iItr);
787+
}
788+
// This isn't the first passenger, so give the previous guy all the stuff that was found since processing him
789+
else
790+
{
791+
for (list<MovableObject *>::iterator iItr = cargoItems.begin(); iItr != cargoItems.end(); ++iItr)
792+
pLastPassenger->AddInventoryItem(*iItr);
793+
}
794+
// Clear out the temporary cargo list since we've assign all the stuff in it to a passenger
795+
cargoItems.clear();
767796

768-
if (pTargetMO != NULL)
769-
{
770-
Actor * pTarget = dynamic_cast<Actor *>(pTargetMO);
771-
if (pTarget)
772-
pPassenger->AddAIMOWaypoint(pTarget);
773-
}
774-
else if (waypoint.m_X > 0 && waypoint.m_Y > 0)
775-
{
776-
pPassenger->AddAISceneWaypoint(waypoint);
777-
}
797+
// Now set the current passenger as the 'last passenger' so he'll eventually get everything found after him.
798+
pLastPassenger = pPassenger;
799+
// Set the team etc for the current passenger and stuff him into the craft
800+
pPassenger->SetTeam(team);
801+
pPassenger->SetControllerMode(Controller::CIM_AI);
802+
pPassenger->SetAIMode((Actor::AIMode)mode);
778803

779-
pDeliveryCraft->AddInventoryItem(pPassenger);
780-
}
781-
// If not, then add it to the temp list of items which will be added to the last passenger's inventory
782-
else
783-
cargoItems.push_back(pInventoryObject);
804+
if (pTargetMO != NULL)
805+
{
806+
Actor * pTarget = dynamic_cast<Actor *>(pTargetMO);
807+
if (pTarget)
808+
pPassenger->AddAIMOWaypoint(pTarget);
809+
}
810+
else if (waypoint.m_X > 0 && waypoint.m_Y > 0)
811+
{
812+
pPassenger->AddAISceneWaypoint(waypoint);
813+
}
814+
815+
pDeliveryCraft->AddInventoryItem(pPassenger);
816+
}
817+
// If not, then add it to the temp list of items which will be added to the last passenger's inventory
818+
else
819+
cargoItems.push_back(pInventoryObject);
820+
}
784821
}
785822

786823
if (crabCount == 500)
@@ -1936,7 +1973,15 @@ void GameActivity::Update()
19361973
//PieMenuGUI::Slice ceaseFireSlice("Propose Cease Fire", PieMenuGUI::PSI_CEASEFIRE, PieMenuGUI::Slice::RIGHT, false);
19371974
//m_pPieMenu[player]->AddSlice(ceaseFireSlice, true);
19381975
}
1939-
// Init the new slice positions and sizes
1976+
1977+
// Init the new slice positions and sizes, build the list of slices in menu
1978+
m_pPieMenu[player]->RealignSlices();
1979+
m_CurrentPieMenuPlayer = player;
1980+
m_CurrentPieMenuSlices = GetCurrentPieMenuSlices(player);
1981+
1982+
OnPieMenu(m_pControlledActor[player]);
1983+
1984+
// Realigns slices after possible external pie-menu changes
19401985
m_pPieMenu[player]->RealignSlices();
19411986
// Enable the pie menu
19421987
m_pPieMenu[player]->SetEnabled(true);

0 commit comments

Comments
 (0)