|
|
|
@ -77,6 +77,7 @@ class Object{ |
|
|
|
|
Flag enableFlag=Flag::NONE; |
|
|
|
|
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 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.
|
|
|
|
|
bool Collision(vd2d pos) { |
|
|
|
|
GAME->SetDrawTarget(layer::COLLISION); |
|
|
|
@ -293,6 +294,7 @@ class Encounter{ |
|
|
|
|
int chance; //Chance of the encounter existing.
|
|
|
|
|
std::vector<Entity*>objs; |
|
|
|
|
std::array<vd2d,4> playerPos; |
|
|
|
|
int id; |
|
|
|
|
Encounter(vd2d pos,std::array<vd2d,4> playerPos,std::vector<Entity*>objs,int chance=25) |
|
|
|
|
: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(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (!GetGameFlag(Flag::TEST_FLAG1)) { |
|
|
|
|
StartCutscene(TestCutscene); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
switch (CurrentAction) { |
|
|
|
|
case ActionType::SET_FLAG_WHEN_CUTSCENE_ENDS:{ |
|
|
|
|
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(); |
|
|
|
|
SetDrawTarget(nullptr); |
|
|
|
|
DrawRectDecal((HIGHLIGHTED_TILE)*32-cameraPos,{32,32},YELLOW); |
|
|
|
|
/*if (EDITING_LAYER==layer::OBJECT) {
|
|
|
|
|
if (EDITING_LAYER==layer::OBJECT) { |
|
|
|
|
DrawStringPropDecal({2,2},"Editing Objects"); |
|
|
|
|
} else { |
|
|
|
|
DrawStringPropDecal({2,2},"Editing Layer "+std::to_string(EDITING_LAYER)); |
|
|
|
|
}*/ |
|
|
|
|
} |
|
|
|
|
}break; |
|
|
|
|
case GameState::TILE_SELECT:{ |
|
|
|
|
//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) { |
|
|
|
|
int marker=data.find_first_of(';'); |
|
|
|
|
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); |
|
|
|
|
std::stringstream split2(data.substr(lastMarker+1,marker-lastMarker-1)); |
|
|
|
|
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; |
|
|
|
|
split4>>id; |
|
|
|
|
|
|
|
|
|
if (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); |
|
|
|
|
} |
|
|
|
|
LoadEncounter(map,{x,y},pct,id,rand()%100<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++) { |
|
|
|
|
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'); |
|
|
|
|
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++) { |
|
|
|
|
f.put(obj[i]); |
|
|
|
|
for (int j=0;j<obj.length();j++) { |
|
|
|
|
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)]; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void LoadEncounter(Map*map,vd2d pos,int chance,int id) { |
|
|
|
|
void LoadEncounter(Map*map,vd2d pos,int chance,int id,bool successful) { |
|
|
|
|
Encounter*data; |
|
|
|
|
switch (id) { |
|
|
|
|
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::TESTMOVE3], |
|
|
|
|
}), |
|
|
|
|
} |
|
|
|
|
,chance); |
|
|
|
|
}); |
|
|
|
|
}break; |
|
|
|
|
case encounter::ENCOUNTER_2:{ |
|
|
|
|
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::TESTMOVE3], |
|
|
|
|
}), |
|
|
|
|
} |
|
|
|
|
,chance); |
|
|
|
|
}); |
|
|
|
|
}break; |
|
|
|
|
case encounter::ENCOUNTER_3:{ |
|
|
|
|
data=new Encounter(pos,std::array<vd2d,4>{vd2d |
|
|
|
@ -1724,16 +1736,25 @@ goes on a very long time, I hope you can understand this is only for testing pur |
|
|
|
|
MOVELIST[BattleMoveName::TESTMOVE2], |
|
|
|
|
MOVELIST[BattleMoveName::TESTMOVE3], |
|
|
|
|
}), |
|
|
|
|
} |
|
|
|
|
,chance); |
|
|
|
|
}); |
|
|
|
|
}break; |
|
|
|
|
default:{ |
|
|
|
|
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); |
|
|
|
|
for (int i=0;i<data->objs.size();i++) { |
|
|
|
|
AddObjectToWorld(data->objs[i]->obj); |
|
|
|
|
if (successful) { |
|
|
|
|
AddObjectToWorld(data->objs[i]->obj); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|