Allowing more gubbins source tutorial

O*riginally posted by Clan\_fd*

I was able allow gubbins to be attached to 5 additional bones.

http://youtu.be/ZFYjiEefXCE

To use this, you will need to remove pre-existing items that use gubbins and related effects by emptying

> Accounts.dat
>
>
>
> Actors.dat
>
> Items.dat
>
> Projectiles.dat
>
>
>
>
>

## Relevant GUE files

> GUE.bb
>
>
>
> Actors3D.bb
>
> Actors.bb
>
>
>
>
> Items.bb
>
>

## GUE Module: GUE.bb

Add this

```
Const GubbinsLimit = 10

```

before

```
Include "Modules\RCEnet.bb"

```

Find this

```
FUI_ComboBoxItem(CActorGubbinMesh, "1st") : FUI_ComboBoxItem(CActorGubbinMesh, "2nd") : FUI_ComboBoxItem(CActorGubbinMesh, "3rd")

FUI_ComboBoxItem(CActorGubbinMesh, "4th") : FUI_ComboBoxItem(CActorGubbinMesh, "5th") : FUI_ComboBoxItem(CActorGubbinMesh, "6th")

```

and replace with this

```
For i = 1 To GubbinsLimit + 1

   FUI_ComboBoxItem(CActorGubbinMesh, i)

Next

```

Find this

```
FUI_ComboBoxItem(CItemGubbin, "Gubbin 1") : FUI_ComboBoxItem(CItemGubbin, "Gubbin 2") : FUI_ComboBoxItem(CItemGubbin, "Gubbin 3")

FUI_ComboBoxItem(CItemGubbin, "Gubbin 4") : FUI_ComboBoxItem(CItemGubbin, "Gubbin 5") : FUI_ComboBoxItem(CItemGubbin, "Gubbin 6")

```

and replace with this

```
For i = 1 To GubbinsLimit + 1

   FUI_ComboBoxItem(CItemGubbin, "Gubbin "+i)

Next

```

Find this

```
FUI_Label(G, 10, 7, "You may specify the bone names to use for the six gubbins:")

FUI_Label(G, 10, 37, "Gubbin 1:")

FUI_Label(G, 10, 62, "Gubbin 2:")

FUI_Label(G, 10, 87, "Gubbin 3:")

FUI_Label(G, 10, 112, "Gubbin 4:")

FUI_Label(G, 10, 137, "Gubbin 5:")

FUI_Label(G, 10, 162, "Gubbin 6:")

TGubbin1 = FUI_TextBox(G, 110, 35, 150, 20, 40) : FUI_SendMessage(TGubbin1, M_SETTEXT, GubbinJoints$(0))

TGubbin2 = FUI_TextBox(G, 110, 60, 150, 20, 40) : FUI_SendMessage(TGubbin2, M_SETTEXT, GubbinJoints$(1))

TGubbin3 = FUI_TextBox(G, 110, 85, 150, 20, 40) : FUI_SendMessage(TGubbin3, M_SETTEXT, GubbinJoints$(2))

TGubbin4 = FUI_TextBox(G, 110, 110, 150, 20, 40) : FUI_SendMessage(TGubbin4, M_SETTEXT, GubbinJoints$(3))

TGubbin5 = FUI_TextBox(G, 110, 135, 150, 20, 40) : FUI_SendMessage(TGubbin5, M_SETTEXT, GubbinJoints$(4))

TGubbin6 = FUI_TextBox(G, 110, 160, 150, 20, 40) : FUI_SendMessage(TGubbin6, M_SETTEXT, GubbinJoints$(5))

```

and replace with this

```
temp% = GubbinsLimit + 1

FUI_Label(G, 10, 7, "You may specify the bone names to use for the "+temp%+" gubbins:")

labely% = 37

yspacing% = 25

For i = 1 To GubbinsLimit+1

   FUI_Label(G, 10, labely%, "Gubbin "+i+":")

   labely% = labely% + yspacing%

Next

Dim TGubbin(GubbinsLimit)

labely% = 35

For i = 0 To GubbinsLimit

   TGubbin(i) = FUI_TextBox(G, 110, labely%, 150, 20, 40) : FUI_SendMessage(TGubbin(i), M_SETTEXT, GubbinJoints$(i))

   labely% = labely% + yspacing%

Next

```

Find this

```
Case TGubbin1, TGubbin2, TGubbin3, TGubbin4, TGubbin5, TGubbin6

            GubbinNamesChanged = True

            F = WriteFile("Data\Game Data\Gubbins.dat")

               WriteString(F, FUI_SendMessage(TGubbin1, M_GETTEXT))

               WriteString(F, FUI_SendMessage(TGubbin2, M_GETTEXT))

               WriteString(F, FUI_SendMessage(TGubbin3, M_GETTEXT))

               WriteString(F, FUI_SendMessage(TGubbin4, M_GETTEXT))

               WriteString(F, FUI_SendMessage(TGubbin5, M_GETTEXT))

               WriteString(F, FUI_SendMessage(TGubbin6, M_GETTEXT))

```

