Print Page | Close Window

Advanced Party System

Printed From: Mirage Source
Category: Tutorials
Forum Name: Temporary Archive (Read Only)
Forum Discription: Temporary 3.0.3 archive tutorials, will be deleted when converted.
URL: http://ms.shannaracorp.com/backup-forums/forum_posts.asp?TID=203
Printed Date: 20 December 2006 at 5:53pm
Software Version: Web Wiz Forums 8.01 - http://www.webwizforums.com


Topic: Advanced Party System
Posted By: Sync
Subject: Advanced Party System
Date Posted: 11 February 2006 at 3:29pm
Welcome to the advanced party system tutorial, part one! This is going to be worked on over time, and I'm going to post the code up as I go and explain it along the way, as well as why I choose to do it this way. This isn't a copy and paste tutorial, so read along.

So, for starters we need to come up with an idea of what we want to do and what we're going to do to achieve that. The basic Mirage party system is simple enough- a look into modTypes yields this segment of code, inside AccountRec:


    PartyPlayer As Long
    InParty As Byte
    TargetType As Byte
    Target As Byte
    CastedSpell As Byte
    PartyStarter As Byte
    GettingMap As Byte


Importantly, you want to see 'PartyPlayer', 'InParty', and 'PartyStarter'. Essentialyl this allows no more two people per party. We're going to take that a bit farther. It's important to consider allowing for easy expansion in the future when you code something, so even if it takes a little extra time to code something, you can save yourself time later.

A brief warning: As I have little way of testing these things, some code may not work as intended- but I pretty thoroughly check my logic and routines, so there *shouldn't* be any problems. Either way, this tutorial will tell you to delete and replace things and running your program along the way will, more than likely, yield errors because of this. Back to the topic at hand.

The variables shown above, located in the AccountRec type, are temporary. That is, they last while the program is running, but when the program starts or ends, they are neither saved nor loaded. I'm going to follow this idea, but if you'd like to make your parties save, you are more than welcome to do so. Now then, lets delete the variables mentioned before. That is, the ones in AccountRec that have the word 'Party' in them. You can comment them out if you'd like, but there's no reason to leave them for later.

Got it deleted? Great. Before we move on, I'd like to explain a concept for everyone. A type is essentially creating a new class/object. It can be used in the same fashion as int, string, and so on(that is, dim Variable as MyType instead of dim Variable as int). The idea is to save time and energy by giving you more access to variables and easier array processing. What you need to understand is that it makes things easier and makes things easier to keep track of.

Moving along, lets go down below AccountRec, in an empty space, and hit enter a few times to clear out some room. It's time to look at what we'd like to accomplish with this code. Another forum member posted this:

4 People
:: Commands ::
-Kick Player(s)
-Recruit Player(s)
-Disband Party
-Appoint New Leader
-Set Amount Of Exp To Share (%)
-Party Chat?


Looking at that, we can tell we need to be able to change people's status in the party, as well as add support for at least 4 people. We also need to associate a bunch of commands with it. I'm not going to mess with setting amount of exp to share as a command. We'll calculate that in later, using a formula. Party chat will be easy enough to set up, and we'll be sure to take care of that as well, towards the end of the tutorial segments.

In the empty space we've made, lets make a new 'type'. Although we could make the variables inside the accountRec like before, we'll use a type to hold most of the information. This is mostly my preference, but it'll make things a bit more organized.

We're gonna go with 4 players for now, but it's easy enough to add more, and hopefully you'll understand how to do so by the end of this tutorial.

Let's name our type PartyRec. Inside of it, let's add the following byte variables: Leader, Member1, Member2, Member3, Member4. Now, we could make it more complicated and use another type to hold more info about the members, but that would make us have to type out a lengthy statement and that's plenty of info. Inside of these variables we will hold the index values of each party member. It is *important* to remember that we're using indexes. If you choose to save the party later on, if you save the index values your players will have different people in their party when they log on next time, because the index changes.

Our type should look like this:

Type PartyRec
Leader as Byte
Member1 as Byte
Member2 as Byte
Member3 as Byte
Member4 as Byte
End Type


Now that we've established that, we can go back to the AccountRec. At the bottom of it, before its End Type statement, lets add in Party as PartyRec. Now, anytime we want to refer to the members or the leader, we can just use Party.Leader or Party.Member1 - simple enough, right? One last thing before we finish up with the types. Below or above the last statement you typed in, type in InParty as Boolean. InParty existed before as a byte statement for whatever reason. It is largely a convenience variable. Though we could make a routine to check to see if Leader, etc had data, by turning this variable to true or false we save ourselves a little time and the server some as well.

At this point most of your infrastructure is taken care of. But not the complicated stuff. ;) We've still got commands to add, exp to share, and a party chat to set up, as well as a treat or two I'll be adding in for you.

But that's it for part one. Part two is soon to follow. If you've got comments or questions, please post them under the 'Code!' topic in General, to leave this thread clean until it's run its course. ;)



Print Page | Close Window

Bulletin Board Software by Web Wiz Forums version 8.01 - http://www.webwizforums.com
Copyright ©2001-2006 Web Wiz Guide - http://www.webwizguide.info