GS-Zone

Click para saber la Vida de los NPCs Ir al Indice

Moderadores: Moderadores de Argentum, Especialistas de Argentum, Especialistas de Programación

1
Este tema se encuentra cerrado.

Nota » 19 Jul 2006 22:24

Código del servidor
Ver status de NPCs

Bien, a continuación les voy a presentar un código bastante útil. El mismo sirve para que al hacer click sobre la vida de los NPCs podramos saber su estado. Éste código en el servidor oficial de Alkon está implementado, pero de una manera que es necesario tener skill en supervivencia. En mi código (o sea, éste), no hace falta tener skill en supervivencia, y además de eso, tenemos 2 opciones para mostrar la vida:

  • Que al hacer click sobre el NPC nos diga el estado del NPC: intacto, levemente herido, herido, etc...
  • Que al hacer click sobre el NPC nos muestre el estado de la vida así: (Vida / Vida Máxima)

Bien, ya tenemos las dos opciones. Entonces... ¡Manos a la obra!

Buscamos en el sub LookAtTtile, dentro del modulo GameLogic.bas:

  1.  
  2.     If FoundChar = 2 Then '¿Encontro un NPC?
  3.             Dim estatus As String
  4.            
  5.             If UserList(UserIndex).Stats.UserSkills(Supervivencia) >= 0 And UserList(UserIndex).Stats.UserSkills(Supervivencia) <= 10 Then
  6.                 estatus = "(Dudoso) "
  7.             ElseIf UserList(UserIndex).Stats.UserSkills(Supervivencia) > 10 And UserList(UserIndex).Stats.UserSkills(Supervivencia) <= 20 Then
  8.                 If Npclist(TempCharIndex).Stats.MinHP < (Npclist(TempCharIndex).Stats.MaxHP / 2) Then
  9.                     estatus = "(Herido) "
  10.                 Else
  11.                     estatus = "(Sano) "
  12.                 End If
  13.             ElseIf UserList(UserIndex).Stats.UserSkills(Supervivencia) > 20 And UserList(UserIndex).Stats.UserSkills(Supervivencia) <= 30 Then
  14.                 If Npclist(TempCharIndex).Stats.MinHP < (Npclist(TempCharIndex).Stats.MaxHP * 0.5) Then
  15.                     estatus = "(Malherido) "
  16.                 ElseIf Npclist(TempCharIndex).Stats.MinHP < (Npclist(TempCharIndex).Stats.MaxHP * 0.75) Then
  17.                     estatus = "(Herido) "
  18.                 Else
  19.                     estatus = "(Sano) "
  20.                 End If
  21.             ElseIf UserList(UserIndex).Stats.UserSkills(Supervivencia) > 30 And UserList(UserIndex).Stats.UserSkills(Supervivencia) <= 40 Then
  22.                 If Npclist(TempCharIndex).Stats.MinHP < (Npclist(TempCharIndex).Stats.MaxHP * 0.25) Then
  23.                     estatus = "(Muy malherido) "
  24.                 ElseIf Npclist(TempCharIndex).Stats.MinHP < (Npclist(TempCharIndex).Stats.MaxHP * 0.5) Then
  25.                     estatus = "(Herido) "
  26.                 ElseIf Npclist(TempCharIndex).Stats.MinHP < (Npclist(TempCharIndex).Stats.MaxHP * 0.75) Then
  27.                     estatus = "(Levemente herido) "
  28.                 Else
  29.                     estatus = "(Sano) "
  30.                 End If
  31.             ElseIf UserList(UserIndex).Stats.UserSkills(Supervivencia) > 40 And UserList(UserIndex).Stats.UserSkills(Supervivencia) < 60 Then
  32.                 If Npclist(TempCharIndex).Stats.MinHP < (Npclist(TempCharIndex).Stats.MaxHP * 0.05) Then
  33.                     estatus = "(Agonizando) "
  34.                 ElseIf Npclist(TempCharIndex).Stats.MinHP < (Npclist(TempCharIndex).Stats.MaxHP * 0.1) Then
  35.                     estatus = "(Casi muerto) "
  36.                 ElseIf Npclist(TempCharIndex).Stats.MinHP < (Npclist(TempCharIndex).Stats.MaxHP * 0.25) Then
  37.                     estatus = "(Muy Malherido) "
  38.                 ElseIf Npclist(TempCharIndex).Stats.MinHP < (Npclist(TempCharIndex).Stats.MaxHP * 0.5) Then
  39.                     estatus = "(Herido) "
  40.                 ElseIf Npclist(TempCharIndex).Stats.MinHP < (Npclist(TempCharIndex).Stats.MaxHP * 0.75) Then
  41.                     estatus = "(Levemente herido) "
  42.                 ElseIf Npclist(TempCharIndex).Stats.MinHP < (Npclist(TempCharIndex).Stats.MaxHP) Then
  43.                     estatus = "(Sano) "
  44.                 Else
  45.                     estatus = "(Intacto) "
  46.                 End If
  47.             ElseIf UserList(UserIndex).Stats.UserSkills(Supervivencia) >= 60 Then
  48.                 estatus = "(" & Npclist(TempCharIndex).Stats.MinHP & "/" & Npclist(TempCharIndex).Stats.MaxHP & ") "
  49.             Else
  50.                 estatus = "!error!"
  51.             End If
  52.  
  53.             If UserList(UserIndex).flags.Privilegios = 1 Or UserList(UserIndex).flags.Privilegios = 2 Then
  54.                 estatus = "(" & Npclist(TempCharIndex).Stats.MaxHP & ")"
  55.             End If
  56.            
  57.             If Len(Npclist(TempCharIndex).Desc) > 1 Then
  58.                 Call SendData(ToIndex, UserIndex, 0, "||" & vbWhite & "°" & Npclist(TempCharIndex).Desc & "°" & Npclist(TempCharIndex).Char.charindex & FONTTYPE_INFO)
  59.             Else
  60.                
  61.                 If Npclist(TempCharIndex).MaestroUser > 0 Then
  62.                     Call SendData(ToIndex, UserIndex, 0, "|| " & estatus & Npclist(TempCharIndex).Name & " es mascota de " & UserList(Npclist(TempCharIndex).MaestroUser).Name & FONTTYPE_INFO)
  63.                 Else
  64.                     Call SendData(ToIndex, UserIndex, 0, "|| " & estatus & Npclist(TempCharIndex).Name & "." & FONTTYPE_INFO)
  65.                 End If
  66.                
  67.             End If
  68.             FoundSomething = 1
  69.             UserList(UserIndex).flags.TargetNpcTipo = Npclist(TempCharIndex).NPCtype
  70.             UserList(UserIndex).flags.TargetNPC = TempCharIndex
  71.             UserList(UserIndex).flags.TargetUser = 0
  72.             UserList(UserIndex).flags.TargetObj = 0
  73.        
  74.     End If
  75.  


