Skip to content

Commit

Permalink
More work on meme wars mode
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinUbl committed Apr 21, 2013
1 parent 476081c commit 0b97ce2
Show file tree
Hide file tree
Showing 11 changed files with 71 additions and 35 deletions.
Binary file modified data/efcds/enemy.db3
Binary file not shown.
1 change: 1 addition & 0 deletions include/Display/Effects/Animations.h
Expand Up @@ -99,6 +99,7 @@ class Animator
void DestroyAnimTicket(uint32 id);
uint32 GetModelAnimTicket(uint32 modelId, uint32 animId, uint32 frameSkipSpeed = 1, uint8 flags = 0);
void ChangeModelAnim(uint32 ticketId, uint32 animId, uint32 startFrame = 0, uint32 frameSkipSpeed = 0, uint8 flags = 0);
void ChangeModelAnimFrameSpeed(uint32 ticketId, uint32 frameSkipSpeed);
uint32 GetActualTexture(uint32 id);
uint32 GetActualFrame(uint32 id);
uint32 GetAnimId(uint32 id);
Expand Down
4 changes: 4 additions & 0 deletions include/Gameplay/AI.h
Expand Up @@ -215,6 +215,9 @@ class MovementHolder
void Generator();
bool TryGenerator(MovementType moveType);

void SetTargettedMovementTarget(ModelDisplayListRecord* target) { m_target = target; };
ModelDisplayListRecord* GetTargettedMovementTarget() { return m_target; };

private:
MovementType m_moveType;

Expand All @@ -229,6 +232,7 @@ class MovementHolder
clock_t m_lastMoveUpdate;

EnemyTemplate* m_src;
ModelDisplayListRecord* m_target;
};

/** \fn MovementHolder::GetMovementType
Expand Down
1 change: 1 addition & 0 deletions include/Gameplay/ScriptMgr.h
Expand Up @@ -20,6 +20,7 @@ struct EnemyAI
virtual void OnCreate() {};

virtual void OnUpdate() {};
virtual bool OnMovementUpdate() { return false; };
virtual void OnDead() {};
virtual void OnDamageHit() {};
virtual bool AvoidDeath() { return false; };
Expand Down
1 change: 1 addition & 0 deletions include/Scripts/Loader.h
Expand Up @@ -8,5 +8,6 @@ extern void LoadScripts();

// Samotne skripty
extern void LoadDummyEnemyScripts();
extern void LoadMemeEnemyScripts();

#endif
2 changes: 1 addition & 1 deletion src/Display/Display.cpp
Expand Up @@ -894,7 +894,7 @@ void DisplayMgr::DrawBillboards()
// - Zvysuje vykon
// Vyjimkou jsou veci, co zas tolik nezatezuji - bonusy a podobne. Jde nam hlavne o zamezeni zobrazeni velkeho
// mnozstvi napriklad castic vybuchu
if (!(temp->textureId >= 33 && temp->textureId <= 35))
if (temp->textureId >= 57 && temp->textureId <= 60)
{
if (pythagoras_c(fabs(temp->x-fabs(m_targetX)), fabs(temp->z-fabs(m_targetZ))) > 14.0f)
{
Expand Down
16 changes: 16 additions & 0 deletions src/Display/Effects/Animations.cpp
Expand Up @@ -353,6 +353,22 @@ void Animator::ChangeModelAnim(uint32 ticketId, uint32 animId, uint32 startFrame
itr->second.frameSkipSpeed = frameSkipSpeed;
}

/** \brief Zmena rychlosti animace podle tiketu
*
* Stara se o zmenu rychlost animace (frame skip)
*/
void Animator::ChangeModelAnimFrameSpeed(uint32 ticketId, uint32 frameSkipSpeed)
{
if (ticketId == 0)
return;

AnimMap::iterator itr = Anims.find(ticketId);
if (itr == Anims.end() || itr->second.animType != ANIM_TYPE_MODEL)
return;

itr->second.frameSkipSpeed = frameSkipSpeed;
}

