Fixed Bullet fixed step movement. Corrected Warrior Block Cooldown (accidently got changed), implemented Turret Monster Strategy.

pull/28/head
sigonasr2 1 year ago
parent 6cfb40d642
commit b1885a1c1e
  1. 4
      Crawler/Bullet.cpp
  2. 13
      Crawler/Crawler.cpp
  3. 12
      Crawler/MonsterStrategyHelpers.h
  4. 1
      Crawler/Player.cpp
  5. 6
      Crawler/RunTowards.cpp
  6. 12
      Crawler/ShootAfar.cpp
  7. 25
      Crawler/Turret.cpp
  8. 2
      Crawler/Version.h
  9. 10
      Crawler/assets/config/MonsterStrategies.txt
  10. 2
      Crawler/assets/config/classes/Warrior.txt

@ -36,8 +36,8 @@ void Bullet::Draw(){
if(animated){
game->view.DrawPartialRotatedDecal(pos,GetFrame().GetSourceImage()->Decal(),rotates?atan2(vel.y,vel.x)-PI/2:0,GetFrame().GetSourceRect().size/2,GetFrame().GetSourceRect().pos,GetFrame().GetSourceRect().size,scale,fadeOutTime==0?col:Pixel{col.r,col.g,col.b,lerp(col.a,0,1-((fadeOutTime-fadeOutTimer)/fadeOutTime))});
} else {
game->view.DrawDecal(pos,game->GFX_BulletCircle.Decal(),{radius,radius},fadeOutTime==0?col:Pixel{col.r,col.g,col.b,lerp(col.a,0,1-((fadeOutTime-fadeOutTimer)/fadeOutTime))});
game->view.DrawDecal(pos,game->GFX_BulletCircleOutline.Decal(),{radius,radius},fadeOutTime==0?WHITE:Pixel{WHITE.r,WHITE.g,WHITE.b,lerp(WHITE.a,0,1-((fadeOutTime-fadeOutTimer)/fadeOutTime))});
game->view.DrawDecal(pos-game->GFX_BulletCircle.Sprite()->Size()*scale/2,game->GFX_BulletCircle.Decal(),scale,fadeOutTime==0?col:Pixel{col.r,col.g,col.b,lerp(col.a,0,1-((fadeOutTime-fadeOutTimer)/fadeOutTime))});
game->view.DrawDecal(pos-game->GFX_BulletCircle.Sprite()->Size()*scale/2,game->GFX_BulletCircleOutline.Decal(),scale,fadeOutTime==0?WHITE:Pixel{WHITE.r,WHITE.g,WHITE.b,lerp(WHITE.a,0,1-((fadeOutTime-fadeOutTimer)/fadeOutTime))});
}
}