Si queremos que la vida se vea como la primera forma, reemplazamos TODO ese If...End If por lo siguiente:

  1.  
  2.     If FoundChar = 2 Then '¿Encontro un NPC?
  3.             Dim estatus As String
  4.  
  5.             If Npclist(TempCharIndex).Stats.MinHP < (Npclist(TempCharIndex).Stats.MaxHP * 0.05) Then
  6.                estatus = "(Agonizando) "
  7.             ElseIf Npclist(TempCharIndex).Stats.MinHP < (Npclist(TempCharIndex).Stats.MaxHP * 0.1) Then
  8.                 estatus = "(Casi muerto) "
  9.             ElseIf Npclist(TempCharIndex).Stats.MinHP < (Npclist(TempCharIndex).Stats.MaxHP * 0.25) Then
  10.                 estatus = "(Malherido) "
  11.             ElseIf Npclist(TempCharIndex).Stats.MinHP < (Npclist(TempCharIndex).Stats.MaxHP * 0.5) Then
  12.                 estatus = "(Herido) "
  13.             ElseIf Npclist(TempCharIndex).Stats.MinHP < (Npclist(TempCharIndex).Stats.MaxHP * 0.75) Then
  14.                 estatus = "(Levemente herido) "
  15.             ElseIf Npclist(TempCharIndex).Stats.MinHP < (Npclist(TempCharIndex).Stats.MaxHP) Then
  16.                 estatus = "(Sano) "
  17.             Else
  18.                 estatus = "(Intacto) "
  19.             End If
  20.  
  21.             If UserList(UserIndex).flags.Privilegios = 1 Or UserList(UserIndex).flags.Privilegios = 2 Then
  22.                 estatus = "(" & Npclist(TempCharIndex).Stats.MaxHP & ")"
  23.             End If
  24.            
  25.             If Len(Npclist(TempCharIndex).Desc) > 1 Then
  26.                 Call SendData(ToIndex, UserIndex, 0, "||" & vbWhite & "°" & Npclist(TempCharIndex).Desc & "°" & Npclist(TempCharIndex).Char.charindex & FONTTYPE_INFO)
  27.             Else
  28.                
  29.                 If Npclist(TempCharIndex).MaestroUser > 0 Then
  30.                     Call SendData(ToIndex, UserIndex, 0, "||" & estatus & Npclist(TempCharIndex).Name & " es mascota de " & UserList(Npclist(TempCharIndex).MaestroUser).Name & FONTTYPE_INFO)
  31.                 Else
  32.                     Call SendData(ToIndex, UserIndex, 0, "||" & estatus & Npclist(TempCharIndex).Name & "." & FONTTYPE_INFO)
  33.                 End If
  34.                
  35.             End If
  36.             FoundSomething = 1
  37.             UserList(UserIndex).flags.TargetNpcTipo = Npclist(TempCharIndex).NPCtype
  38.             UserList(UserIndex).flags.TargetNPC = TempCharIndex
  39.             UserList(UserIndex).flags.TargetUser = 0
  40.             UserList(UserIndex).flags.TargetObj = 0
  41.        
  42.     End If
  43.  