and replace with this

```
Case TGubbin(0), TGubbin(1), TGubbin(2), TGubbin(3), TGubbin(4), TGubbin(5), TGubbin(6), TGubbin(7), TGubbin(8), TGubbin(9), TGubbin(10)

            GubbinNamesChanged = True

            F = WriteFile("Data\Game Data\Gubbins.dat")

               For i = 0 To GubbinsLimit

                  WriteString(F, FUI_SendMessage(TGubbin(i), M_GETTEXT))

               Next

```

Find this

```
For i = 0 To 7 : At\MeshIDs[i] = SelectedActor\MeshIDs[i] : Next

```

and replace with this

```
For i = 0 To 1 : At\MeshIDs[i] = SelectedActor\MeshIDs[i] : Next

               For i = 0 To GubbinsLimit : At\GubbinsIDs[i] = SelectedActor\GubbinsIDs[i] : Next

```

Find this

```
Case CActorGubbinMesh

            If SelectedActor <> Null

               FUI_SendMessage(LActorGubbinMesh, M_SETCAPTION, "Gubbin mesh: " + GetFilename$(EditorMeshName$(SelectedActor\MeshIDs[Int(E\EventData) + 1])))

            EndIf

         Case BActorGubbinMesh

            If SelectedActor <> Null

               NewMesh = ChooseMeshDialog(MeshDialog_All, "Gubbins")

               If NewMesh > -1

                  Selected = FUI_SendMessageI(CActorGubbinMesh, M_GETINDEX) + 1

                  SelectedActor\MeshIDs[Selected] = NewMesh

                  FUI_SendMessage(LActorGubbinMesh, M_SETCAPTION, "Gubbin mesh: " + GetFilename$(EditorMeshName$(SelectedActor\MeshIDs[Selected])))

                  UpdateActorPreview()

                  ActorsSaved = False

               EndIf

            EndIf

         Case BActorGubbinMeshN

            If SelectedActor <> Null

               SelectedActor\MeshIDs[FUI_SendMessageI(CActorGubbinMesh, M_GETINDEX) + 1] = 65535

               FUI_SendMessage(LActorGubbinMesh, M_SETCAPTION, "Gubbin mesh: [NONE]")

               UpdateActorPreview()

               ActorsSaved = False

            EndIf

```

and change + 1 to - 1 like this

```
Case CActorGubbinMesh

            If SelectedActor <> Null

               FUI_SendMessage(LActorGubbinMesh, M_SETCAPTION, "Gubbin mesh: " + GetFilename$(EditorMeshName$(SelectedActor\GubbinsIDs[Int(E\EventData) - 1])))

            EndIf

         Case BActorGubbinMesh

            If SelectedActor <> Null

               NewMesh = ChooseMeshDialog(MeshDialog_All, "Gubbins")

               If NewMesh > -1

                  Selected = FUI_SendMessageI(CActorGubbinMesh, M_GETINDEX) - 1

                  SelectedActor\GubbinsIDs[Selected] = NewMesh

                  FUI_SendMessage(LActorGubbinMesh, M_SETCAPTION, "Gubbin mesh: " + GetFilename$(EditorMeshName$(SelectedActor\GubbinsIDs[Selected])))

                  UpdateActorPreview()

                  ActorsSaved = False

               EndIf

            EndIf

         Case BActorGubbinMeshN

            If SelectedActor <> Null

               SelectedActor\GubbinsIDs[FUI_SendMessageI(CActorGubbinMesh, M_GETINDEX) - 1] = 65535

               FUI_SendMessage(LActorGubbinMesh, M_SETCAPTION, "Gubbin mesh: [NONE]")

               UpdateActorPreview()

               ActorsSaved = False

            EndIf

```

Find this

```
FUI_SendMessage(LActorGubbinMesh, M_SETCAPTION, "Gubbin mesh: " + GetFilename$(EditorMeshName$(SelectedActor\MeshIDs[FUI_SendMessageI(CActorGubbinMesh, M_GETINDEX) + 1])))

```

and change + 1 to - 1 like this

```
FUI_SendMessage(LActorGubbinMesh, M_SETCAPTION, "Gubbin mesh: " + GetFilename$(EditorMeshName$(SelectedActor\GubbinsIDs[FUI_SendMessageI(CActorGubbinMesh, M_GETINDEX) - 1])))

```

Find this

```
For i = 0 To 5 : ShowGubbin(ActorPreview, i, True) : Next

```

and replace with this

```
For i = 0 To GubbinsLimit : ShowGubbin(ActorPreview, i, True) : Next

```

## GUE Module: Actors3D.bb

Find this

```
Dim GubbinJoints$(5)

```

and replace with this

```
Dim GubbinJoints$(GubbinsLimit)

```

