[HELP] My attempt to make a rb npc

06/11/2009 19:58 quadruple1#1
Here is my attempt to create an npc that reborns you

Code:
                case 211091:// Rb Adder
                    {
                        if (LinkBack == 0)
                        {
                            Text("Would you like to be reborn? You need to be level 120 or higher to reborn.", CSocket);
                            Link("1st rb", 1, CSocket);
                            Link("2nd rb", 2, CSocket);
                            Link("No thanks", 225, CSocket);
                            End(CSocket);

                        }
                        else if (LinkBack == 1)
                        {
                            if (CSocket.Client.Reborn == 0)
                            if (CSocket.Client.Level >= 120)
                            {
                                Reborn(+1, CSocket);
                                Level(15, CSocket);
                            }
                            else
                            {
                                Text("You are not high enough level", CSocket);
                                Link("Damn!", 255, CSocket);
                                End(CSocket);
                            }
                        }
                        else if (LinkBack == 2)
                        {
                            if (CSocket.Client.Level >= 120)
                            if (CSocket.Client.Reborn == 1)
                        Reborn(+1, CSocket);
                        Level (15, CSocket);
                        }
                        else
                        {
                            Text("You are not high enough level", CSocket);
                            Link("Damn!", 255, CSocket);
                            End(CSocket);
                        }
                        break;
                    }
Apparently, when i click on the npc and choose the "1st rb" link, it does not make me 1st rb. anyone know what im doing wrong?
06/11/2009 20:31 Kiyono#2
I don't know if this would work but instead of Reborn(+1, CSocket); use CSocket.Client.Reborn = 1; for 1st rb and CSocket.Client.Reborn = 2; for 2nd rb.
06/11/2009 20:41 Incariuz#3
That's the general way I've seen it done in other sources, so I'm assuming that would work Kiyono.
06/11/2009 20:50 kiltz#4
case 211091:// Rb Adder
{
if (LinkBack == 0)
{
Text("Would you like to be reborn? You need to be level 120 or higher to reborn.", CSocket);
Link("1st rb", 1, CSocket);
Link("2nd rb", 2, CSocket);
Link("No thanks", 225, CSocket);
End(CSocket);

}
else if (LinkBack == 1)
{
if (CSocket.Client.Reborn == 0)
if (CSocket.Client.Level >= 120)

{

CSocket.Client.Reborn = 1;
CSocket.Client.Level = 15; ConquerPacket.ToServer(ConquerPacket.Chat(0, "SYSTEM", "ALLUSERS", "CONGRATULATIONS! " + CSocket.Client.Name + " has just been reborn! Good job!", Struct.ChatType.Center), 0);
}
else
{
Text("You are not high enough level", CSocket);
Link("Damn!", 255, CSocket);
End(CSocket);
}
}
else if (LinkBack == 2)
{
if (CSocket.Client.Level >= 120)
if (CSocket.Client.Reborn == 1)
Reborn(+1, CSocket);
Level (15, CSocket);
}
else
{
Text("You are not high enough level", CSocket);
Link("Damn!", 255, CSocket);
End(CSocket);
}
break;
}



i dunno how to make the items lower the level. Im still trying to understand the code. Any Idea would be appreciated
06/11/2009 20:50 quadruple1#5
Yeah it works now. Thanks
06/12/2009 00:29 iamanoob#6
Quote:
Originally Posted by kiltz View Post
i dunno how to make the items lower the level. Im still trying to understand the code. Any Idea would be appreciated
in the item number its laid out so that just change the hundreds and tens digit of the item number to 00 or 01 so as an example:

111009 IronHelmet (level 15)
111019 BronzeHelmet (level 22)
..
111109 ConquestHelmet (level 120)

the code i used was:
Code:
#region change gear lvl
                                    int i;
                                    for (i = 1; i < 9; i++)
                                    {
                                        if (i != 7)
                                        {
                                            CSocket.Client.Equipment[i].ItemID =
                                                Calculation.DownLevel(Convert.ToString(CSocket.Client.Equipment[i].ItemID));
                                            Database.Database.UpdateItem(CSocket.Client.Equipment[i]);
                                            CSocket.Send(ConquerPacket.ItemInfo(
                                                CSocket.Client.Equipment[i].UID,
                                                CSocket.Client.Equipment[i].ItemID,
                                                CSocket.Client.Equipment[i].Plus,
                                                CSocket.Client.Equipment[i].Progress,
                                                CSocket.Client.Equipment[i].Bless,
                                                CSocket.Client.Equipment[i].Enchant,
                                                CSocket.Client.Equipment[i].Soc1,
                                                CSocket.Client.Equipment[i].Soc2,
                                                CSocket.Client.Equipment[i].Dura,
                                                CSocket.Client.Equipment[i].MaxDura,
                                                i,
                                                CSocket.Client.Equipment[i].Color));
                                        }
                                    }
                                    Handler.ItemUnequip(5, CSocket.Client.Equipment[5].UID, CSocket);
                                    

                                    #endregion
