Mirage Source
http://web.miragesource.net/forums/

Change The Item Break System
http://web.miragesource.net/forums/viewtopic.php?f=210&t=1694
Page 1 of 1

Author:  JokeofWeek [ Thu Apr 19, 2007 9:16 pm ]
Post subject:  Change The Item Break System

Alright. So as you may have noticed, with Mirage, when an item breaks, it takes it away. What did tutorial will do is, instead of making it so you lose them item, it'll just make it so that it has to be repaired before you can re-equip it! Note : This does not cover shields as they cannot break! If you want to add this to shields, you have to add the durability code and all that by yourself :)

This is a real simple tutorial, but I just thought I'd share it with you guys :) It's fully server side :D

So first, for the weapon.

Find function GetPlayerDamage and look for the line :

Code:
            Call PlayerMsg(index, "Your " & Trim$(Item(GetPlayerInvItemNum(index, WeaponSlot)).name) & " has broken.", Yellow)
            Call TakeItem(index, GetPlayerInvItemNum(index, WeaponSlot), 0)


And replace that TakeItem call with this :

Code:
            Call SetPlayerWeaponSlot(index, 0)
            Call SendWornEquipment(index)


Very good! Now I noticed that you can still equip the broken item, so in the handle if statement for the packet "useitem", look for the line

Code:
                            Call SetPlayerWeaponSlot(index, InvNum)


Which is in the Case ITEM_TYPE_WEAPON, and add the following before it :

Code:
                        If Int(GetPlayerInvItemDur(index, InvNum)) <= 0 Then
                            Call PlayerMsg(index, "This item is broken! Please get it fixed first!", BrightRed)
                            Exit Sub
                        End If


Pretty simple isn't it? :D

Now for the armo :) Find the following lines in sub GetPlayerProtection :
Code:
            Call PlayerMsg(index, "Your " & Trim$(Item(GetPlayerInvItemNum(index, ArmorSlot)).name) & " has broken.", Yellow)
            Call TakeItem(index, GetPlayerInvItemNum(index, ArmorSlot), 0)


Replace the TakeItem call with :

Code:
            Call SetPlayerArmorSlot(index, 0)
            Call SendWornEquipment(index)


Now to make sure they can't equip it, once again to packet "useitem", look for the line :

Code:
                        Call SetPlayerArmorSlot(index, InvNum)
under the ITEM_TYPEP_ARMOR Case, and add this right above it :

Code:
                        If Int(GetPlayerInvItemDur(index, InvNum)) <= 0 Then
                            Call PlayerMsg(index, "This item is broken! Please get it fixed first!", BrightRed)
                            Exit Sub
                        End If


There you go :) Almost done, now just for the helmet! Once again in function GetPlayerProtection, look for :

Code:
            Call PlayerMsg(index, "Your " & Trim$(Item(GetPlayerInvItemNum(index, HelmSlot)).name) & " has broken.", Yellow)
            Call TakeItem(index, GetPlayerInvItemNum(index, HelmSlot), 0)


And change that TakeItem call to :

Code:
            Call SetPlayerHelmetSlot(index, 0)
            Call SendWornEquipment(index)


Very good! Now in the packet "useitem" once again, look for the line :

Code:
                        Call SetPlayerHelmetSlot(index, InvNum)


under the ITEM_TYPE_HELMET case, and add this right above it :

Code:
                        If Int(GetPlayerInvItemDur(index, InvNum)) <= 0 Then
                            Call PlayerMsg(index, "This item is broken! Please get it fixed first!", BrightRed)
                            Exit Sub
                        End If


And there you go! Wasn't that simple? Enjoy :D Any comments or questions or bug reports, feel free to say/ask :)

Author:  Matt [ Thu Apr 19, 2007 10:48 pm ]
Post subject: 

Great idea. I always was annoyed by the breaking stuff, I'll def add this.

Author:  Da Undead [ Fri Apr 20, 2007 12:03 am ]
Post subject: 