Find this

```
GubbinJoints$(0) = "Head"

GubbinJoints$(1) = "Chest"

GubbinJoints$(2) = "L_Shoulder"

GubbinJoints$(3) = "R_Shoulder"

GubbinJoints$(4) = "L_Forearm"

GubbinJoints$(5) = "R_Forearm"

```

and replace with this

```
GubbinJoints$(0) = "Head"

GubbinJoints$(1) = "Chest"

GubbinJoints$(2) = "R_Shoulder"

GubbinJoints$(3) = "L_Shoulder"

GubbinJoints$(4) = "Pelvis"

GubbinJoints$(5) = "R_Forearm"

GubbinJoints$(6) = "L_Forearm"

GubbinJoints$(7) = "R_Hand"

GubbinJoints$(8) = "L_Hand"

GubbinJoints$(9) = "R_Shin"

GubbinJoints$(10) = "L_Shin"

```

Find this

```
For i = 0 To 5

         GubbinJoints$(i) = ReadString$(F)

      Next

```

and replace with this

```
For i = 0 To GubbinsLimit

         GubbinJoints$(i) = ReadString$(F)

      Next

```

Find this in the FreeActorInstance3D function

```
For i = 0 To 5

      If A\GubbinEN[i] <> 0 Then FreeEntityEmitters(A\GubbinEN[i]) : FreeEntity A\GubbinEN[i] : A\GubbinEN[i] = 0

   Next

```

and replace with this

```
For i = 0 To GubbinsLimit

      If A\GubbinEN[i] <> 0 Then FreeEntityEmitters(A\GubbinEN[i]) : FreeEntity A\GubbinEN[i] : A\GubbinEN[i] = 0

   Next

```

Find this in the ShowGubbin function

```
ID = A\Actor\MeshIDs[2 + Num]

```

and replace with this

```
ID = A\Actor\GubbinsIDs[Num]

```

Find this in the UpdateActorItems function

```
For i = 0 To 5

      HideGubbin(A, i)

   Next

   For i = 0 To SlotI_Backpack - 1

      If A\Inventory\Items[i] <> Null

         For j = 0 To 5

            If A\Inventory\Items[i]\Item\Gubbins[j] = True

               ShowGubbin(A, j)

            EndIf

         Next

      EndIf

   Next

```

and replace with this

```
For i = 0 To GubbinsLimit

      HideGubbin(A, i)

   Next

   For i = 0 To SlotI_Backpack - 1

      If A\Inventory\Items[i] <> Null

         For j = 0 To GubbinsLimit

            If A\Inventory\Items[i]\Item\Gubbins[j] = True

               ShowGubbin(A, j)

            EndIf

         Next

      EndIf

   Next

```

## GUE Module: Actors.bb

Find this

```
Field MeshIDs[7]

```

and replace with this

```
Field MeshIDs[1]

Field GubbinsIDs[GubbinsLimit]

```

Find this

```
Field EN, CollisionEN, HatEN, ChestEN, WeaponEN, ShieldEN, ShadowEN, NametagEN, GubbinEN[5]

```

and replace with this

```
Field EN, CollisionEN, HatEN, ChestEN, WeaponEN, ShieldEN, ShadowEN, NametagEN, GubbinEN[GubbinsLimit]

```

Find this in the CreateActor.Actor() function

```
A\MeshIDs[i] = 65535

```

and replace with this

```
If i <= 1

               A\MeshIDs[i] = 65535

            EndIf

            If i <= GubbinsLimit

               A\GubbinsIDs[i] = 65535

            EndIf

```

Find this in the LoadActors function

```
For i = 0 To 7  : A\MeshIDs[i] = ReadShort(F) : Next

```

and replace with this

```
For i = 0 To 1  : A\MeshIDs[i] = ReadShort(F) : Next

         For i = 0 To GubbinsLimit  : A\GubbinsIDs[i] = ReadShort(F) : Next

```

Find this in the SaveActors function

```
For i = 0 To 7  : WriteShort(F, A\MeshIDs[i]) : Next

```

and replace with this

```
For i = 0 To 1  : WriteShort(F, A\MeshIDs[i]) : Next

         For i = 0 To GubbinsLimit  : WriteShort(F, A\GubbinsIDs[i]) : Next

```

## GUE module: Items.bb

Find this

```
Field Gubbins[5]

```

and replace with this

```
Field Gubbins[GubbinsLimit]

```

Find this in the LoadItems function

```
For j = 0 To 5 : I\Gubbins[j] = ReadShort(F) : Next

```

and replace with this

```
For j = 0 To GubbinsLimit : I\Gubbins[j] = ReadShort(F) : Next

```

Find this in the SaveItems function

```
For j = 0 To 5 : WriteShort F, I\Gubbins[j] : Next

```

and replace with this

```
For j = 0 To GubbinsLimit : WriteShort F, I\Gubbins[j] : Next

```