Mirage Source

Free ORPG making software.
It is currently Tue Jan 18, 2022 3:38 am

All times are UTC




Post new topic Reply to topic  [ 15 posts ] 
Author Message
PostPosted: Mon Jun 19, 2006 9:26 am 
Offline
Knowledgeable

Joined: Tue May 30, 2006 5:11 am
Posts: 156
Location: Australia
Hi, could someone run off to the backup forums and grab my 2 handed weapons tute.. The updated one.. Cheers.. I want to back it up before i format.. Thanks guys.. :wink:


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 19, 2006 9:34 am 
I assume you mean this one..

Code:
Originally posted by Dark Echo

Two Handed Weapons
This is basically what the name saids. I did not create a whole new item type, i just used the old item type and added an option to make weapons two handed or not, by just ticking a checkbox. So thats basically it. If you have any items, when you add this in you will have to remake all your items again, so yeah.. Also, back up your source before you add in this tutorial, just to be safe.

- Tutorial updated..
- Fixed small shield bug

Difficult: 1/5

Part 1 - Server Side
Ok, go into modTypes and find:

Type ItemRec



Add under Data3 As Integer:

TwoHanded As Byte



Alright, now go into modDatabase and find:

Sub SaveItem(ByVal ItemNum As Long)



Now add this to the end of the saving sub, but before the End Sub:

Call PutVar(FileName, "ITEM" & ItemNum, "TwoHanded", Trim(Item(ItemNum).TwoHanded))



Ok, now find:

Sub LoadItems()



And after:

Item(i).Data3 = Val(GetVar(FileName, "ITEM" & i, "Data3"))



Add:

Item(i).TwoHanded = Val(GetVar(FileName, "ITEM" & i, "TwoHanded"))



Alrighty, we're nearly done for server side. go into modHandleData and find:

If LCase(Parse(0)) = "useitem" Then



And find:

Case ITEM_TYPE_WEAPON



And make it look like this:

                 Case ITEM_TYPE_WEAPON
                      If InvNum <> GetPlayerWeaponSlot(Index) Then
                          If Item(GetPlayerInvItemNum(Index, InvNum)).TwoHanded < 1 Then
                                If Int(GetPlayerSTR(Index)) < n Then
                                    Call PlayerMsg(Index, "Your strength is to low to hold this weapon!  Required STR (" & n * 2 & ")", BrightRed)
                                    Exit Sub
                                End If
                                Call SetPlayerWeaponSlot(Index, InvNum)
                          Else
                                If GetPlayerShieldSlot(Index) = 0 Then
                                    Call SetPlayerWeaponSlot(Index, InvNum)
                                    Call SetPlayerShieldSlot(Index, InvNum)
                                Else
                                    Call PlayerMsg(Index, "You already have a shield equiped!", BrightRed)
                                End If
                          End If
                      Else
                          Call SetPlayerWeaponSlot(Index, 0)
                      End If
                      Call SendWornEquipment(Index)



Right under that, you will find the Shield sectin of that sub.. Now just change it so it looks like this one:

                 Case ITEM_TYPE_SHIELD
                      If GetPlayerShieldSlot(Index) > 0 Then
                          If GetPlayerWeaponSlot(Index) = GetPlayerShieldSlot(Index) Then
                                Call PlayerMsg(Index, "You have a two handed weapon equipped! Please unequip it before using your shield!", BrightRed)
                                Exit Sub
                          Else
                                Call PlayerMsg(Index, "You already have a shield equipped! Please unequip it before using your shield!", BrightRed)
                          End If
                      Else
                          If InvNum <> GetPlayerShieldSlot(Index) Then
                                Call SetPlayerShieldSlot(Index, InvNum)
                          Else
                                Call SetPlayerShieldSlot(Index, 0)
                          End If
                          Call SendWornEquipment(Index)
                      End If



Now find:

If LCase(Parse(0)) = "saveitem" Then



And add this to the end of the update item section:

Item(n).TwoHanded = Val(Parse(8))



