Mana Trouble

11/10/2008 05:31 Valkmax#1
I would just like a tip or hint as to were to look for ideals on how to fix this bug.
If anyone could help me with this (not code it for me) I would be very
appreciative.

My mana never runs out on taos, and when I have gourd as a trojan it says 0/800 but I can never get it up.
11/10/2008 07:04 _Emme_#2
It's not a bug,it just has never been coded

Note: This is just an example / part of the code:


Define two things in Character.cs , CurMP, MaxMP, done?
Now lets say you want to gain 100 mana by using an item,it would look something like this:

if (ItemParts[0] == "ManaPotItemID")
{
CurMP += 100;
if (CurMP > MaxMP)
CurMP = MaxMP;
MyClient.SendPacket(General.MyPackets.Vital(UID,2, CurMP));

RemoveItem(ItemUID);
}


Okay,this is the number of the lines and I'll explain why they are there:


1 line : Checks if the item you rightclick on has the ID "ManaPotItemID"

2 line : Pluses your CurMP by 100, but this far,only the server know,not the client. So you still would have as much mana as you had before.


3 line : After your mana got plused ( server sided ) , it checks if it got higher than your max mana,because thats a bug.

4 line: If the mana was higher than max mana, it just takes your mana to max mana.


5. Send the packet to the client with your current mana ( server sided ) , so it upgrades on the client.


6 line : Removes the item you just used.


Hope it helped some


Emme
11/10/2008 07:29 Valkmax#3
Thank you this is just what I needed to learn and understand at same time =)
11/10/2008 13:29 tao4229#4
Gourds and mana removing on skills aren't implemented.
*Bring it on?*
11/10/2008 17:11 _Emme_#5
Mana removing on skills is pretty damn easy? lol
just to do