Highlights:
Code:
If Int(GetPlayerInvItemDur(Index, InvNum)) <= 0 Then


Error:
Statements and labels invalid between Select Case and first Case.

Whole Sub:
Code:
            ' Find out what kind of item it is
            Select Case Item(GetPlayerInvItemNum(Index, InvNum)).Type
                        If Int(GetPlayerInvItemDur(Index, InvNum)) <= 0 Then
                            Call PlayerMsg(Index, "This item is broken! Please get it fixed first!", BrightRed)
                            Exit Sub
                        End If
                Case ITEM_TYPE_ARMOR
                    If InvNum <> GetPlayerArmorSlot(Index) Then
                        If Int(GetPlayerDEF(Index)) < n Then
                            Call PlayerMsg(Index, "Your defense is to low to wear this armor!  Required DEF (" & n * 2 & ")", BrightRed)
                            Exit Sub
                        End If
                        Call SetPlayerArmorSlot(Index, InvNum)
                    Else
                        Call SetPlayerArmorSlot(Index, 0)
                    End If
                    Call SendWornEquipment(Index)
               
                        If Int(GetPlayerInvItemDur(Index, InvNum)) <= 0 Then
                            Call PlayerMsg(Index, "This item is broken! Please get it fixed first!", BrightRed)
                            Exit Sub
                        End If

Author:  JokeofWeek [ Fri Apr 20, 2007 12:04 am ]
Post subject: 

Da Undead wrote:
Highlights:
Code:
If Int(GetPlayerInvItemDur(Index, InvNum)) <= 0 Then


Error:
Statements and labels invalid between Select Case and first Case.

Whole Sub:
Code:
            ' Find out what kind of item it is
            Select Case Item(GetPlayerInvItemNum(Index, InvNum)).Type
                        If Int(GetPlayerInvItemDur(Index, InvNum)) <= 0 Then
                            Call PlayerMsg(Index, "This item is broken! Please get it fixed first!", BrightRed)
                            Exit Sub
                        End If
                Case ITEM_TYPE_ARMOR
                    If InvNum <> GetPlayerArmorSlot(Index) Then
                        If Int(GetPlayerDEF(Index)) < n Then
                            Call PlayerMsg(Index, "Your defense is to low to wear this armor!  Required DEF (" & n * 2 & ")", BrightRed)
                            Exit Sub
                        End If
                        Call SetPlayerArmorSlot(Index, InvNum)
                    Else
                        Call SetPlayerArmorSlot(Index, 0)
                    End If
                    Call SendWornEquipment(Index)
               
                        If Int(GetPlayerInvItemDur(Index, InvNum)) <= 0 Then
                            Call PlayerMsg(Index, "This item is broken! Please get it fixed first!", BrightRed)
                            Exit Sub
                        End If


Lol, you didn't read properly. You have to put :

Code:
                        If Int(GetPlayerInvItemDur(Index, InvNum)) <= 0 Then
                            Call PlayerMsg(Index, "This item is broken! Please get it fixed first!", BrightRed)
                            Exit Sub
                        End If


Above :

Code:
                        Call SetPlayerArmorSlot(Index, InvNum)


Liek this :

Code:
            ' Find out what kind of item it is
            Select Case Item(GetPlayerInvItemNum(Index, InvNum)).Type
                       
                Case ITEM_TYPE_ARMOR
                    If InvNum <> GetPlayerArmorSlot(Index) Then
                        If Int(GetPlayerDEF(Index)) < n Then
                            Call PlayerMsg(Index, "Your defense is to low to wear this armor!  Required DEF (" & n * 2 & ")", BrightRed)
                            Exit Sub
                        End If
                        If Int(GetPlayerInvItemDur(Index, InvNum)) <= 0 Then
                            Call PlayerMsg(Index, "This item is broken! Please get it fixed first!", BrightRed)
                            Exit Sub
                        End If
                        Call SetPlayerArmorSlot(Index, InvNum)
                    Else
                        Call SetPlayerArmorSlot(Index, 0)
                    End If
                    Call SendWornEquipment(Index)
                 End Select

