Fix up warnings (mostly loss of data cast warnings). When an ability gets interrupted, the key is required to be depressed before another cast attempt can be made. Added collision layer tiles to a few tiles in 1-1 due to ability to walk out-of-bounds.
This commit is contained in:
+18
-18
@@ -58,7 +58,7 @@ safemap<int,std::string>STRATEGY_ID_DATA;
|
||||
std::map<int,Renderable*>MonsterData::imgs;
|
||||
|
||||
Monster::Monster(vf2d pos,MonsterData data,bool upperLevel,bool bossMob):
|
||||
pos(pos),hp(data.GetHealth()),maxhp(data.GetHealth()),atk(data.GetAttack()),moveSpd(data.GetMoveSpdMult()),size(data.GetSizeMult()),targetSize(data.GetSizeMult()),strategy(data.GetAIStrategy()),id(data.GetID()),upperLevel(upperLevel),isBoss(bossMob){
|
||||
pos(pos),hp(data.GetHealth()),maxhp(data.GetHealth()),atk(data.GetAttack()),moveSpd(data.GetMoveSpdMult()),size(data.GetSizeMult()),targetSize(data.GetSizeMult()),strategy(data.GetAIStrategy()),id(data.GetID()),upperLevel(upperLevel),isBoss(bossMob),facingDirection(DOWN){
|
||||
bool firstAnimation=true;
|
||||
for(std::string&anim:data.GetAnimations()){
|
||||
animation.AddState(anim,ANIMATION_DATA[anim]);
|
||||
@@ -76,7 +76,7 @@ int Monster::GetHealth(){
|
||||
return hp;
|
||||
}
|
||||
int Monster::GetAttack(){
|
||||
float mod_atk=atk;
|
||||
float mod_atk=float(atk);
|
||||
for(Buff&b:GetBuffs(ATTACK_UP)){
|
||||
mod_atk+=atk*b.intensity;
|
||||
}
|
||||
@@ -109,17 +109,17 @@ void Monster::PerformIdleAnimation(){
|
||||
}
|
||||
bool Monster::SetX(float x){
|
||||
vf2d newPos={x,pos.y};
|
||||
vi2d tilePos=vi2d(newPos/game->GetCurrentMap().tilewidth)*game->GetCurrentMap().tilewidth;
|
||||
vi2d tilePos=vi2d(newPos/float(game->GetCurrentMap().tilewidth))*game->GetCurrentMap().tilewidth;
|
||||
geom2d::rect<int>collisionRect=game->GetTileCollision(game->GetCurrentLevel(),newPos,upperLevel);
|
||||
if(collisionRect.pos==vi2d{0,0}&&collisionRect.size==vi2d{1,1}){
|
||||
pos.x=std::clamp(x,game->GetCurrentMap().tilewidth/2*GetSizeMult(),float(game->GetCurrentMap().width*game->GetCurrentMap().tilewidth-game->GetCurrentMap().tilewidth/2*GetSizeMult()));
|
||||
pos.x=std::clamp(x,game->GetCurrentMap().tilewidth/2.f*GetSizeMult(),float(game->GetCurrentMap().width*game->GetCurrentMap().tilewidth-game->GetCurrentMap().tilewidth/2.f*GetSizeMult()));
|
||||
Moved();
|
||||
return true;
|
||||
} else {
|
||||
geom2d::rect<float>collision={collisionRect.pos,collisionRect.size};
|
||||
collision.pos+=tilePos;
|
||||
if(!geom2d::overlaps(geom2d::circle<float>(newPos,12*GetSizeMult()),collision)){
|
||||
pos.x=std::clamp(x,game->GetCurrentMap().tilewidth/2*GetSizeMult(),float(game->GetCurrentMap().width*game->GetCurrentMap().tilewidth-game->GetCurrentMap().tilewidth/2*GetSizeMult()));
|
||||
pos.x=std::clamp(x,game->GetCurrentMap().tilewidth/2.f*GetSizeMult(),float(game->GetCurrentMap().width*game->GetCurrentMap().tilewidth-game->GetCurrentMap().tilewidth/2.f*GetSizeMult()));
|
||||
Moved();
|
||||
return true;
|
||||
}
|
||||
@@ -128,17 +128,17 @@ bool Monster::SetX(float x){
|
||||
}
|
||||
bool Monster::SetY(float y){
|
||||
vf2d newPos={pos.x,y};
|
||||
vi2d tilePos=vi2d(newPos/game->GetCurrentMap().tilewidth)*game->GetCurrentMap().tilewidth;
|
||||
vi2d tilePos=vi2d(newPos/float(game->GetCurrentMap().tilewidth))*game->GetCurrentMap().tilewidth;
|
||||
geom2d::rect<int>collisionRect=game->GetTileCollision(game->GetCurrentLevel(),newPos,upperLevel);
|
||||
if(collisionRect.pos==vi2d{0,0}&&collisionRect.size==vi2d{1,1}){
|
||||
pos.y=std::clamp(y,game->GetCurrentMap().tilewidth/2*GetSizeMult(),float(game->GetCurrentMap().height*game->GetCurrentMap().tilewidth-game->GetCurrentMap().tilewidth/2*GetSizeMult()));
|
||||
pos.y=std::clamp(y,game->GetCurrentMap().tilewidth/2.f*GetSizeMult(),float(game->GetCurrentMap().height*game->GetCurrentMap().tilewidth-game->GetCurrentMap().tilewidth/2.f*GetSizeMult()));
|
||||
Moved();
|
||||
return true;
|
||||
} else {
|
||||
geom2d::rect<float>collision={collisionRect.pos,collisionRect.size};
|
||||
collision.pos+=tilePos;
|
||||
if(!geom2d::overlaps(geom2d::circle<float>(newPos,game->GetCurrentMap().tilewidth/2*GetSizeMult()),collision)){
|
||||
pos.y=std::clamp(y,game->GetCurrentMap().tilewidth/2*GetSizeMult(),float(game->GetCurrentMap().height*game->GetCurrentMap().tilewidth-game->GetCurrentMap().tilewidth/2*GetSizeMult()));
|
||||
pos.y=std::clamp(y,game->GetCurrentMap().tilewidth/2.f*GetSizeMult(),float(game->GetCurrentMap().height*game->GetCurrentMap().tilewidth-game->GetCurrentMap().tilewidth/2.f*GetSizeMult()));
|
||||
Moved();
|
||||
return true;
|
||||
}
|
||||
@@ -171,7 +171,7 @@ bool Monster::Update(float fElapsedTime){
|
||||
m.Collision(*this);
|
||||
geom2d::line line(pos,m.GetPos());
|
||||
float dist = line.length();
|
||||
m.SetPos(line.rpoint(dist*1.1));
|
||||
m.SetPos(line.rpoint(dist*1.1f));
|
||||
if(m.IsAlive()){
|
||||
vel=line.vector().norm()*-128;
|
||||
}
|
||||
@@ -180,7 +180,7 @@ bool Monster::Update(float fElapsedTime){
|
||||
if(!game->GetPlayer()->HasIframes()&&abs(game->GetPlayer()->GetZ()-GetZ())<=1&&game->GetPlayer()->OnUpperLevel()==OnUpperLevel()&&geom2d::overlaps(geom2d::circle(pos,12*size/2),geom2d::circle(game->GetPlayer()->GetPos(),12*game->GetPlayer()->GetSizeMult()/2))){
|
||||
geom2d::line line(pos,game->GetPlayer()->GetPos());
|
||||
float dist = line.length();
|
||||
SetPos(line.rpoint(-0.1));
|
||||
SetPos(line.rpoint(-0.1f));
|
||||
vel=line.vector().norm()*-128;
|
||||
}
|
||||
}
|
||||
@@ -244,7 +244,7 @@ void Monster::Collision(Monster&m){
|
||||
Collision();
|
||||
}
|
||||
void Monster::Collision(){
|
||||
if(strategy==0&&GetState()==State::MOVE_TOWARDS&&util::random(Monster::STRATEGY::_GetInt(*this,"BumpStopChance",strategy))<1){//The run towards strategy causes state to return to normal upon a collision.
|
||||
if(strategy==0&&GetState()==State::MOVE_TOWARDS&&util::random(float(Monster::STRATEGY::_GetInt(*this,"BumpStopChance",strategy)))<1){//The run towards strategy causes state to return to normal upon a collision.
|
||||
SetState(State::NORMAL);
|
||||
}
|
||||
}
|
||||
@@ -257,7 +257,7 @@ bool Monster::SetPos(vf2d pos){
|
||||
if(resultY&&!resultX){
|
||||
resultX=SetX(pos.x);
|
||||
}
|
||||
return resultX|resultY;
|
||||
return resultX||resultY;
|
||||
}
|
||||
void Monster::Moved(){
|
||||
std::map<std::string,std::vector<ZoneData>>&zoneData=game->GetZoneData(game->GetCurrentLevel());
|
||||
@@ -281,19 +281,19 @@ bool Monster::Hurt(int damage,bool onUpperLevel,float z){
|
||||
game->StartBossEncounter();
|
||||
}
|
||||
game->GetPlayer()->ResetLastCombatTime();
|
||||
float mod_dmg=damage;
|
||||
float mod_dmg=float(damage);
|
||||
for(Buff&b:GetBuffs(BuffType::DAMAGE_REDUCTION)){
|
||||
mod_dmg-=damage*b.intensity;
|
||||
}
|
||||
hp=std::max(0,hp-int(mod_dmg));
|
||||
if(lastHitTimer>0){
|
||||
damageNumberPtr.get()->damage+=int(mod_dmg);
|
||||
damageNumberPtr.get()->pauseTime=0.4;
|
||||
damageNumberPtr.get()->pauseTime=0.4f;
|
||||
} else {
|
||||
damageNumberPtr=std::make_shared<DamageNumber>(pos,int(mod_dmg));
|
||||
DAMAGENUMBER_LIST.push_back(damageNumberPtr);
|
||||
}
|
||||
lastHitTimer=0.05;
|
||||
lastHitTimer=0.05f;
|
||||
if(!IsAlive()){
|
||||
OnDeath();
|
||||
}else{
|
||||
@@ -365,7 +365,7 @@ void Monster::StartPathfinding(float pathingTime){
|
||||
void Monster::PathAroundBehavior(float fElapsedTime){
|
||||
if(path.size()>0){
|
||||
//Move towards the new path.
|
||||
geom2d::line moveTowardsLine=geom2d::line(pos,path[pathIndex]*game->GetCurrentMap().tilewidth);
|
||||
geom2d::line moveTowardsLine=geom2d::line(pos,path[pathIndex]*float(game->GetCurrentMap().tilewidth));
|
||||
if(moveTowardsLine.length()>2){
|
||||
SetPos(pos+moveTowardsLine.vector().norm()*100*fElapsedTime*GetMoveSpdMult());
|
||||
if(moveTowardsLine.vector().x>0){
|
||||
@@ -374,7 +374,7 @@ void Monster::PathAroundBehavior(float fElapsedTime){
|
||||
facingDirection=LEFT;
|
||||
}
|
||||
}else{
|
||||
if(pathIndex+1>=path.size()){
|
||||
if(size_t(pathIndex+1)>=path.size()){
|
||||
//We have reached the end of the path!
|
||||
targetAcquireTimer=0;
|
||||
}else{
|
||||
@@ -450,7 +450,7 @@ void Monster::OnDeath(){
|
||||
for(MonsterDropData data:MONSTER_DATA.at(id).GetDropData()){
|
||||
if(util::random(100)<=data.dropChance){
|
||||
//This isn't necessarily fair odds for each quantity dropped.
|
||||
int dropQuantity=data.minQty+std::round(util::random(data.maxQty-data.minQty));
|
||||
int dropQuantity=int(data.minQty+std::round(util::random(float(data.maxQty-data.minQty))));
|
||||
for(int i=0;i<dropQuantity;i++){
|
||||
ItemDrop::SpawnItem(data.item,GetPos(),OnUpperLevel());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user