Advertisement
Luciano_fuentes

JDH

Mar 23rd, 2017
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.57 KB | None | 0 0
  1. Option Explicit
  2.  
  3. '***************
  4. 'AUTOR: Toyz - Luciano
  5. '***************
  6. Private Const Tiempo_Cancelamiento As Integer = 180
  7. Private Const Cofre_Abierto As Integer = 10 'Número de cofre abierto.
  8. Private Const Cofre_Cerrado As Integer = 11 'Número de cofre cerrado.
  9.  
  10. Private Type tUsuario
  11. ID As Integer
  12. Posicion As WorldPos
  13. X As Byte
  14. Y As Byte
  15. End Type
  16.  
  17. Private Type tCofres
  18. Objetos(1 To 6) As Obj
  19. X As Byte
  20. Y As Byte
  21. Abierto As Boolean
  22. End Type
  23.  
  24. Private Type tJDH
  25. Activo As Boolean
  26. Usuarios(1 To 8) As tUsuario
  27. Cofres(1 To 9) As tCofres
  28. Conteo As Integer
  29. Cupos As Byte
  30. mapa As Integer
  31. Premio As Long
  32. Inscripcion As Long
  33. Total As Byte
  34. EsperarP As Boolean
  35. EsperandoParticipantes As Boolean
  36. Restantes As Byte
  37. End Type
  38.  
  39. Private JDH As tJDH
  40.  
  41. Public Sub Carga_JDH()
  42. Dim LoopC As Long
  43. Dim LoopX As Long
  44. Dim LoopZ As Long
  45. Dim DataCofre As Obj
  46.  
  47. DataCofre.Amount = 1
  48. DataCofre.ObjIndex = Cofre_Cerrado
  49.  
  50. Dim Leer As clsIniManager
  51. Set Leer = New clsIniManager
  52. Call Leer.Initialize(App.Path & "\Dat\JuegosDelHambre.dat")
  53.  
  54. With JDH
  55. .Cupos = UBound(.Usuarios())
  56. .mapa = CInt(Leer.GetValue("EVENTO", "Mapa"))
  57. For LoopC = 1 To .Cupos
  58. .Usuarios(LoopC).X = CByte(Leer.GetValue("USUARIO#" & LoopC, "X"))
  59. .Usuarios(LoopC).Y = CByte(Leer.GetValue("USUARIO#" & LoopC, "Y"))
  60. Next LoopC
  61. For LoopX = 1 To UBound(.Cofres())
  62. .Cofres(LoopX).X = CByte(Leer.GetValue("COFRE#" & LoopX, "X"))
  63. .Cofres(LoopX).Y = CByte(Leer.GetValue("COFRE#" & LoopX, "Y"))
  64. MakeObj DataCofre, .mapa, .Cofres(LoopX).X, .Cofres(LoopX).Y
  65. MapData(.mapa, .Cofres(LoopX).X, .Cofres(LoopX).Y).Blocked = 1
  66. MapData(.mapa, .Cofres(LoopX).X, .Cofres(LoopX).Y).Cofre = LoopX
  67. Bloquear True, .mapa, .Cofres(LoopX).X, .Cofres(LoopX).Y, 1
  68. For LoopZ = 1 To UBound(.Cofres(LoopX).Objetos())
  69. .Cofres(LoopX).Objetos(LoopZ).ObjIndex = CByte(ReadField(1, (Leer.GetValue("COFRE#" & LoopX, "OBJETO#" & LoopZ)), 45))
  70. .Cofres(LoopX).Objetos(LoopZ).Amount = CByte(ReadField(2, (Leer.GetValue("COFRE#" & LoopX, "OBJETO#" & LoopZ)), 45))
  71. Next LoopZ
  72. Next LoopX
  73. End With
  74. End Sub
  75.  
  76. Public Sub Armar_JDH(ByVal ID As Integer, ByVal Premio As Long, ByVal Inscripcion As Long)
  77. With JDH
  78. If .Activo = True Then
  79. Call WriteConsoleMsg(ID, "Juegos del Hambre> El evento ya está en curso.", FontTypeNames.FONTTYPE_GUILD)
  80. Exit Sub
  81. End If
  82. .Inscripcion = Inscripcion
  83. .Premio = Premio
  84. .Total = .Cupos
  85. .Restantes = .Total
  86. .Activo = True
  87. .Conteo = Tiempo_Cancelamiento
  88. .EsperandoParticipantes = True
  89. Call SendData(SendTarget.ToAll, 0, PrepareMessageConsoleMsg("Juegos del Hambre> " & .Cupos & " Cupos, Incripción" & IIf(.Inscripcion > 0, " de: " & .Inscripcion & " Monedas de oro, ", " Gratis, ") & IIf(.Premio > 0, "Premio de: " & .Premio & " Monedas de oro.", " No hay premio.") & " Manden /ENTRARJDH si desean participar, deben tener el inventario completamente vacío.", FontTypeNames.FONTTYPE_GUILD))
  90. End With
  91. End Sub
  92.  
  93. Public Sub Entrar_JDH(ByVal ID As Integer)
  94. Dim ID_JDH As Byte
  95. With JDH
  96. If Puede_Entrar(ID) = False Then Exit Sub
  97. Call WriteConsoleMsg(ID, "Has ingresado al evento" & IIf(.Inscripcion > 0, ", se te han descontado " & .Inscripcion & " monedas de oro.", vbNullString) & ". Espera a que el cupo se complete. ¡Suerte en el campo de batalla!", FontTypeNames.FONTTYPE_GUILD)
  98. UserList(ID).Stats.Gld = UserList(ID).Stats.Gld - .Inscripcion
  99. .Cupos = .Cupos - 1
  100. ID_JDH = JDH_ID
  101. UserList(ID).flags.EnJDH = ID_JDH
  102. .Usuarios(ID_JDH).ID = ID
  103. .Usuarios(ID_JDH).Posicion = UserList(ID).Pos
  104. WarpUserChar ID, .mapa, .Usuarios(ID_JDH).X, .Usuarios(ID_JDH).Y, False
  105. WritePauseToggle ID
  106. WriteUpdateGold ID
  107. If .Cupos = 0 Then
  108. Call SendData(SendTarget.ToAll, 0, PrepareMessageConsoleMsg("Juegos del Hambre> El cupo ha sido completado!", FontTypeNames.FONTTYPE_GUILD))
  109. .Conteo = 10
  110. .EsperarP = True
  111. .EsperandoParticipantes = False
  112. End If
  113. End With
  114. End Sub
  115.  
  116. Private Function JDH_ID() As Byte
  117. Dim LoopC As Long
  118. With JDH
  119. For LoopC = 1 To .Total
  120. If .Usuarios(LoopC).ID = 0 Then
  121. JDH_ID = LoopC
  122. Exit Function
  123. End If
  124. Next LoopC
  125. End With
  126. End Function
  127.  
  128. Private Function Puede_Entrar(ByVal ID As Integer) As Boolean
  129. Puede_Entrar = False
  130. If UserList(ID).flags.Muerto > 0 Then
  131. Call WriteConsoleMsg(ID, "Estás muerto.", FontTypeNames.FONTTYPE_GUILD)
  132. Exit Function
  133. End If
  134. If UserList(ID).flags.EnJDH > 0 Then
  135. Call WriteConsoleMsg(ID, "Ya estás en los Juegos del Hambre.", FontTypeNames.FONTTYPE_GUILD)
  136. Exit Function
  137. End If
  138. If JDH.Activo = False Then
  139. Call WriteConsoleMsg(ID, "El evento no está en curso.", FontTypeNames.FONTTYPE_GUILD)
  140. Exit Function
  141. End If
  142. If JDH.Cupos = 0 Then
  143. Call WriteConsoleMsg(ID, "El evento ya no tiene cupos disponibles.", FontTypeNames.FONTTYPE_GUILD)
  144. Exit Function
  145. End If
  146. If UserList(ID).Stats.Gld < JDH.Inscripcion Then
  147. Call WriteConsoleMsg(ID, "No tienes el oro suficiente.", FontTypeNames.FONTTYPE_GUILD)
  148. Exit Function
  149. End If
  150. If Not UserList(ID).Pos.Map = 1 Then
  151. Call WriteConsoleMsg(ID, "Tienes que estar en Ullathorpe para poder ingresar al evento", FontTypeNames.FONTTYPE_GUILD)
  152. Exit Function
  153. End If
  154. If Tiene_Objeto(ID) = False Then
  155. Call WriteConsoleMsg(ID, "Debes tener el inventario vacío para poder entrar.", FontTypeNames.FONTTYPE_GUILD)
  156. Exit Function
  157. End If
  158. Puede_Entrar = True
  159. End Function
  160.  
  161. Public Sub Contar_JDH()
  162. Dim LoopC As Long
  163. Dim LoopX As Long
  164. With JDH
  165. If .Conteo = 0 Then
  166. .Conteo = -1
  167. If .Activo = True Then
  168. For LoopC = 1 To .Total
  169. WritePauseToggle .Usuarios(LoopC).ID
  170. Next LoopC
  171.  
  172. If .EsperarP = True Then
  173. SendData SendTarget.ToAll, 0, PrepareMessageConsoleMsg("Juegos del Hambre> Ya!", FontTypeNames.FONTTYPE_FIGHT)
  174. .EsperarP = False
  175. ElseIf .EsperandoParticipantes = True Then
  176. SendData SendTarget.ToAll, 0, PrepareMessageConsoleMsg("Juegos del Hambre> Evento cancelado por falta de participantes, se ha devuelto el oro por la inscripción.", FontTypeNames.FONTTYPE_GUILD)
  177. Cancelar_JDH
  178. End If
  179. End If
  180. End If
  181.  
  182. If .Conteo > 0 Then
  183. If .EsperarP = True Then _
  184. SendData SendTarget.ToAll, 0, PrepareMessageConsoleMsg("Juegos del Hambre> " & .Conteo, FontTypeNames.FONTTYPE_GUILD)
  185. .Conteo = .Conteo - 1
  186. End If
  187. End With
  188. End Sub
  189.  
  190. Private Function ID_Usuario() As Byte
  191. Dim LoopC As Long
  192. For LoopC = 1 To JDH.Total
  193. If JDH.Usuarios(LoopC).ID > 0 Then
  194. ID_Usuario = LoopC
  195. Exit For
  196. End If
  197. Next LoopC
  198. End Function
  199.  
  200. Public Sub Muere_JDH(ByVal ID As Integer)
  201. Dim ID_JDH As Byte
  202. ID_JDH = UserList(ID).flags.EnJDH
  203. If ID_JDH = 0 Then Exit Sub
  204. UserList(ID).flags.EnJDH = 0
  205. With JDH
  206. .Restantes = .Restantes - 1
  207. If .Restantes > 1 Then SendData SendTarget.ToAll, 0, PrepareMessageConsoleMsg("Juegos del Hambre> Quedan " & .Restantes & " luchadores.", FontTypeNames.FONTTYPE_GUILD)
  208. Call WriteConsoleMsg(ID, "Juegos del Hambre> ¡Has perdido, has sido descalificado. ¡Suerte para la próxima!", FontTypeNames.FONTTYPE_GUILD)
  209. WarpUserChar ID, .Usuarios(ID_JDH).Posicion.Map, .Usuarios(ID_JDH).Posicion.X, .Usuarios(ID_JDH).Posicion.Y, False
  210. .Usuarios(ID_JDH).ID = 0
  211. If .Restantes = 1 Then Finalizar
  212. End With
  213. End Sub
  214.  
  215. Private Sub Finalizar()
  216. Dim LoopC As Long
  217. Dim Dame_ID As Byte
  218. Dim ID As Integer
  219. With JDH
  220. Dame_ID = ID_Usuario
  221. ID = .Usuarios(Dame_ID).ID
  222. SendData SendTarget.ToAll, 0, PrepareMessageConsoleMsg("Juegos del Hambre> Ganador del evento: " & UserList(ID).name & " se lleva una cantidad de " & .Premio & " monedas de oro, felicitaciones!", FontTypeNames.FONTTYPE_GUILD)
  223. UserList(ID).Stats.Gld = UserList(ID).Stats.Gld + .Premio
  224. WriteUpdateGold ID
  225. UserList(ID).flags.EnJDH = 0
  226. .Premio = 0
  227. WarpUserChar ID, .Usuarios(Dame_ID).Posicion.Map, .Usuarios(Dame_ID).Posicion.X, .Usuarios(Dame_ID).Posicion.Y, False
  228. Limpiar
  229. End With
  230. End Sub
  231.  
  232. Public Sub Cancelar_JDH()
  233. Dim LoopC As Long
  234. With JDH
  235. If .Activo = False Then Exit Sub
  236. For LoopC = 1 To .Total
  237. If .Usuarios(LoopC).ID > 0 Then
  238. WarpUserChar .Usuarios(LoopC).ID, .Usuarios(LoopC).Posicion.Map, .Usuarios(LoopC).Posicion.X, .Usuarios(LoopC).Posicion.Y, False
  239. UserList(.Usuarios(LoopC).ID).flags.EnJDH = 0
  240. UserList(.Usuarios(LoopC).ID).Stats.Gld = UserList(.Usuarios(LoopC).ID).Stats.Gld + .Inscripcion
  241. WriteConsoleMsg .Usuarios(LoopC).ID, "El evento ha sido cancelado, se te ha devuelto el costo de la inscripción.", FontTypeNames.FONTTYPE_GUILD
  242. WriteUpdateGold .Usuarios(LoopC).ID
  243. End If
  244. Next LoopC
  245. End With
  246. SendData SendTarget.ToAll, 0, PrepareMessageConsoleMsg("Juegos del Hambre> Evento cancelado por un Game Master.", FontTypeNames.FONTTYPE_GUILD)
  247. Limpiar
  248. End Sub
  249.  
  250. Public Sub Desconexion_JDH(ByVal ID As Integer)
  251. If UserList(ID).flags.EnJDH = 0 Then Exit Sub
  252. With JDH
  253. If .EsperandoParticipantes = False And .EsperarP = False Then _
  254. TirarTodosLosItems ID
  255. WarpUserChar ID, .Usuarios(UserList(ID).flags.EnJDH).Posicion.Map, .Usuarios(UserList(ID).flags.EnJDH).Posicion.X, .Usuarios(UserList(ID).flags.EnJDH).Posicion.Y, True
  256. .Usuarios(UserList(ID).flags.EnJDH).ID = 0
  257. UserList(ID).flags.EnJDH = 0
  258. .Cupos = .Cupos + 1
  259. If .EsperarP = True Or .EsperandoParticipantes = True Then _
  260. WritePauseToggle ID
  261. End With
  262. End Sub
  263.  
  264. Private Sub Limpiar()
  265. Dim LoopC As Long
  266. With JDH
  267. .Activo = False
  268. .Conteo = -1
  269. .Cupos = UBound(.Usuarios())
  270. .Inscripcion = 0
  271. .Premio = 0
  272. .Restantes = 0
  273. .Total = 0
  274. For LoopC = 1 To .Total
  275. .Usuarios(LoopC).ID = 0
  276. Next LoopC
  277. ReCargar_Cofres
  278. End With
  279. End Sub
  280.  
  281. Private Function Tiene_Objeto(ByVal ID As Integer) As Boolean
  282. Dim LoopC As Long
  283. Tiene_Objeto = False
  284. With UserList(ID)
  285. For LoopC = 1 To .CurrentInventorySlots
  286. If .Invent.Object(LoopC).ObjIndex > 0 Then Exit Function
  287. Next LoopC
  288. Tiene_Objeto = True
  289. End With
  290. End Function
  291.  
  292. Public Sub Clickea_Cofre(ByRef Pos As WorldPos)
  293. Dim ID As Byte
  294. Dim DataCofre As Obj
  295. Dim LoopC As Long
  296. Dim n_Pos As WorldPos
  297.  
  298. DataCofre.Amount = 1
  299. DataCofre.ObjIndex = Cofre_Abierto
  300. ID = MapData(Pos.Map, Pos.X, Pos.Y).Cofre
  301.  
  302. With JDH
  303. If ID = 0 Then Exit Sub
  304. If .Cupos > 0 Then Exit Sub
  305. If .Activo = False Then Exit Sub
  306. If .Cofres(ID).Abierto = True Then Exit Sub
  307. If .Conteo <> -1 Then Exit Sub
  308.  
  309. .Cofres(ID).Abierto = True
  310.  
  311. EraseObj MapData(Pos.Map, Pos.X, Pos.Y).ObjInfo.Amount, Pos.Map, Pos.X, Pos.Y
  312. MakeObj DataCofre, .mapa, .Cofres(ID).X, .Cofres(ID).Y
  313.  
  314. For LoopC = 1 To UBound(.Cofres(ID).Objetos())
  315. Tilelibre Pos, n_Pos, .Cofres(ID).Objetos(LoopC), False, True
  316. MakeObj .Cofres(ID).Objetos(LoopC), .mapa, n_Pos.X, n_Pos.Y
  317. Next LoopC
  318. End With
  319. End Sub
  320.  
  321. Private Sub ReCargar_Cofres()
  322. Dim DataCofre As Obj
  323. Dim LoopC As Long
  324.  
  325. DataCofre.Amount = 1
  326. DataCofre.ObjIndex = Cofre_Cerrado
  327.  
  328. With JDH
  329. For LoopC = 1 To UBound(.Cofres())
  330. .Cofres(LoopC).Abierto = False
  331. EraseObj DataCofre.Amount, .mapa, .Cofres(LoopC).X, .Cofres(LoopC).Y
  332. MakeObj DataCofre, .mapa, .Cofres(LoopC).X, .Cofres(LoopC).Y
  333. Next LoopC
  334. End With
  335. ''''Call m_Limpieza.CleanWorld_Clear
  336. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement