Creating a new character in the desktop build is now fixed. Added NPC interact functionality.
This commit is contained in:
@@ -37,9 +37,39 @@ All rights reserved.
|
||||
#pragma endregion
|
||||
|
||||
#include "Monster.h"
|
||||
#include "AdventuresInLestoria.h"
|
||||
#include "MonsterStrategyHelpers.h"
|
||||
#include "util.h"
|
||||
#include "Menu.h"
|
||||
|
||||
using A=Attribute;
|
||||
|
||||
void Monster::STRATEGY::NPC(Monster&m,float fElapsedTime,std::string strategy){
|
||||
INCLUDE_game
|
||||
|
||||
void Monster::STRATEGY::NPC(Monster&m,float fElapsedTime,std::string strategy){
|
||||
if(m.phase==0){ //Initialization.
|
||||
if(m.npcData.function.length()>0){
|
||||
m.SetStrategyDrawOverlayFunction([](AiL*game,Monster&m,const std::string&strategy){
|
||||
game->KEY_CONFIRM.DrawInput(m.GetPos()+vf2d{ConfigFloatArr("Interaction Display Offset",0),ConfigFloatArr("Interaction Display Offset",1)},"Interact",uint8_t(util::lerp(0.f,255.f,m.F(A::TARGET_TIMER)/ConfigFloat("Interaction Display Ease in Timer"))));
|
||||
});
|
||||
}
|
||||
m.phase=1;
|
||||
}
|
||||
float distFromPlayer=geom2d::line<float>(m.GetPos(),game->GetPlayer()->GetPos()).length();
|
||||
if(distFromPlayer<ConfigFloat("Interaction Distance")/100.f*24.f){
|
||||
m.F(A::TARGET_TIMER)=std::min(m.F(A::TARGET_TIMER)+fElapsedTime,ConfigFloat("Interaction Display Ease in Timer"));
|
||||
if(game->KEY_CONFIRM.Released()&&Menu::stack.size()==0){
|
||||
if(m.npcData.function=="Blacksmith"){
|
||||
Menu::OpenMenu(MenuType::BLACKSMITH);
|
||||
}else
|
||||
if(m.npcData.function=="PotionCrafting"){
|
||||
Menu::OpenMenu(MenuType::CRAFT_CONSUMABLE);
|
||||
}else
|
||||
if(m.npcData.function=="TravelingMerchant"){
|
||||
Menu::OpenMenu(MenuType::MERCHANT);
|
||||
}
|
||||
}
|
||||
}else{
|
||||
m.F(A::TARGET_TIMER)=std::max(0.f,m.F(A::TARGET_TIMER)-fElapsedTime);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user