in calculations add a new class
Code:
using System;
using System.Collections;
using System.Collections.Generic;
using CoEmu_v2_GameServer.Connections;
using CoEmu_v2_GameServer.Entities;
using CoEmu_v2_GameServer.Structs;
using CoEmu_v2_GameServer.Packets;
using CoEmu_v2_GameServer.Calculations;
using CoEmu_v2_GameServer.Database;

namespace CoEmu_v2_GameServer.Calculations
{
    public partial class Calculation
    {
        public static int DownLevel(string ItemID)
        {
            string newID = ItemID;
            newID = newID.Remove(3, 2);
            newID = newID.Insert(3, getNum(Convert.ToInt32(ItemID)));
            return (Convert.ToInt32(newID));
        }
        private static string getNum(int ItemID)
        {
            string num;
            if (ItemID >= 150003 && ItemID <= 159999) //ring 1-126
            {
                if (ItemID == 150310) num = "31";
                else if (ItemID == 150320) num = "32";
                else num = "01";
            }
            else if (ItemID >= 160013 && ItemID <= 169999) //boot 10-126
            {
                num = "01";
            }
            else num = "00";

            return num;

        }
    }
}
06/12/2009 13:00 quadruple1#7
Quote:
Originally Posted by iamanoob View Post
in the item number its laid out so that just change the hundreds and tens digit of the item number to 00 or 01 so as an example:

111009 IronHelmet (level 15)
111019 BronzeHelmet (level 22)
..
111109 ConquestHelmet (level 120)

the code i used was:
Code:
#region change gear lvl
                                    int i;
                                    for (i = 1; i < 9; i++)
                                    {
                                        if (i != 7)
                                        {
                                            CSocket.Client.Equipment[i].ItemID =
                                                Calculation.DownLevel(Convert.ToString(CSocket.Client.Equipment[i].ItemID));
                                            Database.Database.UpdateItem(CSocket.Client.Equipment[i]);
                                            CSocket.Send(ConquerPacket.ItemInfo(
                                                CSocket.Client.Equipment[i].UID,
                                                CSocket.Client.Equipment[i].ItemID,
                                                CSocket.Client.Equipment[i].Plus,
                                                CSocket.Client.Equipment[i].Progress,
                                                CSocket.Client.Equipment[i].Bless,
                                                CSocket.Client.Equipment[i].Enchant,
                                                CSocket.Client.Equipment[i].Soc1,
                                                CSocket.Client.Equipment[i].Soc2,
                                                CSocket.Client.Equipment[i].Dura,
                                                CSocket.Client.Equipment[i].MaxDura,
                                                i,
                                                CSocket.Client.Equipment[i].Color));
                                        }
                                    }
                                    Handler.ItemUnequip(5, CSocket.Client.Equipment[5].UID, CSocket);
                                    

                                    #endregion
in calculations add a new class
Code:
using System;
using System.Collections;
using System.Collections.Generic;
using CoEmu_v2_GameServer.Connections;
using CoEmu_v2_GameServer.Entities;
using CoEmu_v2_GameServer.Structs;
using CoEmu_v2_GameServer.Packets;
using CoEmu_v2_GameServer.Calculations;
using CoEmu_v2_GameServer.Database;

namespace CoEmu_v2_GameServer.Calculations
{
    public partial class Calculation
    {
        public static int DownLevel(string ItemID)
        {
            string newID = ItemID;
            newID = newID.Remove(3, 2);
            newID = newID.Insert(3, getNum(Convert.ToInt32(ItemID)));
            return (Convert.ToInt32(newID));
        }
        private static string getNum(int ItemID)
        {
            string num;
            if (ItemID >= 150003 && ItemID <= 159999) //ring 1-126
            {
                if (ItemID == 150310) num = "31";
                else if (ItemID == 150320) num = "32";
                else num = "01";
            }
            else if (ItemID >= 160013 && ItemID <= 169999) //boot 10-126
            {
                num = "01";
            }
            else num = "00";

            return num;

        }
    }
}
when i add that it gives me this error:
Code:
Warning	1	Unreachable code detected	C:\Users\joe is king\Desktop\CoEmu v2\CoEmu v2 GameServer\Handlers\NpcTalk.cs	5108	21	CoEmu v2 GameServer
06/12/2009 13:18 kiltz#8
on the calculation class, do i need to code all the items? in your example i only see ring and boots, so we need to code each items manually?
06/12/2009 13:22 kiltz#9
HTML Code:
namespace CoEmu_v2_GameServer.Calculations
{
    public partial class Calculation
    {
        public static int DownLevel(string ItemID)
        {
            string newID = ItemID;
            newID = newID.Remove(3, 2);
            newID = newID.Insert(3, getNum(Convert.ToInt32(ItemID)));
            return (Convert.ToInt32(newID));
        }
        private static string getNum(int ItemID)
        {
            string num;
            if (ItemID >= 150003 && ItemID <= 159999) //ring 1-126
            {
                if (ItemID == 150310) num = "31";
                else if (ItemID == 150320) num = "32";
                else num = "01";
            }
            else if (ItemID >= 160013 && ItemID <= 169999) //boot 10-126
            {
                num = "01";
            }
            else num = "00";

            return num;

        }
    }
}

