Pride and fall, weaponManager, equipManager and itemManager

Some complaints and emotional update here serious part bellow 

You might not have taken it from the way I write but I have a hard time asking for help when it comes to code. Why that really is I don’t know but I have that and so for today I asked for help from a million people because of this page:

 

I HATE THIS PAGE

I have seen that page around 50 times today and I hate it OH GOD do I hate it.
So if you read the last blog post I made I can tell you now I did not finish the weapon manager because of this page. I wanted to do an update earlier but THIS page stopped me. It was not meant to be, this page hates me and all around me .

Now that is out of the way I got a suggestion to be more… professional when I talk about code I do and I have taken that comment to my heart and buried it deep. So deep. Well enough joking lets talk CODE!

This is the serious CODE part ——-

The part I have worked on this week is WeaponManager, EquipManager and ItemManager. Since the Item manager will get and use items just like weaponManager will use weapons I have not made any attempt to make a itemManager until the weaponManager Works to my advantage.

-std::map

So I learned a little more about how std::map works today since I learned today why the WeaponManager might have malfunction. I tried to get data in the wrong way and that made all the difference.

First of all after making a std::map, a good idea is to use it. After about half the day looking for a reason why I ended up on the page above me all the time or always got ”BREAK” error messages I realized I did not take any data from the std::map. So I had to ask for a help there because I tried to read it in other ways.

A little instructions.

to make a std::map using a struct is a really good move. Like this

struct weaponSkeleton{

std::string identifier;

int magazine_size;
bool auto_fire;

float bullet_speed;
float damage;
float max_spread;
float min_spread;
float shoot_delay;
float weight;
};

Yes it will keep the data for you and you can sit back and relax. Well maybe it isn’t that easy. To read in the data you have to use the identifier from what I gathered the storage go like this:

identifier -> all other information , identifier -> all other information.

So to get the right information you need the identifier first and so this is an example in how you load it.

auto it = m_weaponData.find(name);
if (it != m_weaponData.end())
{
it->second->identifier = name;
weapon->setAutoFire(it->second->auto_fire);
weapon->setMagazineSize(it->second->magazine_size);
return it->second;
}

so as you see this is the correct way of doing it. This is how I did it:

created a pointer to the struct* m_stupid_move

m_stupid_move->magazine_size;

and that did not work. First of all I already had a pointer so making a new one was not the best idea I ever had and also look at the code above this. Yes I already had that code. So now you know how std::map works.

–equipManager

Now here is something I am a little more proud of…*ahem*
The name of this manager should be inventoryManager  because that is closer to the truth, but as I see it in our game we will not really have an inventory but only pick up ”stuff” and use it. We will have two slots. So for me it seemed more likely to name it Equip because that is what it manages.

So short version of how it will work in the future. The equipManager will be executed when a player and specific entity’s collide such as items and weapons. It will then take a look can I store this for the player? Yes I can or no an item is there let’s get rid of it and replace it with this new item.

Now to make this work I took help from what I learned in creating the weaponManager and made a couple of setName.

but to make it easier for me using two setName1 and setName2 seemed to make it better because I would have two slots and I will get pictures for two things because the GUI will change when the equip is done.

Now for that part it seems to work I did not test it because the weaponManager called for debugging, but the shell is up. Here is something I got as a suggestion though. std::cout << ”Slot 1″ << std::endl; to see if the code work. Now I will test this after the weaponManager is done but yes this is how it should work.

–WeaponManager

I have nothing to say, the progress was slow here and other than mentioned about the std::map above I have made little to none progress. I thought I had made more progress than that but I still can’t make that bullet I want to fire, fire (so that you can see it in the program).
I still have help to get and I am working on it because when that works so will the ItemManager and BOYA equip is all that is left and to make it look good.

–Last Ramble

Thank you good reader for making it this far. Now I will tell you a joke to lighten your mood. ”Who goes in the night, with cane and pointy hat?” ”THAT EVIL PICTURE UP THERE HE IS AFTER YOU AND WANT’S YOUR SOUL!”
”Que?”
”oh never mind I just went crazy there for a bit, the answer is of course Dracula with a bad hip”
”Don’t talk to people no more, okay”