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

[EO] Lightning's Pet System [Completely Bug-Free!]


Yxxe
 Share

Recommended Posts

  • Replies 304
  • Created
  • Last Reply

Top Posters In This Topic

@Shasokais:

> On the server side fault output. Points to .ispet in  modGameLogic
>
> Compile Error:
>
> Method or data member not found
>
> Why? I  did  everything  as  written  here.

Make sure you add "IsPet As Byte" to the bottom of MapNpcRec in modTypes.
Link to comment
Share on other sites

something like this?

    Map(PlayerMap).Npc(PetSlot) = 1
    MapNpc(PlayerMap).Npc(PetSlot).Num = 1
    'set its Pet Data
    MapNpc(PlayerMap).Npc(PetSlot).IsPet = YES
    MapNpc(PlayerMap).Npc(PetSlot).PetData.Name = GetPlayerName(index) & "'s " & Npc(1).Name
    MapNpc(PlayerMap).Npc(PetSlot).PetData.Owner = index

    'If Pet doesn't exist with player, link it to the player
    If Player(index).Pet.SpriteNum <> 1 Then
        Player(index).Pet.SpriteNum = 1
        Player(index).Pet.Name = GetPlayerName(index) & "'s " & Npc(1).Name
    End If

    TempPlayer(index).TempPetSlot = PetSlot
Link to comment
Share on other sites

Hmm …  and  if  I  want to make a few pets.
Then what to do? (This would be a rhetorical question)

And you can probably last question sweat this topic exactly where to be inserted
Hmm ...  and  if  I  want to make a few pets.
Then what to do? (This would be a rhetorical question)

And you can probably last question sweat this topic exactly where to be inserted

```
'check if the NPC attacking us is actually our pet.
'We don't want a rebellion on our hands now do we?

If MapNpc(MapNum).Npc(mapNpcNum).PetData.Owner = Index Then Exit Function

```
I realized  that it is necessary to insert CanNpcAttackPlayer, but where?
Link to comment
Share on other sites

@Shasokais:

> Hmm …  and  if  I  want to make a few pets.
> Then what to do? (This would be a rhetorical question)

Add a new parameter to Sub SpawnPet, called NPCNum. (You would then replace the hashes with "NPCNum".) Then make an item or spell to call SpawnPet.

@Shasokais:

> And you can probably last question sweat this topic exactly where to be inserted
> ```
>
> 'check if the NPC attacking us is actually our pet.
> 'We don't want a rebellion on our hands now do we?
>      
> If MapNpc(MapNum).Npc(mapNpcNum).PetData.Owner = Index Then Exit Function
>
> ```
> I realized  that it is necessary to insert CanNpcAttackPlayer, but where?

Underneath the other validity checks in CanNpcAttackPlayer.

@Magnate:

> This looks really good :P

Thanks! ;)
Link to comment
Share on other sites

Excuse me, I'm  not  really  in  this  parse  (Only  in  some  subjects  get to do yourself) you can please  show  where  to insert.
```
'check if the NPC attacking us is actually our pet.
'We don't want a rebellion on our hands now do we?

If MapNpc (MapNum). Npc (mapNpcNum). PetData.Owner = Index Then Exit Function
```
In:

