Ranger configuration file implemented. Added per-step bullet collisions. Fix Release Desktop project setup.

pull/28/head
sigonasr2 1 year ago
parent 017a72b8cc
commit b2d363cdef
  1. 2
      Crawler/Arrow.cpp
  2. 58
      Crawler/Crawler.cpp
  3. 6
      Crawler/Crawler.vcxproj
  4. 6
      Crawler/Player.cpp
  5. 7
      Crawler/Player.h
  6. 21
      Crawler/Ranger.cpp
  7. 2
      Crawler/Version.h
  8. 43
      Crawler/assets/config/classes/Ranger.txt
  9. BIN
      x64/Release Desktop/Crawler.exe
  10. BIN
      x64/Release/Crawler.exe

@ -8,7 +8,7 @@
INCLUDE_game
Arrow::Arrow(vf2d pos,vf2d targetPos,vf2d vel,float radius,int damage,bool upperLevel,bool friendly,Pixel col)
:finalDistance(geom2d::line(pos,targetPos).length()),
:finalDistance(geom2d::line(pos,targetPos).length()),acc(PI/2*"Ranger.Auto Attack.ArrowSpd"_F),
Bullet(pos,vel,radius,damage,
AnimationState::ARROW,upperLevel,false,INFINITE,true,friendly,col){}

