Print Page | Close Window

Item Invulnerability

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=177
Printed Date: 20 December 2006 at 5:52pm
Software Version: Web Wiz Forums 8.01 - http://www.webwizforums.com


Topic: Item Invulnerability
Posted By: Sync
Subject: Item Invulnerability
Date Posted: 11 February 2006 at 3:18pm
Difficulty: Medium 4/5

Originaly Posted By: Asrrin29

well this is the unpolished version I made before magnus cleaned it up, but it still works:

By Asrrin29

This is server side

Go to modDatabase

Find Sub SaveItem(ByVal ItemNum As Long)

Find Call PutVar(FileName, "ITEM" & ItemNum, "Data3", Trim(Item(ItemNum).Data3)) in Sub

Add Call PutVar(FileName, "ITEM" & ItemNum, "Data4", Trim(Item(ItemNum).Data4)) underneath

Find Sub LoadItems()

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

Add Item(i).Data4 = Val(GetVar(FileName, "ITEM" & i, "Data4")) underneath

Go to modTypes

Find Type ItemRec

Find Data3 As Integer in Type

Add Data4 As Integer underneath

Find Sub ClearItem(ByVal index As Long)

Find Item(index).Data3 = 0 in Sub

Add Item(index).Data4 = 0 underneath

Go to modServerTCP

Find Sub HandleData

Find Save Item Packet

Find Item(n).Data3 = Val(Parse(7)) in Packet

Add Item(n).Data4 = Val(Parse(8)) underneath

Find Sub SendUpdateItemToAll(ByVal ItemNum As Long)

Replace 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 & END_CHAR

With 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).Data4 & SEP_CHAR & END_CHAR

Find Sub SendEditItemTo(ByVal index As Long, ByVal ItemNum As Long)

Replace 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 & END_CHAR

With 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).Data4 & SEP_CHAR & END_CHAR

Go to modGameLogic

Find Function GetPlayerDamage

Replace Call SetPlayerInvItemDur(index, WeaponSlot, GetPlayerInvItemDur(index, WeaponSlot) - 1)

With 'Check to see if Item is invulnrable, and if so, do not take away Durability.
If Item(Player(index).Char(Player(index).CharNum).Inv (WeaponSlot).Num).Data4 = 0 Then
Call SetPlayerInvItemDur(index, WeaponSlot, GetPlayerInvItemDur(index, WeaponSlot) - 1)
End If

Find Function GetPlayerProtection

Replace Call SetPlayerInvItemDur(index, ArmorSlot, GetPlayerInvItemDur(index, ArmorSlot) - 1)

With 'Check to see if Armor is invulnrable, and if so, do not take away Durability.
If Item(Player(index).Char(Player(index).CharNum).Inv (ArmorSlot).Num).Data4 = 0 Then
Call SetPlayerInvItemDur(index, ArmorSlot, GetPlayerInvItemDur(index, ArmorSlot) - 1)
End If

Replace Call SetPlayerInvItemDur(index, HelmSlot, GetPlayerInvItemDur(index, HelmSlot) - 1)

With 'Check to see if Helm is invulnrable, and if so, do not take away Durability.
If Item(Player(index).Char(Player(index).CharNum).Inv (HelmSlot).Num).Data4 = 0 Then
Call SetPlayerInvItemDur(index, HelmSlot, GetPlayerInvItemDur(index, HelmSlot) - 1)
End If

Done with server side :)

Open Client

Go to modClientTCP

Find Sub HandleData

Find Update item packet

Find Item(n).Data3 = 0 in Packet

Add Item(n).Data4 = 0 underneath

Find Edit item packet

Find Item(n).Data3 = Val(Parse(7)) in packet

Add Item(n).Data4 = Val(Parse(8)) underneath

Find Sub SendSaveItem(ByVal ItemNum As Long)

Replace Packet = "SAVEITEM" & 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 & END_CHAR

With Packet = "SAVEITEM" & 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).Data4 & SEP_CHAR & END_CHAR

Go to modTypes

Find Type ItemRec

Find Data3 As Integer in Type

Add Data4 As Interger underneath

Find Sub ClearItem(ByVal Index As Long)

Find Item(Index).Data3 = 0 in Sub

Add Item(Index).Data4 = 0 underneath

Go to modGameLogic

Find Public Sub ItemEditorInit()

Find frmItemEditor.scrlStrength.Value = Item(EditorIndex).Data2 in Public Sub

Add frmItemEditor.chkDUR.Value = Item(EditorIndex).Data4 underneath

Find Public Sub ItemEditorOk()

Replace If (frmItemEditor.cmbType.ListIndex >= ITEM_TYPE_WEAPON) And (frmItemEditor.cmbType.ListIndex <= ITEM_TYPE_SHIELD) Then
Item(EditorIndex).Data1 = frmItemEditor.scrlDurability.Value
Item(EditorIndex).Data2 = frmItemEditor.scrlStrength.Value
Item(EditorIndex).Data3 = 0
End If

With If (frmItemEditor.cmbType.ListIndex >= ITEM_TYPE_WEAPON) And (frmItemEditor.cmbType.ListIndex <= ITEM_TYPE_SHIELD) Then
Item(EditorIndex).Data1 = frmItemEditor.scrlDurability.Value
Item(EditorIndex).Data2 = frmItemEditor.scrlStrength.Value
Item(EditorIndex).Data3 = 0
Item(EditorIndex).Data4 = frmItemEditor.chkDUR.Value
End If

Replace 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
End If

With 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).Data4 = 0
End If

Replace If (frmItemEditor.cmbType.ListIndex = ITEM_TYPE_SPELL) Then
Item(EditorIndex).Data1 = frmItemEditor.scrlSpell.Value
Item(EditorIndex).Data2 = 0
Item(EditorIndex).Data3 = 0
End If

With If (frmItemEditor.cmbType.ListIndex = ITEM_TYPE_SPELL) Then
Item(EditorIndex).Data1 = frmItemEditor.scrlSpell.Value
Item(EditorIndex).Data2 = 0
Item(EditorIndex).Data3 = 0
Item(EditorIndex).Data4 = 0
End If

Now open up frmItemEditor, and find fraEquipment, it should be located under Vitals Data and Spell Data

Make a CheckBox Labled chkDUR and have the caption set to "Invulnrable."

Save both projects and run, you should now have the option to make weapons, armor, and helms invulnrable, never losing durability. this can easily be changed with the checkbox located in frmItemEditor. :D



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