[Aporte] Carga de recursos de ImperiumAO - Dx8 (Parte3)
Página 1 de 1.
[Aporte] Carga de recursos de ImperiumAO - Dx8 (Parte3)
***CARGA DE NPCS***
Ahora buscamos:
Ahora en el ultimo lugar donde borramos el último Type agregamos lo siguiente:
Ahora buscamos:
Ahora buscamos el Sub ConnectUser y lo reemplazamos todo por este:
Se descargan esto que trae todos los recursos de IAO + lo otro Clic Aquì
Y Estos los Recursos del Servidor
Clic Aqui
Ahora buscamos:
- Código:
Public Function OpenNPC(ByVal NpcNumber As Integer, Optional ByVal Respawn = True) As Integer
- Código:
Public Function OpenNPC(ByVal NpcNumber As Integer, Optional ByVal Respawn = True) As Integer
'***************************************************
'Author: Unknown
'Last Modification: -
'
'***************************************************
'###################################################
'# ATENCION PELIGRO #
'###################################################
'
' ¡¡¡¡ NO USAR GetVar PARA LEER LOS NPCS !!!!
'
'El que ose desafiar esta LEY, se las tendrá que ver
'conmigo. Para leer los NPCS se deberá usar la
'nueva clase clsIniReader.
'
'Alejo
'
'###################################################
Dim NpcIndex As Integer
Dim Leer As clsIniReader
Dim LoopC As Long
Dim ln As String
Dim aux As String
Set Leer = LeerNPCs
'If requested index is invalid, abort
If Not Leer.KeyExists("NPC" & NpcNumber) Then
'OpenNPC = MAXNPCS + 1
Exit Function
End If
NpcIndex = NextOpenNPC
If NpcIndex > MAXNPCS Then 'Limite de npcs
OpenNPC = NpcIndex
Exit Function
End If
With Npclist(NpcIndex)
.Numero = NpcNumber
.name = Leer.GetValue("NPC" & NpcNumber, "Name")
.desc = Leer.GetValue("NPC" & NpcNumber, "Desc")
.Movement = val(Leer.GetValue("NPC" & NpcNumber, "Movement"))
.flags.OldMovement = .Movement
.flags.AguaValida = val(Leer.GetValue("NPC" & NpcNumber, "AguaValida"))
.flags.TierraInvalida = val(Leer.GetValue("NPC" & NpcNumber, "TierraInValida"))
.flags.Faccion = val(Leer.GetValue("NPC" & NpcNumber, "Faccion"))
.flags.AtacaDoble = val(Leer.GetValue("NPC" & NpcNumber, "AtacaDoble"))
.NPCtype = val(Leer.GetValue("NPC" & NpcNumber, "NpcType"))
.Char.body = val(Leer.GetValue("NPC" & NpcNumber, "Body"))
.Char.Head = val(Leer.GetValue("NPC" & NpcNumber, "Head"))
.Char.heading = val(Leer.GetValue("NPC" & NpcNumber, "Heading"))
.Attackable = val(Leer.GetValue("NPC" & NpcNumber, "Attackable"))
.Comercia = val(Leer.GetValue("NPC" & NpcNumber, "Comercia"))
.Hostile = val(Leer.GetValue("NPC" & NpcNumber, "Hostile"))
.flags.OldHostil = .Hostile
.GiveEXP = val(Leer.GetValue("NPC" & NpcNumber, "GiveEXP")) * 200
.flags.ExpCount = .GiveEXP
.Veneno = val(Leer.GetValue("NPC" & NpcNumber, "Veneno"))
.flags.Domable = val(Leer.GetValue("NPC" & NpcNumber, "Domable"))
.GiveGLD = val(Leer.GetValue("NPC" & NpcNumber, "GiveGLD")) * 200
.PoderAtaque = val(Leer.GetValue("NPC" & NpcNumber, "PoderAtaque"))
.PoderEvasion = val(Leer.GetValue("NPC" & NpcNumber, "PoderEvasion"))
.InvReSpawn = val(Leer.GetValue("NPC" & NpcNumber, "InvReSpawn"))
With .Stats
.MaxHP = val(Leer.GetValue("NPC" & NpcNumber, "MaxHP"))
.MinHP = val(Leer.GetValue("NPC" & NpcNumber, "MinHP"))
.MaxHIT = val(Leer.GetValue("NPC" & NpcNumber, "MaxHIT"))
.MinHIT = val(Leer.GetValue("NPC" & NpcNumber, "MinHIT"))
.def = val(Leer.GetValue("NPC" & NpcNumber, "DEF"))
.defM = val(Leer.GetValue("NPC" & NpcNumber, "DEFm"))
.Alineacion = val(Leer.GetValue("NPC" & NpcNumber, "Alineacion"))
End With
.Invent.NroItems = val(Leer.GetValue("NPC" & NpcNumber, "NROITEMS"))
If .Invent.NroItems > 0 Then
For LoopC = 1 To .Invent.NroItems
ln = Leer.GetValue("NPC" & NpcNumber, "Obj" & LoopC)
Npclist(NpcIndex).Invent.Object(LoopC).ProbTirar = 9
.Invent.Object(LoopC).ObjIndex = val(ReadField(1, ln, 45))
.Invent.Object(LoopC).Amount = val(ReadField(2, ln, 45))
Next LoopC
End If
.flags.LanzaSpells = val(Leer.GetValue("NPC" & NpcNumber, "LanzaSpells"))
If .flags.LanzaSpells > 0 Then ReDim .Spells(1 To .flags.LanzaSpells)
For LoopC = 1 To .flags.LanzaSpells
.Spells(LoopC) = val(Leer.GetValue("NPC" & NpcNumber, "Sp" & LoopC))
Next LoopC
If .NPCtype = eNPCType.Entrenador Then
.NroCriaturas = val(Leer.GetValue("NPC" & NpcNumber, "NroCriaturas"))
ReDim .Criaturas(1 To .NroCriaturas) As tCriaturasEntrenador
For LoopC = 1 To .NroCriaturas
.Criaturas(LoopC).NpcIndex = Leer.GetValue("NPC" & NpcNumber, "CI" & LoopC)
.Criaturas(LoopC).NpcName = Leer.GetValue("NPC" & NpcNumber, "CN" & LoopC)
Next LoopC
End If
With .flags
.NPCActive = True
If Respawn Then
.Respawn = val(Leer.GetValue("NPC" & NpcNumber, "ReSpawn"))
Else
.Respawn = 1
End If
.BackUp = val(Leer.GetValue("NPC" & NpcNumber, "BackUp"))
.RespawnOrigPos = val(Leer.GetValue("NPC" & NpcNumber, "OrigPos"))
.AfectaParalisis = val(Leer.GetValue("NPC" & NpcNumber, "AfectaParalisis"))
.Snd1 = val(Leer.GetValue("NPC" & NpcNumber, "Snd1"))
.Snd2 = val(Leer.GetValue("NPC" & NpcNumber, "Snd2"))
.Snd3 = val(Leer.GetValue("NPC" & NpcNumber, "Snd3"))
End With
'<<<<<<<<<<<<<< Expresiones >>>>>>>>>>>>>>>>
.NroExpresiones = val(Leer.GetValue("NPC" & NpcNumber, "NROEXP"))
If .NroExpresiones > 0 Then ReDim .Expresiones(1 To .NroExpresiones) As String
For LoopC = 1 To .NroExpresiones
.Expresiones(LoopC) = Leer.GetValue("NPC" & NpcNumber, "Exp" & LoopC)
Next LoopC
'<<<<<<<<<<<<<< Expresiones >>>>>>>>>>>>>>>>
'Tipo de items con los que comercia
.TipoItems = val(Leer.GetValue("NPC" & NpcNumber, "TipoItems"))
End With
'Update contadores de NPCs
If NpcIndex > LastNPC Then LastNPC = NpcIndex
NumNPCs = NumNPCs + 1
'Devuelve el nuevo Indice
OpenNPC = NpcIndex
End Function
Ahora en el ultimo lugar donde borramos el último Type agregamos lo siguiente:
- Código:
Public Type NPCStats
Alineacion As Integer
MaxHP As Long
MinHP As Long
MaxHIT As Integer
MinHIT As Integer
def As Integer
defM As Integer
End Type
Public Type NpcCounters
Paralisis As Integer
TiempoExistencia As Long
End Type
Public Type NPCFlags
AfectaParalisis As Byte
Domable As Integer
Respawn As Byte
NPCActive As Boolean '¿Esta vivo?
Follow As Boolean
Faccion As Byte
AtacaDoble As Byte
LanzaSpells As Byte
ExpCount As Long
OldMovement As TipoAI
OldHostil As Byte
AguaValida As Byte
TierraInvalida As Byte
Sound As Integer
AttackedBy As String
AttackedFirstBy As String
BackUp As Byte
RespawnOrigPos As Byte
Envenenado As Byte
Paralizado As Byte
Inmovilizado As Byte
invisible As Byte
Maldicion As Byte
Bendicion As Byte
Snd1 As Integer
Snd2 As Integer
Snd3 As Integer
End Type
Public Type tCriaturasEntrenador
NpcIndex As Integer
NpcName As String
tmpIndex As Integer
End Type
Public Type npc
name As String
Char As Char 'Define como se vera
desc As String
NPCtype As eNPCType
Numero As Integer
InvReSpawn As Byte
Comercia As Integer
Target As Long
TargetNPC As Long
TipoItems As Integer
Veneno As Byte
Pos As WorldPos 'Posicion
oldPos As WorldPos
Orig As WorldPos
SkillDomar As Integer
Movement As TipoAI
Attackable As Byte
Hostile As Byte
PoderAtaque As Long
PoderEvasion As Long
GiveEXP As Long
GiveGLD As Long
Stats As NPCStats
flags As NPCFlags
Contadores As NpcCounters
Invent As Inventario
CanAttack As Byte
NroExpresiones As Byte
Expresiones() As String ' le da vida
NroSpells As Byte
Spells() As Integer ' le da vida
'<<<<Entrenadores>>>>>
NroCriaturas As Integer
Criaturas() As tCriaturasEntrenador
MaestroUser As Integer
MaestroNpc As Integer
Mascotas As Integer
' New!! Needed for pathfindig
PFINFO As NpcPathFindingInfo
AreasInfo As AreaInfo
Owner As Integer
Drop(1 To MAX_NPC_DROPS) As tDrops
Ciudad As Integer
End Type
- Código:
ProbTirar As Byte
- Código:
Public Sub NPC_TIRAR_ITEMS(ByRef npc As npc, ByVal IsPretoriano As Boolean)
- Código:
Public Sub NPC_TIRAR_ITEMS(ByRef npc As npc, ByVal IsPretoriano As Boolean)
'***************************************************
'Autor: Unknown (orginal version)
'Last Modification: 28/11/2009
'Give away npc's items.
'28/11/2009: ZaMa - Implementado drops complejos
'02/04/2010: ZaMa - Los pretos vuelven a tirar oro.
'***************************************************
On Error Resume Next
With npc
Dim i As Byte
Dim MiObj As Obj
Dim NroDrop As Integer
Dim Random As Integer
Dim ObjIndex As Integer
' Tira todo el inventario
If IsPretoriano Then
For i = 1 To MAX_INVENTORY_SLOTS
If .Invent.Object(i).ObjIndex > 0 Then
MiObj.Amount = .Invent.Object(i).Amount
MiObj.ObjIndex = .Invent.Object(i).ObjIndex
Call TirarItemAlPiso(.Pos, MiObj)
End If
Next i
' Dropea oro?
If .GiveGLD > 0 Then _
Call TirarOroNpc(.GiveGLD, .Pos)
Exit Sub
End If
Random = RandomNumber(1, 100)
' Tiene 10% de prob de no tirar nada
If Random <= 90 Then
NroDrop = 1
If Random <= 10 Then
NroDrop = NroDrop + 1
For i = 1 To 3
' 10% de ir pasando de etapas
If RandomNumber(1, 100) <= 10 Then
NroDrop = NroDrop + 1
Else
Exit For
End If
Next i
End If
Call TirarOroNpc(.GiveGLD, npc.Pos)
End If
End With
End Sub
- Código:
Public Function GetWeaponAnim(ByVal UserIndex As Integer, ByVal ObjIndex As Integer) As Integer
- Código:
Public Function GetWeaponAnim(ByVal UserIndex As Integer, ByVal ObjIndex As Integer) As Integer
'***************************************************
'Author: Torres Patricio (Pato)
'Last Modification: 03/29/10
'
'***************************************************
Dim Tmp As Integer
With UserList(UserIndex)
GetWeaponAnim = ObjData(ObjIndex).WeaponAnim
End With
End Function
Ahora buscamos:
- Código:
Public Sub CargarMapa(ByVal Map As Long, ByVal MAPFl As String)
- Código:
Public Sub CargarMapa(ByVal Map As Long, ByVal MAPFl As String)
On Error GoTo errh
Dim fh As Integer
Dim MH As tMapHeader
Dim Blqs() As tDatosBloqueados
Dim L1() As Long
Dim L2() As tDatosGrh
Dim L3() As tDatosGrh
Dim L4() As tDatosGrh
Dim Triggers() As tDatosTrigger
Dim Luces() As tDatosLuces
Dim Particulas() As tDatosParticulas
Dim Objetos() As tDatosObjs
Dim NPCs() As tDatosNPC
Dim TEs() As tDatosTE
Dim MapSize As tMapSize
Dim MapDat As tMapDat
Dim i As Long
Dim j As Long
If Not FileExist(App.Path & "\Maps\Mapa" & Map & ".csm", vbNormal) Then
MsgBox "El arhivo " & App.Path & "\Maps\Mapa" & Map & ".csm" & " no existe."
Exit Sub
End If
fh = FreeFile
Open App.Path & "\Maps\Mapa" & Map & ".csm" For Binary Access Read As fh
Get #fh, , MH
Get #fh, , MapSize
Get #fh, , MapDat
ReDim L1(MapSize.XMin To MapSize.XMax, MapSize.YMin To MapSize.YMax) As Long
Get #fh, , L1
With MH
If .NumeroBloqueados > 0 Then
ReDim Blqs(1 To .NumeroBloqueados)
Get #fh, , Blqs
For i = 1 To .NumeroBloqueados
MapData(Map, Blqs(i).X, Blqs(i).Y).Blocked = 1
Next i
End If
If .NumeroLayers(2) > 0 Then
ReDim L2(1 To .NumeroLayers(2))
Get #fh, , L2
For i = 1 To .NumeroLayers(2)
MapData(Map, L2(i).X, L2(i).Y).Graphic(2) = L2(i).GrhIndex
Next i
End If
If .NumeroLayers(3) > 0 Then
ReDim L3(1 To .NumeroLayers(3))
Get #fh, , L3
For i = 1 To .NumeroLayers(3)
MapData(Map, L3(i).X, L3(i).Y).Graphic(3) = L3(i).GrhIndex
Next i
End If
If .NumeroLayers(4) > 0 Then
ReDim L4(1 To .NumeroLayers(4))
Get #fh, , L4
For i = 1 To .NumeroLayers(4)
MapData(Map, L4(i).X, L4(i).Y).Graphic(4) = L4(i).GrhIndex
Next i
End If
If .NumeroTriggers > 0 Then
ReDim Triggers(1 To .NumeroTriggers)
Get #fh, , Triggers
For i = 1 To .NumeroTriggers
MapData(Map, Triggers(i).X, Triggers(i).Y).Trigger = Triggers(i).Trigger
Next i
End If
If .NumeroParticulas > 0 Then
ReDim Particulas(1 To .NumeroParticulas)
Get #fh, , Particulas
For i = 1 To .NumeroParticulas
'MapData(Particulas(i).x, Particulas(i).y).particle_group_index = General_Particle_Create(Particulas(i).Particula, Particulas(i).x, Particulas(i).y)
Next i
End If
If .NumeroLuces > 0 Then
ReDim Luces(1 To .NumeroLuces)
Get #fh, , Luces
For i = 1 To .NumeroLuces
'Call frmMain.engine.Light_Create(Luces(i).x, Luces(i).y, Luces(i).color, Luces(i).Rango)
Next i
End If
If .NumeroOBJs > 0 Then
ReDim Objetos(1 To .NumeroOBJs)
Get #fh, , Objetos
For i = 1 To .NumeroOBJs
MapData(Map, Objetos(i).X, Objetos(i).Y).ObjInfo.ObjIndex = Objetos(i).ObjIndex
MapData(Map, Objetos(i).X, Objetos(i).Y).ObjInfo.Amount = Objetos(i).ObjAmmount
Next i
End If
If .NumeroNPCs > 0 Then
ReDim NPCs(1 To .NumeroNPCs)
Get #fh, , NPCs
For i = 1 To .NumeroNPCs
MapData(Map, NPCs(i).X, NPCs(i).Y).NpcIndex = NPCs(i).NpcIndex
If MapData(Map, NPCs(i).X, NPCs(i).Y).NpcIndex > 0 Then
Dim npcfile As String
npcfile = DatPath & "NPCs.dat"
If val(GetVar(npcfile, "NPC" & MapData(Map, NPCs(i).X, NPCs(i).Y).NpcIndex, "PosOrig")) = 1 Then
MapData(Map, NPCs(i).X, NPCs(i).Y).NpcIndex = OpenNPC(MapData(Map, NPCs(i).X, NPCs(i).Y).NpcIndex)
Npclist(MapData(Map, NPCs(i).X, NPCs(i).Y).NpcIndex).Orig.Map = Map
Npclist(MapData(Map, NPCs(i).X, NPCs(i).Y).NpcIndex).Orig.X = NPCs(i).X
Npclist(MapData(Map, NPCs(i).X, NPCs(i).Y).NpcIndex).Orig.Y = NPCs(i).Y
Else
MapData(Map, NPCs(i).X, NPCs(i).Y).NpcIndex = OpenNPC(MapData(Map, NPCs(i).X, NPCs(i).Y).NpcIndex)
End If
If Not MapData(Map, NPCs(i).X, NPCs(i).Y).NpcIndex = 0 Then
Npclist(MapData(Map, NPCs(i).X, NPCs(i).Y).NpcIndex).Pos.Map = Map
Npclist(MapData(Map, NPCs(i).X, NPCs(i).Y).NpcIndex).Pos.X = NPCs(i).X
Npclist(MapData(Map, NPCs(i).X, NPCs(i).Y).NpcIndex).Pos.Y = NPCs(i).Y
Call MakeNPCChar(True, 0, MapData(Map, NPCs(i).X, NPCs(i).Y).NpcIndex, Map, NPCs(i).X, NPCs(i).Y)
End If
End If
Next i
End If
If .NumeroTE > 0 Then
ReDim TEs(1 To .NumeroTE)
Get #fh, , TEs
For i = 1 To .NumeroTE
MapData(Map, TEs(i).X, TEs(i).Y).TileExit.Map = TEs(i).DestM
MapData(Map, TEs(i).X, TEs(i).Y).TileExit.X = TEs(i).DestX
MapData(Map, TEs(i).X, TEs(i).Y).TileExit.Y = TEs(i).DestY
Next i
End If
End With
Close fh
For j = MapSize.YMin To MapSize.YMax
For i = MapSize.XMin To MapSize.XMax
If L1(i, j) > 0 Then
MapData(Map, i, j).Graphic(1) = L1(i, j)
End If
Next i
Next j
MapDat.map_name = Trim$(MapDat.map_name)
MapInfo(Map).name = MapDat.map_name
MapInfo(Map).Music = MapDat.music_number
MapInfo(Map).StartPos.Map = val(ReadField(1, GetVar(MAPFl & ".dat", "Mapa" & Map, "StartPos"), Asc("-")))
MapInfo(Map).StartPos.X = val(ReadField(2, GetVar(MAPFl & ".dat", "Mapa" & Map, "StartPos"), Asc("-")))
MapInfo(Map).StartPos.Y = val(ReadField(3, GetVar(MAPFl & ".dat", "Mapa" & Map, "StartPos"), Asc("-")))
MapInfo(Map).MagiaSinEfecto = val(GetVar(MAPFl & ".dat", "Mapa" & Map, "MagiaSinEfecto"))
MapInfo(Map).InviSinEfecto = val(GetVar(MAPFl & ".dat", "Mapa" & Map, "InviSinEfecto"))
MapInfo(Map).ResuSinEfecto = val(GetVar(MAPFl & ".dat", "Mapa" & Map, "ResuSinEfecto"))
MapInfo(Map).NoEncriptarMP = val(GetVar(MAPFl & ".dat", "Mapa" & Map, "NoEncriptarMP"))
MapInfo(Map).Seguro = MapDat.extra1
If val(GetVar(MAPFl & ".dat", "Mapa" & Map, "Pk")) = 0 Then
MapInfo(Map).Pk = True
Else
MapInfo(Map).Pk = False
End If
MapInfo(Map).Terreno = MapDat.terrain
MapInfo(Map).Zona = MapDat.zone
MapInfo(Map).Restringir = MapDat.restrict_mode
MapInfo(Map).BackUp = MapDat.backup_mode
Exit Sub
errh:
Call LogError("Error cargando mapa: " & Map & " ." & Err.description)
End Sub
- Código:
Private Type tMapHeader
NumeroBloqueados As Long
NumeroLayers(2 To 4) As Long
NumeroTriggers As Long
NumeroLuces As Long
NumeroParticulas As Long
NumeroNPCs As Long
NumeroOBJs As Long
NumeroTE As Long
End Type
Private Type tDatosBloqueados
X As Integer
Y As Integer
End Type
Private Type tDatosGrh
X As Integer
Y As Integer
GrhIndex As Long
End Type
Private Type tDatosTrigger
X As Integer
Y As Integer
Trigger As Integer
End Type
Private Type tDatosLuces
X As Integer
Y As Integer
color As Long
Rango As Byte
End Type
Private Type tDatosParticulas
X As Integer
Y As Integer
Particula As Long
End Type
Private Type tDatosNPC
X As Integer
Y As Integer
NpcIndex As Integer
End Type
Private Type tDatosObjs
X As Integer
Y As Integer
ObjIndex As Integer
ObjAmmount As Integer
End Type
Private Type tDatosTE
X As Integer
Y As Integer
DestM As Integer
DestX As Integer
DestY As Integer
End Type
Private Type tMapSize
XMax As Integer
XMin As Integer
YMax As Integer
YMin As Integer
End Type
Private Type tMapDat
map_name As String * 64
battle_mode As Byte
backup_mode As Byte
restrict_mode As String * 4
music_number As String * 16
zone As String * 16
terrain As String * 16
ambient As String * 16
base_light As Long
letter_grh As Long
extra1 As Long
extra2 As Long
extra3 As String * 32
End Type
- Código:
Type MapInfo
NumUsers As Integer
Music As String
name As String
StartPos As WorldPos
MapVersion As Integer
Seguro As Byte
Pk As Boolean
MagiaSinEfecto As Byte
NoEncriptarMP As Byte
InviSinEfecto As Byte
ResuSinEfecto As Byte
Terreno As String
Zona As String
Restringir As String
BackUp As Byte
RoboNpcsPermitido As Byte
End Type
Ahora buscamos el Sub ConnectUser y lo reemplazamos todo por este:
- Código:
Sub ConnectUser(ByVal UserIndex As Integer, ByRef name As String, ByRef Password As String)
'***************************************************
'Autor: Unknown (orginal version)
'Last Modification: 3/12/2009 (Budi)
'26/03/2009: ZaMa - Agrego por default que el color de dialogo de los dioses, sea como el de su nick.
'12/06/2009: ZaMa - Agrego chequeo de nivel al loguear
'14/09/2009: ZaMa - Ahora el usuario esta protegido del ataque de npcs al loguear
'11/27/2009: Budi - Se envian los InvStats del personaje y su Fuerza y Agilidad
'03/12/2009: Budi - Optimización del código
'***************************************************
Dim N As Integer
Dim tStr As String
With UserList(UserIndex)
If .flags.UserLogged Then
Call LogCheating("El usuario " & .name & " ha intentado loguear a " & name & " desde la IP " & .ip)
'Kick player ( and leave character inside )!
Call CloseSocketSL(UserIndex)
Call Cerrar_Usuario(UserIndex)
Exit Sub
End If
'Reseteamos los FLAGS
.flags.Escondido = 0
.flags.TargetNPC = 0
.flags.TargetNpcTipo = eNPCType.Comun
.flags.TargetObj = 0
.flags.TargetUser = 0
.Char.FX = 0
'Controlamos no pasar el maximo de usuarios
If NumUsers >= MaxUsers Then
Call WriteErrorMsg(UserIndex, "El servidor ha alcanzado el máximo de usuarios soportado, por favor vuelva a intertarlo más tarde.")
Call FlushBuffer(UserIndex)
Call CloseSocket(UserIndex)
Exit Sub
End If
'¿Este IP ya esta conectado?
If AllowMultiLogins = 0 Then
If CheckForSameIP(UserIndex, .ip) = True Then
Call WriteErrorMsg(UserIndex, "No es posible usar más de un personaje al mismo tiempo.")
Call FlushBuffer(UserIndex)
Call CloseSocket(UserIndex)
Exit Sub
End If
End If
'¿Existe el personaje?
If Not FileExist(CharPath & UCase$(name) & ".chr", vbNormal) Then
Call WriteErrorMsg(UserIndex, "El personaje no existe.")
Call FlushBuffer(UserIndex)
Call CloseSocket(UserIndex)
Exit Sub
End If
'¿Es el passwd valido?
If UCase$(Password) <> UCase$(GetVar(CharPath & UCase$(name) & ".chr", "INIT", "Password")) Then
Call WriteErrorMsg(UserIndex, "Password incorrecto.")
Call FlushBuffer(UserIndex)
Call CloseSocket(UserIndex)
Exit Sub
End If
'¿Ya esta conectado el personaje?
If CheckForSameName(name) Then
If UserList(NameIndex(name)).Counters.Saliendo Then
Call WriteErrorMsg(UserIndex, "El usuario está saliendo.")
Else
Call WriteErrorMsg(UserIndex, "Perdón, un usuario con el mismo nombre se ha logueado.")
End If
Call FlushBuffer(UserIndex)
Call CloseSocket(UserIndex)
Exit Sub
End If
'Reseteamos los privilegios
.flags.Privilegios = 0
'Vemos que clase de user es (se lo usa para setear los privilegios al loguear el PJ)
If EsAdmin(name) Then
.flags.Privilegios = .flags.Privilegios Or PlayerType.Admin
Call LogGM(name, "Se conecto con ip:" & .ip)
ElseIf EsDios(name) Then
.flags.Privilegios = .flags.Privilegios Or PlayerType.Dios
Call LogGM(name, "Se conecto con ip:" & .ip)
ElseIf EsSemiDios(name) Then
.flags.Privilegios = .flags.Privilegios Or PlayerType.SemiDios
Call LogGM(name, "Se conecto con ip:" & .ip)
ElseIf EsConsejero(name) Then
.flags.Privilegios = .flags.Privilegios Or PlayerType.Consejero
Call LogGM(name, "Se conecto con ip:" & .ip)
Else
.flags.Privilegios = .flags.Privilegios Or PlayerType.User
.flags.AdminPerseguible = True
End If
'Add RM flag if needed
If EsRolesMaster(name) Then
.flags.Privilegios = .flags.Privilegios Or PlayerType.RoleMaster
End If
If ServerSoloGMs > 0 Then
If (.flags.Privilegios And (PlayerType.Admin Or PlayerType.Dios Or PlayerType.SemiDios Or PlayerType.Consejero)) = 0 Then
Call WriteErrorMsg(UserIndex, "Servidor restringido a administradores. Por favor reintente en unos momentos.")
Call FlushBuffer(UserIndex)
Call CloseSocket(UserIndex)
Exit Sub
End If
End If
'Cargamos el personaje
Dim Leer As New clsIniReader
Call Leer.Initialize(CharPath & UCase$(name) & ".chr")
'Cargamos los datos del personaje
Call LoadUserInit(UserIndex, Leer)
Call LoadUserStats(UserIndex, Leer)
If Not ValidateChr(UserIndex) Then
Call WriteErrorMsg(UserIndex, "Error en el personaje.")
Call CloseSocket(UserIndex)
Exit Sub
End If
Call LoadUserReputacion(UserIndex, Leer)
Set Leer = Nothing
If .Invent.EscudoEqpSlot = 0 Then .Char.ShieldAnim = NingunEscudo
If .Invent.CascoEqpSlot = 0 Then .Char.CascoAnim = NingunCasco
If .Invent.WeaponEqpSlot = 0 Then .Char.WeaponAnim = NingunArma
.CurrentInventorySlots = MAX_NORMAL_INVENTORY_SLOTS
If (.flags.Muerto = 0) Then
.flags.SeguroResu = False
Call WriteMultiMessage(UserIndex, eMessages.ResuscitationSafeOff) 'Call WriteResuscitationSafeOff(UserIndex)
Else
.flags.SeguroResu = True
Call WriteMultiMessage(UserIndex, eMessages.ResuscitationSafeOn) 'Call WriteResuscitationSafeOn(UserIndex)
End If
Call UpdateUserInv(True, UserIndex, 0)
Call UpdateUserHechizos(True, UserIndex, 0)
If .flags.Paralizado Then
Call WriteParalizeOK(UserIndex)
End If
''
'TODO : Feo, esto tiene que ser parche cliente
If .flags.Estupidez = 0 Then
Call WriteDumbNoMore(UserIndex)
End If
'Posicion de comienzo
If .Pos.Map = 0 Then
Select Case .Hogar
Case eCiudad.cNix
.Pos = Nix
Case eCiudad.cUllathorpe
.Pos = Ullathorpe
Case eCiudad.cBanderbill
.Pos = Banderbill
Case eCiudad.cLindos
.Pos = Lindos
Case eCiudad.cArghal
.Pos = Arghal
Case Else
.Hogar = eCiudad.cUllathorpe
.Pos = Ullathorpe
End Select
Else
If Not MapaValido(.Pos.Map) Then
Call WriteErrorMsg(UserIndex, "El PJ se encuenta en un mapa inválido.")
Call FlushBuffer(UserIndex)
Call CloseSocket(UserIndex)
Exit Sub
End If
End If
'Tratamos de evitar en lo posible el "Telefrag". Solo 1 intento de loguear en pos adjacentes.
'Codigo por Pablo (ToxicWaste) y revisado por Nacho (Integer), corregido para que realmetne ande y no tire el server por Juan Martín Sotuyo Dodero (Maraxus)
If MapData(.Pos.Map, .Pos.X, .Pos.Y).UserIndex <> 0 Or MapData(.Pos.Map, .Pos.X, .Pos.Y).NpcIndex <> 0 Then
Dim FoundPlace As Boolean
Dim esAgua As Boolean
Dim tX As Long
Dim tY As Long
FoundPlace = False
esAgua = HayAgua(.Pos.Map, .Pos.X, .Pos.Y)
For tY = .Pos.Y - 1 To .Pos.Y + 1
For tX = .Pos.X - 1 To .Pos.X + 1
If esAgua Then
'reviso que sea pos legal en agua, que no haya User ni NPC para poder loguear.
If LegalPos(.Pos.Map, tX, tY, True, False) Then
FoundPlace = True
Exit For
End If
Else
'reviso que sea pos legal en tierra, que no haya User ni NPC para poder loguear.
If LegalPos(.Pos.Map, tX, tY, False, True) Then
FoundPlace = True
Exit For
End If
End If
Next tX
If FoundPlace Then _
Exit For
Next tY
If FoundPlace Then 'Si encontramos un lugar, listo, nos quedamos ahi
.Pos.X = tX
.Pos.Y = tY
Else
'Si no encontramos un lugar, sacamos al usuario que tenemos abajo, y si es un NPC, lo pisamos.
If MapData(.Pos.Map, .Pos.X, .Pos.Y).UserIndex <> 0 Then
'Si no encontramos lugar, y abajo teniamos a un usuario, lo pisamos y cerramos su comercio seguro
If UserList(MapData(.Pos.Map, .Pos.X, .Pos.Y).UserIndex).ComUsu.DestUsu > 0 Then
'Le avisamos al que estaba comerciando que se tuvo que ir.
If UserList(UserList(MapData(.Pos.Map, .Pos.X, .Pos.Y).UserIndex).ComUsu.DestUsu).flags.UserLogged Then
Call FinComerciarUsu(UserList(MapData(.Pos.Map, .Pos.X, .Pos.Y).UserIndex).ComUsu.DestUsu)
Call WriteConsoleMsg(UserList(MapData(.Pos.Map, .Pos.X, .Pos.Y).UserIndex).ComUsu.DestUsu, "Comercio cancelado. El otro usuario se ha desconectado.", FontTypeNames.FONTTYPE_TALK)
Call FlushBuffer(UserList(MapData(.Pos.Map, .Pos.X, .Pos.Y).UserIndex).ComUsu.DestUsu)
End If
'Lo sacamos.
If UserList(MapData(.Pos.Map, .Pos.X, .Pos.Y).UserIndex).flags.UserLogged Then
Call FinComerciarUsu(MapData(.Pos.Map, .Pos.X, .Pos.Y).UserIndex)
Call WriteErrorMsg(MapData(.Pos.Map, .Pos.X, .Pos.Y).UserIndex, "Alguien se ha conectado donde te encontrabas, por favor reconéctate...")
Call FlushBuffer(MapData(.Pos.Map, .Pos.X, .Pos.Y).UserIndex)
End If
End If
Call CloseSocket(MapData(.Pos.Map, .Pos.X, .Pos.Y).UserIndex)
End If
End If
End If
'Nombre de sistema
.name = name
.showName = True 'Por default los nombres son visibles
'If in the water, and has a boat, equip it!
If .Invent.BarcoObjIndex > 0 And _
(HayAgua(.Pos.Map, .Pos.X, .Pos.Y) Or BodyIsBoat(.Char.body)) Then
Dim Barco As ObjData
Barco = ObjData(.Invent.BarcoObjIndex)
.Char.Head = 0
If .flags.Muerto = 0 Then
Call ToogleBoatBody(UserIndex)
Else
.Char.body = iFragataFantasmal
.Char.ShieldAnim = NingunEscudo
.Char.WeaponAnim = NingunArma
.Char.CascoAnim = NingunCasco
End If
.flags.Navegando = 1
End If
'Info
Call WriteUserIndexInServer(UserIndex) 'Enviamos el User index
Call WriteChangeMap(UserIndex, .Pos.Map, MapInfo(.Pos.Map).MapVersion) 'Carga el mapa
Call WritePlayMidi(UserIndex, val(ReadField(1, MapInfo(.Pos.Map).Music, 45)))
If .flags.Privilegios = PlayerType.Dios Then
.flags.ChatColor = RGB(250, 250, 150)
ElseIf .flags.Privilegios <> PlayerType.User And .flags.Privilegios <> (PlayerType.User Or PlayerType.ChaosCouncil) And .flags.Privilegios <> (PlayerType.User Or PlayerType.RoyalCouncil) Then
.flags.ChatColor = RGB(0, 255, 0)
ElseIf .flags.Privilegios = (PlayerType.User Or PlayerType.RoyalCouncil) Then
.flags.ChatColor = RGB(0, 255, 255)
ElseIf .flags.Privilegios = (PlayerType.User Or PlayerType.ChaosCouncil) Then
.flags.ChatColor = RGB(255, 128, 64)
Else
.flags.ChatColor = vbWhite
End If
''[EL OSO]: TRAIGO ESTO ACA ARRIBA PARA DARLE EL IP!
#If ConUpTime Then
.LogOnTime = Now
#End If
'Crea el personaje del usuario
Call MakeUserChar(True, .Pos.Map, UserIndex, .Pos.Map, .Pos.X, .Pos.Y)
Call WriteUserCharIndexInServer(UserIndex)
''[/el oso]
Call CheckUserLevel(UserIndex)
Call WriteUpdateUserStats(UserIndex)
Call WriteUpdateHungerAndThirst(UserIndex)
Call WriteUpdateStrenghtAndDexterity(UserIndex)
Call SendMOTD(UserIndex)
If haciendoBK Then
Call WritePauseToggle(UserIndex)
Call WriteConsoleMsg(UserIndex, "Servidor> Por favor espera algunos segundos, el WorldSave está ejecutándose.", FontTypeNames.FONTTYPE_SERVER)
End If
If EnPausa Then
Call WritePauseToggle(UserIndex)
Call WriteConsoleMsg(UserIndex, "Servidor> Lo sentimos mucho pero el servidor se encuentra actualmente detenido. Intenta ingresar más tarde.", FontTypeNames.FONTTYPE_SERVER)
End If
If EnTesting And .Stats.ELV >= 18 Then
Call WriteErrorMsg(UserIndex, "Servidor en Testing por unos minutos, conectese con PJs de nivel menor a 18. No se conecte con Pjs que puedan resultar importantes por ahora pues pueden arruinarse.")
Call FlushBuffer(UserIndex)
Call CloseSocket(UserIndex)
Exit Sub
End If
'Actualiza el Num de usuarios
'DE ACA EN ADELANTE GRABA EL CHARFILE, OJO!
NumUsers = NumUsers + 1
.flags.UserLogged = True
'usado para borrar Pjs
Call WriteVar(CharPath & .name & ".chr", "INIT", "Logged", "1")
Call EstadisticasWeb.Informar(CANTIDAD_ONLINE, NumUsers)
MapInfo(.Pos.Map).NumUsers = MapInfo(.Pos.Map).NumUsers + 1
If .Stats.SkillPts > 0 Then
Call WriteSendSkills(UserIndex)
Call WriteLevelUp(UserIndex, .Stats.SkillPts)
End If
If NumUsers > recordusuarios Then
Call SendData(SendTarget.ToAll, 0, PrepareMessageConsoleMsg("Record de usuarios conectados simultaneamente." & "Hay " & NumUsers & " usuarios.", FontTypeNames.FONTTYPE_INFO))
recordusuarios = NumUsers
Call WriteVar(IniPath & "Server.ini", "INIT", "Record", str(recordusuarios))
Call EstadisticasWeb.Informar(RECORD_USUARIOS, recordusuarios)
End If
If .NroMascotas > 0 And MapInfo(.Pos.Map).Pk Then
Dim i As Integer
For i = 1 To MAXMASCOTAS
If .MascotasType(i) > 0 Then
.MascotasIndex(i) = SpawnNpc(.MascotasType(i), .Pos, True, True)
If .MascotasIndex(i) > 0 Then
Npclist(.MascotasIndex(i)).MaestroUser = UserIndex
Call FollowAmo(.MascotasIndex(i))
Else
.MascotasIndex(i) = 0
End If
End If
Next i
End If
If .flags.Navegando = 1 Then
Call WriteNavigateToggle(UserIndex)
End If
If criminal(UserIndex) Then
Call WriteMultiMessage(UserIndex, eMessages.SafeModeOff) 'Call WriteSafeModeOff(UserIndex)
.flags.Seguro = False
Else
.flags.Seguro = True
Call WriteMultiMessage(UserIndex, eMessages.SafeModeOn) 'Call WriteSafeModeOn(UserIndex)
End If
If .GuildIndex > 0 Then
'welcome to the show baby...
If Not modGuilds.m_ConectarMiembroAClan(UserIndex, .GuildIndex) Then
Call WriteConsoleMsg(UserIndex, "Tu estado no te permite entrar al clan.", FontTypeNames.FONTTYPE_GUILD)
End If
End If
Call SendData(SendTarget.ToPCArea, UserIndex, PrepareMessageCreateFX(.Char.CharIndex, FXIDs.FXWARP, 0))
Call WriteLoggedMessage(UserIndex)
Call modGuilds.SendGuildNews(UserIndex)
' Esta protegido del ataque de npcs por 5 segundos, si no realiza ninguna accion
Call IntervaloPermiteSerAtacado(UserIndex, True)
If Lloviendo Then
Call WriteRainToggle(UserIndex)
End If
tStr = modGuilds.a_ObtenerRechazoDeChar(.name)
If LenB(tStr) <> 0 Then
Call WriteShowMessageBox(UserIndex, "Tu solicitud de ingreso al clan ha sido rechazada. El clan te explica que: " & tStr)
End If
'Load the user statistics
Call Statistics.UserConnected(UserIndex)
Call MostrarNumUsers
#If SeguridadAlkon Then
Call Security.UserConnected(UserIndex)
#End If
N = FreeFile
Open App.Path & "\logs\numusers.log" For Output As N
Print #N, NumUsers
Close #N
N = FreeFile
'Log
Open App.Path & "\logs\Connect.log" For Append Shared As #N
Print #N, .name & " ha entrado al juego. UserIndex:" & UserIndex & " " & time & " " & Date
Close #N
End With
End Sub
- Código:
Sub NPCAI(ByVal NpcIndex As Integer)
'**************************************************************
'Author: Unknown
'Last Modify by: ZaMa
'Last Modify Date: 15/11/2009
'08/16/2008: MarKoxX - Now pets that do mel� attacks have to be near the enemy to attack.
'15/11/2009: ZaMa - Implementacion de npc objetos ai.
'**************************************************************
On Error GoTo ErrorHandler
With Npclist(NpcIndex)
'<<<<<<<<<<< Ataques >>>>>>>>>>>>>>>>
If .MaestroUser = 0 Then
'Busca a alguien para atacar
'�Es un guardia?
'If .NPCtype = eNPCType.GuardiaReal Then
' Call GuardiasAI(NpcIndex, False)
'ElseIf .NPCtype = eNPCType.Guardiascaos Then
' Call GuardiasAI(NpcIndex, True)
'ElseIf .Hostile And .Stats.Alineacion <> 0 Then
' Call HostilMalvadoAI(NpcIndex)
'ElseIf .Hostile And .Stats.Alineacion = 0 Then
' Call HostilBuenoAI(NpcIndex)
'End If
Else
'Evitamos que ataque a su amo, a menos
'que el amo lo ataque.
'Call HostilBuenoAI(NpcIndex)
End If
'<<<<<<<<<<<Movimiento>>>>>>>>>>>>>>>>
Select Case .Movement
Case TipoAI.MueveAlAzar
If .flags.Inmovilizado = 1 Then Exit Sub
If .NPCtype = eNPCType.GuardiaReal Then
If RandomNumber(1, 12) = 3 Then
'Call MoveNPCChar(NpcIndex, CByte(RandomNumber(eHeading.NORTH, eHeading.WEST)))
End If
'Call PersigueCriminal(NpcIndex)
ElseIf .NPCtype = eNPCType.Guardiascaos Then
If RandomNumber(1, 12) = 3 Then
'Call MoveNPCChar(NpcIndex, CByte(RandomNumber(eHeading.NORTH, eHeading.WEST)))
End If
'Call PersigueCiudadano(NpcIndex)
Else
If RandomNumber(1, 12) = 3 Then
'Call MoveNPCChar(NpcIndex, CByte(RandomNumber(eHeading.NORTH, eHeading.WEST)))
End If
End If
'Va hacia el usuario cercano
Case TipoAI.NpcMaloAtacaUsersBuenos
'Call IrUsuarioCercano(NpcIndex)
'Va hacia el usuario que lo ataco(FOLLOW)
Case TipoAI.NPCDEFENSA
'Call SeguirAgresor(NpcIndex)
'Persigue criminales
Case TipoAI.GuardiasAtacanCriminales
'Call PersigueCriminal(NpcIndex)
Case TipoAI.SigueAmo
If .flags.Inmovilizado = 1 Then Exit Sub
'Call SeguirAmo(NpcIndex)
If RandomNumber(1, 12) = 3 Then
'Call MoveNPCChar(NpcIndex, CByte(RandomNumber(eHeading.NORTH, eHeading.WEST)))
End If
Case TipoAI.NpcAtacaNpc
'Call AiNpcAtacaNpc(NpcIndex)
Case TipoAI.NpcObjeto
'Call AiNpcObjeto(NpcIndex)
Case TipoAI.NpcPathfinding
If .flags.Inmovilizado = 1 Then Exit Sub
If ReCalculatePath(NpcIndex) Then
'Call PathFindingAI(NpcIndex)
'Existe el camino?
If .PFINFO.NoPath Then 'Si no existe nos movemos al azar
'Move randomly
'Call MoveNPCChar(NpcIndex, RandomNumber(eHeading.NORTH, eHeading.WEST))
End If
Else
If Not PathEnd(NpcIndex) Then
'Call FollowPath(NpcIndex)
Else
.PFINFO.PathLenght = 0
End If
End If
End Select
End With
Exit Sub
ErrorHandler:
Call LogError("NPCAI " & Npclist(NpcIndex).name & " " & Npclist(NpcIndex).MaestroUser & " " & Npclist(NpcIndex).MaestroNpc & " mapa:" & Npclist(NpcIndex).Pos.Map & " x:" & Npclist(NpcIndex).Pos.X & " y:" & Npclist(NpcIndex).Pos.Y & " Mov:" & Npclist(NpcIndex).Movement & " TargU:" & Npclist(NpcIndex).Target & " TargN:" & Npclist(NpcIndex).TargetNPC)
Dim MiNPC As npc
MiNPC = Npclist(NpcIndex)
Call QuitarNPC(NpcIndex)
Call ReSpawnNpc(MiNPC)
End Sub
- Código:
Public Type UserFlags
- Código:
Public Type UserFlags
Muerto As Byte '¿Esta muerto?
Escondido As Byte '¿Esta escondido?
Comerciando As Boolean '¿Esta comerciando?
UserLogged As Boolean '¿Esta online?
Meditando As Boolean
Descuento As String
Hambre As Byte
Sed As Byte
PuedeMoverse As Byte
TimerLanzarSpell As Long
PuedeTrabajar As Byte
Envenenado As Byte
Paralizado As Byte
Inmovilizado As Byte
Estupidez As Byte
Ceguera As Byte
invisible As Byte
Maldicion As Byte
Bendicion As Byte
Oculto As Byte
Desnudo As Byte
Descansar As Boolean
Hechizo As Integer
TomoPocion As Boolean
TipoPocion As Byte
NoPuedeSerAtacado As Boolean
AtacablePor As Integer
ShareNpcWith As Integer
Vuela As Byte
Navegando As Byte
Seguro As Boolean
SeguroResu As Boolean
DuracionEfecto As Long
TargetNPC As Integer ' Npc señalado por el usuario
TargetNpcTipo As eNPCType ' Tipo del npc señalado
OwnedNpc As Integer ' Npc que le pertenece (no puede ser atacado)
NpcInv As Integer
Ban As Byte
AdministrativeBan As Byte
TargetUser As Integer ' Usuario señalado
TargetObj As Integer ' Obj señalado
TargetObjMap As Integer
TargetObjX As Integer
TargetObjY As Integer
TargetMap As Integer
TargetX As Integer
TargetY As Integer
TargetObjInvIndex As Integer
TargetObjInvSlot As Integer
AtacadoPorNpc As Integer
AtacadoPorUser As Integer
NPCAtacado As Integer
Ignorado As Boolean
EnConsulta As Boolean
StatsChanged As Byte
Privilegios As PlayerType
ValCoDe As Integer
LastCrimMatado As String
LastCiudMatado As String
OldBody As Integer
OldHead As Integer
AdminInvisible As Byte
AdminPerseguible As Boolean
ChatColor As Long
'[el oso]
MD5Reportado As String
'[/el oso]
'[Barrin 30-11-03]
TimesWalk As Long
StartWalk As Long
CountSH As Long
'[/Barrin 30-11-03]
'[CDT 17-02-04]
UltimoMensaje As Byte
'[/CDT]
Silenciado As Byte
Mimetizado As Byte
CentinelaOK As Boolean 'Centinela
lastMap As Integer
Traveling As Byte 'Travelin Band ¿?
End Type
Se descargan esto que trae todos los recursos de IAO + lo otro Clic Aquì
Y Estos los Recursos del Servidor
Clic Aqui
- Foto:
- FUENTE:
- www.GS-ZONE.org
Temas similares
» [Aporte] Carga de recursos de ImperiumAO - Dx8 (Parte1)
» [Aporte] Carga de recursos de ImperiumAO - Dx8 (Parte2)
» [Problema] Carga de recursos comprimidos IAO Clon
» [Aporte] Interfaces ImperiumAO 1.5.0
» [Aporte] Carga particula en mapa desde un Frm
» [Aporte] Carga de recursos de ImperiumAO - Dx8 (Parte2)
» [Problema] Carga de recursos comprimidos IAO Clon
» [Aporte] Interfaces ImperiumAO 1.5.0
» [Aporte] Carga particula en mapa desde un Frm
Página 1 de 1.
Permisos de este foro:
No puedes responder a temas en este foro.