if (SkillID == ManaSkill)
{
if (skilllvl == blabla)
CurMP -= blabla;
sendpacket.


easy

And for gourd,pretty damn easy too. Just in the equip and unequip item part,do SOMETHING like this,its just in my head right now:


In Equip:

if (ItemID == Gourd)
{
MyChar.CurHP += 800;
SendPacket


In Unequip:

if (ItemID == Gourd)
{
CurHP -= 800;
SendPacket





Edit:
Maybe,just maybe this would work,you know at the use item part,such as exppots,expballs and all that,if you would do like this instead of equip


if (ItemParts[0] == Gourd)
{
CurHP += 800;
SendPacket
Equip(ItemUID);
}

Wouldnt that work? Lol
11/10/2008 17:18 kinshi88#6
Wouldn't you have to increase the MaxHP for adding gourd Emme?
11/10/2008 19:43 _Emme_#7
Does it do that on real co?
If so,you would just do:

CurHP += 800;
if (CurHP > MaxHP)
MaxHP = CurHP;



=]


Edit:
At unequip,you would do like:

CurHP -= 800;
MaxHP -= 800;
11/10/2008 20:21 Valkmax#8
Ok so this is what I have done and I still can't get mana to work,
Problems
1. Mana never goes down when casting spell (i.e nado)
2. Gourd Gives HP but not MP (i.e 0/800)
3. Mana pots don't seem to work but half way
Tao (full mana cause doe not go down)
Your mana is full you can not use this item (w/e)
Trojan with gourd 0/800
This item is not implemented yet blah (w/e)

Any tips would be nice,
Thanks in advance
If you rather pm things or msn me just let me know (will give msn to select people if needed)
#################
LOTF Source (TCWNN)
#################

CurMP, MaxMP
Code:
public ushort CurMP = 0;
public ushort MaxMP = 0;
Setting mana
Code:
public ushort BaseMana()
        {
            Ready = false;
            ushort mp = (ushort)(Spi * 15);
            if (Job == 133 || Job == 143)
                mp = (ushort)(Spi * 20);
            if (Job == 134 || Job == 144)
                mp = (ushort)(Spi * 25);
            if (Job == 135 || Job == 145)
                mp = (ushort)(Spi * 30);
            Ready = true;

            return (ushort)mp;
        }
Nado so it knows how much mana to remove (32,36,etc)
Code:
 SkillAttributes[1002] = new ushort[4][];
            SkillAttributes[1002][0] = new ushort[6] { 2, 0, 32, 505, 0, 0 };
            SkillAttributes[1002][1] = new ushort[6] { 2, 0, 36, 666, 0, 0 };
            SkillAttributes[1002][2] = new ushort[6] { 2, 0, 50, 882, 0, 0 };
            SkillAttributes[1002][3] = new ushort[6] { 2, 0, 62, 1166, 0, 0 };
            SkillsDone.Add(1002, 3);
Pots
Code:
else if (ItemParts[0] == "720014")
            {
                CurMP += 1000;
                if (CurMP > MaxMP)
                    CurMP = MaxMP;
                MyClient.SendPacket(General.MyPackets.Vital(UID, 0, CurMP));

                RemoveItem(720014);
            }
            else if (ItemParts[0] == "720015")
            {
                CurMP += 2000;
                if (CurMP > MaxMP)
                    CurMP = MaxMP;
                MyClient.SendPacket(General.MyPackets.Vital(UID, 0, CurMP));

                RemoveItem(720015);
            }
            else if (ItemParts[0] == "720016")
            {
                CurMP += 3000;
                if (CurMP > MaxMP)
                    CurMP = MaxMP;
                MyClient.SendPacket(General.MyPackets.Vital(UID, 0, CurMP));

                RemoveItem(720016);
            }
            else if (ItemParts[0] == "720017")
            {
                CurMP += 4500;
                if (CurMP > MaxMP)
                    CurMP = MaxMP;
                MyClient.SendPacket(General.MyPackets.Vital(UID, 0, CurMP));

                RemoveItem(720017);
            }
Gourd
Code:
ushort ExtraHP = 0;
                ushort ExtraAtk = 0;
                ushort ExtraMP = 0;

                if (ItemId == 137310)
                    ExtraHP = 30000;
                if (ItemId == 2100025)
                {
                    ExtraHP = 800;
                    ExtraMP = 800;
                }
                if (ItemId == 2100045)
                    ExtraMP = 400;


                ushort AddDef = (ushort)(TheItem[10] + ushort.Parse(PItem[5]));
                ushort AddMDef = (ushort)(TheItem[11] + ushort.Parse(PItem[7]));
                ushort AddMinAtk = 0;
                ushort AddMaxAtk = 0;
                if (Pos != 5)
                {
                    AddMinAtk = (ushort)(TheItem[8] + uint.Parse(PItem[3]) + ExtraAtk);
                    AddMaxAtk = (ushort)(TheItem[9] + uint.Parse(PItem[4]) + ExtraAtk);
                }
                else
                {
                    AddMinAtk = (ushort)((TheItem[8] + uint.Parse(PItem[3]) + ExtraAtk) / 2);
                    AddMaxAtk = (ushort)((TheItem[9] + uint.Parse(PItem[4]) + ExtraAtk) / 2);
                }
                ushort AddMAtk = (ushort)(TheItem[12] + ushort.Parse(PItem[6]));
                ushort AddHP = (ushort)(ItemEnchant + ExtraHP + ushort.Parse(PItem[2]));
                ushort AddMP = (ushort)(ItemEnchant + ExtraMP + ushort.Parse(PItem[2]));
                ushort AddDex = (ushort)(TheItem[14] + ushort.Parse(PItem[8]));
                byte AddDodge = (byte)(TheItem[13] + byte.Parse(PItem[9]));
With this
Code:
if (SkillID == ManaSkill)
{
if (skilllvl == blabla)
CurMP -= blabla;
sendpacket.

I don't understand why you would need to define the skill a second time? If that make since, cause in database. Under SkillAttributes you are telling it how much to remove already?

I am very lost and this is one of the main things I want to work so I can start fixing and adding more skills and then work on damage's. If anyone can help me with MANA in general I would be very happy. I am trying to learn C# I am new to it, but I am trying to learn and not copy and paste things.
11/10/2008 20:53 _Emme_#9
You dont need to define it a second time,that was just an example =P
About gourd,you could just do:

CurMP += 800;
if (CurMP > MaxMP;
MaxMP = CurMP;

SendPacket


Unequip:

CurMP -= 800;
MaxMP -= 800;
if (CurMP < 0)
CurMP = 0;
SendPacket
11/10/2008 21:34 Valkmax#10
I think the problem with gourd is same with skills, it just does not know what mana is? I don't know :P I truly am lost here with this mana stuff and I haven't found anything on it besides whats in this post.
11/10/2008 21:41 Incariuz#11
You're not alone man. The whole mana deal is confusing the hell out of me to. I've been trying for 2 days now to try and figure it out, and just no luck. If I figure something out, I'll update you, but the way this is progressing for me, doubt that's gonna happen.
11/10/2008 21:41 _Emme_#12
No listen,this is how it works:

You define mana,now its CurMP on your source ( i think ).

Okay,client has no idea at all what curmp is,right? But still,you add like 100 mana,in the server.
Now,to let the client know,you need to send a packet to the client.

We have this far figure out that the mana type is 2, so, we have to send the current mana to the type 2.

So,you would do that like this:

SendPacket(General.MyPackets.Vital(MyChar.UID, 2, CurMP));

Okay,so what you do is:

SendPacket(General.MyPackets.Vital

Sends an vital packet


MyChar.UID

So it knows it should send it to your character.


2

The type is 2 for mana,so we send it to the mana bar. 0 is for HP, 12 is for Model, and 2 is for mana. ( There is alot more,those were just examples! )


CurMP

And for the value of the code,how much MP you should gain,there, we define CurMP. So if you have CurMP = 100 in the source, it will gain 100 MP in the client, mana bar.

Understand a bit better now? Hope you did.

Emme
11/10/2008 21:42 nTL3fTy#13
I noticed with your potions you're trying to remove an item by its ItemID. The parameter is supposed to be the ItemUID (unique ID) so the client knows exactly which item was used. So change it to ItemUID (a parameter for the method [UseItem(ulong ItemUID, string Item)]). An item's UID is really a uint, but that's another story.
11/10/2008 21:48 Valkmax#14
Thank you all and emme I think I understand what you are saying I will try to miss with it some more and see what I can do.
@ntl I will change that thank you.

Did some missing and seems nothing is helping

So I added
MyClient.SendPacket(General.MyPackets.Vital((long) UID, 2, CurMP));

After every
MyClient.SendPacket(General.MyPackets.Vital((long) UID, 0, CurHP));

Then I added every
CurMP = MaxMP;
after
CurHP = MaxHP;

Then
MaxMP = BaseMaxMP();

After every
MaxHP = BaseMaxHP();

Then did this
Code:
public ushort BaseMaxMP()
        {
            Ready = false;
            ushort mp = (ushort)(Spi * 15);
            if (Job == 133 || Job == 143)
                mp = (ushort)(Spi * 20);
            if (Job == 134 || Job == 144)
                mp = (ushort)(Spi * 25);
            if (Job == 135 || Job == 145)
                mp = (ushort)(Spi * 30);
            Ready = true;

            return (ushort)mp;
        }
after
Code:
   public ushort BaseMaxHP()
        {
            Ready = false;
            double hp = Vit * 24 + Str * 3 + Agi * 3 + Spi * 3;
            if (Job == 11)
                hp *= 1.05;
            if (Job == 12)
                hp *= 1.08;
            if (Job == 13)
                hp *= 1.1;
            if (Job == 14)
                hp *= 1.12;
            if (Job == 15)
                hp *= 1.15;
            Ready = true;
            return (ushort)hp;
        }
And still nothing has change so I don't know what I am doing wrong
11/10/2008 22:26 Incariuz#15
I noticed an error with the coding you did for using pots. Seems there are 2 ID's for each, and you need to have both added for them to work.

So simply add this above the ones you already added, and they work. However, the weekest pill hasn't been coded, I'll search them after and add.

Code:
else if (ItemParts[0] == "1001030")
            {
                CurMP += 1000;
                if (CurMP > MaxMP)
                    CurMP = MaxMP;
                MyClient.SendPacket(General.MyPackets.Vital(UID, 2, CurMP));

                RemoveItem(ItemUID);
            }
            else if (ItemParts[0] == "1001040")
            {
                CurMP += 2000;
                if (CurMP > MaxMP)
                    CurMP = MaxMP;
                MyClient.SendPacket(General.MyPackets.Vital(UID, 2, CurMP));

                RemoveItem(ItemUID);
            }
            else if (ItemParts[0] == "1002030")
            {
                CurMP += 3000;
                if (CurMP > MaxMP)
                    CurMP = MaxMP;
                MyClient.SendPacket(General.MyPackets.Vital(UID, 2, CurMP));

                RemoveItem(ItemUID);
            }
            else if (ItemParts[0] == "1002040")
            {
                CurMP += 4500;
                if (CurMP > MaxMP)
                    CurMP = MaxMP;
                MyClient.SendPacket(General.MyPackets.Vital(UID, 2, CurMP));

                RemoveItem(ItemUID);
            }
Oh, and go to all your codes and change the send packets to...

Code:
MyClient.SendPacket(General.MyPackets.Vital(UID, 2, CurMP));
nothing major, you just used 0 instead of 2. Pots are usable once that's done. I'm going to keep trying to figure out the whole spells using mana still.