|
|
@ -77,6 +77,7 @@ class Object{ |
|
|
|
Flag enableFlag=Flag::NONE; |
|
|
|
Flag enableFlag=Flag::NONE; |
|
|
|
int objArrElement; //Which element in the object array this object is located in. For sorting purposes.
|
|
|
|
int objArrElement; //Which element in the object array this object is located in. For sorting purposes.
|
|
|
|
bool temp=false; //If set to true, it's marked for deletion after cutscene handling.
|
|
|
|
bool temp=false; //If set to true, it's marked for deletion after cutscene handling.
|
|
|
|
|
|
|
|
bool enc=false; //If set to true, it's not included in the main list of entities for map saving because it's from an encounter.
|
|
|
|
//animationSpd is how long to wait before switching frames.
|
|
|
|
//animationSpd is how long to wait before switching frames.
|
|
|
|
bool Collision(vd2d pos) { |
|
|
|
bool Collision(vd2d pos) { |
|
|
|
GAME->SetDrawTarget(layer::COLLISION); |
|
|
|
GAME->SetDrawTarget(layer::COLLISION); |
|
|
@ -293,6 +294,7 @@ class Encounter{ |
|
|
|
int chance; //Chance of the encounter existing.
|
|
|
|
int chance; //Chance of the encounter existing.
|
|
|
|
std::vector<Entity*>objs; |
|
|
|
std::vector<Entity*>objs; |
|
|
|
std::array<vd2d,4> playerPos; |
|
|
|
std::array<vd2d,4> playerPos; |
|
|
|
|
|
|
|
int id; |
|
|
|
Encounter(vd2d pos,std::array<vd2d,4> playerPos,std::vector<Entity*>objs,int chance=25) |
|
|
|
Encounter(vd2d pos,std::array<vd2d,4> playerPos,std::vector<Entity*>objs,int chance=25) |
|
|
|
:pos(pos),objs(objs),chance(chance),playerPos(playerPos){} |
|
|
|
:pos(pos),objs(objs),chance(chance),playerPos(playerPos){} |
|
|
|
}; |
|
|
|
}; |
|
|
@ -496,10 +498,6 @@ goes on a very long time, I hope you can understand this is only for testing pur |
|
|
|
CurrentCutscene->LockAction(); |
|
|
|
CurrentCutscene->LockAction(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (!GetGameFlag(Flag::TEST_FLAG1)) { |
|
|
|
|
|
|
|
StartCutscene(TestCutscene); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
switch (CurrentAction) { |
|
|
|
switch (CurrentAction) { |
|
|
|
case ActionType::SET_FLAG_WHEN_CUTSCENE_ENDS:{ |
|
|
|
case ActionType::SET_FLAG_WHEN_CUTSCENE_ENDS:{ |
|
|
|
CurrentCutscene->SetupEndingCutsceneFlag(((SetFlagWhenCutsceneEnds*)CurrentCutscene->GetAction())->GetCutsceneEndingFlag(),((SetFlagWhenCutsceneEnds*)CurrentCutscene->GetAction())->GetCutsceneEndingVal()); |
|
|
|
CurrentCutscene->SetupEndingCutsceneFlag(((SetFlagWhenCutsceneEnds*)CurrentCutscene->GetAction())->GetCutsceneEndingFlag(),((SetFlagWhenCutsceneEnds*)CurrentCutscene->GetAction())->GetCutsceneEndingVal()); |
|
|
@ -908,11 +906,11 @@ goes on a very long time, I hope you can understand this is only for testing pur |
|
|
|
DrawGameWorld(); |
|
|
|
DrawGameWorld(); |
|
|
|
SetDrawTarget(nullptr); |
|
|
|
SetDrawTarget(nullptr); |
|
|
|
DrawRectDecal((HIGHLIGHTED_TILE)*32-cameraPos,{32,32},YELLOW); |
|
|
|
DrawRectDecal((HIGHLIGHTED_TILE)*32-cameraPos,{32,32},YELLOW); |
|
|
|
/*if (EDITING_LAYER==layer::OBJECT) {
|
|
|
|
if (EDITING_LAYER==layer::OBJECT) { |
|
|
|
DrawStringPropDecal({2,2},"Editing Objects"); |
|
|
|
DrawStringPropDecal({2,2},"Editing Objects"); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
DrawStringPropDecal({2,2},"Editing Layer "+std::to_string(EDITING_LAYER)); |
|
|
|
DrawStringPropDecal({2,2},"Editing Layer "+std::to_string(EDITING_LAYER)); |
|
|
|
}*/ |
|
|
|
} |
|
|
|
}break; |
|
|
|
}break; |
|
|
|
case GameState::TILE_SELECT:{ |
|
|
|
case GameState::TILE_SELECT:{ |
|
|
|
//14x14 pixels per tile.
|
|
|
|
//14x14 pixels per tile.
|
|
|
@ -1075,7 +1073,7 @@ goes on a very long time, I hope you can understand this is only for testing pur |
|
|
|
if (data.find("OBJECT")!=std::string::npos||data.find("ENCOUNTER")!=std::string::npos) { |
|
|
|
if (data.find("OBJECT")!=std::string::npos||data.find("ENCOUNTER")!=std::string::npos) { |
|
|
|
int marker=data.find_first_of(';'); |
|
|
|
int marker=data.find_first_of(';'); |
|
|
|
int lastMarker=marker; |
|
|
|
int lastMarker=marker; |
|
|
|
std::stringstream split1(data.substr(6,marker-6)); |
|
|
|
std::stringstream split1((data.find("OBJECT")!=std::string::npos)?data.substr(6,marker-6):data.substr(9,marker-9)); |
|
|
|
marker=data.find_first_of(';',marker+1); |
|
|
|
marker=data.find_first_of(';',marker+1); |
|
|
|
std::stringstream split2(data.substr(lastMarker+1,marker-lastMarker-1)); |
|
|
|
std::stringstream split2(data.substr(lastMarker+1,marker-lastMarker-1)); |
|
|
|
lastMarker=marker; |
|
|
|
lastMarker=marker; |
|
|
@ -1114,12 +1112,7 @@ goes on a very long time, I hope you can understand this is only for testing pur |
|
|
|
int pct=id; |
|
|
|
int pct=id; |
|
|
|
split4>>id; |
|
|
|
split4>>id; |
|
|
|
|
|
|
|
|
|
|
|
if (rand()%100<pct) { |
|
|
|
LoadEncounter(map,{x,y},pct,id,rand()%100<pct); |
|
|
|
LoadEncounter(map,{x,y},pct,id); |
|
|
|
|
|
|
|
printf(" Encounter %d (%d\%) in world.\n",id,pct); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
printf(" Encounter %d (%d\%) Failed Roll Check.\n",id,pct); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
printf("Encounter %d (%d\%) Loaded.\n",id,pct); |
|
|
|
printf("Encounter %d (%d\%) Loaded.\n",id,pct); |
|
|
|
} |
|
|
|
} |
|
|
@ -1216,10 +1209,31 @@ goes on a very long time, I hope you can understand this is only for testing pur |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
for (int i=0;i<OBJECTS.size();i++) { |
|
|
|
for (int i=0;i<OBJECTS.size();i++) { |
|
|
|
|
|
|
|
bool allowed=true; |
|
|
|
|
|
|
|
for (int j=1;j<PARTY_MEMBER_COUNT;j++) { |
|
|
|
|
|
|
|
if (OBJECTS[i]==PARTY_MEMBER_OBJ[j]) { |
|
|
|
|
|
|
|
allowed=false; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (OBJECTS[i]->temp||OBJECTS[i]->enc) { |
|
|
|
|
|
|
|
continue; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (!allowed) { |
|
|
|
|
|
|
|
continue; |
|
|
|
|
|
|
|
} |
|
|
|
f.put('\n'); |
|
|
|
f.put('\n'); |
|
|
|
const std::string obj="OBJECT"+std::to_string(OBJECTS[i]->GetPos().x)+";"+std::to_string(OBJECTS[i]->GetPos().y)+";"+std::to_string(OBJECTS[i]->id); |
|
|
|
const std::string obj="OBJECT"+std::to_string(OBJECTS[i]->GetPos().x)+";"+std::to_string(OBJECTS[i]->GetPos().y)+";"+std::to_string(OBJECTS[i]->id); |
|
|
|
for (int i=0;i<obj.length();i++) { |
|
|
|
for (int j=0;j<obj.length();j++) { |
|
|
|
f.put(obj[i]); |
|
|
|
f.put(obj[j]); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (int i=0;i<map->encounters.size();i++) { |
|
|
|
|
|
|
|
f.put('\n'); |
|
|
|
|
|
|
|
const std::string enc="ENCOUNTER"+std::to_string(map->encounters[i]->pos.x)+";"+std::to_string(map->encounters[i]->pos.y)+";"+std::to_string(map->encounters[i]->chance)+";"+std::to_string(map->encounters[i]->id); |
|
|
|
|
|
|
|
for (int j=0;j<enc.length();j++) { |
|
|
|
|
|
|
|
f.put(enc[j]); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -1654,7 +1668,7 @@ goes on a very long time, I hope you can understand this is only for testing pur |
|
|
|
return GAME_FLAGS[toint(flag)]; |
|
|
|
return GAME_FLAGS[toint(flag)]; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void LoadEncounter(Map*map,vd2d pos,int chance,int id) { |
|
|
|
void LoadEncounter(Map*map,vd2d pos,int chance,int id,bool successful) { |
|
|
|
Encounter*data; |
|
|
|
Encounter*data; |
|
|
|
switch (id) { |
|
|
|
switch (id) { |
|
|
|
case encounter::ENCOUNTER_1:{ |
|
|
|
case encounter::ENCOUNTER_1:{ |
|
|
@ -1682,8 +1696,7 @@ goes on a very long time, I hope you can understand this is only for testing pur |
|
|
|
MOVELIST[BattleMoveName::TESTMOVE2], |
|
|
|
MOVELIST[BattleMoveName::TESTMOVE2], |
|
|
|
MOVELIST[BattleMoveName::TESTMOVE3], |
|
|
|
MOVELIST[BattleMoveName::TESTMOVE3], |
|
|
|
}), |
|
|
|
}), |
|
|
|
} |
|
|
|
}); |
|
|
|
,chance); |
|
|
|
|
|
|
|
}break; |
|
|
|
}break; |
|
|
|
case encounter::ENCOUNTER_2:{ |
|
|
|
case encounter::ENCOUNTER_2:{ |
|
|
|
data=new Encounter(pos,std::array<vd2d,4>{vd2d |
|
|
|
data=new Encounter(pos,std::array<vd2d,4>{vd2d |
|
|
@ -1710,8 +1723,7 @@ goes on a very long time, I hope you can understand this is only for testing pur |
|
|
|
MOVELIST[BattleMoveName::TESTMOVE2], |
|
|
|
MOVELIST[BattleMoveName::TESTMOVE2], |
|
|
|
MOVELIST[BattleMoveName::TESTMOVE3], |
|
|
|
MOVELIST[BattleMoveName::TESTMOVE3], |
|
|
|
}), |
|
|
|
}), |
|
|
|
} |
|
|
|
}); |
|
|
|
,chance); |
|
|
|
|
|
|
|
}break; |
|
|
|
}break; |
|
|
|
case encounter::ENCOUNTER_3:{ |
|
|
|
case encounter::ENCOUNTER_3:{ |
|
|
|
data=new Encounter(pos,std::array<vd2d,4>{vd2d |
|
|
|
data=new Encounter(pos,std::array<vd2d,4>{vd2d |
|
|
@ -1724,18 +1736,27 @@ goes on a very long time, I hope you can understand this is only for testing pur |
|
|
|
MOVELIST[BattleMoveName::TESTMOVE2], |
|
|
|
MOVELIST[BattleMoveName::TESTMOVE2], |
|
|
|
MOVELIST[BattleMoveName::TESTMOVE3], |
|
|
|
MOVELIST[BattleMoveName::TESTMOVE3], |
|
|
|
}), |
|
|
|
}), |
|
|
|
} |
|
|
|
}); |
|
|
|
,chance); |
|
|
|
|
|
|
|
}break; |
|
|
|
}break; |
|
|
|
default:{ |
|
|
|
default:{ |
|
|
|
printf("WARNING! Dead encounter found! THIS SHOULD NOT BE HAPPENING!"); |
|
|
|
printf("WARNING! Dead encounter found! THIS SHOULD NOT BE HAPPENING!"); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
data->chance=chance; |
|
|
|
|
|
|
|
data->id=id; |
|
|
|
|
|
|
|
for (int i=0;i<data->objs.size();i++) { |
|
|
|
|
|
|
|
data->objs[i]->obj->enc=true; |
|
|
|
|
|
|
|
if (!successful) { |
|
|
|
|
|
|
|
data->objs[i]->HP=0; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
map->encounters.push_back(data); |
|
|
|
map->encounters.push_back(data); |
|
|
|
for (int i=0;i<data->objs.size();i++) { |
|
|
|
for (int i=0;i<data->objs.size();i++) { |
|
|
|
|
|
|
|
if (successful) { |
|
|
|
AddObjectToWorld(data->objs[i]->obj); |
|
|
|
AddObjectToWorld(data->objs[i]->obj); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void UpdatePlayerTrail(vd2d newMovement) { |
|
|
|
void UpdatePlayerTrail(vd2d newMovement) { |
|
|
|
for (int i=PARTY_TRAIL_LENGTH-1;i>0;i--) { |
|
|
|
for (int i=PARTY_TRAIL_LENGTH-1;i>0;i--) { |
|
|
|