@ -417,39 +417,49 @@ void Crawler::UpdateBullets(float fElapsedTime){
Bullet*b=(*it).get();
b->UpdateFadeTime(fElapsedTime);
b->Update(fElapsedTime);
b->pos+=b->vel*fElapsedTime;
b->animation.UpdateState(b->internal_animState,fElapsedTime);
if(!b->deactivated){
if(b->friendly){
for(Monster&m:MONSTER_LIST){
if(geom2d::overlaps(geom2d::circle(m.GetPos(),12*m.GetSizeMult()),geom2d::circle(b->pos,b->radius))){
if(b->hitList.find(&m)==b->hitList.end()&&m.Hurt(b->damage,b->OnUpperLevel())){
if(!b->hitsMultiple){
if(b->MonsterHit(m)){
it=BULLET_LIST.erase(it);
if(it==BULLET_LIST.end()){
goto outsidePlayerBulletLoop;
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;
if(b->friendly){
for(Monster&m:MONSTER_LIST){
if(geom2d::overlaps(geom2d::circle(m.GetPos(),12*m.GetSizeMult()),geom2d::circle(b->pos,b->radius))){
if(b->hitList.find(&m)==b->hitList.end()&&m.Hurt(b->damage,b->OnUpperLevel())){
if(!b->hitsMultiple){
if(b->MonsterHit(m)){
it=BULLET_LIST.erase(it);
if(it==BULLET_LIST.end()){
goto outsideBulletLoop;
}
}
goto continueBulletLoop;
}
goto continuePlayerBulletLoop;
b->hitList[&m]=true;
}
b->hitList[&m]=true;
}
}
}
} else {
if(geom2d::overlaps(geom2d::circle(player->GetPos(),12*player->GetSizeMult()/2),geom2d::circle(b->pos,b->radius))){
if(player->Hurt(b->damage,b->OnUpperLevel())){
if(b->PlayerHit(GetPlayer())){
it=BULLET_LIST.erase(it);
if(it==BULLET_LIST.end()){
break;
} else {
if(geom2d::overlaps(geom2d::circle(player->GetPos(),12*player->GetSizeMult()/2),geom2d::circle(b->pos,b->radius))){
if(player->Hurt(b->damage,b->OnUpperLevel())){
if(b->PlayerHit(GetPlayer())){
it=BULLET_LIST.erase(it);
if(it==BULLET_LIST.end()){
goto outsideBulletLoop;
}
}
goto continueBulletLoop;
}
continue;
}
}
}
} else {
b->pos+=b->vel*fElapsedTime;
}
if(b->pos.x+b->radius<view.GetWorldTL().x||b->pos.x-b->radius>view.GetWorldBR().x||b->pos.y+b->radius<view.GetWorldTL().y||b->pos.y-b->radius>view.GetWorldBR().y){
it=BULLET_LIST.erase(it);
@ -466,10 +476,10 @@ void Crawler::UpdateBullets(float fElapsedTime){
}
continue;
}
continuePlayerBulletLoop:
continueBulletLoop:
continue;
}
outsidePlayerBulletLoop:
outsideBulletLoop:
int a;
}
void Crawler::HurtEnemies(vf2d pos,float radius,int damage,bool upperLevel){
@ -1152,6 +1162,8 @@ datafiledoubledata Crawler::GetDoubleList(std::string key){
int main()
{
char*testArr = new char[5000];
delete[]testArr;
Crawler demo;
if (demo.Construct(WINDOW_SIZE.x, WINDOW_SIZE.y, 4, 4))
demo.Start();

@ -112,6 +112,12 @@
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release Desktop|Win32'">
<OutDir>$(SolutionDir)$(PlatformTarget)\Release</OutDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release Desktop|x64'">
<OutDir>$(SolutionDir)$(PlatformTarget)\Release</OutDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>

@ -163,6 +163,10 @@ State Player::GetState(){
return state;
}
void Player::Knockback(vf2d vel){
this->vel+=vel;
}
void Player::Update(float fElapsedTime){
Ability&rightClickAbility=GetRightClickAbility(),
&ability=GetAbility1(),
@ -441,7 +445,7 @@ void Player::Update(float fElapsedTime){
vf2d extendedLine=pointTowardsCursor.upoint(1.1);
float angleToCursor=atan2(extendedLine.y-GetPos().y,extendedLine.x-GetPos().x);
attack_cooldown_timer=ARROW_ATTACK_COOLDOWN;
BULLET_LIST.push_back(std::make_unique<Arrow>(Arrow(GetPos(),extendedLine,vf2d{cos(angleToCursor)*250,float(sin(angleToCursor)*250-PI/8*250)}+movementVelocity,12,GetAttack(),OnUpperLevel(),true)));
BULLET_LIST.push_back(std::make_unique<Arrow>(Arrow(GetPos(),extendedLine,vf2d{cos(angleToCursor)*"Ranger.Ability 1.ArrowSpd"_F,float(sin(angleToCursor)*"Ranger.Ability 1.ArrowSpd"_F-PI/8*"Ranger.Ability 1.ArrowSpd"_F)}+movementVelocity,12*"Ranger.Ability 1.ArrowRadius"_F/100,GetAttack()*"Ranger.Ability 1.DamageMult"_F,OnUpperLevel(),true)));
SetAnimationBasedOnTargetingDirection(angleToCursor);
rapidFireTimer=RAPID_FIRE_SHOOT_DELAY;
}else{

@ -69,6 +69,7 @@ protected:
void SetZ(float z);
//Returns true if the move was valid and successful.
bool SetPos(vf2d pos);
void Knockback(vf2d vel);
float friction=400;
float attack_cooldown_timer=0;
float iframe_time=0;
@ -86,7 +87,7 @@ protected:
void PrepareCast(Ability&ability);
vf2d precastLocation={};
void SetVelocity(vf2d vel);
const float RETREAT_DISTANCE=122.5*"Ranger.Right Click Ability.RetreatDistance"_F/100;
const float RETREAT_DISTANCE=24*"Ranger.Right Click Ability.RetreatDistance"_F/100;
float RETREAT_TIME="Ranger.Right Click Ability.RetreatTime"_F; //How long the Retreat ability takes.
const int RETREAT_GHOST_FRAMES=8;
const float RETREAT_GHOST_FRAME_DELAY=0.025;
@ -97,8 +98,8 @@ protected:
std::vector<vf2d>ghostPositions;
float rapidFireTimer=0;
int remainingRapidFireShots=0;
const float RAPID_FIRE_SHOOT_DELAY=0.1;
const int RAPID_FIRE_SHOOT_AMOUNT=4;
const float RAPID_FIRE_SHOOT_DELAY="Ranger.Ability 1.ArrowDelay"_F;
const int RAPID_FIRE_SHOOT_AMOUNT="Ranger.Ability 1.ArrowCount"_I;
public:
Player();
//So this is rather fascinating and only exists because we have the ability to change classes which means we need to initialize a class

@ -63,7 +63,9 @@ void Ranger::InitializeClassAbilities(){
[](Player*p,vf2d pos={}){
p->remainingRapidFireShots=p->RAPID_FIRE_SHOOT_AMOUNT;
p->rapidFireTimer=p->RAPID_FIRE_SHOOT_DELAY;
p->SetState(State::ANIMATION_LOCK);
if("Ranger.Ability 1.IsAnimationLocked"_I){
p->SetState(State::ANIMATION_LOCK);
}
return true;
};
#pragma endregion
@ -71,9 +73,10 @@ void Ranger::InitializeClassAbilities(){
Ranger::ability2.action=
[](Player*p,vf2d pos={}){
vf2d arrowVelocity=util::pointTo(p->GetPos(),game->GetWorldMousePos());
BULLET_LIST.push_back(std::make_unique<ChargedArrow>(p->GetPos(),arrowVelocity*600,20,p->GetAttack()*2.5,p->OnUpperLevel(),true));
BULLET_LIST.push_back(std::make_unique<ChargedArrow>(p->GetPos(),arrowVelocity*"Ranger.Ability 2.Speed"_F,12*"Ranger.Ability 2.Radius"_F/100,p->GetAttack()*"Ranger.Ability 2.DamageMult"_F,p->OnUpperLevel(),true));
p->SetAnimationBasedOnTargetingDirection(atan2(arrowVelocity.y,arrowVelocity.x));
game->SetupWorldShake(0.3);
game->SetupWorldShake("Ranger.Ability 2.WorldShakeTime"_F);
p->Knockback(-1.f*arrowVelocity.norm()*"Ranger.Ability 2.Knockback"_F);
return true;
};
#pragma endregion
@ -84,12 +87,16 @@ void Ranger::InitializeClassAbilities(){
float shootingDist=pointTowardsCursor.length();
vf2d shootingDirMiddle=pointTowardsCursor.vector();
float shootingAngle=atan2(shootingDirMiddle.y,shootingDirMiddle.x);
for(int i=0;i<7;i++){
if(i==3)continue;
float newAngle=shootingAngle-3.f/16*PI+i*1.f/16*PI;
int arrowCount="Ranger.Ability 3.ArrowCount"_I%2==0?"Ranger.Ability 3.ArrowCount"_I+1:"Ranger.Ability 3.ArrowCount"_I;
for(int i=0;i<arrowCount;i++){
if("Ranger.Ability 3.ArrowCount"_I%2==0&&i=="Ranger.Ability 3.ArrowCount"_I/2)continue;
const float halfAngle="Ranger.Ability 3.MultiShotSpread"_F*PI/180;
const float leftAngle=-halfAngle;
const float increment=halfAngle/"Ranger.Ability 3.ArrowCount"_I;
const float newAngle=shootingAngle+leftAngle/2+i*increment;
geom2d::line pointTowardsCursor=geom2d::line(p->GetPos(),p->GetPos()+vf2d{cos(newAngle),sin(newAngle)}*shootingDist);
vf2d extendedLine=pointTowardsCursor.upoint(1.1);
BULLET_LIST.push_back(std::make_unique<Arrow>(Arrow(p->GetPos(),extendedLine,vf2d{cos(newAngle)*250,float(sin(newAngle)*250-PI/8*250)}+p->movementVelocity,12,p->GetAttack(),p->OnUpperLevel(),true)));
BULLET_LIST.push_back(std::make_unique<Arrow>(Arrow(p->GetPos(),extendedLine,vf2d{cos(newAngle)*"Ranger.Ability 3.ArrowSpd"_F,float(sin(newAngle)*"Ranger.Ability 3.ArrowSpd"_F-PI/8*"Ranger.Ability 3.ArrowSpd"_F)}+p->movementVelocity,12*"Ranger.Ability 3.ArrowRadius"_F/100,p->GetAttack()*"Ranger.Ability 3.DamageMult"_F,p->OnUpperLevel(),true)));
}
p->SetAnimationBasedOnTargetingDirection(shootingAngle);
return true;

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

@ -6,7 +6,7 @@ Ranger
{
DamageMult = 1
Radius = 100
Cooldown = 0.35
Cooldown = 0.6
ArrowSpd = 250
}
@ -27,7 +27,7 @@ Ranger
# How long the retreat takes.
RetreatTime = 0.2
# The distance the retreat moves the Ranger.
RetreatDistance = 500
RetreatDistance = 250
}
Ability 1
{
@ -42,6 +42,20 @@ Ranger
Precast Time = 0
Casting Range = 0
Casting Size = 0
# Damage multiplier per shot
DamageMult = 1.0
# Speed of arrows that Rapid Fire shoots out.
ArrowSpd = 300
# Number of arrows Rapid Fire shoots out.
ArrowCount = 4
# Amount of time between each arrow shot.
ArrowDelay = 0.1
# Whether or not this ability locks you in place. (0=Not Locked)
IsAnimationLocked = 1
# Hitbox radius of the arrows
ArrowRadius = 100
}
Ability 2
{
@ -56,6 +70,18 @@ Ranger
Precast Time = 0.3
Casting Range = 0
Casting Size = 0
# The amount of knockback that this ability causes.
Knockback = 200
# Speed of the charged arrow shot.
Speed = 600
# Radius of the shot.
Radius = 166.6667
# Damage Multiplier of the charged shot.
DamageMult = 2.5
# How long the world shakes upon using this ability.
WorldShakeTime = 0.3
}
Ability 3
{
@ -70,5 +96,18 @@ Ranger
Precast Time = 0
Casting Range = 0
Casting Size = 0
# Damage multiplier per shot
DamageMult = 1.0
# Number of arrows in the shot spread.
ArrowCount = 6
# How far the shot spread in one angle is. For example, if the value here is set to 18.375, then Multi shot divides the arrows evenly from a span of -18.375 degrees to the left to 18.375 degrees to the right of the player.
MultiShotSpread = 18.375
# Speed of arrows that Rapid Fire shoots out.
ArrowSpd = 300
# Hitbox radius of the arrows
ArrowRadius = 100
}
}

Binary file not shown.

Binary file not shown.
Loading…
Cancel
Save