beginner in private server programming

11/14/2014 00:20 danielstudent#1
Hello, I'm daniel and I'm a c# and vb.net programmer (well everything I write in a language i can manage and write it in the other language). I am not a professional since I am a self taught orgrammmer.

I've downloaded Redux source by pro4never and successfully ran the server. Well it was pretty easy to figure out how to add new npc and these basic stuff but for example when I go to the function or the procedure of writing the NPC I don't understand most of the code written inside them. In other words i dont know how does the system work.

I know basic programming skills and i want somone to tell me from where do I begin. Please don't mention links explaining the meaning of packets and these things, i just want to use.my programming skills in conquer development.

Summary: i know how to code, i know the basics of computer science(i mean theoretical and practical) like for example how to think and write an algorithm, I can use any dbms professionally and finally I know many of the features of the programming languages i use.

Sorry if my question isn't clear, excuse my English.
11/14/2014 00:30 pro4never#2
The question isn't very clear because you claim you understand programming basics (syntax, flow of logic, data structures, etc) and yet are unable to understand what things are doing in the source.

While redux isn't exactly 'clean' in terms of documentation, things are labled half decently. It's pretty obvious what each function should be doing because it's what the function is called (there's plenty of exceptions, again I'm aware it's a mess).


Can you give us a SPECIFIC question on what it is you don't understand?

NPCs are really simple. There's a constructor where you set the ID for the script and the optional avatar the NPC will use when you talk to it.

Code:
  public NPC_102093(Game_Server.Player _client)
            :base (_client)
    	{
            ID = 102093;	
			Face = 123;    
    	}
You then have a run function which accepts the parameters Game_Server.Player (the player using the script) and a linkback (which npc option they have used)

Code:
   public override void Run(Game_Server.Player _client, ushort _linkback)
        {
            Responses = new List<NpcDialogPacket>();
            AddAvatar();
            switch (_linkback)
            {
                case 0:
                    AddText("What can I do for you?");
                    AddOption("Enter the guild area.", 1);
                    AddOption("Just passing by.", 255);
                    break;
                case 1:
                    _client.ChangeMap(1038, 350, 339);
                    break;
            }
            AddFinish();
            Send();
        }

We create a list of responses, add the avatar and then perform a switch statement based on what option the client has used. Depending on the option we either respond to the client (addtext, addoption, etc) or perform actions (change map)

You should be able to read through BASIC npcs like this to get an understanding of how the source is structured. You can then work your way towards larger things in terms of flow of logic but honestly it should be pretty simple to understand the basic flow of logic if you are familiar with entry level programming concepts.


Then again, I could have misunderstood the question and you could be referring to something completely different.
11/14/2014 00:47 danielstudent#3
Sorry i was writing on the phone and couldnt provide an example.
Well these codes are very simple to understand, but for example:
Code:
public void AddOption(string _value, byte _linkback)
        {
            var packet = NpcDialogPacket.Create();
            packet.Action = DialogAction.Option;
            packet.Linkback = _linkback;
            packet.Strings.AddString(_value);
            Responses.Add(packet);
        }
and
Code:
public unsafe struct NpcDialogPacket
    {
        public uint UID;
        public ushort ID;
        public byte Linkback;
        public DialogAction Action;
        public NetStringPacker Strings;

        public ushort PositionX
        {
            get { return (ushort)UID; }
            set { UID = (uint)((PositionY << 16) | value); }
        }

        public ushort PositionY
        {
            get { return (ushort)(UID >> 16); }
            set { UID = (uint)((value << 16) | PositionX); }
        }
        
        public static NpcDialogPacket Create ()
        {        
        	var packet = new NpcDialogPacket();
            packet.Strings = new NetStringPacker();
        	return packet;
        }

......
Well it is very clear what does each block do, but how I dont understand much of the code like for example I ran the server, and I found that attacking isn't working properly in the source (just an example), I dont think I can manage this bug even if I know what lines I have to edit and so on.
I have touched the source only since yesterday and if your comment is "you have to take some time to get used on everything and try again" just tell me so.

Ill reply tomorrow, goodnight and thanks.
11/14/2014 01:17 pro4never#4
Packets are how the client and server communicate with eachother. Their structure is fixed (TQ decides them, not us) and it's our job to write code that allows us to easily write a block of data and send it over the network.

Those methods are all just to help make it easier to interact with that stream of data in a user friendly way. At the end of the day all it's doing is writing a group of bytes so they can be sent to the client or is used to interpret what data received from the client means.