Fix bow goblin reload AI and changing facing direction while aiming at target. Release Build 9174.

pull/57/head
sigonasr2 7 months ago
parent 7375d37d99
commit 8827d1ca4e
  1. 1
      Adventures in Lestoria/Arrow.cpp
  2. 10
      Adventures in Lestoria/Goblin_Bow.cpp
  3. 2
      Adventures in Lestoria/Version.h
  4. 9
      Adventures in Lestoria/assets/Campaigns/2_1.tmx
  5. 2
      Adventures in Lestoria/assets/config/Monsters.txt
  6. BIN
      x64/Release/Adventures in Lestoria.exe

@ -81,7 +81,6 @@ void Arrow::PointToBestTargetPath(const uint8_t perceptionLevel){
if(distToPlayer<closestDist){ if(distToPlayer<closestDist){
closestDist=distToPlayer; closestDist=distToPlayer;
closestVel=originalSimulatedShootingAngle; closestVel=originalSimulatedShootingAngle;
LOG(std::format("Angle {} is a better choice as the arrow gets to {} distance from the player.",util::radToDeg(closestVel.polar().y),closestDist));
} }
} }
} }

@ -65,14 +65,14 @@ void Monster::STRATEGY::GOBLIN_BOW(Monster&m,float fElapsedTime,std::string stra
}; };
#pragma endregion #pragma endregion
m.F(A::ATTACK_COOLDOWN)+=fElapsedTime;
switch(m.phase){ switch(m.phase){
case INITIALIZE_PERCEPTION:{ case INITIALIZE_PERCEPTION:{
m.F(A::PERCEPTION_LEVEL)=ConfigFloat("Starting Perception Level"); m.F(A::PERCEPTION_LEVEL)=ConfigFloat("Starting Perception Level");
m.phase=MOVE; m.phase=MOVE;
}break; }break;
case MOVE:{ case MOVE:{
m.F(A::ATTACK_COOLDOWN)+=fElapsedTime;
float distToPlayer=m.GetDistanceFrom(game->GetPlayer()->GetPos()); float distToPlayer=m.GetDistanceFrom(game->GetPlayer()->GetPos());
const bool outsideMaxShootingRange=distToPlayer>=ConfigPixelsArr("Stand Still and Shoot Range",1); const bool outsideMaxShootingRange=distToPlayer>=ConfigPixelsArr("Stand Still and Shoot Range",1);
@ -103,12 +103,14 @@ void Monster::STRATEGY::GOBLIN_BOW(Monster&m,float fElapsedTime,std::string stra
float targetDir=m.B(A::RANDOM_DIRECTION)==CW?dirFromPlayer+PI/4:dirFromPlayer-PI/4; float targetDir=m.B(A::RANDOM_DIRECTION)==CW?dirFromPlayer+PI/4:dirFromPlayer-PI/4;
m.target=game->GetPlayer()->GetPos()+vf2d{m.F(A::RANDOM_RANGE),targetDir}.cart(); m.target=game->GetPlayer()->GetPos()+vf2d{m.F(A::RANDOM_RANGE),targetDir}.cart();
RUN_TOWARDS(m,fElapsedTime,"Run Towards"); RUN_TOWARDS(m,fElapsedTime,"Run Towards");
}else{ //Only the stand still and shoot range remains... }else
if(m.F(A::ATTACK_COOLDOWN)>=ConfigFloat("Attack Reload Time")/2.f){ //Only the stand still and shoot range remains, which is twice as fast...
PrepareToShoot(); PrepareToShoot();
} }
}break; }break;
case WINDUP:{ case WINDUP:{
m.F(A::SHOOT_TIMER)-=fElapsedTime; m.F(A::SHOOT_TIMER)-=fElapsedTime;
m.UpdateFacingDirection(game->GetPlayer()->GetPos());
if(m.F(A::SHOOT_TIMER)<=0){ if(m.F(A::SHOOT_TIMER)<=0){
geom2d::line pointTowardsPlayer(m.GetPos(),game->GetPlayer()->GetPos()); geom2d::line pointTowardsPlayer(m.GetPos(),game->GetPlayer()->GetPos());
vf2d extendedLine=pointTowardsPlayer.upoint(1.1f); vf2d extendedLine=pointTowardsPlayer.upoint(1.1f);
@ -116,7 +118,9 @@ void Monster::STRATEGY::GOBLIN_BOW(Monster&m,float fElapsedTime,std::string stra
Arrow&arrow=static_cast<Arrow&>(*BULLET_LIST.back()); Arrow&arrow=static_cast<Arrow&>(*BULLET_LIST.back());
arrow.PointToBestTargetPath(m.F(A::PERCEPTION_LEVEL)); arrow.PointToBestTargetPath(m.F(A::PERCEPTION_LEVEL));
m.F(A::ATTACK_COOLDOWN)=0.f;
m.F(A::PERCEPTION_LEVEL)=std::min(ConfigFloat("Maximum Perception Level"),m.F(A::PERCEPTION_LEVEL)+ConfigFloat("Perception Level Increase")); m.F(A::PERCEPTION_LEVEL)=std::min(ConfigFloat("Maximum Perception Level"),m.F(A::PERCEPTION_LEVEL)+ConfigFloat("Perception Level Increase"));
m.PerformAnimation("IDLE",m.GetFacingDirectionToTarget(game->GetPlayer()->GetPos()));
m.phase=MOVE; m.phase=MOVE;
} }
m.B(A::RANDOM_DIRECTION)=util::random()%2; m.B(A::RANDOM_DIRECTION)=util::random()%2;

@ -39,7 +39,7 @@ All rights reserved.
#define VERSION_MAJOR 1 #define VERSION_MAJOR 1
#define VERSION_MINOR 2 #define VERSION_MINOR 2
#define VERSION_PATCH 0 #define VERSION_PATCH 0
#define VERSION_BUILD 9169 #define VERSION_BUILD 9174
#define stringify(a) stringify_(a) #define stringify(a) stringify_(a)
#define stringify_(a) #a #define stringify_(a) #a

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<map version="1.10" tiledversion="1.10.2" class="Map" orientation="orthogonal" renderorder="right-down" width="238" height="369" tilewidth="24" tileheight="24" infinite="0" nextlayerid="7" nextobjectid="28"> <map version="1.10" tiledversion="1.10.2" class="Map" orientation="orthogonal" renderorder="right-down" width="238" height="369" tilewidth="24" tileheight="24" infinite="0" nextlayerid="7" nextobjectid="30">
<properties> <properties>
<property name="Backdrop" propertytype="Backdrop" value="mountain_day"/> <property name="Backdrop" propertytype="Backdrop" value="mountain_day"/>
<property name="Background Music" propertytype="BGM" value="foresty1_1"/> <property name="Background Music" propertytype="BGM" value="foresty1_1"/>
@ -1887,7 +1887,12 @@
</properties> </properties>
</object> </object>
<object id="28" name="Player Spawn" type="PlayerSpawnLocation" x="5112" y="8064" width="24" height="24"/> <object id="28" name="Player Spawn" type="PlayerSpawnLocation" x="5112" y="8064" width="24" height="24"/>
<object id="27" template="../maps/Monsters/Boar.tx" x="4552" y="8063"> <object id="28" template="../maps/Monsters/Goblin (Bow).tx" x="4472" y="8175">
<properties>
<property name="spawner" type="object" value="15"/>
</properties>
</object>
<object id="29" template="../maps/Monsters/Goblin (Bow).tx" x="4815" y="7821">
<properties> <properties>
<property name="spawner" type="object" value="15"/> <property name="spawner" type="object" value="15"/>
</properties> </properties>

@ -591,7 +591,7 @@ Monsters
# The First Four animations must represent a standing, walking, attack, and death animation. Their names are up to the creator. # The First Four animations must represent a standing, walking, attack, and death animation. Their names are up to the creator.
IDLE = 2, 0.6, Repeat IDLE = 2, 0.6, Repeat
WALK = 3, 0.2, Repeat WALK = 3, 0.2, Repeat
SHOOT = 4, 0.03, OneShot SHOOT = 4, 0.06, OneShot
DEATH = 4, 0.15, OneShot DEATH = 4, 0.15, OneShot
} }

Loading…
Cancel
Save