Precast targeting indicator now centered
Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
This commit is contained in:
		
							parent
							
								
									5da8b19c34
								
							
						
					
					
						commit
						50a73a53e7
					
				| @ -19,7 +19,7 @@ struct Ability{ | ||||
| 	int manaCost=0; | ||||
| 	Pixel barColor1,barColor2; | ||||
| 	PrecastData precastInfo; | ||||
| 	std::function<bool()>action=[&](){return false;}; | ||||
| 	std::function<bool(vf2d)>action=[&](vf2d){return false;}; | ||||
| 	Ability(); | ||||
| 	Ability(std::string name,float cooldownTime,int manaCost,Pixel barColor1=VERY_DARK_RED,Pixel barColor2=DARK_RED,PrecastData precastInfo={}); | ||||
| }; | ||||
| @ -568,7 +568,7 @@ void Crawler::RenderWorld(float fElapsedTime){ | ||||
| 	} | ||||
| 	if(player->GetState()==State::PREP_CAST){ | ||||
| 		float precastSize=GetPlayer()->castPrepAbility->precastInfo.size; | ||||
| 		view.DrawDecal(GetWorldMousePos()-vf2d{precastSize/6,precastSize/6},GFX_Circle.Decal(),{precastSize/3,precastSize/3},{255,0,0,192}); | ||||
| 		view.DrawDecal(GetWorldMousePos()-vf2d{precastSize/4.5f,precastSize/4.5f},GFX_Circle.Decal(),{precastSize/3,precastSize/3},{255,0,0,192}); | ||||
| 	} | ||||
| 	#pragma region Foreground Rendering | ||||
| 		for(TileGroup&group:foregroundTileGroups){ | ||||
|  | ||||
| @ -166,7 +166,7 @@ void Player::Update(float fElapsedTime){ | ||||
| 	if(castInfo.castTimer>0){ | ||||
| 		castInfo.castTimer-=fElapsedTime; | ||||
| 		if(castInfo.castTimer<=0){ | ||||
| 			if(castPrepAbility->action()){ | ||||
| 			if(castPrepAbility->action(castInfo.castPos)){ | ||||
| 				castPrepAbility->cooldown=castPrepAbility->COOLDOWN_TIME; | ||||
| 				mana-=castPrepAbility->manaCost; | ||||
| 			} | ||||
| @ -307,7 +307,7 @@ void Player::Update(float fElapsedTime){ | ||||
| 	auto CheckAndPerformAbility=[&](Ability&ability,HWButton key){ | ||||
| 		if(ability.cooldown==0&&GetMana()>=ability.manaCost){ | ||||
| 			if(key.bPressed||key.bReleased&&&ability==castPrepAbility&&GetState()==State::PREP_CAST){ | ||||
| 				if(AllowedToCast(ability)&&ability.action()){ | ||||
| 				if(AllowedToCast(ability)&&ability.action({})){ | ||||
| 					ability.cooldown=ability.COOLDOWN_TIME; | ||||
| 					mana-=ability.manaCost; | ||||
| 				}else | ||||
| @ -495,7 +495,7 @@ std::vector<Buff>Player::GetBuffs(BuffType buff){ | ||||
| } | ||||
| 
 | ||||
| void Player::CastSpell(Ability&ability){ | ||||
| 	castInfo={ability.name,ability.precastInfo.castTime,ability.precastInfo.castTime}; | ||||
| 	castInfo={ability.name,ability.precastInfo.castTime,ability.precastInfo.castTime,game->GetWorldMousePos()}; | ||||
| 	SetState(State::CASTING); | ||||
| } | ||||
| 
 | ||||
|  | ||||
| @ -13,6 +13,7 @@ struct CastInfo{ | ||||
| 	std::string name; | ||||
| 	float castTimer; | ||||
| 	float castTotalTime; | ||||
| 	vf2d castPos; | ||||
| }; | ||||
| 
 | ||||
| struct Player{ | ||||
|  | ||||
| @ -37,25 +37,25 @@ bool Ranger::AutoAttack(){ | ||||
| void Ranger::InitializeClassAbilities(){ | ||||
|     #pragma region Ranger Right-click Ability (???) | ||||
|         Ranger::rightClickAbility.action= | ||||
|             [&](){ | ||||
|             [&](vf2d pos={}){ | ||||
|                 return false; | ||||
|             }; | ||||
|     #pragma endregion | ||||
|     #pragma region Ranger Ability 1 (???) | ||||
|         Ranger::ability1.action= | ||||
|             [&](){ | ||||
|             [&](vf2d pos={}){ | ||||
|                 return false; | ||||
|             }; | ||||
|     #pragma endregion | ||||
|     #pragma region Ranger Ability 2 (???) | ||||
|         Ranger::ability2.action= | ||||
|             [&](){ | ||||
|             [&](vf2d pos={}){ | ||||
|                 return false; | ||||
|             }; | ||||
|     #pragma endregion | ||||
|     #pragma region Ranger Ability 3 (???) | ||||
|         Ranger::ability3.action= | ||||
|             [&](){ | ||||
|             [&](vf2d pos={}){ | ||||
|                 return false; | ||||
|             }; | ||||
|     #pragma endregion | ||||
|  | ||||
| @ -37,25 +37,25 @@ bool Thief::AutoAttack(){ | ||||
| void Thief::InitializeClassAbilities(){ | ||||
|     #pragma region Thief Right-click Ability (???) | ||||
|         Thief::rightClickAbility.action= | ||||
|             [&](){ | ||||
|             [&](vf2d pos={}){ | ||||
|                 return false; | ||||
|             }; | ||||
|     #pragma endregion | ||||
|     #pragma region Thief Ability 1 (???) | ||||
|         Thief::ability1.action= | ||||
|             [&](){ | ||||
|             [&](vf2d pos={}){ | ||||
|                 return false; | ||||
|             }; | ||||
|     #pragma endregion | ||||
|     #pragma region Thief Ability 2 (???) | ||||
|         Thief::ability2.action= | ||||
|             [&](){ | ||||
|             [&](vf2d pos={}){ | ||||
|                 return false; | ||||
|             }; | ||||
|     #pragma endregion | ||||
|     #pragma region Thief Ability 3 (???) | ||||
|         Thief::ability3.action= | ||||
|             [&](){ | ||||
|             [&](vf2d pos={}){ | ||||
|                 return false; | ||||
|             }; | ||||
|     #pragma endregion | ||||
|  | ||||
| @ -37,25 +37,25 @@ bool Trapper::AutoAttack(){ | ||||
| void Trapper::InitializeClassAbilities(){ | ||||
|     #pragma region Trapper Right-click Ability (???) | ||||
|         Trapper::rightClickAbility.action= | ||||
|             [&](){ | ||||
|             [&](vf2d pos={}){ | ||||
|                 return false; | ||||
|             }; | ||||
|     #pragma endregion | ||||
|     #pragma region Trapper Ability 1 (???) | ||||
|         Trapper::ability1.action= | ||||
|             [&](){ | ||||
|             [&](vf2d pos={}){ | ||||
|                 return false; | ||||
|             }; | ||||
|     #pragma endregion | ||||
|     #pragma region Trapper Ability 2 (???) | ||||
|         Trapper::ability2.action= | ||||
|             [&](){ | ||||
|             [&](vf2d pos={}){ | ||||
|                 return false; | ||||
|             }; | ||||
|     #pragma endregion | ||||
|     #pragma region Trapper Ability 3 (???) | ||||
|         Trapper::ability3.action= | ||||
|             [&](){ | ||||
|             [&](vf2d pos={}){ | ||||
|                 return false; | ||||
|             }; | ||||
|     #pragma endregion | ||||
|  | ||||
| @ -70,7 +70,7 @@ bool Warrior::AutoAttack(){ | ||||
| void Warrior::InitializeClassAbilities(){ | ||||
|     #pragma region Warrior Right-click Ability (Block) | ||||
|         Warrior::rightClickAbility.action= | ||||
|             [&](){ | ||||
|             [&](vf2d pos={}){ | ||||
|                 if(GetState()==State::NORMAL){ | ||||
|                     rightClickAbility.cooldown=rightClickAbility.COOLDOWN_TIME; | ||||
|                     SetState(State::BLOCK); | ||||
| @ -82,7 +82,7 @@ void Warrior::InitializeClassAbilities(){ | ||||
|     #pragma endregion | ||||
|     #pragma region Warrior Ability 1 (Battlecry) | ||||
|         Warrior::ability1.action= | ||||
|             [&](){ | ||||
|             [&](vf2d pos={}){ | ||||
|                 game->AddEffect(std::make_unique<Effect>(GetPos(),0.1,AnimationState::BATTLECRY_EFFECT,upperLevel,1,0.3)); | ||||
|                 AddBuff(BuffType::ATTACK_UP,10,0.1); | ||||
|                 AddBuff(BuffType::DAMAGE_REDUCTION,10,0.1); | ||||
| @ -96,7 +96,7 @@ void Warrior::InitializeClassAbilities(){ | ||||
|     #pragma endregion | ||||
|     #pragma region Warrior Ability 2 (Ground Slam) | ||||
|         Warrior::ability2.action= | ||||
|             [&](){ | ||||
|             [&](vf2d pos={}){ | ||||
|                 Spin(GROUND_SLAM_SPIN_TIME,14*PI); | ||||
|                 iframe_time=GROUND_SLAM_SPIN_TIME+0.1; | ||||
|                 return true; | ||||
| @ -104,7 +104,7 @@ void Warrior::InitializeClassAbilities(){ | ||||
|     #pragma endregion | ||||
|     #pragma region Warrior Ability 3 (Sonic Slash) | ||||
|         Warrior::ability3.action= | ||||
|             [&](){ | ||||
|             [&](vf2d pos={}){ | ||||
|                 SetState(State::SWING_SONIC_SWORD); | ||||
|                 AddBuff(BuffType::SLOWDOWN,0.5,1); | ||||
|                 vf2d bulletVel={}; | ||||
|  | ||||
| @ -37,25 +37,25 @@ bool Witch::AutoAttack(){ | ||||
| void Witch::InitializeClassAbilities(){ | ||||
|     #pragma region Witch Right-click Ability (???) | ||||
|         Witch::rightClickAbility.action= | ||||
|             [&](){ | ||||
|             [&](vf2d pos={}){ | ||||
|                 return false; | ||||
|             }; | ||||
|     #pragma endregion | ||||
|     #pragma region Witch Ability 1 (???) | ||||
|         Witch::ability1.action= | ||||
|             [&](){ | ||||
|             [&](vf2d pos={}){ | ||||
|                 return false; | ||||
|             }; | ||||
|     #pragma endregion | ||||
|     #pragma region Witch Ability 2 (???) | ||||
|         Witch::ability2.action= | ||||
|             [&](){ | ||||
|             [&](vf2d pos={}){ | ||||
|                 return false; | ||||
|             }; | ||||
|     #pragma endregion | ||||
|     #pragma region Witch Ability 3 (???) | ||||
|         Witch::ability3.action= | ||||
|             [&](){ | ||||
|             [&](vf2d pos={}){ | ||||
|                 return false; | ||||
|             }; | ||||
|     #pragma endregion | ||||
|  | ||||
| @ -75,7 +75,7 @@ bool Wizard::AutoAttack(){ | ||||
| void Wizard::InitializeClassAbilities(){ | ||||
|     #pragma region Wizard Right-click Ability (Teleport) | ||||
|         Wizard::rightClickAbility.action= | ||||
|             [&](){ | ||||
|             [&](vf2d pos={}){ | ||||
|                 float pointMouseDirection=atan2(game->GetWorldMousePos().y-GetPos().y,game->GetWorldMousePos().x-GetPos().x); | ||||
|                 vf2d pointTowardsMouse={cos(pointMouseDirection),sin(pointMouseDirection)}; | ||||
|                 float dist=std::clamp(geom2d::line<float>{GetPos(),game->GetWorldMousePos()}.length(),0.f,6.5f*24); | ||||
| @ -103,7 +103,7 @@ void Wizard::InitializeClassAbilities(){ | ||||
|     #pragma endregion | ||||
|     #pragma region Wizard Ability 1 (Fire Bolt) | ||||
|         Wizard::ability1.action= | ||||
|             [&](){ | ||||
|             [&](vf2d pos={}){ | ||||
|                 float angleToCursor=atan2(game->GetWorldMousePos().y-GetPos().y,game->GetWorldMousePos().x-GetPos().x); | ||||
|                 BULLET_LIST.push_back(std::make_unique<FireBolt>(FireBolt(GetPos(),{cos(angleToCursor)*275,sin(angleToCursor)*275},12,GetAttack(),upperLevel,true,{240,120,60}))); | ||||
|                 return true; | ||||
| @ -111,7 +111,7 @@ void Wizard::InitializeClassAbilities(){ | ||||
|     #pragma endregion | ||||
|     #pragma region Wizard Ability 2 (Lightning Bolt) | ||||
|         Wizard::ability2.action= | ||||
|             [&](){ | ||||
|             [&](vf2d pos={}){ | ||||
|                 float angleToCursor=atan2(game->GetWorldMousePos().y-GetPos().y,game->GetWorldMousePos().x-GetPos().x); | ||||
|                 BULLET_LIST.push_back(std::make_unique<LightningBolt>(LightningBolt(GetPos(),{cos(angleToCursor)*230,sin(angleToCursor)*230},12,GetAttack()*4,upperLevel,true,WHITE))); | ||||
|                 return true; | ||||
| @ -119,9 +119,9 @@ void Wizard::InitializeClassAbilities(){ | ||||
|     #pragma endregion | ||||
|     #pragma region Wizard Ability 3 (Meteor) | ||||
|         Wizard::ability3.action= | ||||
|             [&](){ | ||||
|             [&](vf2d pos={}){ | ||||
|                 CastSpell(Wizard::ability3); | ||||
|                 game->AddEffect(std::make_unique<Meteor>(GetPos(),3,AnimationState::METEOR,OnUpperLevel(),vf2d{1,1},2)); | ||||
|                 game->AddEffect(std::make_unique<Meteor>(pos,3,AnimationState::METEOR,OnUpperLevel(),vf2d{1,1},2)); | ||||
|                 return true; | ||||
|             }; | ||||
|     #pragma endregion | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user