|
|
|
@ -156,6 +156,8 @@ int MONEY=0; |
|
|
|
|
int ENEMY_MONEY_SUM=0; |
|
|
|
|
int SHOP_MENU_CURSOR=0; |
|
|
|
|
Object*SHOPKEEPER_INTERACTING_WITH=nullptr; |
|
|
|
|
extern std::map<TriggerName::Trigger,std::string> TRIGGERS; |
|
|
|
|
TriggerName::Trigger SELECTED_TRIGGER; |
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
[Choice1,Choice2,Choice3] |
|
|
|
@ -191,8 +193,6 @@ std::vector<std::vector<TILE*>> MAP2={}; |
|
|
|
|
std::vector<std::vector<TILE*>> MAP3={}; |
|
|
|
|
std::vector<std::vector<TILE*>> MAP4={}; |
|
|
|
|
std::vector<std::vector<TILE*>> MAP5={}; //Collision Layer
|
|
|
|
|
std::vector<Trigger*> TRIGGERS={}; |
|
|
|
|
std::map<TriggerName::Trigger,Trigger*> Trigger::TRIGGERLIST={}; |
|
|
|
|
std::map<std::string,Decal*> SPRITES; |
|
|
|
|
std::map<std::string,Animation*> ANIMATIONS={}; |
|
|
|
|
std::map<int,Object*> OBJ_INFO={}; |
|
|
|
@ -793,7 +793,6 @@ void SeasonI::LoadMap(Map*map) { |
|
|
|
|
delete OBJECTS[i]; |
|
|
|
|
} |
|
|
|
|
OBJECTS.clear(); |
|
|
|
|
TRIGGERS.clear(); |
|
|
|
|
for (int i=0;i<4;i++) { |
|
|
|
|
PARTY_MEMBER_OBJ[i]=nullptr; |
|
|
|
|
PARTY_MEMBER_ID[i]=0; |
|
|
|
@ -848,7 +847,6 @@ void SeasonI::LoadMap(Map*map) { |
|
|
|
|
lastMarker=marker; |
|
|
|
|
int pct=id; |
|
|
|
|
split4>>id; |
|
|
|
|
|
|
|
|
|
LoadEncounter(map,{x,y},pct,id,rand()%100<pct); |
|
|
|
|
|
|
|
|
|
printf("Encounter %d (%d%c) Loaded.\n",id,pct,'%'); |
|
|
|
@ -862,8 +860,7 @@ void SeasonI::LoadMap(Map*map) { |
|
|
|
|
std::stringstream split5(data.substr(lastMarker+1,marker-lastMarker-1)); |
|
|
|
|
lastMarker=marker; |
|
|
|
|
split5>>size_y; |
|
|
|
|
TRIGGERS.push_back(new Trigger({(int)x,(int)y},{size_x,size_y},id)); |
|
|
|
|
map->triggers.push_back(Trigger::TRIGGERLIST[(TriggerName::Trigger)id]); |
|
|
|
|
map->triggers.push_back(new Trigger({(int)x,(int)y},{size_x,size_y},(TriggerName::Trigger)id)); |
|
|
|
|
printf("Trigger %d Loaded.\n",id); |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
@ -989,7 +986,7 @@ void SeasonI::SaveMap(Map*map) { |
|
|
|
|
|
|
|
|
|
for (int i=0;i<map->triggers.size();i++) { |
|
|
|
|
f.put('\n'); |
|
|
|
|
const std::string trigger="TRIGGER"+std::to_string(map->triggers[i]->GetPosX())+";"+std::to_string(map->triggers[i]->GetPosY())+";"+";"+std::to_string(map->triggers[i]->GetID())+std::to_string(map->triggers[i]->GetSizeX())+";"+std::to_string(map->triggers[i]->GetSizeY()); |
|
|
|
|
const std::string trigger="TRIGGER"+std::to_string(map->triggers[i]->GetPosX())+";"+std::to_string(map->triggers[i]->GetPosY())+";"+std::to_string(map->triggers[i]->GetID())+";"+std::to_string(map->triggers[i]->GetSizeX())+";"+std::to_string(map->triggers[i]->GetSizeY()); |
|
|
|
|
for (int j=0;j<trigger.length();j++) { |
|
|
|
|
f.put(trigger[j]); |
|
|
|
|
} |
|
|
|
@ -1226,6 +1223,11 @@ void SeasonI::updateGame(){ |
|
|
|
|
GAME_STATE=GameState::EDITOR; |
|
|
|
|
} |
|
|
|
|
}break; |
|
|
|
|
case GameState::TRIGGER_SELECT:{ |
|
|
|
|
if (!GetKey(CTRL).bHeld) { |
|
|
|
|
GAME_STATE=GameState::EDITOR; |
|
|
|
|
} |
|
|
|
|
}break; |
|
|
|
|
case GameState::GAME_WORLD:{ |
|
|
|
|
if (PlayerCanMove()) { |
|
|
|
|
bool moved=false; |
|
|
|
@ -1245,6 +1247,11 @@ void SeasonI::updateGame(){ |
|
|
|
|
if (movementComponents.mag()>0) { |
|
|
|
|
if (PARTY_MEMBER_OBJ[0]->SmoothMove(movementComponents)) { |
|
|
|
|
UpdatePlayerTrail(movementComponents); |
|
|
|
|
for (int i=0;i<CURRENT_MAP->triggers.size();i++) { |
|
|
|
|
if (CURRENT_MAP->triggers[i]->IsInside(PARTY_MEMBER_OBJ[0]->GetPosWithOrigin())) { |
|
|
|
|
CURRENT_MAP->triggers[i]->Interact(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
moved=true; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -1274,6 +1281,10 @@ void SeasonI::updateGame(){ |
|
|
|
|
if (GetKey(SHIFT).bHeld) { |
|
|
|
|
GAME_STATE=GameState::ENCOUNTER_SELECT; |
|
|
|
|
} |
|
|
|
|
if (GetKey(CTRL).bHeld) { |
|
|
|
|
GAME_STATE=GameState::TRIGGER_SELECT; |
|
|
|
|
SELECTED_TRIGGER=TriggerName::NONE; |
|
|
|
|
} |
|
|
|
|
if (PlayerCanMove()) { |
|
|
|
|
if (GetKey(I).bHeld) { |
|
|
|
|
if (PARTY_MEMBER_OBJ[0]->SmoothMove({0,-1})) { |
|
|
|
@ -1304,9 +1315,19 @@ void SeasonI::updateGame(){ |
|
|
|
|
if (GetMouse(0).bHeld) { |
|
|
|
|
switch (EDITING_LAYER) { |
|
|
|
|
case layer::COLLISION:{ |
|
|
|
|
TILE*tile=MAP5[HIGHLIGHTED_TILE.y][HIGHLIGHTED_TILE.x]; |
|
|
|
|
tile->tileX=SELECTED_TILE.x; |
|
|
|
|
tile->tileY=SELECTED_TILE.y; |
|
|
|
|
if (EDITING_LAYER==layer::COLLISION&&SELECTED_TRIGGER!=TriggerName::NONE) { |
|
|
|
|
for (int i=0;i<CURRENT_MAP->triggers.size();i++) { |
|
|
|
|
if (CURRENT_MAP->triggers[i]->GetPos()==HIGHLIGHTED_TILE*32) { |
|
|
|
|
delete CURRENT_MAP->triggers[i]; |
|
|
|
|
CURRENT_MAP->triggers.erase(CURRENT_MAP->triggers.begin()+i--); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
CURRENT_MAP->triggers.push_back(new Trigger(HIGHLIGHTED_TILE*32,{32,32},SELECTED_TRIGGER)); |
|
|
|
|
} else { |
|
|
|
|
TILE*tile=MAP5[HIGHLIGHTED_TILE.y][HIGHLIGHTED_TILE.x]; |
|
|
|
|
tile->tileX=SELECTED_TILE.x; |
|
|
|
|
tile->tileY=SELECTED_TILE.y; |
|
|
|
|
} |
|
|
|
|
}break; |
|
|
|
|
case layer::HIGH:{ |
|
|
|
|
TILE*tile=MAP[HIGHLIGHTED_TILE.y][HIGHLIGHTED_TILE.x]; |
|
|
|
@ -2487,7 +2508,6 @@ void SeasonI::drawGame(){ |
|
|
|
|
bool underAttack=false; |
|
|
|
|
if (BATTLE_ENCOUNTER!=nullptr) { |
|
|
|
|
std::vector<Entity*> attackedAllies; |
|
|
|
|
|
|
|
|
|
if (CURRENT_TURN>=0&&BATTLE_STATE==BattleState::WAIT_ANIMATION&&BATTLE_ENCOUNTER->objs[CURRENT_TURN]->selectedTarget<0) { |
|
|
|
|
attackedAllies=GetEntitiesInRange(BATTLE_ENCOUNTER->objs[CURRENT_TURN]->selectedTarget,BATTLE_ENCOUNTER->objs[CURRENT_TURN]->channelPos,BATTLE_ENCOUNTER->objs[CURRENT_TURN]->selectedMove); |
|
|
|
|
} |
|
|
|
@ -2728,6 +2748,15 @@ void SeasonI::drawGame(){ |
|
|
|
|
DrawGameWorld(); |
|
|
|
|
SetDrawTarget(nullptr); |
|
|
|
|
DrawRectDecal((HIGHLIGHTED_TILE)*32-cameraPos,{32,32},YELLOW); |
|
|
|
|
if (EDITING_LAYER==layer::COLLISION&&SELECTED_TRIGGER!=TriggerName::NONE) { |
|
|
|
|
DrawStringPropDecal({2,2},Wrap("Editing Triggers - Selected "+TRIGGERS[SELECTED_TRIGGER],WIDTH-4,true,{1,1})); |
|
|
|
|
for (auto&trigger:CURRENT_MAP->triggers) { |
|
|
|
|
FillRectDecal(trigger->GetPos()-cameraPos,trigger->GetSize(),Pixel(255,0,0,64)); |
|
|
|
|
DrawRectDecal(trigger->GetPos()-cameraPos,trigger->GetSize(),YELLOW); |
|
|
|
|
vi2d textOffset={2,2}; |
|
|
|
|
DrawStringDecal(trigger->GetPos()-cameraPos+textOffset,TRIGGERS[(TriggerName::Trigger)trigger->GetID()],WHITE,{28.f/GetTextSize(TRIGGERS[(TriggerName::Trigger)trigger->GetID()]).x,1.f}); |
|
|
|
|
} |
|
|
|
|
} else |
|
|
|
|
if (EDITING_LAYER==layer::ENCOUNTER) { |
|
|
|
|
if (IsTextEntryEnabled()) { |
|
|
|
|
DrawStringPropDecal({2,2},"Input Chance: "+TextEntryGetString()+"%",YELLOW); |
|
|
|
@ -2827,6 +2856,40 @@ void SeasonI::drawGame(){ |
|
|
|
|
counter++; |
|
|
|
|
} |
|
|
|
|
}break; |
|
|
|
|
case GameState::TRIGGER_SELECT:{ |
|
|
|
|
vd2d drawpos={0,0}; |
|
|
|
|
int counter=0; |
|
|
|
|
for (std::map<TriggerName::Trigger,std::string>::const_iterator it = TRIGGERS.cbegin();it!=TRIGGERS.cend();++it){ |
|
|
|
|
if (counter<OBJ_DISPLAY_OFFSET) { |
|
|
|
|
counter++; |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
if (drawpos.y>HEIGHT) { |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
TriggerName::Trigger trigger = it->first; |
|
|
|
|
if (GetMouse(0).bHeld&& |
|
|
|
|
GetMousePos().x>=drawpos.x&& |
|
|
|
|
GetMousePos().x<drawpos.x+16&& |
|
|
|
|
GetMousePos().y>=drawpos.y&& |
|
|
|
|
GetMousePos().y<drawpos.y+24) { |
|
|
|
|
SELECTED_TRIGGER=trigger; |
|
|
|
|
EDITING_LAYER=layer::COLLISION; |
|
|
|
|
EnableLayer(layer::COLLISION,false); |
|
|
|
|
} |
|
|
|
|
FillRectDecal(drawpos,{16,24},VERY_DARK_GREY); |
|
|
|
|
DrawStringDecal({(float)(drawpos.x+2),(float)(drawpos.y)},it->second,WHITE,{(float)(12.0/GetTextSize(it->second).x),1.0}); |
|
|
|
|
if (SELECTED_TRIGGER==it->first) { |
|
|
|
|
DrawRectDecal(drawpos,{16,24},YELLOW); |
|
|
|
|
} |
|
|
|
|
drawpos.x+=16; |
|
|
|
|
if (drawpos.x>=WIDTH) { |
|
|
|
|
drawpos.x=0; |
|
|
|
|
drawpos.y+=24; |
|
|
|
|
} |
|
|
|
|
counter++; |
|
|
|
|
} |
|
|
|
|
}break; |
|
|
|
|
} |
|
|
|
|
if (BATTLE_ENCOUNTER!=nullptr&&BATTLE_STATE==BattleState::TARGET_SELECT||GAME_STATE==GameState::OVERWORLD_TARGET_MENU) { |
|
|
|
|
SetDrawTarget(layer::GROUND); |
|
|
|
|