in your calculation folder.. replace all the code with the code above the calculation.cs
06/12/2009 19:52 quadruple1#10
When i do that i get an error saying

Error 1 The call is ambiguous between the following methods or properties: 'CoEmu_v2_GameServer.Calculations.Calculation.Down Level(string)' and 'CoEmu_v2_GameServer.Calculations.Calculation.Down Level(string)' C:\Users\joe is king\Desktop\CoEmu v2\CoEmu v2 GameServer\Handlers\NpcTalk.cs 5114 97 CoEmu v2 GameServer
06/13/2009 02:59 iamanoob#11
@kllitz
no those are just because those items' lowest level item id starts with 01
31 and 32 i think are the loveforever rings thats why its there

@quadruple1
are you using it right? that code is placed in npctalk.cs in a linkback if statement so basically
Code:
 if (LinkBack == /*some number*/){
//insert the above code here
}
06/13/2009 15:20 kiltz#12
HTML Code:
[B]THIS IS JUST SAMPLE CODE AND STILL NEED A LOT OF WORK AND CODING TO BE DONE [/B]

HTML Code:
case 211091: /* Rb Adder  [B]Corrections would be appreciated since i am still learning how to code C Sharp  [/B] */
{
if (LinkBack == 0)
{
Text("Would you like to be reborn? You need to be level 120 or higher to reborn.", CSocket);
Link("1st rb", 1, CSocket);
Link("2nd rb", 2, CSocket);
Link("No thanks", 225, CSocket);
End(CSocket);

}
else if (LinkBack == 1)
{
if (CSocket.Client.Reborn == 0) &&  (CSocket.Client.Level >= 110)
 /*  if (CSocket.Client.Class =     )   dunno what to put here this is supposed to be for water taoist which can reborn at lvl 110 , any idea would be appreciated*/
   if (InventoryContains(721258, 1, CSocket))  // 721258 <---Cleanwater ID

{

CSocket.Client.Reborn = 1;
CSocket.Client.Level = 15; 
ConquerPacket.ToServer(ConquerPacket.Chat(0, "SYSTEM", "ALLUSERS", "CONGRATULATIONS! " + CSocket.Client.Name + " has just been reborn! Good job!", Struct.ChatType.Center), 0);
#region change gear lvl
                                    int i;
                                    for (i = 1; i < 9; i++)
                                    {
                                        if (i != 7)
                                        {
                                            CSocket.Client.Equipment[i].ItemID =
                                                Calculation.DownLevel(Convert.ToString(CSocket.Client.Equipment[i].ItemID));
                                            Database.Database.UpdateItem(CSocket.Client.Equipment[i]);
                                            CSocket.Send(ConquerPacket.ItemInfo(
                                                CSocket.Client.Equipment[i].UID,
                                                CSocket.Client.Equipment[i].ItemID,
                                                CSocket.Client.Equipment[i].Plus,
                                                CSocket.Client.Equipment[i].Progress,
                                                CSocket.Client.Equipment[i].Bless,
                                                CSocket.Client.Equipment[i].Enchant,
                                                CSocket.Client.Equipment[i].Soc1,
                                                CSocket.Client.Equipment[i].Soc2,
                                                CSocket.Client.Equipment[i].Dura,
                                                CSocket.Client.Equipment[i].MaxDura,
                                                i,
                                                CSocket.Client.Equipment[i].Color));
                                        }
                                    }
                                    Handler.ItemUnequip(5, CSocket.Client.Equipment[5].UID, CSocket);
                                    

                                    #endregion
}
else
{
Text("You are not high enough level", CSocket);
Link("Damn!", 255, CSocket);
End(CSocket);
}
}
else if (LinkBack == 2)
{
if (CSocket.Client.Level >= 120)
if (CSocket.Client.Reborn == 1)
Reborn(+1, CSocket);
Level (15, CSocket);
}
else
{
Text("You are not high enough level", CSocket);
Link("Damn!", 255, CSocket);
End(CSocket);
}
break;
}