```
Function CanNpcAttackPlayer(ByVal mapNpcNum As Long, ByVal index As Long) As Boolean
    Dim MapNum As Long
    Dim npcNum As Long

    ' Check for subscript out of range
    If mapNpcNum <= 0 Or mapNpcNum > MAX_MAP_NPCS Or Not IsPlaying(index) Then
        Exit Function
    End If

    ' Check for subscript out of range
    If MapNpc(GetPlayerMap(index)).Npc(mapNpcNum).Num <= 0 Then
        Exit Function
    End If

    MapNum = GetPlayerMap(index)
    npcNum = MapNpc(MapNum).Npc(mapNpcNum).Num

    ' Make sure the npc isn't already dead
    If MapNpc(MapNum).Npc(mapNpcNum).Vital(Vitals.HP) <= 0 Then
        Exit Function
    End If

    ' Make sure npcs dont attack more then once a second
    If GetTickCount < MapNpc(MapNum).Npc(mapNpcNum).AttackTimer + 1000 Then
        Exit Function
    End If

    ' Make sure we dont attack the player if they are switching maps
    If TempPlayer(index).GettingMap = YES Then
        Exit Function
    End If

    MapNpc(MapNum).Npc(mapNpcNum).AttackTimer = GetTickCount

    ' Make sure they are on the same map
    If IsPlaying(index) Then
        If npcNum > 0 Then

            ' Check if at same coordinates
            If (GetPlayerY(index) + 1 = MapNpc(MapNum).Npc(mapNpcNum).y) And (GetPlayerX(index) = MapNpc(MapNum).Npc(mapNpcNum).x) Then
                CanNpcAttackPlayer = True
            Else
                If (GetPlayerY(index) - 1 = MapNpc(MapNum).Npc(mapNpcNum).y) And (GetPlayerX(index) = MapNpc(MapNum).Npc(mapNpcNum).x) Then
                    CanNpcAttackPlayer = True
                Else
                    If (GetPlayerY(index) = MapNpc(MapNum).Npc(mapNpcNum).y) And (GetPlayerX(index) + 1 = MapNpc(MapNum).Npc(mapNpcNum).x) Then
                        CanNpcAttackPlayer = True
                    Else
                        If (GetPlayerY(index) = MapNpc(MapNum).Npc(mapNpcNum).y) And (GetPlayerX(index) - 1 = MapNpc(MapNum).Npc(mapNpcNum).x) Then
                            CanNpcAttackPlayer = True
                        End If
                    End If
                End If
            End If
        End If
    End If
End Function

```
Link to comment
Share on other sites

@Soul:

> You could put it under:
>
> ```
>     If TempPlayer(index).GettingMap = YES Then
>         Exit Function
>     End If
>
> ```
> There's a lot of other places you could put it under too; but this'll do.

Just got in before me… thanks! ;)
Link to comment
Share on other sites

Lightning, I try what you say (to Shasokasis request), but it don't works.

Subscript out of range in:

MapNpc(PlayerMap).Npc(PetSlot).PetData.Name = GetPlayerName(index) & "'s " & Npc(**NpcNum**).Name

Yes, I give the NPC a name, I created the parameter NpcNum.

You know how works the GetVar and PutVar functions of EO?

Example, I clicked on command button in CLIENT, so how I can put a var in the account of player?

And, replace the NpcNum with a get var?

Example:

I clicked on command button 01\. So, the script put var '1' in "Pet =", in player's account. So, "Pet = 1".

Then, when I click spawn pet, the script will get var of Pet =.

If the var is 1, so will execute the script Case 1 (or spawn the NPC 1).

Please, help me XD