/** \brief Konstruktor
*
* Prazdny
Expand Down
67 changes: 39 additions & 28 deletions src/Gameplay/AI.cpp
Expand Up @@ -634,6 +634,7 @@ MovementHolder::MovementHolder(EnemyTemplate* src)
m_path.clear();
m_tryPath.clear();
m_src = src;
m_target = NULL;
m_moveType = MOVEMENT_NONE;
m_lastMoveUpdate = clock();
m_nodeStartTime = 0;
Expand Down Expand Up @@ -662,7 +663,11 @@ void MovementHolder::Generator()
case MOVEMENT_TARGETTED:
{
// Pokud se pohybujeme za cilem, musi cil existovat
ModelDisplayListRecord* pTarget = sDisplay->GetTargetModel();
ModelDisplayListRecord* pTarget = m_target;

if (!pTarget)
pTarget = sDisplay->GetTargetModel();

if (!pTarget)
{
m_path.clear();
Expand Down Expand Up @@ -766,7 +771,11 @@ bool MovementHolder::TryGenerator(MovementType moveType)
{
case MOVEMENT_TARGETTED:
{
ModelDisplayListRecord* pTarget = sDisplay->GetTargetModel();
ModelDisplayListRecord* pTarget = m_target;

if (!pTarget)
pTarget = sDisplay->GetTargetModel();

if (!pTarget)
{
m_moveType = MOVEMENT_NONE;
Expand Down Expand Up @@ -853,7 +862,7 @@ void MovementHolder::Mutate(MovementType moveType)

// Zmenime animaci modelu - je treba presunout asi, tady se mi to nelibi
if (sAnimator->GetAnimId(m_src->pRecord->AnimTicket) != ANIM_WALK)
sAnimator->ChangeModelAnim(m_src->pRecord->AnimTicket, ANIM_WALK, 0, 0);
sAnimator->ChangeModelAnim(m_src->pRecord->AnimTicket, ANIM_WALK, 0, 1);
}

/** \brief Pokusi se o zmenu movement generatoru, pokud existuje cesta
Expand All @@ -877,7 +886,7 @@ bool MovementHolder::TryMutate(MovementType moveType)

// Zmenime animaci modelu - je treba presunout asi, tady se mi to nelibi
if (sAnimator->GetAnimId(m_src->pRecord->AnimTicket) != ANIM_WALK)
sAnimator->ChangeModelAnim(m_src->pRecord->AnimTicket, ANIM_WALK, 0, 0);
sAnimator->ChangeModelAnim(m_src->pRecord->AnimTicket, ANIM_WALK, 0, 1);

return true;
}
Expand Down Expand Up @@ -924,7 +933,7 @@ void MovementHolder::Update()

// Opet zmena animace modelu na chuzi, tady se mi to taky nelibi, bude treba vymyslet nejake hezci umisteni
if (sAnimator->GetAnimId(m_src->pRecord->AnimTicket) != ANIM_WALK)
sAnimator->ChangeModelAnim(m_src->pRecord->AnimTicket, ANIM_WALK, 0, 0);
sAnimator->ChangeModelAnim(m_src->pRecord->AnimTicket, ANIM_WALK, 0, 1);

float timePass = 500 * m_speedMod * MOVEMENT_DELAY_COEF;
float timeDiff = tnow-m_nodeStartTime;
Expand Down Expand Up @@ -1048,9 +1057,6 @@ void EnemyTemplate::Init(uint32 enemyId, uint32 x, uint32 y, uint32 position)
sDisplay->AddModelFeature(pRecord, MF_TYPE_EMITTER, 0.0f, 2.0f, 0.0f, sParticleEmitterMgr->AddEmitter(
BillboardDisplayListRecord::Create(61, 0,0,0, 0.2f, 0.2f, true, true), 0,0,0,0.3f, 0.3f, 270.0f, 0.0f, 0.0f, 0.0f, 120, 10, 0.9f, 0.05f, 10,1, 0,0, 0,-1));
break;
case 11: // Headless bomberman - pouze Meme mody
sDisplay->AddModelFeature(pRecord, MF_TYPE_BILLBOARD, 0.0f, 1.55f, 0.0f, sDisplay->DrawBillboard(65, 0, 0, 0, 0, 1, 0.4f, 0.45f, false, true));
break;
}

m_AI->OnCreate();
Expand Down Expand Up @@ -1121,31 +1127,36 @@ void EnemyTemplate::Update()
* level 5 = navic jeste spolupracuje s jinymi neprateli
*/

if (m_AILevel >= 3)
// OnMovementUpdate metoda AI vraci, zdali byl prepsan standardni postup zmeny movement generatoru

