Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Npc Walking Alterations (Based off Advocate's tut)
#1
First off im giving credit to Advocate since its his code this is based off. This is walking alterations for NPCs. It is easy but just posting it here to help the community. Credit to Advocate.

sub bltnpc
replace
Code:
' Check for animation
    Anim = 0
    If MapNpc(MapNpcNum).Attacking = 0 Then
        Select Case MapNpc(MapNpcNum).Dir
            Case DIR_UP
                If (MapNpc(MapNpcNum).YOffset < PIC_Y / 2) Then Anim = 1
            Case DIR_DOWN
                If (MapNpc(MapNpcNum).YOffset < PIC_Y / 2 * -1) Then Anim = 1
            Case DIR_LEFT
                If (MapNpc(MapNpcNum).XOffset < PIC_Y / 2) Then Anim = 1
            Case DIR_RIGHT
                If (MapNpc(MapNpcNum).XOffset < PIC_Y / 2 * -1) Then Anim = 1
        End Select
    Else
        If MapNpc(MapNpcNum).AttackTimer + 500 > GetTickCount Then
            Anim = 2
        End If
    End If

withhhhh
Code:
' Check for animation
    Anim = 0
    If MapNpc(MapNpcNum).Attacking = 0 Then
        Select Case MapNpc(MapNpcNum).Dir
    Case DIR_UP
                If (MapNpc(MapNpcNum).YOffset < PIC_Y / 3) Then
               Anim = 1
               ElseIf (MapNpc(MapNpcNum).YOffset > PIC_Y / 3) And ((MapNpc(MapNpcNum).YOffset > PIC_Y / 3 * 2)) Then
               Anim = 2
                End If
    Case DIR_DOWN
                Anim = 1
               If (MapNpc(MapNpcNum).YOffset < PIC_X / 4 * -1) Then Anim = 0
               If (MapNpc(MapNpcNum).YOffset < PIC_X / 2 * -1) Then Anim = 2
    Case DIR_LEFT
                Anim = 0
               If (MapNpc(MapNpcNum).XOffset < PIC_Y / 3) Then
               Anim = 1
               ElseIf (MapNpc(MapNpcNum).XOffset > PIC_Y / 3) And ((MapNpc(MapNpcNum).XOffset > PIC_Y / 3 * 2)) Then
               Anim = 2
               End If
    Case DIR_RIGHT
                  Anim = 0
               If (MapNpc(MapNpcNum).XOffset < PIC_Y / 4 * -1) Then Anim = 1
               If (MapNpc(MapNpcNum).XOffset < PIC_Y / 2 * -1) Then Anim = 2
       End Select
   Else
       If MapNpc(MapNpcNum).AttackTimer + 500 > GetTickCount Then
           Anim = 2
       End If
   End If

im pretty sure it works =P
Reply
#2
It would be nice if you typed up on what you updated from advo's code.

:: Pando
Reply
#3
alrighty pando sure Big Grin
its not really much
Code:
If Player(Index).Attacking = 0 Then
       Select Case GetPlayerDir(Index)
           Case DIR_UP
               Anim = 0
               If (Player(Index).YOffset < PIC_Y / 3) Then
               Anim = 1
               ElseIf (Player(Index).YOffset > PIC_Y / 3) And ((Player(Index).YOffset > PIC_Y / 3 * 2)) Then
               Anim = 2
               End If
           Case DIR_DOWN
               Anim = 1
               If (Player(Index).YOffset < PIC_X / 4 * -1) Then Anim = 0
               If (Player(Index).YOffset < PIC_X / 2 * -1) Then Anim = 2
           Case DIR_LEFT
               Anim = 0
               If (Player(Index).XOffset < PIC_Y / 3) Then
               Anim = 1
               ElseIf (Player(Index).XOffset > PIC_Y / 3) And ((Player(Index).XOffset > PIC_Y / 3 * 2)) Then
               Anim = 2
               End If
           Case DIR_RIGHT
               Anim = 0
               If (Player(Index).XOffset < PIC_Y / 4 * -1) Then Anim = 1
               If (Player(Index).XOffset < PIC_Y / 2 * -1) Then Anim = 2
       End Select
   Else
       If Player(Index).AttackTimer + 500 > GetTickCount Then
           Anim = 2
       End If
   End If
thats Advocates code. All i really did was change the (Player(Index)'s to MapNpc(MapNpcNum). so case dir right would be like
Code:
Case DIR_RIGHT
               Anim = 0
               If (MapNpc(MapNpcNum).XOffset < PIC_Y / 4 * -1) Then Anim = 1
               If (MapNpc(MapNpcNum).XOffset < PIC_Y / 2 * -1) Then Anim = 2
i would have explained more but there really isnt much to explain Big Grin
Reply
#4
Nothing's really updated. Just show's how to modify it for use with NPCs.
Reply
#5
Oh! Dumb me. :lol: I haven't ever looked at advo's thread. So I didn't know, if I did I wouldnt have asked you to do that.

:: Pando
Reply
#6
I was planning on getting around to this sooner or later. Much appreciated for saving me the time! ^_^
Reply
#7
So what does this do, exactly?
Reply
#8
Well why don't you read the code? It changes the walking system for NPCS.
Reply
#9
oh whatever, same shit. -_____-"
Reply
#10
No, it's not the same. There's a bug of sorts with this system, well, for players. It seems if you're running, it will only blit 2 frames. =\
Reply
#11
Advocate Wrote:No, it's not the same. There's a bug of sorts with this system, well, for players. It seems if you're running, it will only blit 2 frames. =\

What do you mean..?
Reply
#12
When holding shift to run, it won't use three frames like walking. It will look like how it did before you add the new system. Though this doesn't apply to this tut, it applies to my tut.
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)