|
|
|
@ -277,8 +277,9 @@ class Encounter{ |
|
|
|
|
vd2d pos; |
|
|
|
|
int chance; //Chance of the encounter existing.
|
|
|
|
|
std::vector<Entity*>objs; |
|
|
|
|
Encounter(vd2d pos,std::vector<Entity*>objs,int chance=25) |
|
|
|
|
:pos(pos),objs(objs),chance(chance){} |
|
|
|
|
std::array<vd2d,4> playerPos; |
|
|
|
|
Encounter(vd2d pos,std::array<vd2d,4> playerPos,std::vector<Entity*>objs,int chance=25) |
|
|
|
|
:pos(pos),objs(objs),chance(chance),playerPos(playerPos){} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -357,6 +358,7 @@ public: |
|
|
|
|
|
|
|
|
|
bool OnUserCreate() override |
|
|
|
|
{ |
|
|
|
|
srand(time(NULL)); |
|
|
|
|
GAME=this; |
|
|
|
|
for (int i=1;i<6;i++) { |
|
|
|
|
CreateLayer(); |
|
|
|
@ -1035,7 +1037,15 @@ goes on a very long time, I hope you can understand this is only for testing pur |
|
|
|
|
lastMarker=marker; |
|
|
|
|
int pct=id; |
|
|
|
|
split4>>id; |
|
|
|
|
printf("Encounter %d (%d%) Loaded.\n",id,pct); |
|
|
|
|
|
|
|
|
|
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); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
printf("Encounter %d (%d\%) Loaded.\n",id,pct); |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
std::vector<TILE*> tiles; |
|
|
|
@ -1544,22 +1554,85 @@ goes on a very long time, I hope you can understand this is only for testing pur |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void LoadEncounter(Map*map,vd2d pos,int chance,int id) { |
|
|
|
|
Encounter*data; |
|
|
|
|
switch (id) { |
|
|
|
|
case encounter::ENCOUNTER_1:{ |
|
|
|
|
map->encounters.push_back( |
|
|
|
|
new Encounter(pos, |
|
|
|
|
std::vector<Entity*>{new Entity( |
|
|
|
|
new Object( |
|
|
|
|
NPC1_4,"Test Obj",{pos.x+20,pos.y+48},ANIMATIONS["player.png"] |
|
|
|
|
),70,70,14,std::array<int,4>{0,0,0,0},0,std::vector<Battle::Move*>{ |
|
|
|
|
MOVELIST[BattleMoveName::TESTMOVE1], |
|
|
|
|
MOVELIST[BattleMoveName::TESTMOVE2], |
|
|
|
|
MOVELIST[BattleMoveName::TESTMOVE3], |
|
|
|
|
} |
|
|
|
|
)} |
|
|
|
|
,chance) |
|
|
|
|
); |
|
|
|
|
data=new Encounter(pos,std::array<vd2d,4>{vd2d |
|
|
|
|
{pos.x+10,pos.y+24},{pos.x+30,pos.y+24},{pos.x+50,pos.y+24},{pos.x+70,pos.y+24}}, |
|
|
|
|
std::vector<Entity*>{ |
|
|
|
|
new Entity(new Object( |
|
|
|
|
NPC1_4,"Test Obj",{pos.x+20,pos.y+48},ANIMATIONS["player.png"]), |
|
|
|
|
70,70,14,std::array<int,4>{0,0,0,0},0,std::vector<Battle::Move*>{ |
|
|
|
|
MOVELIST[BattleMoveName::TESTMOVE1], |
|
|
|
|
MOVELIST[BattleMoveName::TESTMOVE2], |
|
|
|
|
MOVELIST[BattleMoveName::TESTMOVE3], |
|
|
|
|
}), |
|
|
|
|
new Entity(new Object( |
|
|
|
|
NPC1_4,"Test Obj 2",{pos.x+40,pos.y+64},ANIMATIONS["player.png"]), |
|
|
|
|
70,70,14,std::array<int,4>{0,0,0,0},0,std::vector<Battle::Move*>{ |
|
|
|
|
MOVELIST[BattleMoveName::TESTMOVE1], |
|
|
|
|
MOVELIST[BattleMoveName::TESTMOVE2], |
|
|
|
|
MOVELIST[BattleMoveName::TESTMOVE3], |
|
|
|
|
}), |
|
|
|
|
new Entity(new Object( |
|
|
|
|
NPC1_4,"Test Obj 3",{pos.x+60,pos.y+24},ANIMATIONS["player.png"]), |
|
|
|
|
70,70,14,std::array<int,4>{0,0,0,0},0,std::vector<Battle::Move*>{ |
|
|
|
|
MOVELIST[BattleMoveName::TESTMOVE1], |
|
|
|
|
MOVELIST[BattleMoveName::TESTMOVE2], |
|
|
|
|
MOVELIST[BattleMoveName::TESTMOVE3], |
|
|
|
|
}), |
|
|
|
|
} |
|
|
|
|
,chance); |
|
|
|
|
}break; |
|
|
|
|
case encounter::ENCOUNTER_2:{ |
|
|
|
|
data=new Encounter(pos,std::array<vd2d,4>{vd2d |
|
|
|
|
{pos.x+10,pos.y+24},{pos.x+30,pos.y+24},{pos.x+50,pos.y+24},{pos.x+70,pos.y+24}}, |
|
|
|
|
std::vector<Entity*>{ |
|
|
|
|
new Entity(new Object( |
|
|
|
|
NPC1_4,"Test Obj",{pos.x+20,pos.y+48},ANIMATIONS["player.png"],{2,2},GREEN), |
|
|
|
|
70,70,14,std::array<int,4>{0,0,0,0},0,std::vector<Battle::Move*>{ |
|
|
|
|
MOVELIST[BattleMoveName::TESTMOVE1], |
|
|
|
|
MOVELIST[BattleMoveName::TESTMOVE2], |
|
|
|
|
MOVELIST[BattleMoveName::TESTMOVE3], |
|
|
|
|
}), |
|
|
|
|
new Entity(new Object( |
|
|
|
|
NPC1_4,"Test Obj 2",{pos.x+40,pos.y+64},ANIMATIONS["player.png"],{2,2},GREEN), |
|
|
|
|
70,70,14,std::array<int,4>{0,0,0,0},0,std::vector<Battle::Move*>{ |
|
|
|
|
MOVELIST[BattleMoveName::TESTMOVE1], |
|
|
|
|
MOVELIST[BattleMoveName::TESTMOVE2], |
|
|
|
|
MOVELIST[BattleMoveName::TESTMOVE3], |
|
|
|
|
}), |
|
|
|
|
new Entity(new Object( |
|
|
|
|
NPC1_4,"Test Obj 3",{pos.x+60,pos.y+24},ANIMATIONS["player.png"],{2,2},GREEN), |
|
|
|
|
70,70,14,std::array<int,4>{0,0,0,0},0,std::vector<Battle::Move*>{ |
|
|
|
|
MOVELIST[BattleMoveName::TESTMOVE1], |
|
|
|
|
MOVELIST[BattleMoveName::TESTMOVE2], |
|
|
|
|
MOVELIST[BattleMoveName::TESTMOVE3], |
|
|
|
|
}), |
|
|
|
|
} |
|
|
|
|
,chance); |
|
|
|
|
}break; |
|
|
|
|
case encounter::ENCOUNTER_3:{ |
|
|
|
|
data=new Encounter(pos,std::array<vd2d,4>{vd2d |
|
|
|
|
{pos.x+10,pos.y+24},{pos.x+30,pos.y+24},{pos.x+50,pos.y+24},{pos.x+70,pos.y+24}}, |
|
|
|
|
std::vector<Entity*>{ |
|
|
|
|
new Entity(new Object( |
|
|
|
|
NPC1_4,"Test Obj",{pos.x+20,pos.y+48},ANIMATIONS["player.png"],{1,1},MAGENTA), |
|
|
|
|
70,70,14,std::array<int,4>{0,0,0,0},0,std::vector<Battle::Move*>{ |
|
|
|
|
MOVELIST[BattleMoveName::TESTMOVE1], |
|
|
|
|
MOVELIST[BattleMoveName::TESTMOVE2], |
|
|
|
|
MOVELIST[BattleMoveName::TESTMOVE3], |
|
|
|
|
}), |
|
|
|
|
} |
|
|
|
|
,chance); |
|
|
|
|
}break; |
|
|
|
|
default:{ |
|
|
|
|
printf("WARNING! Dead encounter found! THIS SHOULD NOT BE HAPPENING!"); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
map->encounters.push_back(data); |
|
|
|
|
for (int i=0;i<data->objs.size();i++) { |
|
|
|
|
AddObjectToWorld(data->objs[i]->obj); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|