Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

RPG styled team system!


Link
 Share

Recommended Posts

**Please be sure to read the contents of the Spoiler, VERY IMPORTANT!**

>! Hi, I did say I'd re-release this tutorials sooner or later, but it's an old tutorial I made a while back and took down, but more well written. So basically here today I'll be releasing an RPG styled team system also known as a recruitment system to "_Pokemon Mystery Dungeon_" based games! This will be a basic version, though it's made for Pokemon it could be easily shaped up for any game! Per say you wanted to make a Final Fantasy type game, this system is definitely for you!
>!  
>! The example I'll be showing today is mainly for "_Pokemon Mystery Dungeon"_ games, so most of what you'll see will indeed be related to that. This system was once widely sought after by many on the eclipse forums, I don't know if that's the case today, but I know people were willing to pay good amounts for it. Do not be confused though, as I said, this is the basic version! If you want a full detailed version or anything further I can discuss pay with you over skype or here at eclipse as I've done it before.
>!  
>! **Contact information:**
>! **Skype;** zarachi6
>!  
>! So, let's get down to the basics, I'll answer most of your questions here and now! -
>!  
>! **What does this even do?** It's as simple as this! In the npc editor you'll be able to set an Npc as recruit-able, for now there's a set recruit chance which is out of ten! So there's a 1/10 chance of being able to Recruit the Npc!
>!  
>! **What does it mean to recruit the NPC?** Well, when you hit that 1/10 chance a box will appear in which the NPC will ask to join your team! You then have the option of accepting or denying this request. Upon accepting the Npc would join your team (current maximum of four) Your team will be displayed somewhere on your client, that's your choice, upon clicking on anyone of these recruited team members you then get to switch to that team member! So it's a basic sprite switching system, nothing too fancy for this basic release!
>!  
>! In any case it has that Final Fantasy or PMD feel of having more than one playable character at a time! So now that that's out of the way let's move on to the what and not! Also Note: Basic or not, I'm the first to release this system with this much detail, and I don't mind! I do plan to release an advanced RPG team styled system, which I already have for a game I'm working on! Also, this should work with Eclipse 2.0 and possibly 3.0, it's been fully tested with Dragon Eclipse. Be sure to brace yourself, this isn't a short tut!

>! **What this will include -**
>! - Basic Sprite Switching Style -
>! - Team of four excluding your starting character! -
>! - Visual interface with switching and recruiting! -
>! - Team switching at any time -
>! - RPG Final Fantasy Feel! -
>!  
>! **What this wont include -**
>! - Individual stats for the recruited characters! -
>! - Team storage (To have more than four team members) excluding your starting char. -
>! - Less complex switching method -