@ -430,14 +430,19 @@ void Crawler::UpdateBullets(float fElapsedTime){
b->Update(fElapsedTime);
b->animation.UpdateState(b->internal_animState,fElapsedTime);
if(!b->deactivated){
float totalDistance=(b->vel*fElapsedTime).mag();
vf2d moveStep=b->vel*fElapsedTime;
int stepCount=1;
if((b->vel*fElapsedTime).mag()>1){
moveStep=(b->vel*fElapsedTime).norm();
stepCount=b->vel.x*fElapsedTime/moveStep.x;
}
for(;stepCount>0;stepCount--){
b->pos+=moveStep;
while(totalDistance>0){
if(totalDistance>=1){
b->pos+=moveStep;
totalDistance--;
} else {
b->pos+=moveStep*totalDistance;
totalDistance=0;
}
if(b->friendly){
for(Monster&m:MONSTER_LIST){
if(geom2d::overlaps(geom2d::circle(m.GetPos(),12*m.GetSizeMult()),geom2d::circle(b->pos,b->radius))){

@ -1,7 +1,7 @@
#pragma once
#define GetInt(param) _GetInt(m,param,strategyNumber)
#define GetFloat(param) _GetFloat(m,param,strategyNumber)
#define GetString(param) _GetString(m,param,strategyNumber)
#define GetIntArr(param,ind) _GetInt(m,param,strategyNumber,ind)
#define GetFloatArr(param,ind) _GetFloat(m,param,strategyNumber,ind)
#define GetStringArr(param,ind) _GetString(m,param,strategyNumber,ind)
#define ConfigInt(param) _GetInt(m,param,strategyNumber)
#define ConfigFloat(param) _GetFloat(m,param,strategyNumber)
#define ConfigString(param) _GetString(m,param,strategyNumber)
#define ConfigIntArr(param,ind) _GetInt(m,param,strategyNumber,ind)
#define ConfigFloatArr(param,ind) _GetFloat(m,param,strategyNumber,ind)
#define ConfigStringArr(param,ind) _GetString(m,param,strategyNumber,ind)

@ -169,7 +169,6 @@ void Player::Knockback(vf2d vel){
}
void Player::Update(float fElapsedTime){
Ability&rightClickAbility=GetRightClickAbility(),
&ability=GetAbility1(),
&ability2=GetAbility2(),

@ -9,12 +9,12 @@ INCLUDE_MONSTER_DATA
void Monster::STRATEGY::RUN_TOWARDS(Monster&m,float fElapsedTime,int strategyNumber){
m.targetAcquireTimer=std::max(0.f,m.targetAcquireTimer-fElapsedTime);
if(m.targetAcquireTimer==0){
m.targetAcquireTimer=GetFloat("WaitTime");
m.targetAcquireTimer=ConfigFloat("WaitTime");
auto desiredTargetLine = geom2d::line(m.pos,game->GetPlayer()->GetPos());
if(desiredTargetLine.length()>=GetInt("MaxDistance")/100.f*24){
if(desiredTargetLine.length()>=ConfigInt("MaxDistance")/100.f*24){
//Trim to max distance desired.
m.target=desiredTargetLine.rpoint(GetInt("MaxDistance")/100.f*24);
m.target=desiredTargetLine.rpoint(ConfigInt("MaxDistance")/100.f*24);
} else {
m.target=desiredTargetLine.upoint(1.2);
}

@ -14,14 +14,14 @@ void Monster::STRATEGY::SHOOT_AFAR(Monster&m,float fElapsedTime,int strategyNumb
if(m.queueShotTimer<0){
m.queueShotTimer=0;
{
BULLET_LIST.push_back(std::make_unique<Bullet>(Bullet(m.pos + vf2d{ 0,-4 }, geom2d::line(m.pos + vf2d{ 0,-4 }, game->GetPlayer()->GetPos()).vector().norm() * 24 * GetInt("BulletSpeed")/100.f, 24.f*GetInt("BulletSize")/100.f, m.GetAttack(),m.upperLevel,false, { uint8_t(GetIntArr("BulletColor",0)),uint8_t(GetIntArr("BulletColor",1)),uint8_t(GetIntArr("BulletColor",2)),uint8_t(GetIntArr("BulletColor",3) )})));
BULLET_LIST.push_back(std::make_unique<Bullet>(Bullet(m.pos + vf2d{ 0,-4 }, geom2d::line(m.pos + vf2d{ 0,-4 }, game->GetPlayer()->GetPos()).vector().norm() * 24 * ConfigInt("BulletSpeed")/100.f, 12.f*ConfigInt("BulletSize")/100.f, m.GetAttack(),m.upperLevel,false, { uint8_t(ConfigIntArr("BulletColor",0)),uint8_t(ConfigIntArr("BulletColor",1)),uint8_t(ConfigIntArr("BulletColor",2)),uint8_t(ConfigIntArr("BulletColor",3) )},{ConfigInt("BulletSize")/100.f*8,ConfigInt("BulletSize")/100.f*8})));
}
}
}
geom2d::line line(m.pos,game->GetPlayer()->GetPos());
if(m.targetAcquireTimer==0&&m.queueShotTimer==0){
m.targetAcquireTimer=1;
if(line.length()<24.f*GetInt("Range")/100.f){
if(line.length()<24.f*ConfigInt("Range")/100.f){
m.target=line.upoint(-1.2);
if(m.canMove){
m.SetState(MOVE_AWAY);
@ -29,7 +29,7 @@ void Monster::STRATEGY::SHOOT_AFAR(Monster&m,float fElapsedTime,int strategyNumb
m.SetState(NORMAL);
}
} else
if(line.length()>24.f*GetInt("CloseInRange")/100.0f){
if(line.length()>24.f*ConfigInt("CloseInRange")/100.0f){
m.target=line.upoint(1.2);
m.SetState(MOVE_TOWARDS);
} else {
@ -51,7 +51,7 @@ void Monster::STRATEGY::SHOOT_AFAR(Monster&m,float fElapsedTime,int strategyNumb
if(!pathfindingDecision){
m.StartPathfinding(2.5);
}else
if(line.length()<=24.f*GetInt("CloseInRange")/100.0f){
if(line.length()<=24.f*ConfigInt("CloseInRange")/100.0f){
m.SetState(NORMAL);
}
if(moveTowardsLine.vector().x>0){
@ -72,7 +72,7 @@ void Monster::STRATEGY::SHOOT_AFAR(Monster&m,float fElapsedTime,int strategyNumb
if(!pathfindingDecision){
m.StartPathfinding(2.5);
}else
if(line.length()>=24.f*GetInt("Range")/100.f){
if(line.length()>=24.f*ConfigInt("Range")/100.f){
m.SetState(NORMAL);
}
if(moveTowardsLine.vector().x>0){
@ -87,7 +87,7 @@ void Monster::STRATEGY::SHOOT_AFAR(Monster&m,float fElapsedTime,int strategyNumb
}break;
default:{
if(m.attackCooldownTimer==0){
m.attackCooldownTimer=GetFloat("ShootingSpeed");
m.attackCooldownTimer=ConfigFloat("ShootingSpeed");
m.queueShotTimer=std::min(m.attackCooldownTimer-0.001,0.7);
m.PerformShootAnimation();
}

@ -1,6 +1,29 @@
#include "Monster.h"
#include "MonsterStrategyHelpers.h"
#include "DEFINES.h"
#include "Crawler.h"
#include "utils.h"
INCLUDE_game
INCLUDE_BULLET_LIST
void Monster::STRATEGY::TURRET(Monster&m,float fElapsedTime,int strategyNumber){
m.attackCooldownTimer=std::max(0.f,m.attackCooldownTimer-fElapsedTime);
if(m.queueShotTimer>0){
m.queueShotTimer-=fElapsedTime;
if(m.queueShotTimer<0){
m.queueShotTimer=0;
BULLET_LIST.push_back(std::make_unique<Bullet>(Bullet(m.pos + vf2d{ 0,-4 }, geom2d::line(m.pos + vf2d{ 0,-4 }, game->GetPlayer()->GetPos()).vector().norm() * 24 * ConfigInt("BulletSpeed")/100.f, 12.f*ConfigInt("BulletSize")/100.f, m.GetAttack(),m.upperLevel,false, { uint8_t(ConfigIntArr("BulletColor",0)),uint8_t(ConfigIntArr("BulletColor",1)),uint8_t(ConfigIntArr("BulletColor",2)),uint8_t(ConfigIntArr("BulletColor",3) )},{ConfigInt("BulletSize")/100.f*8,ConfigInt("BulletSize")/100.f*8})));
}
}
auto dist=geom2d::line(m.GetPos(),game->GetPlayer()->GetPos()).length();
if(dist<ConfigInt("Range")/100.f*24){
if(m.attackCooldownTimer==0){
m.attackCooldownTimer=ConfigFloat("ShootingSpeed");
m.queueShotTimer=std::min(m.attackCooldownTimer-0.001,0.3);
m.PerformShootAnimation();
}
}
}

@ -2,7 +2,7 @@
#define VERSION_MAJOR 0
#define VERSION_MINOR 2
#define VERSION_PATCH 0
#define VERSION_BUILD 999
#define VERSION_BUILD 1009
#define stringify(a) stringify_(a)
#define stringify_(a) #a

@ -54,7 +54,7 @@ MonsterStrategy
# How often the enemy shoots.
ShootingSpeed = 1
BulletSpeed = 300
BulletSize = 8
BulletSize = 20
BulletColor = 37, 131, 112, 255
}
2
@ -63,9 +63,9 @@ MonsterStrategy
# How far away the monster starts shooting from
Range = 800
# How often the enemy shoots.
ShootingSpeed = 1
BulletSpeed = 100
BulletSize = 100
BulletColor = 0, 0, 255, 255
ShootingSpeed = 0.6
BulletSpeed = 450
BulletSize = 30
BulletColor = 0, 255, 0, 255
}
}

@ -13,7 +13,7 @@ Warrior
Right Click Ability
{
Name = Block
Cooldown = 1
Cooldown = 15
Mana Cost = 0
#RGB Values. Color 1 is the left side of the bar, Color 2 is the right side.

Loading…
Cancel
Save