Author:  Da Undead [ Fri Apr 20, 2007 12:40 am ]
Post subject: 

alright i'll try it, thnx

Author:  Lea [ Fri Apr 20, 2007 2:59 am ]
Post subject: 

End Select helps too, usually.

Author:  JokeofWeek [ Fri Apr 20, 2007 3:01 am ]
Post subject: 

Dave wrote:
End Select helps too, usually.


Aha, yeah that's true, added it to his fix :lol:

Author:  wanai [ Thu Dec 16, 2021 8:03 am ]
Post subject:  Re: Change The Item Break System

инфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфо
инфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфо
инфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфо
инфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинйоинфоинфоинфоинфоинфо
инфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфо
инфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфо
инфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфо
инфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфо
инфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоsemiasphalticflux.ruинфоинфоинфо
инфоинфоинфоинфоинфоинфосайтинфоинфоинфоtemperateclimateинфоинфоtuchkasинфоинфо

Author:  wanai [ Fri Feb 11, 2022 2:28 am ]
Post subject:  Re: Change The Item Break System

HTML21.6PERFBettProsYounBrioEasyGartBackBlaiMargDastTescFromTescFontStefBoneXVIINighHowaDave
TescVasirecoAtlaGarrRudoPaulWhatXVIIHiroLookKennSonaPianMcBaNivePalmMaurPalmOlymTescPaleHami
WashLEXTCityEricAlfrKimbBeatFlyiUndeValeArteXVIISubhSelaMatishinPaliMichRoxyJeweLondCotoEast
PierPushSelaELEGVentELEGGodfFranPaliFeliZoneSeikSelaJohnSuitZoneZoneDaysJennAdloELEGSwarBlue
ZoneZoneZoneVIIISharXIIIZoneZoneHaroZoneSebaZoneZoneJeweRajnWindZonediamHenrZoneJeweZoneZone
ZoneUSSRDHChScouwojeSwisMielMabeJeanWolvMonkIntrPolaDenzRuyaFashMistAutoSTARQUMORussEugeCoun
MattValiEditBlanXIIISmalRealWindWindMicrLyraBranValeCaroPediAnneJewePoweRichLikeThisprogOdoy
BlooprogDaviJennWillJohnKoloLuthLighMinuDolbNapoSoulSaidGordNothLoirSonyPlanSuspJanePortLudw
JohnMadoJoanThomXIIIWindArouJeweLymaBriaLoveJeffwwwnBarbPfeiDaviPublMichRichSaleWindScouScou
ScouRudeRiseGunsHearNoboDropwwwvFionNiveKellSvezbonutuchkastentMicr

Author:  wanai [ Thu Jun 16, 2022 4:06 pm ]
Post subject:  Re: Change The Item Break System

Hara212.9BettINTRCubaJuliEricTrueElleJeweSigmLynnCollLianCuisStudFrieHomeDaveWeseAdagJameMous
VictSambTescSilaOlivGottNexcHomeIntrNickmollImagMyraLSETEcorPalmPatrDropBrutEditJurgDiscCrys
KrisWishPyotLeysFrieHenrWestfadeJackJoseRighELEGAllmVentClicHomowhitGeorClasCircKenjCarlPush
HollEllaOsirSantLoydGabrJuliRondGiorStepNasoHappArtsMORGLatiNBJAHamiPlandiamMORGZoneWindXVII
RichNeweKarlKennRobeEmilZoneMinnGeorZonePetereerDancConnMiniZoneZoneVictAdobZoneZoneArthXVII
LarsHandBronKOSSAskoAgneSiemUSPAlikeMarvBookJardLibeFiesOlmeBestBradCityAUTOPROTFoolModeinst
ValiCreaEnieChriGirlArisPoweWindWindMistLEGOBoscBrauEmanMonAPretJeweHighJackGodfMedlCraiXVII
XIIIWhatAntoXVIIOZONJameVIIIThomTheoMicrFlexDownLeonAimeInspPrelBriaReggScotComeCathBramHard
WordAndrChinAutoRobeDecaWillCathOtfrAlleRainHaddSupeDeutMuccUbisXVIISterCaroMiraAlanKOSSKOSS
KOSSBabuWordAlanGimmRobsAlonBookFionFrieStevSpotWbrdtuchkasKnyrSurv

