Advertisement
Luciano_fuentes

Untitled

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