Skip to content

Commit

Permalink
Merge pull request #5 from Rushwind13/develop
Browse files Browse the repository at this point in the history
0.06
  • Loading branch information
Rushwind13 committed Dec 6, 2017
2 parents 7ad1cdf + d5b2cd0 commit 65dc636
Show file tree
Hide file tree
Showing 48 changed files with 437 additions and 288 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.DS_Store
*.png
*.txt

Expand Down
7 changes: 4 additions & 3 deletions AIMgr.cpp
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ m_eBrainState(BRAINSTATE_INVALID)
}

bool CAIBrain::Update( float fCurTime )
{
{
m_pParent->m_fColorChangeInterval += fCurTime;
switch( m_eBrainState )
{
case BRAINSTATE_REST:
Expand Down Expand Up @@ -126,7 +127,7 @@ bool CAIBrain::SetRandomDest(float fCurTime)

dest = m_vPos + delta;

if( Util::IsInWorld(dest) && (g_pGame->GetDungeon()->IsWalkable(dest) == DUNG_COLL_NO_COLLISION) )
if( Util::IsInWorld(dest) && (g_pGame->GetDungeon()->IsWalkableFor(dest) == DUNG_COLL_NO_COLLISION) )
{
//printf( "dest <%f %f> delta <%f %f>\n", VEC_EXPAND(dest), VEC_EXPAND(delta) );
//m_vDest = dest;
Expand All @@ -144,4 +145,4 @@ bool CAIBrain::SetRandomDest(float fCurTime)
bool CAIBrain::WalkSeek(float fCurTime)
{
return true;
}
}
Empty file modified AIMgr.h
100755 → 100644
Empty file.
2 changes: 1 addition & 1 deletion CmdState.cpp
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ void CCmdState::GetDir(SDL_Keysym *keysym, JVector &vDir)

int CCmdState::TestCollision( JVector &vTest )
{
return (g_pGame->GetDungeon()->IsWalkable(vTest));
return (g_pGame->GetDungeon()->IsWalkableFor(vTest, true));
}

void CCmdState::UpdatePlayerPos( JVector &vNewPos )
Expand Down
Empty file modified CmdState.h
100755 → 100644
Empty file.
Empty file modified Constants.cpp
100755 → 100644
Empty file.
24 changes: 16 additions & 8 deletions Constants.h
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
// how to make them work with CL /EP for monsters.dat
#ifndef __CONSTANTS_H__
#define __CONSTANTS_H__
#include <stdio.h>
#include <stdio.h>

#define VERSION "0.06"

// all the states which the game can run in
// this modifies the event handling
Expand Down Expand Up @@ -53,7 +55,8 @@
#define MON_IDX_ICKY 2
#define MON_IDX_DRAGON 3
#define MON_IDX_ANCIENT_DRAGON 4
#define MON_IDX_MAX 5
#define MON_IDX_SNAKE 5
#define MON_IDX_MAX 6

#define MON_FLAG_SPORE 0x00000001
#define MON_FLAG_TOUCH 0x00000002
Expand All @@ -63,13 +66,16 @@
#define MON_FLAG_CLAW 0x00000010
#define MON_FLAG_POISON 0x00000020
#define MON_FLAG_FIRE 0x00000040


#define MON_FLAG_BREATHE 0x00000100
#define MON_AI_DONTMOVE 0x00010000
#define MON_AI_100RANDOMMOVE 0x00020000
#define MON_AI_75RANDOMMOVE 0x00040000

#define MON_COLOR_MULTI 0x01000000

// Make sure you change below here if you added any flags.
#define NUM_STRINGS 15
#define NUM_STRINGS 16
#include "TextEntry.h"
class Constants
{
Expand All @@ -86,16 +92,18 @@ class Constants
m_StringTable[i++].Init("MON_IDX_SHROOM", MON_IDX_SHROOM);
m_StringTable[i++].Init("MON_IDX_JELLY", MON_IDX_JELLY);
m_StringTable[i++].Init("MON_IDX_ICKY", MON_IDX_ICKY);
m_StringTable[i++].Init("MON_IDX_ANCIENT_DRAGON", MON_IDX_ANCIENT_DRAGON);
m_StringTable[i++].Init("MON_IDX_DRAGON", MON_IDX_DRAGON);
m_StringTable[i++].Init("MON_IDX_DRAGON", MON_IDX_DRAGON);
m_StringTable[i++].Init("MON_IDX_ANCIENT_DRAGON", MON_IDX_ANCIENT_DRAGON);
m_StringTable[i++].Init("MON_IDX_SNAKE", MON_IDX_SNAKE);
// attack types
m_StringTable[i++].Init("MON_FLAG_SPORE", MON_FLAG_SPORE);
m_StringTable[i++].Init("MON_FLAG_TOUCH", MON_FLAG_TOUCH);
m_StringTable[i++].Init("MON_FLAG_BITE", MON_FLAG_BITE);
m_StringTable[i++].Init("MON_FLAG_DROOL", MON_FLAG_DROOL);
m_StringTable[i++].Init("MON_FLAG_CLAW", MON_FLAG_CLAW);
m_StringTable[i++].Init("MON_FLAG_POISON", MON_FLAG_POISON);
m_StringTable[i++].Init("MON_FLAG_FIRE", MON_FLAG_FIRE);
m_StringTable[i++].Init("MON_FLAG_POISON", MON_FLAG_POISON);
m_StringTable[i++].Init("MON_FLAG_FIRE", MON_FLAG_FIRE);
m_StringTable[i++].Init("MON_FLAG_BREATHE", MON_FLAG_BREATHE);
// AI flags
// movement flags
m_StringTable[i++].Init("MON_AI_DONTMOVE", MON_AI_DONTMOVE);
Expand Down
Empty file modified DisplayText.cpp
100755 → 100644
Empty file.
Empty file modified DisplayText.h
100755 → 100644
Empty file.
Empty file modified Draw.h
100755 → 100644
Empty file.
106 changes: 21 additions & 85 deletions Dungeon.cpp
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ void CDungeon::Init()
}
}

// Create the monster list
// Load the monster list from config
// TODO: Make this a method on CMonsterDef.
m_llMonsters = new JLinkList<CMonster>;
m_llMonsterDefs = new JLinkList<CMonsterDef>;

Expand All @@ -103,94 +104,21 @@ void CDungeon::Init()
}

delete pmd;


// Spawn a monster into dungeon
// TODO: make this into a method on CMonster.
#define RANDOM_MONSTER
#ifdef RANDOM_MONSTER
int which_monster = Util::GetRandom(0, m_llMonsterDefs->length()-1);
printf("trying to spawn monster %d\n", which_monster);
#else
int which_monster = m_llMonsterDefs->length()-1;
//which_monster = 0;
#endif // RANDOM_MONSTER
CMonsterDef *chosen_monster = m_llMonsterDefs->GetLink(which_monster)->m_lpData;

CMonster *pMon;
pMon = new CMonster;
pMon->Init(chosen_monster);


pMon->m_pllLink = m_llMonsters->Add(pMon);
g_pGame->GetAIMgr()->m_llAIBrains->Add(pMon->m_pBrain);
pMon->m_pBrain->SetParent(pMon);

/*
CMonster *pMon, *pMon2, *pMon3;
CMonsterDef *pmd, *pmd2, *pmd3;
pMon = new CMonster;
pMon2 = new CMonster;
pMon3 = new CMonster;
pmd = new CMonsterDef;
pmd2 = new CMonsterDef;
pmd3 = new CMonsterDef;
// jelly; monster 1
pMon2->m_pBrain->m_fSpeed = 0.0f;
pMon2->m_pBrain->m_dwMoveType = MON_AI_DONTMOVE;
pMon2->m_pBrain->SetState(BRAINSTATE_REST);
pmd2->m_fBaseHP = 10.0f;
pmd2->m_fBaseAC = 10.0f;
pmd2->m_dwIndex = MonIDs[MON_IDX_JELLY] - ' ' - 1;
pmd2->m_dwType = MON_IDX_JELLY;
pmd2->m_dwFlags = MON_FLAG_TOUCH;
pmd2->m_szName = new char[32];
pmd2->m_Color.SetColor(255,0,0,255);
sprintf( pmd2->m_szName, "Red Jelly" );
pMon2->Init(pmd2);
pMon2->m_pllLink = m_llMonsters->Add(pMon2);
g_pGame->GetAIMgr()->m_llAIBrains->Add(pMon2->m_pBrain);
pMon2->m_pBrain->SetParent(pMon2);
// mushroom patch; monster 2
pMon->m_pBrain->m_fSpeed = 0.0f;
pMon->m_pBrain->m_dwMoveType = MON_AI_DONTMOVE;
pMon->m_pBrain->SetState(BRAINSTATE_REST);
pmd->m_fBaseHP = 4.0f;
pmd->m_fBaseAC = 50.0f;
pmd->m_dwIndex = MonIDs[MON_IDX_SHROOM] - ' ' - 1;
pmd->m_dwType = MON_IDX_SHROOM;
pmd->m_dwFlags = MON_FLAG_SPORE;
pmd->m_szName = new char[32];
pmd->m_Color.SetColor(255,255,0,255);
sprintf( pmd->m_szName, "Yellow Mushroom Patch" );
pMon->Init(pmd);
pMon->m_pllLink = m_llMonsters->Add(pMon);
g_pGame->GetAIMgr()->m_llAIBrains->Add(pMon->m_pBrain);
pMon->m_pBrain->SetParent(pMon);
// icky thing; random mover
pMon3->m_pBrain->m_fSpeed = 1.0f;
pMon3->m_pBrain->m_dwMoveType = MON_AI_100RANDOMMOVE;
pMon3->m_pBrain->SetState(BRAINSTATE_SEEK);
pmd3->m_fBaseHP = 4.0f;
pmd3->m_fBaseAC = 50.0f;
pmd3->m_dwIndex = MonIDs[MON_IDX_ICKY] - ' ' - 1;
pmd3->m_dwType = MON_IDX_ICKY;
pmd3->m_dwFlags = MON_FLAG_TOUCH|MON_AI_100RANDOMMOVE;
pmd3->m_szName = new char[32];
pmd3->m_Color.SetColor(0,0,255,255);
sprintf( pmd3->m_szName, "Blue Icky Thing" );
pMon3->Init(pmd3);
pMon3->m_pllLink = m_llMonsters->Add(pMon3);
g_pGame->GetAIMgr()->m_llAIBrains->Add(pMon3->m_pBrain);
pMon3->m_pBrain->SetParent(pMon3);
/* */
//
CMonsterDef *chosen_monster = m_llMonsterDefs->GetLink(which_monster)->m_lpData;
printf("Choosing monster %d, called %s\n", which_monster, chosen_monster->m_szName);

CMonster::CreateMonster(chosen_monster);

m_TileSet = new CTileset("Resources/Courier.png", 32, 32 );
}
Expand Down Expand Up @@ -322,7 +250,7 @@ void CDungeon::RemoveMonster( CMonster *pMon )
}


int CDungeon::IsWalkable( JVector &vPos )
int CDungeon::IsWalkableFor( JVector &vPos, bool isPlayer )
{
// Check for someone else standing there first (handles things that can walk thru walls)
CDungeonTile *curTile = GetTile(vPos);
Expand All @@ -331,10 +259,18 @@ int CDungeon::IsWalkable( JVector &vPos )
printf("Hey! That's a bad tile.\n");
return false;
}
if( curTile->m_pCurMonster != NULL )
if( isPlayer && curTile->m_pCurMonster != NULL )
{
return DUNG_COLL_MONSTER;
}
else if( !isPlayer
&& g_pGame->GetPlayer()
&& g_pGame->GetPlayer()->m_HasSpawned
&& g_pGame->GetPlayer()->m_vPos == vPos )
{
printf("Monster attacking not implemented yet.\n");
return DUNG_COLL_PLAYER;
}

// If you get here, the square was unoccupied. Now check for running into inanimates...
int type = curTile->m_dtd->m_dwType;
Expand Down
4 changes: 2 additions & 2 deletions Dungeon.h
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class CDungeon
// casting to int is *absolutely* the wrong way to do this. fix this once it inevitably breaks.
return (m_Tiles + ((int)vPos.y * DUNG_WIDTH) + (int)vPos.x ); // going to have to work in offsets, too, if the dungeon's bigger than the screen. --Jimbo
};
int IsWalkable( JVector &vPos );
int IsWalkableFor( JVector &vPos, bool isPlayer=false );
bool IsOpenable( JVector &vPos );
bool IsTunnelable( JVector &vPos );
bool IsCloseable( JVector &vPos );
Expand All @@ -103,4 +103,4 @@ class CDungeon

bool IsOnScreen(JVector vPos);
};
#endif // __DUNGEON_H__
#endif // __DUNGEON_H__
Empty file modified DungeonConstants.h
100755 → 100644
Empty file.
Empty file modified DungeonMap.cpp
100755 → 100644
Empty file.
Empty file modified DungeonMap.h
100755 → 100644
Empty file.
Empty file modified DungeonTile.h
100755 → 100644
Empty file.
87 changes: 72 additions & 15 deletions FileParse.cpp
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,15 @@ CMonsterDef *CDataFile::ReadMonster(CMonsterDef &mdIn)
if( strncasecmp( szLine, "plural", 6 ) == 0 )
{
mdIn.m_szPlural = GetValue( szLine, mdIn.m_szPlural );
}
else if( strncasecmp( szLine, "speed", 5 ) == 0 )
{
mdIn.m_fSpeed = GetValue( szLine, mdIn.m_fSpeed );
}
}
else if( strncasecmp( szLine, "appear", 6 ) == 0 )
{
mdIn.m_szAppear = GetValue( szLine, mdIn.m_szAppear );
}
else if( strncasecmp( szLine, "speed", 5 ) == 0 )
{
mdIn.m_fSpeed = GetValue( szLine, mdIn.m_fSpeed );
}
else if( strncasecmp( szLine, "movetype", 8 ) == 0 )
{
szValue = GetValue( szLine, szValue );
Expand All @@ -119,12 +123,23 @@ CMonsterDef *CDataFile::ReadMonster(CMonsterDef &mdIn)
else if( strncasecmp( szLine, "expvalue", 8 ) == 0 )
{
GetValue( szLine, mdIn.m_dwExpValue );
}
else if( strncasecmp( szLine, "type", 4 ) == 0 )
{
szValue = GetValue( szLine, szValue );
mdIn.m_dwIndex = g_Constants.LookupString(szValue);
}
}
else if( strncasecmp( szLine, "type", 4 ) == 0 )
{
szValue = GetValue( szLine, szValue );
mdIn.m_dwIndex = g_Constants.LookupString(szValue);
}
else if( strncasecmp( szLine, "flags", 5 ) == 0 )
{
szValue = GetValue( szLine, szValue );

char *c = strtok( szValue, "," );
while( c != NULL )
{
mdIn.m_dwFlags |= g_Constants.LookupString(c);
c = strtok( NULL, "," );
}
}
else if( strncasecmp( szLine, "attack", 6 ) == 0 )
{
CAttack *curAttack;
Expand Down Expand Up @@ -186,8 +201,21 @@ CMonsterDef *CDataFile::ReadMonster(CMonsterDef &mdIn)
}
else if( strncasecmp( szLine, "color", 5 ) == 0 )
{
szValue = GetValue( szLine, szValue );
mdIn.m_Color.SetColor(szValue);
char *color = chomp( szLine, szValue );
if( strchr( color, '<' ) != NULL )
{
// multi-hued
// <<rgb1>,<rgb2>,...,<rgbn>>
mdIn.m_Colors = ParseColors(color);

mdIn.m_dwFlags |= MON_COLOR_MULTI;
}
else
{
// single-hued
// <rgb1>
mdIn.m_Color.SetColor(color);
}
}
else if( *szLine == '}' )
{
Expand All @@ -207,7 +235,9 @@ CMonsterDef *CDataFile::ReadMonster(CMonsterDef &mdIn)
return &mdIn;
}

