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

Pet System script (No Longer Beign Worked On)


Dennys
 Share

Recommended Posts

  • Replies 417
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

@Ridrik:

> Actually this might work, i'm going to get in this project even though i do not know alot in scripting, but I know enough to help. So i'll be watching this topic for any progress and helping on it's way.

And what would that help include?
Link to comment
Share on other sites

Yes it is a source edit and a script.

Edit:
I foudn this this seems something to do with the npc's attacking code.
                    If frmMirage.chkNpcDamage.Value = 1 Then
                        If frmMirage.chkPlayerName.Value = 0 Then
                            If GetTickCount < NPCDmgTime + 2000 Then
                                Call DrawText(TexthDC, (Int(Len(NPCDmgDamage)) / 2) * 3 + NewX + sx, NewY - 22 - ii + sx, NPCDmgDamage, QBColor(BRIGHTRED))
                            End If
Link to comment
Share on other sites

@мсичġġεт:

> Yes it is a source edit and a script.
>
> Edit:
> I foudn this this seems something to do with the npc's attacking code.
>                     If frmMirage.chkNpcDamage.Value = 1 Then
>                         If frmMirage.chkPlayerName.Value = 0 Then
>                             If GetTickCount < NPCDmgTime + 2000 Then
>                                 Call DrawText(TexthDC, (Int(Len(NPCDmgDamage)) / 2) * 3 + NewX + sx, NewY - 22 - ii + sx, NPCDmgDamage, QBColor(BRIGHTRED))
>                             End If

Npc processing code is server side in modGeneral -> Sub GameAI. The npc attack on sight/movement/respawn/health regen is all there
Link to comment
Share on other sites

Some usefull commands:

Function GetNpcName(ByVal number As Long) As String - Gets the "pet's" name

Function GetNpcBehavior(ByVal number As Long) As Long - Behavior of the "pet" - needs a new one, so that we can se it to "pet".

Function GetNpcExp(ByVal number As Long) As Long - How much the exp will you get for killing exp, but if you flip it around and edit it a bit, that will show how much will pet get exp to level.

Function GetNpcDefense(ByVal number As Long) As Long - defence of the "pet"

Function GetNpcStrength(ByVal number As Long) As Long - strengh of the "pet"

Hope i helped a bit.

-Ridrik
Link to comment
Share on other sites