In the Calculation/Calculation.cs
replace the code with this one.

Credit goes to iamanob


HTML Code:

using System;
using System.Collections;
using System.Collections.Generic;
using CoEmu_v2_GameServer.Connections;
using CoEmu_v2_GameServer.Entities;
using CoEmu_v2_GameServer.Structs;
using CoEmu_v2_GameServer.Packets;
using CoEmu_v2_GameServer.Calculations;
using CoEmu_v2_GameServer.Database;

namespace CoEmu_v2_GameServer.Calculations
{
    public partial class Calculation
    {
        public static int DownLevel(string ItemID)
        {
            string newID = ItemID;
            newID = newID.Remove(3, 2);
            newID = newID.Insert(3, getNum(Convert.ToInt32(ItemID)));
            return (Convert.ToInt32(newID));
        }
        private static string getNum(int ItemID)
        {
            string num;
            if (ItemID >= 150003 && ItemID <= 159999) //ring 1-126
            {
                if (ItemID == 150310) num = "31";
                else if (ItemID == 150320) num = "32";
                else num = "01";
            }
            else if (ItemID >= 160013 && ItemID <= 169999) //boot 10-126
            {
                num = "01";
            }
            else num = "00";

            return num;

        }
    }
}


I am willing to learn, so correct me if i am wrong.
06/17/2009 18:38 quadruple1#13
I put them in the correct places.

how do you get rid of this error?

Error 2 The call is ambiguous between the following methods or properties: 'CoEmu_v2_GameServer.Calculations.Calculation.Down Level(string)' and 'CoEmu_v2_GameServer.Calculations.Calculation.Down Level(string)' C:\Users\joe is king\Desktop\CoEmu v2\CoEmu v2 GameServer\Handlers\NpcTalk.cs 5282 45 CoEmu v2 GameServer
06/19/2009 04:45 WHITELIONX#14
I get 6 errors with npctalk >.<
Error 1 Only assignment, call, increment, decrement, and new object expressions can be used as a statement C:\Documents and Settings\alan\My Documents\CoEmu v2\CoEmu v2\CoEmu v2 GameServer\Handlers\NpcTalk.cs 3145 37 CoEmu v2 GameServer
Error 2 Pointers and fixed size buffers may only be used in an unsafe context C:\Documents and Settings\alan\My Documents\CoEmu v2\CoEmu v2\CoEmu v2 GameServer\Handlers\NpcTalk.cs 3145 37 CoEmu v2 GameServer
Error 3 Cannot take the address of the given expression C:\Documents and Settings\alan\My Documents\CoEmu v2\CoEmu v2\CoEmu v2 GameServer\Handlers\NpcTalk.cs 3145 37 CoEmu v2 GameServer
Error 4 The name 'InventoryContains' does not exist in the current context C:\Documents and Settings\alan\My Documents\CoEmu v2\CoEmu v2\CoEmu v2 GameServer\Handlers\NpcTalk.cs 3147 8 CoEmu v2 GameServer
Error 5 The name 'Reborn' does not exist in the current context C:\Documents and Settings\alan\My Documents\CoEmu v2\CoEmu v2\CoEmu v2 GameServer\Handlers\NpcTalk.cs 3194 1 CoEmu v2 GameServer
Error 6 The name 'Level' does not exist in the current context C:\Documents and Settings\alan\My Documents\CoEmu v2\CoEmu v2\CoEmu v2 GameServer\Handlers\NpcTalk.cs 3195 1 CoEmu v2 GameServer

Now just the one error >.<
Error 1 Invalid expression term '&&' C:\Documents and Settings\alan knight\My Documents\CoEmu v2\CoEmu v2\CoEmu v2 GameServer\Handlers\NpcTalk.cs 3145 37 CoEmu v2 GameServer
06/19/2009 07:24 kiltz#15
@WhiteLion

HTML Code:
if (CSocket.Client.Reborn == 0) &&  (CSocket.Client.Level >= 110)
 /*  if (CSocket.Client.Class =     )   dunno what to put here this is supposed to be for water taoist which can reborn at lvl 110 , any idea would be appreciated*/
   if (InventoryContains(721258, 1, CSocket))  // 721258 <---Cleanwater ID
replace with


HTML Code:
if (CSocket.Client.Reborn == 0) 
  if  (CSocket.Client.Level >= 110)
 /*  if (CSocket.Client.Class =     )   dunno what to put here this is supposed to be for water taoist which can reborn at lvl 110 , any idea would be appreciated*/
   if (InventoryContains(721258, 1, CSocket))  // 721258 <---Cleanwater ID