Added encounter data to the save map file format

Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
master
sigonasr2 2 years ago
parent 8ee9e1de23
commit 67ccb1d0c8
  1. BIN
      C++ProjectTemplate
  2. 10
      assets/maps/map0
  3. 2
      assets/maps/map0_5
  4. 1
      battlemoves.cpp
  5. 8
      battlemoves.h
  6. 65
      main.cpp

Binary file not shown.

@ -53,15 +53,16 @@ OBJECT224.000000;128.000000;8
OBJECT160.000000;128.000000;8
OBJECT192.000000;128.000000;8
OBJECT288.000000;128.000000;8
OBJECT313.000000;151.000000;8
OBJECT313.000000;131.000000;10
OBJECT192.000000;160.000000;8
OBJECT160.000000;160.000000;8
OBJECT256.000000;160.000000;8
OBJECT224.000000;160.000000;7
OBJECT288.000000;160.000000;7
OBJECT123.000000;163.000000;0
OBJECT313.000000;136.000000;11
OBJECT313.000000;141.000000;12
OBJECT313.000000;151.000000;8
OBJECT288.000000;160.000000;9
OBJECT224.000000;160.000000;9
OBJECT160.000000;192.000000;8
@ -74,12 +75,11 @@ OBJECT160.000000;224.000000;8
OBJECT288.000000;224.000000;8
OBJECT224.000000;224.000000;8
OBJECT256.000000;224.000000;7
OBJECT212.000000;228.000000;0
OBJECT288.000000;256.000000;8
OBJECT256.000000;256.000000;8
OBJECT224.000000;256.000000;8
OBJECT192.000000;256.000000;8
OBJECT160.000000;256.000000;8
ENCOUNTER64;64;90;0
ENCOUNTER64;256;90;1
ENCOUNTER64;512;90;2
ENCOUNTER64.000000;64.000000;90;0
ENCOUNTER64.000000;256.000000;90;1
ENCOUNTER64.000000;512.000000;90;2

@ -4,7 +4,7 @@
????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
??????????0717??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????

@ -0,0 +1 @@
#include "battlemoves.h"

@ -0,0 +1,8 @@
#include <string>
#include <map>
#include <array>
#include <vector>
#ifndef BATTLEMOVES_H
#define BATTLEMOVES_H
#endif

@ -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,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::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++) {
if (successful) {
AddObjectToWorld(data->objs[i]->obj);
}
}
}
void UpdatePlayerTrail(vd2d newMovement) {
for (int i=PARTY_TRAIL_LENGTH-1;i>0;i--) {

Loading…
Cancel
Save