```
        ' /////////////////////////////////////////////
                ' // This is used for NPC walking/targetting //
                ' /////////////////////////////////////////////
                ' Make sure theres a npc with the map
                If Map(Y).NPC(X) > 0 Then
                    If MapNPC(Y, X).num > 0 Then
                        Target = MapNPC(Y, X).Target

                        ' Check to see if its time for the npc to walk
                        If NPC(NPCnum).Behavior <> NPC_BEHAVIOR_SHOPKEEPER Then
                            ' Check to see if we are following a player or not
                            If Target > 0 Then
                                ' Check if the player is even playing, if so follow'm
                                If IsPlaying(Target) Then
                                    If GetPlayerMap(Target) = Y Then
                                        DidWalk = False

                                        I = Int(Rnd * 4)

                                        ' Lets move the npc
                                        Select Case I
                                            Case 0
                                                ' Up
                                                If MapNPC(Y, X).Y > GetPlayerY(Target) Then
                                                    If DidWalk = False Then
                                                        If CanNpcMove(Y, X, DIR_UP) Then
                                                            Call NpcMove(Y, X, DIR_UP, MOVING_WALKING)
                                                            DidWalk = True
                                                        End If
                                                    End If
                                                End If
                                                ' Down
                                                If MapNPC(Y, X).Y < GetPlayerY(Target) Then
                                                    If DidWalk = False Then
                                                        If CanNpcMove(Y, X, DIR_DOWN) Then
                                                            Call NpcMove(Y, X, DIR_DOWN, MOVING_WALKING)
                                                            DidWalk = True
                                                        End If
                                                    End If
                                                End If
                                                ' Left
                                                If MapNPC(Y, X).X > GetPlayerX(Target) Then
                                                    If DidWalk = False Then
                                                        If CanNpcMove(Y, X, DIR_LEFT) Then
                                                            Call NpcMove(Y, X, DIR_LEFT, MOVING_WALKING)
                                                            DidWalk = True
                                                        End If
                                                    End If
                                                End If
                                                ' Right
                                                If MapNPC(Y, X).X < GetPlayerX(Target) Then
                                                    If DidWalk = False Then
                                                        If CanNpcMove(Y, X, DIR_RIGHT) Then
                                                            Call NpcMove(Y, X, DIR_RIGHT, MOVING_WALKING)
                                                            DidWalk = True
                                                        End If
                                                    End If
                                                End If

                                            Case 1
                                                ' Right
                                                If MapNPC(Y, X).X < GetPlayerX(Target) Then
                                                    If DidWalk = False Then
                                                        If CanNpcMove(Y, X, DIR_RIGHT) Then
                                                            Call NpcMove(Y, X, DIR_RIGHT, MOVING_WALKING)
                                                            DidWalk = True
                                                        End If
                                                    End If
                                                End If
                                                ' Left
                                                If MapNPC(Y, X).X > GetPlayerX(Target) Then
                                                    If DidWalk = False Then
                                                        If CanNpcMove(Y, X, DIR_LEFT) Then
                                                            Call NpcMove(Y, X, DIR_LEFT, MOVING_WALKING)
                                                            DidWalk = True
                                                        End If
                                                    End If
                                                End If
                                                ' Down
                                                If MapNPC(Y, X).Y < GetPlayerY(Target) Then
                                                    If DidWalk = False Then
                                                        If CanNpcMove(Y, X, DIR_DOWN) Then
                                                            Call NpcMove(Y, X, DIR_DOWN, MOVING_WALKING)
                                                            DidWalk = True
                                                        End If
                                                    End If
                                                End If
                                                ' Up
                                                If MapNPC(Y, X).Y > GetPlayerY(Target) Then
                                                    If DidWalk = False Then
                                                        If CanNpcMove(Y, X, DIR_UP) Then
                                                            Call NpcMove(Y, X, DIR_UP, MOVING_WALKING)
                                                            DidWalk = True
                                                        End If
                                                    End If
                                                End If

                                            Case 2
                                                ' Down
                                                If MapNPC(Y, X).Y < GetPlayerY(Target) Then
                                                    If DidWalk = False Then
                                                        If CanNpcMove(Y, X, DIR_DOWN) Then
                                                            Call NpcMove(Y, X, DIR_DOWN, MOVING_WALKING)
                                                            DidWalk = True
                                                        End If
                                                    End If
                                                End If
                                                ' Up
                                                If MapNPC(Y, X).Y > GetPlayerY(Target) Then
                                                    If DidWalk = False Then
                                                        If CanNpcMove(Y, X, DIR_UP) Then
                                                            Call NpcMove(Y, X, DIR_UP, MOVING_WALKING)
                                                            DidWalk = True
                                                        End If
                                                    End If
                                                End If
                                                ' Right
                                                If MapNPC(Y, X).X < GetPlayerX(Target) Then
                                                    If DidWalk = False Then
                                                        If CanNpcMove(Y, X, DIR_RIGHT) Then
                                                            Call NpcMove(Y, X, DIR_RIGHT, MOVING_WALKING)
                                                            DidWalk = True
                                                        End If
                                                    End If
                                                End If
                                                ' Left
                                                If MapNPC(Y, X).X > GetPlayerX(Target) Then
                                                    If DidWalk = False Then
                                                        If CanNpcMove(Y, X, DIR_LEFT) Then
                                                            Call NpcMove(Y, X, DIR_LEFT, MOVING_WALKING)
                                                            DidWalk = True
                                                        End If
                                                    End If
                                                End If

                                            Case 3
                                                ' Left
                                                If MapNPC(Y, X).X > GetPlayerX(Target) Then
                                                    If DidWalk = False Then
                                                        If CanNpcMove(Y, X, DIR_LEFT) Then
                                                            Call NpcMove(Y, X, DIR_LEFT, MOVING_WALKING)
                                                            DidWalk = True
                                                        End If
                                                    End If
                                                End If
                                                ' Right
                                                If MapNPC(Y, X).X < GetPlayerX(Target) Then
                                                    If DidWalk = False Then
                                                        If CanNpcMove(Y, X, DIR_RIGHT) Then
                                                            Call NpcMove(Y, X, DIR_RIGHT, MOVING_WALKING)
                                                            DidWalk = True
                                                        End If
                                                    End If
                                                End If
                                                ' Up
                                                If MapNPC(Y, X).Y > GetPlayerY(Target) Then
                                                    If DidWalk = False Then
                                                        If CanNpcMove(Y, X, DIR_UP) Then
                                                            Call NpcMove(Y, X, DIR_UP, MOVING_WALKING)
                                                            DidWalk = True
                                                        End If
                                                    End If
                                                End If
                                                ' Down
                                                If MapNPC(Y, X).Y < GetPlayerY(Target) Then
                                                    If DidWalk = False Then
                                                        If CanNpcMove(Y, X, DIR_DOWN) Then
                                                            Call NpcMove(Y, X, DIR_DOWN, MOVING_WALKING)
                                                            DidWalk = True
                                                        End If
                                                    End If
                                                End If
                                        End Select

                                        ' Check if we can't move and if player is behind something and if we can just switch dirs
                                        If Not DidWalk Then
                                            If MapNPC(Y, X).X - 1 = GetPlayerX(Target) Then
                                                If MapNPC(Y, X).Y = GetPlayerY(Target) Then
                                                    If MapNPC(Y, X).Dir <> DIR_LEFT Then
                                                        Call NpcDir(Y, X, DIR_LEFT)
                                                    End If
                                                End If
                                                DidWalk = True
                                            End If
                                            If MapNPC(Y, X).X + 1 = GetPlayerX(Target) Then
                                                If MapNPC(Y, X).Y = GetPlayerY(Target) Then
                                                    If MapNPC(Y, X).Dir <> DIR_RIGHT Then
                                                        Call NpcDir(Y, X, DIR_RIGHT)
                                                    End If
                                                End If
                                                DidWalk = True
                                            End If
                                            If MapNPC(Y, X).X = GetPlayerX(Target) Then
                                                If MapNPC(Y, X).Y - 1 = GetPlayerY(Target) Then
                                                    If MapNPC(Y, X).Dir <> DIR_UP Then
                                                        Call NpcDir(Y, X, DIR_UP)
                                                    End If
                                                End If
                                                DidWalk = True
                                            End If
                                            If MapNPC(Y, X).X = GetPlayerX(Target) Then
                                                If MapNPC(Y, X).Y + 1 = GetPlayerY(Target) Then
                                                    If MapNPC(Y, X).Dir <> DIR_DOWN Then
                                                        Call NpcDir(Y, X, DIR_DOWN)
                                                    End If
                                                End If
                                                DidWalk = True
                                            End If

                                            ' We could not move so player must be behind something, walk randomly.
                                            If Not DidWalk Then
                                                I = Int(Rnd * 2)
                                                If I = 1 Then
                                                    I = Int(Rnd * 4)
                                                    If CanNpcMove(Y, X, I) Then
                                                        Call NpcMove(Y, X, I, MOVING_WALKING)
                                                    End If
                                                End If
                                            End If
                                        End If
                                    Else
                                        MapNPC(Y, X).Target = 0
                                    End If
                                End If

                            Else
                                I = Int(Rnd * 4)
                                If I = 1 Then
                                    I = Int(Rnd * 4)
                                    If CanNpcMove(Y, X, I) Then
                                        Call NpcMove(Y, X, I, MOVING_WALKING)
                                    End If
                                End If
                            End If

                        End If
                    End If

                End If

```
Found it, this is where we begin..
Link to comment
Share on other sites