if (!m_AI || !m_AI->OnMovementUpdate())
{
// Nejdrive zkusime, zdali se nejak muzeme dostat k cili
if (m_movement->GetMovementType() != MOVEMENT_TARGETTED)
if (m_AILevel >= 3)
{
if (!m_movement->TryMutate(MOVEMENT_TARGETTED))
// Nejdrive zkusime, zdali se nejak muzeme dostat k cili
if (m_movement->GetMovementType() != MOVEMENT_TARGETTED)
{
if (!m_movement->TryMutate(MOVEMENT_TARGETTED))
m_movement->TryMutate(MOVEMENT_OUTOFZERO);
}
}
if (m_AILevel >= 2)
{
// Pokud cesta neexistuje, muze to byt i tim, ze stojime na zablokovanem miste bombou nebo plamenem
if (!m_movement->HasPath())
m_movement->TryMutate(MOVEMENT_OUTOFZERO);
}
}
if (m_AILevel >= 2)
{
// Pokud cesta neexistuje, muze to byt i tim, ze stojime na zablokovanem miste bombou nebo plamenem
if (!m_movement->HasPath())
m_movement->TryMutate(MOVEMENT_OUTOFZERO);
}
if (m_AILevel >= 1)
{
// Pokud stale cesta neexistuje, jdeme tedy nahodne
if ((m_movement->GetMovementType() == MOVEMENT_TARGETTED || m_movement->GetMovementType() == MOVEMENT_OUTOFZERO) && !m_movement->HasPath())
if (m_AILevel >= 1)
{
// 2 a vice se umi vyhybat nebezpecnym polim, nizsi do nich muzou vejit a "spachat sebevrazdu"
if (m_AILevel < 2)
m_movement->TryMutate(MOVEMENT_RANDOM_BARE);
else
m_movement->TryMutate(MOVEMENT_RANDOM);
// Pokud stale cesta neexistuje, jdeme tedy nahodne
if ((m_movement->GetMovementType() == MOVEMENT_TARGETTED || m_movement->GetMovementType() == MOVEMENT_OUTOFZERO) && !m_movement->HasPath())
{
// 2 a vice se umi vyhybat nebezpecnym polim, nizsi do nich muzou vejit a "spachat sebevrazdu"
if (m_AILevel < 2)
m_movement->TryMutate(MOVEMENT_RANDOM_BARE);
else
m_movement->TryMutate(MOVEMENT_RANDOM);
}
}
}

Expand Down
9 changes: 3 additions & 6 deletions src/Gameplay/GameTypes/MemeSingleType.cpp
Expand Up @@ -16,9 +16,9 @@ void MemeSingleGameType::FillGameTypeResources()
{
gameResources.PlayerModelIDs.push_back(11);

// nepratele 1-5 jsou prirazeni poporade
// model bude prepsan ve specialni metode jejich skriptu
gameResources.EnemyIDs.push_back(0+sGameplayMgr->GetSetting(SETTING_ENEMY_AI_LEVEL));
gameResources.EnemyIDs.push_back(6);
gameResources.EnemyIDs.push_back(7);
gameResources.EnemyIDs.push_back(8);

// 62-69 jsou textury rage comics obliceju
for (uint32 i = 62; i <= 69; i++)
Expand Down Expand Up @@ -119,9 +119,6 @@ void MemeSingleGameType::OnUpdate()

(*itr)->Update();

if ((*itr)->pRecord && sDisplay->ModelIntersection(sGameplayMgr->GetPlayerRec(), (*itr)->pRecord))
sGameplayMgr->PlayerDied();

++itr;
}
}
Expand Down
1 change: 1 addition & 0 deletions src/Scripts/Loader.cpp
Expand Up @@ -4,4 +4,5 @@
void LoadScripts()
{
LoadDummyEnemyScripts();
LoadMemeEnemyScripts();
}
4 changes: 4 additions & 0 deletions win/bomber-scripts.vcproj
Expand Up @@ -153,6 +153,10 @@
RelativePath="..\src\Scripts\Loader.cpp"
>
</File>
<File
RelativePath="..\src\Scripts\EnemyScripts\MemeEnemy.cpp"
>
</File>
</Filter>
<Filter
Name="include"
Expand Down

0 comments on commit 0b97ce2

Please sign in to comment.