Enchanting
#41
First of all don't declare the enchantments enum - it's already declared in cEnchantments, you just need to name it there (put the "eEnchantmentType" after the "enum" keyword), then you can use it anywhere as cEnchantments::eEnchantmentType.

Then, to simplify the later hooks, use:
// In Enchantments.h:
typedef std::vector<cEnchantment> cEnchantments;
Use the cEnchantments type to store the enchantments.

Also, in order to reduce needless copying, use the following function signature:
/** Fills a_Enchantments with the list of enchantments applicable to the specified item type */
static void cItem::GetApplicableEnchantmentsForType(short a_ItemType, cEnchantments & a_Enchantments);
Reply
Thanks given by: daniel0916
#42
cItem::GetApplicableEnchantmentsForType(EnchantItem.m_ItemType, );
What should i use for cEnchantments & a_Enchantments?
Reply
Thanks given by:
#43
(01-26-2014, 08:58 PM)xoft Wrote:
// In Enchantments.h:
typedef std::vector<cEnchantment> cEnchantments;

Do you mean?
typedef std::vector<cEnchantments> cEnchantments;
or should i create a cEnchantment Class?

(01-26-2014, 04:08 AM)xoft Wrote:
class cEnchantment
{
  enum eEnchantmentType { enchProtection ... };  // <-- NAME the enchantment enum
  ...
  /** Returns true if the item type supports the specified enchantment type and level */
  static bool CanEnchantItemType(short a_ItemType, eEnchantmentType a_EnchantmentType, int a_Level);

  /** Returns true if the specified item can be enchanted with the specified enchantment 
  This includes checks for mutually exclusive enchantments, such as Sharpness and Smite */
  static bool CanEnchantItem(const cItem & a_Item, eEnchantmentType a_EnchantmentType, int a_Level);
} ;

Ah okay. I will create this.
Reply
Thanks given by:
#44
Ah, I wrote this from memory, so it's wrong.
I though our existing enchantments container was called cEnchantment. So, to revise:
typedef std::vector<cEnchantments> cEnchantmentsArray;

/** Fills a_Enchantments with the list of enchantments applicable to the specified item type */
static void cItem::GetApplicableEnchantmentsForType(short a_ItemType, cEnchantmentsArray & a_Enchantments);
Reply
Thanks given by: daniel0916
#45
How can i now add to the a_Enchantments Array enchantments?
Reply
Thanks given by:
#46
You know, this is becoming really tiresome. You keep asking us for each and every little detail. In the end, it's like we do most of the work in our answers and then you still don't submit any code that we could use, so it's time effectively wasted. I don't mind losing time teaching beginners, but I hate losing time due to wasting it. This project requires at least a basic knowledge of C++, along with the mindset to learn by yourself, not by bothering others for things you can try out faster than we write our answer. If you want to learn C++, you need to do it somewhere else, this is not the right place for learning the basics.
Reply
Thanks given by:
#47
You have right. I will try it myself.
Reply
Thanks given by:
#48
Aww, xoft, that's harsh :P
Reply
Thanks given by:
#49
I won't make stupid question and i know now that i can use .push_back().
In the array's typedef the argument is cEnchantments.
a_Enchantments.push_back(cEnchantments::enchAquaAffinity);
But this isn't cEnchantments, this is "enum cEnchantments::<unnamed>"
When i know that, i can make the cItem method ready.
Reply
Thanks given by:
#50
The question is, do we want a list of raw enchantments, or do we want a list of enchantments together with levels? For the first one, use the (unnamed) enum - name it first. For the second one, use the entire cEnchantments class as the contained item. Discuss the advantages and disadvantages of both.
Reply
Thanks given by: daniel0916




Users browsing this thread: 5 Guest(s)