char *CDataFile::GetValue(char *szLine, char *szIn)
// Removes outermost <> from data entry
char *CDataFile::GetValue(char *szLine, char *szIn) { return chomp(szLine, szIn); }
char *CDataFile::chomp(const char *szLine, char *szIn)
{
if( szLine == NULL || *szLine == nul )
{
Expand Down Expand Up @@ -237,6 +267,33 @@ char *CDataFile::GetValue(char *szLine, char *szIn)
return szIn;
}

JLinkList<JColor> * CDataFile::ParseColors(char *szLine)
{
JColor *outcolor=NULL;
char szToken[32][32];
int count=0;
char *temp = NULL;
JLinkList<JColor> *retval = new JLinkList<JColor>;
char *c = strtok( szLine, ";" );
while( c != NULL )
{
memset(szToken[count], 0, 32);
strcpy(szToken[count++], c);
c = strtok( NULL, ";" );
}

for( int i = 0; i < count; i++)
{
char *tok = szToken[i];
temp = chomp(tok, temp);
outcolor = new JColor();
outcolor->SetColor(temp);
retval->Add(outcolor);
}

return retval;
}

int CDataFile::GetValue(char *szLine, int &dwIn)
{
char label[100];
Expand All @@ -255,4 +312,4 @@ float CDataFile::GetValue(char *szLine, float &fIn)
fIn = (float)atof(value);

return fIn;
}
}
Loading

0 comments on commit 65dc636

Please sign in to comment.