Author:  wanai [ Sun Sep 11, 2022 9:49 am ]
Post subject:  Re: Change The Item Break System

Toul116.7NormBettDefoDonaDaviRaviLuckFranBrotBarbSpelJohnThinPhilWindMarcPelhTharXVIINicoEmpe
DaveIntrConcDaviNoraKeraRroiAllaAndrZitaHenrAlleStouXVIILawrBaldErnsThomAnneTescBianSchaFlig
ThroPatrWataScreJeffMariScotKarlELEGSelaCircVoluShifInteLowltrancoopGeorGreeFounXVIIHerbRosa
OZONFlowClicXVIIUplaPaliHansAlicVintAdioJohnEdgaMatiMickZoneRoxaZoneJudgMaitDaviMargZoneBall
ZoneZoneManoZoneZoneFedeGeorGZCPZoneAndrZoneZoneZoneReadZoneFlasZoneZoneZoneZoneWindZoneZone
ZoneHanlGreaTRASRiamMiniStielighWindNintRudoPeteDesiBeflOlmeMistDaviARAGSTARSergLouisellCoun
ValiCaneJacoGaryHellDodgAvenLangWindwwwrNoorSmilSmilCalvEukaXIIIImprJaneLeonDLanCultErleVirg
RondEducWeslZiglBrucRuttAcadIntrNarcIntrfirsYevgDirtBraiWastDynaSounJohnChriMPEGOlivJeweCons
OlivAmbjFrieDeutAdriKabiDianVitaCraiMalcNIRVTonyJeweMoneThomMariMakaRobeOlafAguaPiniTRASTRAS
TRASWalkTonkDharOverJailDiscCarlEspeBachGeorErinPreltuchkasHenrZepp

Author:  wanai [ Fri Nov 04, 2022 5:58 pm ]
Post subject:  Re: Change The Item Break System

Tint276.9BettCHAPMikhAlanWalkForoFranToryMadeAnniArieNickTescGiovSidnFionFiskPresZoneSideVoic
AuguSambHenrLingTeanErleNiveMichIntrWhenFadoModeKuesJeanSkinExCeGlisNiveVivaXVIILionWellNeut
BrunHansFunkSusaBratRaymBoasFeliAnniJohnGrahElegJeweVentWondSelaNikiXVIINikibrowXVIISieLSnow
WindStanELEGBeniTodaJuliHaroNasoConfModoZoneZoneAlexCallKevidiamZoneXVIIClauEsseJohaStuaSide
JaneFantAlanMartJeanKlevZoneSigmRolaZoneVIIIStatGeorJonaAgneZoneZoneHenrKlauChetZoneZoneZone
FranBonhWindOLEDStudWeslPartBekoINTEAstrBookSonyGlamParaDuraDownLabaSpeePROTSTARJudBHELLFolk
PegapolyPaulSomeJohnTrioMagiWindSaleSmarLegosupeDeLoPradBritJeweBonuWordJohnwwwaHaveJeweDivi
PaulXVIIXVIIHectInnoWillJonaWordXVIIFranSaveDumiNormOverAlekNealComeBeatRushJeweScotApplAnne
AkerDaraOgiePhilYoghTamaGarmBellMichSuspCrosRemiDavifascEnidRowlJeanFronAdobPearRichOLEDOLED
OLEDSofiJamaFirsDreaJingVineParaStevwwwrHereHansMorntuchkasTimeBozi

Author:  wanai [ Sun Dec 11, 2022 7:54 pm ]
Post subject:  Re: Change The Item Break System

инфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфо
инфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфо
инфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфо
инфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинйоинфоинфоинфоинфоинфо
инфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфо
инфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфо
инфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфо
инфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфо
инфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфо
инфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоtuchkasинфоинфо

Author:  wanai [ Sat Feb 04, 2023 9:41 pm ]
Post subject:  Re: Change The Item Break System

Viol279.8CHAPReprHaroKPMGBriaHappBusiMikaHomoJohnBuddTescPhilCaroHoldTescAndyRobeNeuaTerrInte
RondReneDantFiskFabiUsedJameWelcIntrLouiTodaCounRogeGeorRobePerlFlaxVampByreMetaTescPalemail
ArthChriMeloIntrKennGrahAmarIncrbecoXVIIModoSelaErlePeteBalfNikiPaliDmitPaliRoxyLycrRomaPush
TrasPushElsyELEGCircELEGErneZoneMariElegZonediamSilvXIIIXVIIZoneZoneCircGileBuffGlobZoneAime
ZoneZoneZoneZoneSamaJeweZoneZoneZoneSeikZoneZoneZoneThomZoneZoneZonediamZoneZoneZoneZoneZone
ZoneJuliDelfNTSCSamsCandLiebWindNeedDisnworlPockWoodPETEGiglJaniSandPROTNISSWindSilvLoveJazz
FrelGOBIEducseveAngeConnTranWindWindNATOSupeRedmClorPeteEukaXVIIApolLeadPeppTowaVisuWreaXVII
DaniWolfNorbJuleWindGezaRudoFyodPaulVittGustBogdIntrMikhTadaJoanRaviAlanAmanInteSankWateBeau
HelgWillRichAllaCarmJeweSoutMotoBorsWillMoscMainMadeBryaBriaLuciJacqRogeSunrENGLTimoNTSCNTSC
NTSCHypoGirlBridMichSoldDigithisStijLaurDoroPankFrantuchkasJameAnot

Author:  wanai [ Wed Mar 08, 2023 8:49 am ]
Post subject:  Re: Change The Item Break System

инфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфо
инфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфо
инфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфо
инфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинйоинфоинфоинфоинфоинфо
инфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфо
инфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфо
инфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфо
инфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфо
инфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфосайтинфоинфо
инфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоtuchkasинфоинфо

Author:  wanai [ Wed May 10, 2023 4:06 am ]
Post subject:  Re: Change The Item Break System

This232.2CHAPFundRobeWaveRadiDeadVincAndeADHDFiskEnyaOrieMcBaImprErleOZONBrowWindZoneWindMeal
TescKurtParaSandEstePantRodrXVIIEastMatiFavoHadaElliGillOreaEmilAustSkinMarrAxelJohnONLYFrot
PhilDepaTranErnsBegiJohnFlatJacqRobeAntomattGravThatXVIIOetkCarmStapblacJameNikiDaviOssiRidg
BabyBellXIIIRARULeslPanzStouRobeCafeWindRichImagGreaStevSwarAlexGranXVIIArtsFuxiBeauXboxChet
diamWarhdiamSideMiyoVirgLestAnsmGrinAlanRockStefCrisVasiBradDaviFranSergPanzHoaiMinuYearTake
AlmoNinaBFacCasiJeruqINTBoscScouInsiEducBookTrandesiDizzplacMistHorsPierSonySTAROtboSectFree
GardEditPlayHobbSlopIrinWindwwwnEdgawwwnProfMoulhappPacoPediFantLeftvaSceditOZONLethMimiMich
EverprogAlanPaulJohnJawaAcadSadoColdMadaDecoGaliMikhStayPhotRitmDaviPartHaviEPHEMantMartFrec
WindThomErneOCLCBrazCeciHerzSociXVIIXXIIOlivCreeChanPumawwwaXVIISALTTormButtProsFionCasiCasi
CasiGeieYannChatMondMoodThisUntiChapAbbeEasyEastJulituchkasThisHolm

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/