I quickly made this:

```
Type PlayerPetRec
    Name As String * NAME_LENGTH
    AttackSay As String * 100

    Sprite As Long
    Behavior As Byte
    Range As Byte

    STR As Long
    DEF As Long
    Speed As Long
    Magi As Long
    Big As Long
    MAXHP As Long
    Exp As Long
    SpawnTime As Long

    PetHeldItem As Integer

    Element As Long

    SPRITESIZE As Byte
End Type
```
Pretty sure all the data needed for the pet is there.

The pet processing code would probably be something like this: (server-side in modGeneral -> Sub GameAI)

```
-normal npc processing code-

For i = 1 To MAX_PLAYERS
    -check if player pet is attack on sight, if so mark closest unfriendly npc as target-
    -move pet towards npc, if no target set, do nothing as the pet will follow the player-
    -do the actual attacking-
    -hp/mp regen-
Next i
```
Link to comment
Share on other sites

@Dᴺᴬ:

> I'm sorry, but:
>
> HOLY FUC K!!!!

please resist from merely spamming the thread with 99 font. if you are going to post thats fine, but i reccomend at least using a regular font for using  a font that large is merely annoying and doesnt help anything

back on subject: Nice find(s) ridrik, this is definately a good start but npc v npc is going to be the big problem and is probably going to take a few roundabout scripts
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...