Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sandbox update #9

Merged
merged 2 commits into from
Jun 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions include/AI/AIScripts.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class AIScript {
Util::Time m_Time;

bool m_active;
float m_paid =0;

public:
AIScript(){};
Expand Down
12 changes: 9 additions & 3 deletions src/AI/AIScripts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
//
#include "AI/AIScripts.hpp"

#define MAX_TROOPS_SIZE 50
#define MAX_TROOPS_SIZE 30
void AIScript::Start(std::shared_ptr<UnitManager> GameObjectManager,
std::shared_ptr<UnitManager> EnemyObjectManager,
std::shared_ptr<MapClass> map, bool active) {
Expand Down Expand Up @@ -38,7 +38,9 @@ void AIScript::Update() {
m_mainDeltaTime = 0;
if (m_buildingCDTime < 1.f) {
m_EnemyObjectManager->addTotalCurrency(m_buildingCost / (-1.f));
m_paid += m_buildingCost /m_buildingCDTime * (-1.f);
} else {
m_paid += m_buildingCost /m_buildingCDTime * (-1.f);
m_EnemyObjectManager->addTotalCurrency(m_buildingCost /
m_buildingCDTime * (-1.f));
}
Expand Down Expand Up @@ -120,6 +122,7 @@ void AIScript::setCost(float cost, SpawnMode spawnMode) {
}
if (spawnMode == SpawnMode::BUILDINGS) {
m_buildingCost = cost;
m_paid = 0;
if(m_EnemyObjectManager->getCheatMode()){
m_buildingCost = 1;
}
Expand All @@ -128,6 +131,9 @@ void AIScript::setCost(float cost, SpawnMode spawnMode) {

void AIScript::buildBasic() {
if (m_selectedBuildingType != UnitType::NONE) {
if(m_selectedBuildingType != UnitType::ORE_REF && m_EnemyObjectManager->getTotalCurrency() > 2000+100-m_paid){
spawnUnit();
}
return;
}
if (m_EnemyObjectManager->getUnitConstructCount(UnitType::POWER_PLANT) <
Expand Down Expand Up @@ -171,10 +177,10 @@ void AIScript::buildADV() {

void AIScript::spawnUnit() {
if (m_selectedAvatarType != UnitType::NONE ||
m_EnemyObjectManager->getAvatarCount() > 16) {
m_EnemyObjectManager->getAvatarCount() > MAX_TROOPS_SIZE) {
return;
}
if (m_EnemyObjectManager->getAvatarCount() <= 25 &&
if (m_EnemyObjectManager->getAvatarCount() <= MAX_TROOPS_SIZE &&
m_EnemyObjectManager->getTotalCurrency() > 100) {
setCDTime(5.f, SpawnMode::AVATAR);
setCost(100, SpawnMode::AVATAR);
Expand Down
Loading