(Again, **sorry my bad english**, I'm brazilian!)

(Sorry my bad english I'm brazilian)
Link to comment
Share on other sites

I translated the tutorial in portuguese (to brazilians). I'm brazilian, so, it isn't Google Tradutor, okay?

______________________________________

>! Olá, seja bem-vindo ao meu tutorial básico de pets! Quando você terminar o tutorial, você terá criado um sistema de pet básico, onde poderá aprimorar-se ainda mais nele. Antes de iniciar, tenha certeza que você possui os requerimentos:
>! * Visual Basic 6
* Cliente e Servidor
* Básico de programação
>! **Compatível com: Eclipse Origins 2.0.0**
>! ![](http://i801.photobucket.com/albums/yy294/Adrammelech_2009/SummonedPet.png)
>! **Client~Side (Projeto do cliente)**
>! Primeiramente, trabalharemos com o cliente. O que iremos realizar no sistema de pet, inclui:
>! * Invocar pet
* Pet atacar inimigo
* Pet seguir o dono
* Pet andar livremente pelo mapa
* Esconder/desinvocar seu pet
>! De início, vamos trabalhar com o modGameLogic.
Vá ao final dos códigos e cole estes cinco subs:
>! ```
Sub SpawnPet(ByVal Index As Long)
    Dim Buffer As clsBuffer

    Set Buffer = New clsBuffer

    Buffer.WriteLong CSpawnPet

    SendData Buffer.ToArray()

    Set Buffer = Nothing
>! End Sub
>! Sub PetFollow(ByVal Index As Long)
    Dim Buffer As clsBuffer

    Set Buffer = New clsBuffer

    Buffer.WriteLong CPetFollowOwner

    SendData Buffer.ToArray()

    Set Buffer = Nothing
End Sub
>! Sub PetAttack(ByVal Index As Long)
    Dim Buffer As clsBuffer

    Set Buffer = New clsBuffer

    Buffer.WriteLong CPetAttackTarget

    SendData Buffer.ToArray()

    Set Buffer = Nothing
End Sub
>! Sub PetWander(ByVal Index As Long)
    Dim Buffer As clsBuffer

    Set Buffer = New clsBuffer

    Buffer.WriteLong CPetWander

    SendData Buffer.ToArray()

    Set Buffer = Nothing
End Sub
>! Sub PetDisband(ByVal Index As Long)
    Dim Buffer As clsBuffer

    Set Buffer = New clsBuffer

    Buffer.WriteLong CPetDisband

    SendData Buffer.ToArray()

    Set Buffer = Nothing
End Sub
```
Estes são os códigos de controle do pet (já citados acima).
>! Agora, abriremos o modEnumerations.
>! Haverá uma lista enorme com várias variáveis iniciando com 'C'. Após:
>! ```
CPartyLeave
```
Cole o seguinte código:
>! ```
CSpawnPet
CPetFollowOwner
CPetAttackTarget
CPetWander
CPetDisband
```
Agora, acesse o modHandleData, e substitua todo o "Sub HandleSpawnNpc", por isto:
>! ```
Private Sub HandleSpawnNpc(ByVal Index As Long, ByRef Data() As Byte, ByVal StartAddr As Long, ByVal ExtraVar As Long)
Dim n As Long
Dim Buffer As clsBuffer
>!     ' If debug mode, handle error then exit out
    If Options.Debug = 1 Then On Error GoTo errorhandler

    Set Buffer = New clsBuffer
    Buffer.WriteBytes Data()
    n = Buffer.ReadLong
>!     With MapNpc(n)
        .Num = Buffer.ReadLong
        .x = Buffer.ReadLong
        .y = Buffer.ReadLong
        .Dir = Buffer.ReadLong
        .IsPet = Buffer.ReadByte
        .PetData.Name = Buffer.ReadString
        .PetData.Owner = Buffer.ReadLong
        ' Client use only
        .XOffset = 0
        .YOffset = 0
        .Moving = 0
    End With
>!     ' Error handler
    Exit Sub
errorhandler:
    HandleError "HandleSpawnNpc", "modHandleData", Err.Number, Err.Description, Err.Source, Err.HelpContext
    Err.Clear
    Exit Sub
End Sub
```
Agora, acesse o frmMain, e crie uma nova picturebox, ou qualquer coisa, e dentro dela, adicione 5 labels, como no exemplo (em inglês) abaixo:
>! ![](http://i801.photobucket.com/albums/yy294/Adrammelech_2009/Commands.png)
>! Estes são os comandos do pet (citados no início do tutorial). Clique em cima de cada um deles, e adicione o código:
>! Call Pet (Invocar pet):
```
Call SpawnPet(MyIndex)
```
Attack Target (Atacar inimigo):
>! ```
Call PetAttack(MyIndex)
```
Follow Me! (Seguir o dono):
>! ```
Call PetFollow(MyIndex)
```
Wander (Deixar o pet livre pelo mapa):
>! ```
Call PetWander(MyIndex)
```
Disband Pet (Esconder/desinvocar pet):
>! ```
Call PetDisband(MyIndex)
```
Agora, adicione o código abaixo no final do "MapNpcRec", no modTypes:
>! ```
  'Pet Data
    IsPet As Byte
    PetData As PetRec
```
Abaixo de "Dir As Byte" no PlayerRec (ainda em modTypes), adicione:
>! ```
Pet As PetRec
```
E adicione isto acima do "PlayerRec":
>! ```
Public Type PetRec
    SpriteNum As Byte
    Name As String * 50
    Owner As Long
End Type
```

______________________________________

Tomorrow I'll translate the Server~Side message, I'm tired now >.<
Link to comment
Share on other sites

@Gimulex:

> You lost me here:
>
> Place them in the options menu, or in any other menu you wish. After you have created them, they should look something like this:
> *Image*
>
> Okay, HOW do I place them in the options menu?

@sunku:

> How would i make the labels for Eclipse Origins if i already made the pet system?

Open up the client-side source, go to the in-game form > picOptions, then set it to "Bring To Front" and add the labels. Don't forget to compile.
Link to comment
Share on other sites

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...