En cambio, si queremos que se vea de la segunda forma, reemplazamos todo ese If...End If por lo siguiente:

  1.  
  2.     If FoundChar = 2 Then '¿Encontro un NPC?
  3.             Dim estatus As String
  4.  
  5.             estatus = "(" & Npclist(TempCharIndex).Stats.MinHP & "/" & Npclist(TempCharIndex).Stats.MaxHP & ") "
  6.  
  7.             If UserList(UserIndex).flags.Privilegios = 1 Or UserList(UserIndex).flags.Privilegios = 2 Then
  8.                 estatus = "(" & Npclist(TempCharIndex).Stats.MaxHP & ")"
  9.             End If
  10.            
  11.             If Len(Npclist(TempCharIndex).Desc) > 1 Then
  12.                 Call SendData(ToIndex, UserIndex, 0, "||" & vbWhite & "°" & Npclist(TempCharIndex).Desc & "°" & Npclist(TempCharIndex).Char.charindex & FONTTYPE_INFO)
  13.             Else
  14.                
  15.                 If Npclist(TempCharIndex).MaestroUser > 0 Then
  16.                     Call SendData(ToIndex, UserIndex, 0, "||" & estatus & Npclist(TempCharIndex).Name & " es mascota de " & UserList(Npclist(TempCharIndex).MaestroUser).Name & FONTTYPE_INFO)
  17.                 Else
  18.                     Call SendData(ToIndex, UserIndex, 0, "||" & estatus & Npclist(TempCharIndex).Name & "." & FONTTYPE_INFO)
  19.                 End If
  20.                
  21.             End If
  22.             FoundSomething = 1
  23.             UserList(UserIndex).flags.TargetNpcTipo = Npclist(TempCharIndex).NPCtype
  24.             UserList(UserIndex).flags.TargetNPC = TempCharIndex
  25.             UserList(UserIndex).flags.TargetUser = 0
  26.             UserList(UserIndex).flags.TargetObj = 0
  27.        
  28.     End If
  29.  


¡Listo! Cualquiera de las 2 formas funciona correctamente. Cualquier duda / queja / sugerencia o cualquier cosa referida a este thread, posteen abajo.

¡Espero que les haya servido!

Amraphen.-
Usuario Registrado
Aprendiz [7]
Registrado: 5 Años de membresía!
Ubicación: Rosario, Argentina
Mensajes: 468
Aportes: 18

Este tema se encuentra cerrado.

Volver a AO 0.11.2 / AOReady

¿Quién está conectado?

Usuarios navegando por este Foro: No hay usuarios registrados visitando el Foro y 0 invitados