So that section looks like this:

' Update the item
Item(n).Name = Parse(2)
Item(n).Pic = Val(Parse(3))
Item(n).Type = Val(Parse(4))
Item(n).Data1 = Val(Parse(5))
Item(n).Data2 = Val(Parse(6))
Item(n).Data3 = Val(Parse(7))
Item(n).TwoHanded = Val(Parse(8))



Go into modGameLogic, remember this is all server side for now.. And find:

Sub PlayerMapDropItem(ByVal Index As Long, ByVal InvNum As Long, ByVal Ammount As Long)



Now, look for:

Case ITEM_TYPE_WEAPON



And make that whole case look like this:

                 Case ITEM_TYPE_WEAPON
                      If Item(GetPlayerInvItemNum(Index, InvNum)).TwoHanded < 1 Then
                          If InvNum = GetPlayerWeaponSlot(Index) Then
                                Call SetPlayerWeaponSlot(Index, 0)
                                Call SendWornEquipment(Index)
                          End If
                          MapItem(GetPlayerMap(Index), i).Dur = GetPlayerInvItemDur(Index, InvNum)
                      Else
                          If InvNum = GetPlayerWeaponSlot(Index) And InvNum = GetPlayerShieldSlot(Index) Then
                                Call SetPlayerWeaponSlot(Index, 0)
                                Call SetPlayerShieldSlot(Index, 0)
                                Call SendWornEquipment(Index)
                          End If
                          MapItem(GetPlayerMap(Index), i).Dur = GetPlayerInvItemDur(Index, InvNum)
                      End If



Woohoo, so close, just a few more lines. :) Alrighty, go into modServerTCP and find:

Sub SendUpdateItemToAll(ByVal ItemNum As Long)



And make the packet look like this:

Packet = "UPDATEITEM" & SEP_CHAR & ItemNum & SEP_CHAR & Trim(Item(ItemNum).Name) & SEP_CHAR & Item(ItemNum).Pic & SEP_CHAR & Item(ItemNum).Type & SEP_CHAR & Item(ItemNum).Data1 & SEP_CHAR & Item(ItemNum).Data2 & SEP_CHAR & Item(ItemNum).Data3 & SEP_CHAR & Item(ItemNum).TwoHanded & SEP_CHAR & END_CHAR



Last sub, woot!! Find:

Sub SendEditItemTo(ByVal Index As Long, ByVal ItemNum As Long)



And make that last packet look like this:

Packet = "EDITITEM" & SEP_CHAR & ItemNum & SEP_CHAR & Trim(Item(ItemNum).Name) & SEP_CHAR & Item(ItemNum).Pic & SEP_CHAR & Item(ItemNum).Type & SEP_CHAR & Item(ItemNum).Data1 & SEP_CHAR & Item(ItemNum).Data2 & SEP_CHAR & Item(ItemNum).Data3 & SEP_CHAR & Item(ItemNum).TwoHanded & SEP_CHAR & END_CHAR



And thats it for the server side..

Part 2 - Client Side
Ok, go into modTypes and find:

Type ItemRec



Add under Data3 As Integer:

TwoHanded As Byte



Alright, now go into modClientTCP and find:

Public Sub SendSaveItem(ByVal ItemNum As Long)



Add this to the end of your packet:

.TwoHanded & SEP_CHAR &



If you've done this correctly, it should look like this:

Packet = "SAVEITEM" & SEP_CHAR & ItemNum & SEP_CHAR & Trim(.Name) & SEP_CHAR & .Pic & SEP_CHAR & .Type & SEP_CHAR & .Data1 & SEP_CHAR & .Data2 & SEP_CHAR & .Data3 & SEP_CHAR & .TwoHanded & SEP_CHAR & END_CHAR



You now have to add a checkbox in the equipment frame, in the items editor. Call it chkTwoHanded and your set.

Now, go into modGameLogic and find:

Public Sub ItemEditorOk()



Now at the bottom of:

If (frmItemEditor.cmbType.ListIndex >= ITEM_TYPE_POTIONADDHP) And (frmItemEditor.cmbType.ListIndex <= ITEM_TYPE_POTIONSUBSP) Then



And:

If (frmItemEditor.cmbType.ListIndex = ITEM_TYPE_SPELL) Then



Add:

Item(EditorIndex).TwoHanded = 0



So they both should look like this:

    If (frmItemEditor.cmbType.ListIndex >= ITEM_TYPE_POTIONADDHP) And (frmItemEditor.cmbType.ListIndex <= ITEM_TYPE_POTIONSUBSP) Then
        Item(EditorIndex).Data1 = frmItemEditor.scrlVitalMod.Value
        Item(EditorIndex).Data2 = 0
        Item(EditorIndex).Data3 = 0
        Item(EditorIndex).TwoHanded = 0
    End If
   
    If (frmItemEditor.cmbType.ListIndex = ITEM_TYPE_SPELL) Then
        Item(EditorIndex).Data1 = frmItemEditor.scrlSpell.Value
        Item(EditorIndex).Data2 = 0
        Item(EditorIndex).Data3 = 0
        Item(EditorIndex).TwoHanded = 0
    End If



Now, add at the bottom of:

If (frmItemEditor.cmbType.ListIndex >= ITEM_TYPE_WEAPON) And (frmItemEditor.cmbType.ListIndex <= ITEM_TYPE_SHIELD) Then



After:

Item(EditorIndex).Data3 = 0



Add:

Item(EditorIndex).TwoHanded = frmItemEditor.chkTwoHanded.Value



Ok, now go into modHandleData and find:

If (LCase(Parse(0)) = "updateitem") Then



Add below the update item section this:

Item(n).TwoHanded = 0



Now find:

If (LCase(Parse(0)) = "edititem") Then



And below:

Item(n).Data3 = Val(Parse(7))



Add:

Item(n).TwoHanded = Val(Parse(8))



Woot.. Done done done!! Another one of these little things people like in their games :) I just like helping out!! Now, if any of yous have realised, i did the client side first, because i thought i had already done the server side.. Well, i actually did, but forgot i deleted it.. Idiot me.. Anyway, so thats why i got so excited near the end of the server side.. :D Look forward to more tutorials like these.. Adding in simple and easy features that people want desperately in their games!! :D


Top
  
 
 Post subject:
PostPosted: Mon Jun 19, 2006 12:23 pm 
Offline
Knowledgeable

Joined: Tue May 30, 2006 5:11 am
Posts: 156
Location: Australia
Ahh.. Cheers dude.. Thanks heaps.. :D


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 19, 2006 10:07 pm 
Eh, no problem. I've told you, if you need, you can have my old ID/Pass for things like this.


Top
  
 
 Post subject:
PostPosted: Tue Jun 20, 2006 12:59 pm 
Offline
Knowledgeable

Joined: Tue May 30, 2006 5:11 am
Posts: 156
Location: Australia
Yeah i know, but it was for just a small things, nothing big.. Lol..


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 22, 2006 3:38 am 
Offline
Pro

Joined: Mon May 29, 2006 2:15 am
Posts: 368
You definately wrote this the hard way. Apart from the editor saving/loading you can write about 6 lines of code to do this.

_________________
Image
Image
The quality of a man is not measured by how well he treats the knowledgeable and competent, but rather how he treats those less fortunate than himself.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 22, 2006 4:29 am 
Offline
Knowledgeable

Joined: Tue May 30, 2006 5:11 am
Posts: 156
Location: Australia
Really? I know i didnt take the best path possible, but i thought it was pretty clean.. Lol.. If you dont mind me asking, could you explain it more, i wouldnt mind changing my tutorial or make it faster.. Thanks dude.. :wink:


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 22, 2006 4:42 am 
Offline
Pro

Joined: Mon May 29, 2006 2:58 pm
Posts: 370
in most games Data3 is unused, yay for making things already sent/recieved and unused into other things :wink:

