The open source repository for the action RPG game in development by Sig Productions titled 'Adventures in Lestoria'!
https://forums.lestoria.net
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
137 lines
6.0 KiB
137 lines
6.0 KiB
#pragma region License
|
|
/*
|
|
License (OLC-3)
|
|
~~~~~~~~~~~~~~~
|
|
|
|
Copyright 2024 Joshua Sigona <sigonasr2@gmail.com>
|
|
|
|
Redistribution and use in source and binary forms, with or without modification,
|
|
are permitted provided that the following conditions are met:
|
|
|
|
1. Redistributions or derivations of source code must retain the above copyright
|
|
notice, this list of conditions and the following disclaimer.
|
|
|
|
2. Redistributions or derivative works in binary form must reproduce the above
|
|
copyright notice. This list of conditions and the following disclaimer must be
|
|
reproduced in the documentation and/or other materials provided with the distribution.
|
|
|
|
3. Neither the name of the copyright holder nor the names of its contributors may
|
|
be used to endorse or promote products derived from this software without specific
|
|
prior written permission.
|
|
|
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
|
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
|
SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
|
TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
|
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
|
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
SUCH DAMAGE.
|
|
|
|
Portions of this software are copyright © 2024 The FreeType
|
|
Project (www.freetype.org). Please see LICENSE_FT.txt for more information.
|
|
All rights reserved.
|
|
*/
|
|
#pragma endregion
|
|
#pragma once
|
|
#include "DEFINES.h"
|
|
#include "Item.h"
|
|
#include "Direction.h"
|
|
#include <unordered_set>
|
|
|
|
INCLUDE_ITEM_DATA
|
|
|
|
struct MonsterDropData{
|
|
const ItemInfo&item;
|
|
float dropChance;
|
|
int minQty=1;
|
|
int maxQty=1;
|
|
//Drop Chance is between 0-100 (NOT a percentage (Like 1.0f does not mean 100% here)!!)
|
|
MonsterDropData(std::string itemName,float dropChance,int minQty=1,int maxQty=1)
|
|
:item(ITEM_DATA.at(itemName)),dropChance(dropChance),minQty(minQty),maxQty(maxQty){}
|
|
//Drop Chance is between 0-100 (NOT a percentage (Like 1.0f does not mean 100% here)!!)
|
|
MonsterDropData(const ItemInfo&item,float dropChance,int minQty=1,int maxQty=1)
|
|
:item(item),dropChance(dropChance),minQty(minQty),maxQty(maxQty){}
|
|
MonsterDropData(const MonsterDropData&ref)=default;
|
|
MonsterDropData operator=(const MonsterDropData&ref){
|
|
return {ref.item,ref.dropChance,ref.minQty,ref.maxQty};
|
|
}
|
|
};
|
|
|
|
struct MonsterData{
|
|
public:
|
|
MonsterData();
|
|
MonsterData(std::string name,std::string displayName,int hp,int atk,const uint32_t xp,std::vector<MonsterDropData>drops,float moveSpd=100.f,float size=1.0f,std::string strategy="Run Towards",int collisionDmg=0);
|
|
int GetHealth();
|
|
int GetAttack();
|
|
const uint32_t GetXP()const;
|
|
float GetMoveSpdMult();
|
|
float GetSizeMult()const;
|
|
const std::string&GetAIStrategy()const;
|
|
int GetCollisionDmg();
|
|
const std::string GetDefaultIdleAnimation()const;
|
|
const std::string GetDefaultJumpAnimation()const;
|
|
const std::string GetDefaultShootAnimation()const;
|
|
const std::string GetDefaultDeathAnimation()const;
|
|
const std::string GetIdleAnimation(const Direction&dir)const;
|
|
const std::string GetJumpAnimation(const Direction&dir)const;
|
|
const std::string GetShootAnimation(const Direction&dir)const;
|
|
const std::string GetDeathAnimation(const Direction&dir)const;
|
|
const EventName&GetHurtSound();
|
|
const EventName&GetDeathSound();
|
|
const EventName&GetWalkSound();
|
|
const bool IsNPC()const;
|
|
std::unordered_set<std::string>GetAnimations(){
|
|
return animations;
|
|
}
|
|
const std::vector<MonsterDropData>&GetDropData();
|
|
const std::string&GetInternalName()const;
|
|
const std::string&GetDisplayName()const;
|
|
static void InitializeMonsterData();
|
|
static void InitializeNPCData();
|
|
static std::unordered_map<std::string,Renderable*>imgs;
|
|
const bool HasFourWaySprites()const;
|
|
void SetUsesFourWaySprites();
|
|
const bool HasMountedAnimation()const;
|
|
const std::optional<const std::string>GetMountedAnimation()const;
|
|
const vf2d&GetMountedAnimationOffset()const;
|
|
const bool IgnoresTerrainCollision()const;
|
|
const bool Immovable()const;
|
|
const bool Invulnerable()const;
|
|
//If an object has a lifetime set, returns it.
|
|
const std::optional<float>GetLifetime()const;
|
|
//If an object has a collision radius, returns it.
|
|
const float GetCollisionRadius()const;
|
|
const bool HasArrowIndicator()const;
|
|
private:
|
|
std::string name;
|
|
int hp;
|
|
int atk;
|
|
uint32_t xp;
|
|
float moveSpd;//1.0=100%
|
|
float size;
|
|
std::unordered_set<std::string>animations;
|
|
std::string displayName;
|
|
std::string idleAnimation="WARRIOR_IDLE_S"; //Represents the basic animation name, not the full animation name that ANIMATION_DATA indexes into!! (Ex. Not GREEN_SLIME_IDLE, but IDLE)
|
|
std::string jumpAnimation="WARRIOR_IDLE_S"; //Represents the basic animation name, not the full animation name that ANIMATION_DATA indexes into!! (Ex. Not GREEN_SLIME_JUMP, but JUMP)
|
|
std::string shootAnimation="WARRIOR_IDLE_S"; //Represents the basic animation name, not the full animation name that ANIMATION_DATA indexes into!! (Ex. Not GREEN_SLIME_SHOOT, but SHOOT)
|
|
std::string deathAnimation="WARRIOR_IDLE_S"; //Represents the basic animation name, not the full animation name that ANIMATION_DATA indexes into!! (Ex. Not GREEN_SLIME_DEATH, but DEATH)
|
|
std::string strategy;
|
|
int collisionDmg;
|
|
EventName hurtSound="";
|
|
EventName deathSound="";
|
|
EventName walkSound="";
|
|
std::vector<MonsterDropData> dropData;
|
|
bool isNPC=false;
|
|
bool fourWayDirectionalSprites=false; //When this flag is set, a monster has 4-way animations instead of the default 1-direction animation.
|
|
std::optional<std::string>mountedAnimName;
|
|
vf2d mountedAnimationOffset{};
|
|
bool ignoresCollision{false}; //If set to true, this monster does not run into terrain.
|
|
bool immovable{false};
|
|
bool invulnerable{false};
|
|
std::optional<float>lifetime{};
|
|
float collisionRadius{};
|
|
bool hasArrowIndicator{false};
|
|
}; |