Now let's get down to the best parts! You'll need to start by downloading this attachment! here -> [!Recruitment!](http://www.mediafire.com/download/jwkmqosqugwgp1c/modRecruitment.bas) <- This Module needs to be added to your project! You'll need it for this to work. If you have any further questions of errors feel free to pm me about them!

Now, let's get physical! We'll start with the visual side in the client! We're not at the code yet though!

>! **Step 1:** You'll need to create a picture box in the "pic-screen" name it **"_picRecruitNPC_"** and inside that picture box, another picture box, name that one **"_picRecruitFace_"** and create a label with the caption being "The Pokemon would like to join your team" or whatever you want it to say.
>!          Now you need two labels (Yes/No) the labels will have to be indexed 1 and 2\. Name them both **"lblRecOpt"** Set **"Yes"** index to **1** and **"No"** index to **2**. Here's an example of what it should look like!
>!  
>! ![](http://i41.tinypic.com/154dlzs.png)
>!  
>! Step 2: Now you'll need to create your team menu or space if you'd like to call it that. This will require four picture boxes, note I'm just using my old game as an example, it no longer looks this way. Click the following link for the example - [TeamMenu](http://i46.tinypic.com/2n8csuw.png "External link") Each picture box should be named "_picRecruited_" with an index of 1 - 4!
>!  
>! Now let's move on to coding shall we? Via Client side source! First make sure you have ctrl + f prepared, we'll be using this a lot.
>!  
>! **- Client Side -**
>! Start by going into **modTypes** now while you're there and have ctrl + f open search for **Private Type PlayerRec** , now above where it says
>! **' projectiles** add the following code:
>! ```
>! ' Recruitment
Recruitments(1 To MAX_RECRUITMENTS) As Long ''Recruitment
PlayerNum As Long ''Recruitment
>! ```
Now while we're still in **modTypes** search for   **Private Type NpcRec**  once you're there look for **Spell(1 To MAX_NPC_SPELLS) As Long** once you've found it, directly below it add the following code:
>! ```
>! 'Recruitment
Type As Byte 'Pokemon System
>! '' Recruitment System
' Link's programming notes -
'Type will determine if the Pokemon is a Pokemon and is or is not recruit-able.
'If the type is not set to Pokemon in the editor, it can't be recruited
Recruitable As Boolean 'Recruitment
Type1 As Byte
Type2 As Byte
SwitchAnim As Long 'Recruitment
>! ```
We're done here for now, so next we'll go to **modText** using our useful ctrl + f tool, search for Public Sub **DrawPlayerName****(ByVal Index As Long)** Now below the list of things being declared or all of those "dim" listings, add the following code:
>! ```
>! ' Link's notes, this does the obvious and is pretty much self explanatory.
'If you don't know, here we're basically going to show the recruit-able Pokemon's names as a special color!
Dim NpcName As String 'recruitment System
Dim NpcColor As Long 'recruitment System
Dim NpcTextX As Long 'recruitment system
Dim NpcTextY As Long 'recruitment system
' This will be used later, it's not needed right now.
>! ```
While still in **modText** we'll be searching for **Public Sub DrawNpcName(ByVal Index As Long)** now find **npcnum
= MapNpc(Index).num** and below it you'll add the following code:
>! ```
>! 'Link's notes - This will let us know if the npc type is or isn't recruit-able.
If Npc(npcnum).Type = NPC_TYPE_NORMAL Then ''recruitment system
Select Case Npc(npcnum).Behaviour
>! ```
We'll be moving on to **modHandleData** at the bottom of **Public Sub InitMessages()** you'll need to add these!
>! ```
>! ' Recruitment
HandleDataSub(SNpcRecruit) = GetAddress(AddressOf HandleNpcRecruit)
HandleDataSub(SShowBox) = GetAddress(AddressOf HandleShowBox)
>! ```
While we're still in **modHandleData** we'll be searching for **Private Sub HandlePlayerData(ByVal Index As Long, ByRef Data() As Byte, ByVal StartAddr As Long, ByVal ExtraVar As Long)** once you've found that look for **Call SetPlayerClass(i, Buffer.ReadLong)** now below it you'll be adding this code:
>! ```
>! Call SetPlayerNum(i, Buffer.ReadLong) ''recruitment
For k = 1 To MAX_RECRUITMENTS ''recruitment
SetPlayerRecruitValue i, k, Buffer.ReadLong
Next
>! ```
Now at the very bottom of **modHandleData** we'll be adding the following code:
>! ```
>! Private Sub HandleNpcRecruit(ByVal Index As Long, ByRef Data() As Byte, ByVal StartAddr As Long, ByVal ExtraVar As Long)
Dim Buffer As clsBuffer
Dim i As Long
>! ' If debug mode, handle error then exit out
If Options.Debug = 1 Then On Error GoTo errorhandler
>! Set Buffer = New clsBuffer
Buffer.WriteBytes Data()
i = Buffer.ReadLong
Set Buffer = Nothing
Call RecruitableNpcKilled(i)
>! ' Error handler
Exit Sub
errorhandler:
HandleError "HandleHotbar", "modHandleData", Err.Number, Err.Description, Err.Source, Err.HelpContext
Err.Clear
Exit Sub
End Sub

'Special thanks to deathbeam for helping with the snippet below!
Private Sub HandleShowBox(ByVal Index As Long, ByRef Data() As Byte, ByVal StartAddr As Long, ByVal ExtraVar As Long)
Dim npcnum As Long
Dim Buffer As clsBuffer
Set Buffer = New clsBuffer
Buffer.WriteBytes Data()
RecruitNpcNum = Buffer.ReadLong
Set Buffer = Nothing
frmMain.picRecruitNPC.Visible = True
frmMain.picRecruitFace.Picture = LoadPicture(App.Path & GFX_PATH & "\faces\" & Npc(RecruitNpcNum).Sprite & ".bmp")
>! End Sub
>! ```
Now we're moving on to **modGlobals** here you'll search for **Public EditorShop As Long** once you've found it, below it you'll add the following code snippet:
>! ```
>! Public SpawnNpcRecruitable As Boolean
>! ```
Now at the bottom of **modGlobals** we'll add this code:
>! ```
>! 'Recruitment
Public RecruitNpcNum As Long
>! ```
Now we'll make our way to **modGameEditors** and search for this code **If
frmEditor_Map.optNpcSpawn.Value Then** now once you've found it, look for **.
Data2 = SpawnNpcDir** below that we'll add the following:
>! ```
>! .Data3 = SpawnNpcRecruitable
>! ```
While we're still in **modGameEditors** we'll now search for . **txtDamage
.text = Npc(EditorIndex).Damage** and below that we'll add this following code:
>! ```
>! .cmbType.ListIndex = Npc(EditorIndex).Type ''Recruitment
.scrlSwitchAnim.Max = MAX_ANIMATIONS ''Recruitment
>! ```
Hold on, we're still in **modGameEditors** but now we'll be searching for the following code **Call EditorNpc_BltSprite** you'll need to scroll down and find this bit of code:
>! ```
>! For i = 1 To Stats.Stat_Count - 1
.scrlStat(i).Value = Npc(EditorIndex).Stat(i)
Next
>! ```
Once you've found that "bit of code" below it we're going to actually add some code! like so ->
>! ```
>! ''''''''''''''''''''
''Recruitment ''''
''''''''''''''''''''
z = Npc(EditorIndex).Type1 - 1
If Npc(EditorIndex).Recruitable = True Then ''Recruitment
.chkRecruitable.Value = 1
Else
.chkRecruitable.Value = 0
End If
.cmbPkmnType1.ListIndex = z
.cmbPkmnType2.ListIndex = Npc(EditorIndex).Type2
End With
>! ```
**Finally we can move past that and into a different module. If you need to, take a break right now, feel free to.**
>!  
>! Ok so back from our break we'll be going into **modEnumerations** now we'll be adding the following two sets of Enums!
>! ```
>! 'Recruitment
SNpcRecruit
SShowBox
>! ```
and
>! ```
>! 'Recruitment
CRecruitNpcToTeam
CRecruitmentSwitch
CRecruitResponse
>! ```
We're done here, so let's go to **modDatabase** now at the bottom of **modDatabase** we'll add the following code! :3
>! ```
>! Function GetPlayerRecruitValue(ByVal Index As Long, ByVal RecruitmentSlot As Long) As Long
' If debug mode, handle error then exit out
If Options.Debug = 1 Then On Error GoTo errorhandler
If Index > MAX_PLAYERS Then Exit Function
If RecruitmentSlot = 0 Then Exit Function
GetPlayerRecruitValue = Player(Index).Recruitments(RecruitmentSlot)
>! ' Error handler
Exit Function
errorhandler:
HandleError "GetPlayerRecruitmentSlotValue", "modDatabase", Err.Number, Err.Description, Err.Source, Err.HelpContext
Err.Clear
Exit Function
End Function
Sub SetPlayerRecruitValue(ByVal Index As Long, ByVal RecruitmentSlot As Long, ByVal npcnum As Long)
' If debug mode, handle error then exit out
If Options.Debug = 1 Then On Error GoTo errorhandler
If Index > MAX_PLAYERS Then Exit Sub
Player(Index).Recruitments(RecruitmentSlot) = npcnum
>! ' Error handler
Exit Sub
errorhandler:
HandleError "SetPlayerRecruitValue", "modDatabase", Err.Number, Err.Description, Err.Source, Err.HelpContext
Err.Clear
Exit Sub
End Sub
Sub SetPlayerNum(ByVal Index As Long, ByVal PlayerNum As Long) ''Recruitment
' If debug mode, handle error then exit out
If Options.Debug = 1 Then On Error GoTo errorhandler
If Index > MAX_PLAYERS Then Exit Sub
Player(Index).PlayerNum = PlayerNum
>! ' Error handler
Exit Sub
errorhandler:
HandleError "SetPlayerNum", "modDatabase", Err.Number, Err.Description, Err.Source, Err.HelpContext
Err.Clear
Exit Sub
End Sub
Function GetPlayerNum(ByVal Index As Long) As Long
' If debug mode, handle error then exit out
If Options.Debug = 1 Then On Error GoTo errorhandler
If Index > MAX_PLAYERS Then Exit Function
GetPlayerNum = Player(Index).PlayerNum
>! ' Error handler
Exit Function
errorhandler:
HandleError "GetPlayerNum", "modDatabase", Err.Number, Err.Description, Err.Source, Err.HelpContext
Err.Clear
Exit Function
End Function
>! ```
See, it's not too hard so far is it? If you're still with me let's move on!! So, we'll be going to **modConstants** now we'll be in the **' General Constants** section at the bottom of the **' General Constants** we'll add the following:
>! ```
>! 'Link's notes - this represents the number of team members you can have, feel free to try and change it, but be sure you know what you're doing!
Public Const MAX_RECRUITMENTS As Long = 4
>! ```
now at the bottom of **modConstants** itself you'll be adding this:
>! ```
>! ' NPC Type '' Recruitment
Public Const NPC_TYPE_NORMAL As Byte = 0
Public Const NPC_TYPE_POKEMON As Byte = 1
>! ```
We're done there, we'll be moving to **modTCP** next! at the bottom of **modTCP** add the following:
>! ```
>! 'Link's notes - Your basic packets! For anyone new, this helps us send and receive information from the server!
Public Sub SendRecruit(ByVal PlayerInput As Long)
Dim Buffer As clsBuffer
Set Buffer = New clsBuffer
>! Buffer.WriteLong CRecruitResponse
Buffer.WriteLong PlayerInput
SendData Buffer.ToArray
Set Buffer = Nothing
End Sub
>! ```
Now we'll be going out of the module section for a bit, we'll be heading over to **frmMain** remember those two labels we made earlier? Yes and No? We'll now be working on those! Double click either one and add the following code:
>! ```
>! Private Sub lblRecOpt_Click(Index As Integer)
Dim i As Long
Dim k As Long
Select Case Index
Case 1
Call sendRecruitNpc(MyIndex, RecruitNpcNum)
RecruitNpcNum = 0
frmMain.picRecruitNPC.Visible = False
Case 2
RecruitNpcNum = 0
frmMain.picRecruitNPC.Visible = False
End Select
For i = 1 To MAX_RECRUITMENTS
k = GetPlayerRecruitValue(MyIndex, i)
If k > 0 Then
frmMain.picRecruited(i).Picture = LoadPicture(App.Path & "\data files\graphics\faces\" & k & ".bmp")
End If
Next
End Sub
>! ```
Now back into **frmMain** and double click on the "picRecruited" boxes! and add the following code:
>! ```
>! Private Sub picRecruited_Click(Index As Integer)
Select Case Index
Case 1
If Player(MyIndex).Recruitments(1) > 0 Then
Call RecruitmentSwitch(MyIndex, (Player(MyIndex).Recruitments(1)), 1, Player(MyIndex).PlayerNum)
End If
Case 2
If Player(MyIndex).Recruitments(2) > 0 Then
Call RecruitmentSwitch(MyIndex, (Player(MyIndex).Recruitments(2)), 2, Player(MyIndex).PlayerNum)
End If
Case 3
If Player(MyIndex).Recruitments(3) > 0 Then
Call RecruitmentSwitch(MyIndex, (Player(MyIndex).Recruitments(3)), 3, Player(MyIndex).PlayerNum)
End If
Case 4
If Player(MyIndex).Recruitments(4) > 0 Then
Call RecruitmentSwitch(MyIndex, (Player(MyIndex).Recruitments(4)), 4, Player(MyIndex).PlayerNum)
End If
End Select
End Sub
>! ```
**This is the part where you jump for joy, we're now done with the client side code! Feel free to take a short break?** Now it's time to work via server side source!
>!  
>! **- Server Side -**
>! We'll be going into **modTypes** and then we'll use our handy ctrl + f and search for  ** Private Type NpcRec**  and within that code we'll be adding this at the bottom :
>! ```
>! Type As Byte '' Recruitment'
>! ''Recruitment System
Recruitable As Boolean ''Recruitment
Type1 As Byte
Type2 As Byte
SwitchAnim As Long ''Recruitment
End Type
>! ```
Now search for  ** Private Type MapNpcRec**  and within that code at the bottom we'll be adding the following:
>! ```
>! 'Recruitment'
Recruitable As Boolean ''Recruitment
>! ```
Now we'll be moving on to **modServerTCP** and search for **Function PlayerData(ByVal index As Long) As Byte()** now below the buffer writelong stuff add the following!
>! ```
>! 'Recruitment, zarachi
For k = 1 To MAX_RECRUITMENTS
buffer.WriteLong GetPlayerRecruitmentNpcNum(index, k)
Next
'end
'Recruitment Save Pokemon stats
'This will save all the npc's(recruited) stats so that it's unique
'This will also make every Pokemon you recruit unique with their own stats
'This is because originally your recruited Pokemon would have the same stats you started out with!
>! ```
Now at the bottom of **modServerTCP** add:
>! ```
>! Sub SendShowBox(ByVal index As Long, ByVal npcNum As Long)
Dim buffer As clsBuffer
Set buffer = New clsBuffer
buffer.WriteLong SShowBox
buffer.WriteLong npcNum
SendDataTo index, buffer.ToArray()
Set buffer = Nothing
End Sub
>! ```
We'll now be moving on to **modPlayer** and at the bottom of **modPlayer** we'll add the following code:
>! ```
>! Function FindOpenRecruitmentSlot(ByVal index As Long, ByVal npcNum As Long) As Long
Dim i As Long
' Check for subscript out of range
If IsPlaying(index) = False Or npcNum <= 0 Or npcNum > MAX_NPCS Then
Exit Function
End If
If Npc(npcNum).Type = NPC_TYPE_POKEMON Then
' If currency then check to see if they already have an instance of the item and add it to that
For i = 1 To MAX_RECRUITMENTS
If GetPlayerRecruitmentNpcNum(index, i) = 0 Then
FindOpenRecruitmentSlot = i
Exit Function
End If
Next
End If
End Function
>! Function GetPlayerRecruitmentNpcNum(ByVal index As Long, ByVal RecruitmentSlot As Long) As Long
If index > MAX_PLAYERS Then Exit Function
If RecruitmentSlot = 0 Then Exit Function
GetPlayerRecruitmentNpcNum = Player(index).Recruitments(RecruitmentSlot)
End Function
Function GetPlayerNum(ByVal index As Long) As Long ''Recruitment
If index > MAX_PLAYERS Then Exit Function
GetPlayerNum = Player(index).PlayerNum
End Function
>! ```
Now we'll be going to **modHandleData** and we'll find **HandleDataSub(CSwitchesAndVariables) = GetAddress(AddressOf HandleSwitchesAndVariables)** now below it we'll add the following:
>! ```
>! 'Recruitment
HandleDataSub(CRecruitNpcToTeam) = GetAddress(AddressOf HandleRecruitNpcToTeam)
HandleDataSub(CRecruitmentSwitch) = GetAddress(AddressOf HandleRecruitmentSwitch)
HandleDataSub(CRecruitResponse) = GetAddress(AddressOf HandleRecruitChance)
>! ```
Now at the bottom of **modHandleData** add the following blot of code!
>! ```
>! Sub HandleRecruitNpcToTeam(ByVal index As Long, ByRef Data() As Byte, ByVal StartAddr As Long, ByVal ExtraVar As Long)
Dim n As Long
Dim i As Long
Dim k As Long
Dim FreeRecSlot As Long
Dim buffer As clsBuffer
Set buffer = New clsBuffer
buffer.WriteBytes Data()
n = buffer.ReadLong
i = buffer.ReadInteger
Set buffer = Nothing
k = FindOpenRecruitmentSlot(n, i)
Player(n).Recruitments(k) = i
SendPlayerData index
End Sub
Sub HandleRecruitmentSwitch(ByVal index As Long, ByRef Data() As Byte, ByVal StartAddr As Long, ByVal ExtraVar As Long)
Dim npcNum As Integer
Dim SlotNum As Long
Dim PlayerNum As Long
Dim mapNum As Long
>! Dim buffer As clsBuffer
Set buffer = New clsBuffer
buffer.WriteBytes Data()
index = buffer.ReadLong
npcNum = buffer.ReadInteger
SlotNum = buffer.ReadLong
PlayerNum = buffer.ReadLong
>! Set buffer = Nothing
>! Player(index).Sprite = Npc(npcNum).Sprite
Player(index).Recruitments(SlotNum) = PlayerNum
Player(index).PlayerNum = npcNum
SendAnimation mapNum, Npc(Player(index).PlayerNum).SwitchAnim, 0, 0, TARGET_TYPE_PLAYER, index ''Recruitment Switch Animation
SendPlayerData index
>! End Sub
Sub HandleRecruitChance(ByVal index As Long, ByRef Data() As Byte, ByVal StartAddr As Long, ByVal ExtraVar As Long)
'Carim's Contributions!!!!!! thanks
>! Dim buffer As clsBuffer
Dim response As Long
Dim SelNum As Long, i As Long
>! ' Exit out if we have no need to carry on.
If Player(index).CanRecruit = False Then Exit Sub
>! Set buffer = New clsBuffer
buffer.WriteBytes Data()
>! response = buffer.ReadLong
>! Set buffer = Nothing
>! ' Prevent hacking/server takedown efforts.
If Player(index).CurRecruit <= 0 Or Player(index).CurRecruit > MAX_NPCS Then Exit Sub
>! ' Here, we check if the response is yes or no.
If response = 1 Then
' Set SelNum to -1, a number that's not possible to go in the loop.
SelNum = -1
' The reasoning for this is so that if we extend the loop, we can easily
' verify that there's no space!

' Now, assign to the owest possible rec.
For i = 1 To MAX_RECRUITMENTS
If Player(index).Recruitments(i) = 0 Then
' We've found the lowest possible one to assign to!
SelNum = i
Exit For
End If
Next

' The case where we might have extended the loop…
If SelNum = -1 Then
PlayerMsg index, "You do not have enough space to recruit a new Pokemon!", BrightRed
GoTo continue
End If

' But from here, it's all good! Set the recruit.
Player(index).Recruitments(SelNum) = Player(index).CurRecruit
' And after all of those checks, that's it!
Else
PlayerMsg index, "The Pokemon went away!", BrightRed
End If

continue:
' After all of this, flag us able to recruit again.
Player(index).CanRecruit = True
' Flag this to 0, just so we can't attempt to recreate this sub, and we'll
' be stopped dead in our tracks by the above prevent hack/server takedown bit.
Player(index).CurRecruit = 0
End Sub
>! ```
We'll be going to **modGameLogic** next and then we'll search for this: **Public Sub SpawnNpc(ByVal mapNpcNum As Long, ByVal mapNum As Long, Optional ByVal SetX As Long, Optional ByVal SetY As Long)**
when you're there you'll look for  **MapNpc(mapNum).Npc(mapNpcNum).Dir = Map(mapNum).Tile(x, y).Data2** below it you'll add the following code:
>! ```
>! 'Recruitable?
MapNpc(mapNum).Npc(mapNpcNum).Recruitable = Map(mapNum).Tile(x, y).Data3
Spawned = True
>! ```
Now we'll go into **modEnumerations** and add the following enum sets!
>! ```
>! SNpcRecruit
SShowBox
>! ```
and
>! ```
>! 'Recruitment
CRecruitNpcToTeam
CRecruitmentSwitch
CRecruitResponse
>! ```
Moving on to **modDatabase** we'll now search for
>! ```
>! Sub AddChar(ByVal index As Long, ByVal Name As String, ByVal poontang As Byte, ByVal ClassNum As Long, ByVal Sprite As Long)
>! ```
Now scroll down until you see:
>! ```
>! Player(index).Level = 1
>! ```
Once you've found that, below it you shall add the following code!
>! ```
>! For k = 1 To MAX_RECRUITMENTS
Player(index).Recruitments(k) = 0
Next
>! ```
Now like we did in the client side, we'll head to **modConstants** and find **' General Constants** and in the **' General Constants** add the following
>! ```
>! 'Recruitment
Public Const MAX_RECRUITMENTS As Long = 4 ' ''Recruitments, again determined number in which can be recruited
>! ```
Now at the bottom of **modConstants** add the following code:
>! ```
>! ' NPC Types ''Recruitment
Public Const NPC_TYPE_NORMAL As Byte = 0
Public Const NPC_TYPE_POKEMON As Byte = 1
>! ```
We'll be moving to **modCombat** now! find this line of code:
>! ```
>! Public Sub PlayerAttackNpc(ByVal Attacker As Long, ByVal mapNpcNum As Long, ByVal Damage As Long, Optional ByVal SpellNum As Long, Optional ByVal overTime As Boolean = False)
>! ```
Once you've found it, below it add the following
>! ```
>! 'This sets the chance of the npc being recruited to a random number or chance out of 10, thanks to Deathbeam for this contribution.
'You can chance the number to be something else instead of 10, but the higher the number the harder the chance(zarachi)
Chance = rand(1, 10)
If Chance = 10 Then SendShowBox Attacker, npcNum
>! ```
Now just scroll down a bit until you find this code:
>! ```
>! 'Loop through entire map and purge NPC from targets
For i = 1 To Player_HighIndex
If IsPlaying(i) And IsConnected(i) Then
If Player(i).Map = mapNum Then
If TempPlayer(i).targetType = TARGET_TYPE_NPC Then
If TempPlayer(i).target = mapNpcNum Then
TempPlayer(i).target = 0
TempPlayer(i).targetType = TARGET_TYPE_NONE
SendTarget i
End If
End If
End If
End If
Next
>! ```
Below this code add the following!
>! ```
>! ''Recruitment
If Npc(npcNum).Type = NPC_TYPE_POKEMON Then
If Npc(npcNum).Recruitable = True Then
If MapNpc(mapNum).Npc(mapNpcNum).Recruitable = True Then
If Player(Attacker).CanRecruit = True Then
Set buffer = New clsBuffer
buffer.WriteLong SNpcRecruit
buffer.WriteLong npcNum
SendDataTo Attacker, buffer.ToArray()
Set buffer = Nothing

Player(Attacker).CurRecruit = npcNum
Player(Attacker).CanRecruit = False

End If
End If
End If
End If
>! ```
We're now moving on to the final portion of the tutorials! We're going back to the client to finish up a bit of work! So save your code!Now in the client go to frmEditor_NPC now you'll need to use this picture for reference! Here -> [!Example!](http://i48.tinypic.com/r7jej9.png) < - Important!
>!  
>! In the frmEditor_NPC create a Tab window and name one of the tabs Recruitable make sure that's the caption.
>! You will create a combobox with the Text and Name both saying cmbType, you'll create a checkbox named "chkRecruitable" with the caption being "Recruitable" or whatever do not worry about the rest it's only for test purposes now double click cmbType and have this code:
>! ```
>! Private Sub cmbType_Click()
' If debug mode, handle error then exit out
If Options.Debug = 1 Then On Error GoTo errorhandler

Npc(EditorIndex).Type = cmbType.ListIndex

Select Case cmbType.ListIndex
Case 0
chkRecruitable.Value = False
chkRecruitable.Enabled = False

Case 1
chkRecruitable.Enabled = True
End Select

' Error handler
Exit Sub
errorhandler:
HandleError "cmbType_Click", "frmEditor_NPC", Err.Number, Err.Description, Err.Source, Err.HelpContext
Err.Clear
Exit Sub
End Sub
>! ```
Double click "chkRecruitable" and have this code there…
>! ```
>! Private Sub chkRecruitable_Click()
If chkRecruitable.Value = 0 Then
Npc(EditorIndex).Recruitable = False
Else
Npc(EditorIndex).Recruitable = True
End If
End Sub
>! ```
That's it, we got through this together! Please notify me of any errors, or feel free to ask me for help or something! I hope you read everything carefully before adding anything to your project! Also, in case you missed the attatchment at the top for some reason, here it is again! [!Recruitment!](http://www.mediafire.com/download/jwkmqosqugwgp1c/modRecruitment.bas) < - There you are!
>!  
>! - Death
Link to comment
Share on other sites

I want to justify what is wrong here

You forgot in **PlayerRec ServerSide **for add

```

' Recruitment
Recruitments(1 To MAX_RECRUITMENTS) As Long ''RecruitmentPlayerNum As Long ''Recruitment
```

and in **Client Work** you forget for add **scrlSwitchAnim**

and for what this code ?

```

.cmbPkmnType1.ListIndex = z
.cmbPkmnType2.ListIndex = Npc(EditorIndex).Type2
```
you not add that in **frmEditor_NPC **

sorry for bad english
Link to comment
Share on other sites

> There are some subs missing like in client~side
>
>  
>
> Sub:
>
>  
>
> "SendRecruitNpc"
>
>  
>
> of modClientTCP…

are you sure ,you add this [http://www.mediafire.com/download/jwkmqosqugwgp1c/modRecruitment.bas](http://www.mediafire.com/download/jwkmqosqugwgp1c/modRecruitment.bas)
Link to comment
Share on other sites

Download the attachment and add it to the project or you'll be missing things. Death, nothing should be missing code wise, but if it's true, I must have missed it from the original tutorial, though it had no problems before.
Link to comment
Share on other sites

yes actually this system is great for adding into the EO, but your lack of detail in objects such as the addition of "cmbStyle" You just told him to add it, but I see the listindex takes the contents of 

```

' NPC Types ''Recruitment
Public Const NPC_TYPE_NORMAL As Byte = 0
Public Const NPC_TYPE_POKEMON As Byte = 1
```

a little advice
better to use text instead of images on adding objects

:ph34r:  sorry for bad english
Link to comment
Share on other sites

> yes actually this system is great for adding into the EO, but your lack of detail in objects such as the addition of "cmbStyle" You just told him to add it, but I see the listindex takes the contents of 
>
> ```
>
> ' NPC Types ''Recruitment
> Public Const NPC_TYPE_NORMAL As Byte = 0
> Public Const NPC_TYPE_POKEMON As Byte = 1
> ```
>
> a little advice
> better to use text instead of images on adding objects
>
> :ph34r:  sorry for bad english

This is a tutorial I made in 2012\. I just decided to paste everything again, the advanced system I have would step all over this, to say the least, lol. If anyone wanted to make additions or something, that would be cool, but I was just releasing it "again" as some type of start point and something super basic. So in a nut shell, my code was a bit more sloppy back then than it is now, haha.

To me there's no point in fixing up something that doesn't have great significance for me, unless a contest comes around with a cash prize, only then would I go all out. But I guess in a way it's more or less something to build off, and for me personally something to look back on as far as a comparison to how I program now.

Also, your English is perfectly understandable, lol.
Link to comment
Share on other sites

  • 3 weeks later...
> - Individual stats for the recruited characters! -
>
> - Team storage (To have more than four team members) excluding your starting char. -
>
> - Less complex switching method -
>
>  
>
> I guess that

already got that .. but what do you mean about Less Complex Switching Method?
Link to comment
Share on other sites

  • 7 months later...
Help error Client 

         Next
         ''''''''''''''''''''
         ''Recruitment ''''
         ''''''''''''''''''''
         z = Npc(EditorIndex).Type1 - 1
         If Npc(EditorIndex).Recruitable = True Then ''Recruitment
                         .chkRecruitable.Value = 1
                 Else
                         .chkRecruitable.Value = 0
         End If
         .cmbPkmnType1.ListIndex = z    ' here error
         .cmbPkmnType2.ListIndex = Npc(EditorIndex).Type2  ' here error
End With

    Call EditorNpc_BltSprite
    NPC_Changed(EditorIndex) = True

help My
Link to comment
Share on other sites

> Help error Client 
>
>  
>
>          Next
>          ''''''''''''''''''''
>          ''Recruitment ''''
>          ''''''''''''''''''''
>          z = Npc(EditorIndex).Type1 - 1
>          If Npc(EditorIndex).Recruitable = True Then ''Recruitment
>                          .chkRecruitable.Value = 1
>                  Else
>                          .chkRecruitable.Value = 0
>          End If
>          .cmbPkmnType1.ListIndex = z    ' here error
>          .cmbPkmnType2.ListIndex = Npc(EditorIndex).Type2  ' here error
> End With
>
>     Call EditorNpc_BltSprite
>     NPC_Changed(EditorIndex) = True
>
> help My

Error Description??
Link to comment
Share on other sites

  • 2 weeks later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...