_________________
Image


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 22, 2006 8:31 am 
Offline
Knowledgeable

Joined: Tue May 30, 2006 5:11 am
Posts: 156
Location: Australia
Ahh.. Right.. Of course.. Although i have a habit to name things when coding..


Top
 Profile  
 
PostPosted: Thu Dec 16, 2021 8:32 am 
Online
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 87583
audiobookkeepercottageneteyesvisioneyesvisionsfactoringfeefilmzonesgadwallgaffertapegageboardgagrulegallductgalvanometricgangforemangangwayplatformgarbagechutegardeningleavegascauterygashbucketgasreturngatedsweepgaugemodelgaussianfiltergearpitchdiameter
geartreatinggeneralizedanalysisgeneralprovisionsgeophysicalprobegeriatricnursegetintoaflapgetthebouncehabeascorpushabituatehackedbolthackworkerhadronicannihilationhaemagglutininhailsquallhairyspherehalforderfringehalfsiblingshallofresidencehaltstatehandcodinghandportedheadhandradarhandsfreetelephone
hangonparthaphazardwindinghardalloyteethhardasironhardenedconcreteharmonicinteractionhartlaubgoosehatchholddownhaveafinetimehazardousatmosphereheadregulatorheartofgoldheatageingresistanceheatinggasheavydutymetalcuttingjacketedwalljapanesecedarjibtypecranejobabandonmentjobstressjogformationjointcapsulejointsealingmaterial
journallubricatorjuicecatcherjunctionofchannelsjusticiablehomicidejuxtapositiontwinkaposidiseasekeepagoodoffingkeepsmthinhandkentishglorykerbweightkerrrotationkeymanassurancekeyserumkickplatekillthefattedcalfkilowattsecondkingweakfishkinozoneskleinbottlekneejointknifesethouseknockonatomknowledgestate
kondoferromagnetlabeledgraphlaborracketlabourearningslabourleasinglaburnumtreelacingcourselacrimalpointlactogenicfactorlacunarycoefficientladletreatedironlaggingloadlaissezallerlambdatransitionlaminatedmateriallammasshootlamphouselancecorporallancingdielandingdoorlandmarksensorlandreformlanduseratio
languagelaboratorylargeheartlasercalibrationlaserlenslaserpulselatereventlatrinesergeantlayaboutleadcoatingleadingfirmlearningcurveleavewordmachinesensiblemagneticequatormagnetotelluricfieldmailinghousemajorconcernmammasdarlingmanagerialstaffmanipulatinghandmanualchokemedinfobooksmp3lists
nameresolutionnaphtheneseriesnarrowmouthednationalcensusnaturalfunctornavelseedneatplasternecroticcariesnegativefibrationneighbouringrightsobjectmoduleobservationballoonobstructivepatentoceanminingoctupolephononofflinesystemoffsetholderolibanumresinoidonesticketpackedspherespagingterminalpalatinebonespalmberry
papercoatingparaconvexgroupparasolmonoplaneparkingbrakepartfamilypartialmajorantquadruplewormqualityboosterquasimoneyquenchedsparkquodrecuperetrabbetledgeradialchaserradiationestimatorrailwaybridgerandomcolorationrapidgrowthrattlesnakemasterreachthroughregionreadingmagnifierrearchainrecessionconerecordedassignment
rectifiersubstationredemptionvaluereducingflangereferenceantigenregeneratedproteinreinvestmentplansafedrillingsagprofilesalestypeleasesamplingintervalsatellitehydrologyscarcecommodityscrapermatscrewingunitseawaterpumpsecondaryblocksecularclergyseismicefficiencyselectivediffuserhttp://semiasphalticflux.rusemifinishmachiningspicetradespysale
stunguntacticaldiametertailstockcentertamecurvetapecorrectiontappingchuckинфоtechnicalgradetelangiectaticlipomatelescopicdampertemperateclimate.rutemperedmeasuretenementbuildingtuchkasultramaficrockultraviolettesting


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 15 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group