Godlord Posted July 29, 2008 Author Share Posted July 29, 2008 Greetings,**Addendum:** a source and binary will not be released with this, perhaps somewhere in the future but not now.**Addendum:** this topic has been revived and it came out of his grave!**Addendum:** topic icon fixed.**Addendum:** a F.A.Q. has been added right [here](http://www.touchofdeathforums.com/smf/index.php/topic,29761.msg307528.html#msg307528).It took me one night and one morning to look over all this and fix this.The following will help you with making the spells work:**Server - modTypes.bas**Change:```Public Type PlayerRec ' General Name As String * NAME_LENGTH Guild As String GuildAccess As Byte Sex As Byte Class As Integer Sprite As Long LEVEL As Integer Exp As Long Access As Byte PK As Byte ' Vitals HP As Long MP As Long SP As Long ' Stats STR As Long DEF As Long Speed As Long Magi As Long POINTS As Long ' Worn equipment ArmorSlot As Integer WeaponSlot As Integer HelmetSlot As Integer ShieldSlot As Integer LegsSlot As Integer RingSlot As Integer NecklaceSlot As Integer ' Inventory Inv(1 To MAX_INV) As PlayerInvRec Spell(1 To MAX_PLAYER_SPELLS) As Integer Bank(1 To MAX_BANK) As BankRec ' Position and movement Map As Integer X As Byte Y As Byte Dir As Byte TargetNPC As Integer Head As Integer Body As Integer Leg As Integer PAPERDOLL As Byte MAXHP As Long MAXMP As Long MAXSP As LongEnd Type```To:```Public Type PlayerRec ' General Name As String * NAME_LENGTH Guild As String GuildAccess As Byte Sex As Byte Class As Integer Sprite As Long LEVEL As Integer Exp As Long Access As Byte PK As Byte ' Vitals HP As Long MP As Long SP As Long ' Stats STR As Long DEF As Long Speed As Long Magi As Long POINTS As Long ' Worn equipment ArmorSlot As Integer WeaponSlot As Integer HelmetSlot As Integer ShieldSlot As Integer LegsSlot As Integer RingSlot As Integer NecklaceSlot As Integer ' Inventory Inv(1 To MAX_INV) As PlayerInvRec Spell(1 To MAX_PLAYER_SPELLS) As Integer Bank(1 To MAX_BANK) As BankRec ' Position and movement Map As Integer X As Byte Y As Byte Dir As Byte Head As Integer Body As Integer Leg As Integer PAPERDOLL As Byte MAXHP As Long MAXMP As Long MAXSP As LongEnd Type```Change:```Public Type AccountRec ' Account Login As String * NAME_LENGTH Password As String * NAME_LENGTH Email As String ' Some error here that needs to be fixed. [Mellowz] Char(0 To MAX_CHARS) As PlayerRec ' None saved local vars Buffer As String IncBuffer As String CharNum As Byte InGame As Boolean AttackTimer As Long DataTimer As Long DataBytes As Long DataPackets As Long PartyPlayer As Long InParty As Boolean TargetType As Byte Target As Byte CastedSpell As Byte SpellTime As Long SpellVar As Long SpellDone As Long SpellNum As Long PartyStarter As Byte GettingMap As Byte Party As PartyRec InvitedBy As Byte Emoticon As Long InTrade As Boolean TradePlayer As Long TradeOk As Byte TradeItemMax As Byte TradeItemMax2 As Byte Trading(1 To MAX_PLAYER_TRADES) As PlayerTradeRec InChat As Byte ChatPlayer As Long Mute As Boolean Locked As Boolean LockedSpells As Boolean LockedItems As Boolean LockedAttack As Boolean TargetNPC As Long Pet As Long HookShotX As Byte HookShotY As Byte ' MENUS CustomMsg As String CustomTitle As StringEnd Type```To:```Public Type AccountRec ' Account Login As String * NAME_LENGTH Password As String * NAME_LENGTH Email As String ' Some error here that needs to be fixed. [Mellowz] Char(0 To MAX_CHARS) As PlayerRec ' None saved local vars Buffer As String IncBuffer As String CharNum As Byte InGame As Boolean AttackTimer As Long DataTimer As Long DataBytes As Long DataPackets As Long PartyPlayer As Long InParty As Boolean Target As Long TargetType As Byte CastedSpell As Byte SpellTime As Long SpellVar As Long SpellDone As Long SpellNum As Long PartyStarter As Byte GettingMap As Byte Party As PartyRec InvitedBy As Byte Emoticon As Long InTrade As Boolean TradePlayer As Long TradeOk As Byte TradeItemMax As Byte TradeItemMax2 As Byte Trading(1 To MAX_PLAYER_TRADES) As PlayerTradeRec InChat As Byte ChatPlayer As Long Mute As Boolean Locked As Boolean LockedSpells As Boolean LockedItems As Boolean LockedAttack As Boolean Pet As Long HookShotX As Byte HookShotY As Byte ' MENUS CustomMsg As String CustomTitle As StringEnd Type```**Server - modGameLogic.bas**Change:```Sub AttackNpc(ByVal Attacker As Long, ByVal MapNpcNum As Long, ByVal Damage As Long) Dim Name As String Dim Exp As Long Dim n As Long, I As Long, q As Integer, X As Long Dim MapNum As Long, NPCnum As Long ' Removes one SP when you attack. If SP_ATTACK = 1 Then If GetPlayerSP(Attacker) > 0 Then Call SetPlayerSP(Attacker, GetPlayerSP(Attacker) - 1) Call SendSP(Attacker) Else Call PlayerMsg(Attacker, "You feel exhausted from fighting.", BLUE) Exit Sub End If End If ' Check for subscript out of range If IsPlaying(Attacker) = False Or MapNpcNum <= 0 Or MapNpcNum > MAX_MAP_NPCS Or Damage < 0 Then Exit Sub End If ' Check for weapon If GetPlayerWeaponSlot(Attacker) > 0 Then n = GetPlayerInvItemNum(Attacker, GetPlayerWeaponSlot(Attacker)) Else n = 0 End If ' Send this packet so they can see the person attacking Call SendDataToMapBut(Attacker, GetPlayerMap(Attacker), "ATTACK" & SEP_CHAR & Attacker & END_CHAR) MapNum = GetPlayerMap(Attacker) NPCnum = MapNPC(MapNum, MapNpcNum).num Name = Trim$(NPC(NPCnum).Name) If Damage >= MapNPC(MapNum, MapNpcNum).HP Then ' Check for a weapon and say damage Player(Attacker).TargetNPC = 0 ' Call BattleMsg(Attacker, "You killed a " & Name, BrightRed, 0) If SCRIPTING = 1 Then MyScript.ExecuteStatement "Scripts\Main.txt", "OnNPCDeath " & Attacker & "," & MapNum & "," & NPCnum & "," & MapNpcNum End If Dim Add As String Add = 0 If GetPlayerWeaponSlot(Attacker) > 0 Then Add = Add + Item(GetPlayerInvItemNum(Attacker, GetPlayerWeaponSlot(Attacker))).AddEXP End If If GetPlayerArmorSlot(Attacker) > 0 Then Add = Add + Item(GetPlayerInvItemNum(Attacker, GetPlayerArmorSlot(Attacker))).AddEXP End If If GetPlayerShieldSlot(Attacker) > 0 Then Add = Add + Item(GetPlayerInvItemNum(Attacker, GetPlayerShieldSlot(Attacker))).AddEXP End If If GetPlayerLegsSlot(Attacker) > 0 Then Add = Add + Item(GetPlayerInvItemNum(Attacker, GetPlayerLegsSlot(Attacker))).AddEXP End If If GetPlayerRingSlot(Attacker) > 0 Then Add = Add + Item(GetPlayerInvItemNum(Attacker, GetPlayerRingSlot(Attacker))).AddEXP End If If GetPlayerNecklaceSlot(Attacker) > 0 Then Add = Add + Item(GetPlayerInvItemNum(Attacker, GetPlayerNecklaceSlot(Attacker))).AddEXP End If If GetPlayerHelmetSlot(Attacker) > 0 Then Add = Add + Item(GetPlayerInvItemNum(Attacker, GetPlayerHelmetSlot(Attacker))).AddEXP End If If Add > 0 Then If Add < 100 Then If Add < 10 Then Add = 0 & ".0" & Right$(Add, 2) Else Add = 0 & "." & Right$(Add, 2) End If Else Add = Mid$(Add, 1, 1) & "." & Right$(Add, 2) End If End If ' Calculate exp to give attacker If Add > 0 Then Exp = NPC(NPCnum).Exp + (NPC(NPCnum).Exp * Val(Add)) Else Exp = NPC(NPCnum).Exp End If ' Make sure we dont get less then 0 If Exp < 0 Then Exp = 1 End If ' Check if in party, if so divide the exp up by 2 If Player(Attacker).InParty = False Or Player(Attacker).Party.ShareExp = False Then If GetPlayerLevel(Attacker) = MAX_LEVEL Then Call SetPlayerExp(Attacker, Experience(MAX_LEVEL)) Call BattleMsg(Attacker, "You can't gain anymore experience!", BRIGHTBLUE, 0) Else Call SetPlayerExp(Attacker, GetPlayerExp(Attacker) + Exp) Call BattleMsg(Attacker, "You gained " & Exp & " experience.", BRIGHTBLUE, 0) End If Else q = 0 ' The following code will tell us how many party members we have active For X = 1 To MAX_PARTY_MEMBERS If Player(Attacker).Party.Member(X) > 0 Then q = q + 1 End If Next X ' MsgBox "in party" & q If q = 2 Then 'Remember, if they aren't in a party they'll only get one person, so this has to be at least two Exp = Exp * 0.75 ' 3/4 experience ' MsgBox Exp For X = 1 To MAX_PARTY_MEMBERS If Player(Attacker).Party.Member(X) > 0 Then If Player(Player(Attacker).Party.Member(X)).Party.ShareExp = True Then If GetPlayerLevel(Player(Attacker).Party.Member(X)) = MAX_LEVEL Then Call SetPlayerExp(Player(Attacker).Party.Member(X), Experience(MAX_LEVEL)) Call BattleMsg(Player(Attacker).Party.Member(X), "You can't gain anymore experience!", BRIGHTBLUE, 0) Else Call SetPlayerExp(Player(Attacker).Party.Member(X), GetPlayerExp(Player(Attacker).Party.Member(X)) + Exp) Call BattleMsg(Player(Attacker).Party.Member(X), "You gained " & Exp & " party experience.", BRIGHTBLUE, 0) End If Call SendEXP(X) End If End If Next X Else 'if there are 3 or more party members.. Exp = Exp * 0.5 ' 1/2 experience For X = 1 To MAX_PARTY_MEMBERS If Player(Attacker).Party.Member(X) > 0 Then If Player(Player(Attacker).Party.Member(X)).Party.ShareExp = True Then If GetPlayerLevel(Player(Attacker).Party.Member(X)) = MAX_LEVEL Then Call SetPlayerExp(Player(Attacker).Party.Member(X), Experience(MAX_LEVEL)) Call BattleMsg(Player(Attacker).Party.Member(X), "You can't gain anymore experience!", BRIGHTBLUE, 0) Else Call SetPlayerExp(Player(Attacker).Party.Member(X), GetPlayerExp(Player(Attacker).Party.Member(X)) + Exp) Call BattleMsg(Player(Attacker).Party.Member(X), "You gained " & Exp & " party experience.", BRIGHTBLUE, 0) End If Call SendEXP(X) End If End If Next X End If End If ' Drop the items if they earn it. For I = 1 To MAX_NPC_DROPS If NPC(NPCnum).ItemNPC(I).ItemNum > 0 Then n = Int(Rnd * NPC(NPCnum).ItemNPC(I).Chance) + 1 If n = 1 Then Call SpawnItem(NPC(NPCnum).ItemNPC(I).ItemNum, NPC(NPCnum).ItemNPC(I).ItemValue, MapNum, MapNPC(MapNum, MapNpcNum).X, MapNPC(MapNum, MapNpcNum).Y) End If End If Next I ' Now set HP to 0 so we know to actually kill them in the server loop (this prevents subscript out of range) MapNPC(MapNum, MapNpcNum).num = 0 MapNPC(MapNum, MapNpcNum).SpawnWait = GetTickCount MapNPC(MapNum, MapNpcNum).HP = 0 Call SendDataToMap(MapNum, "NPCDEAD" & SEP_CHAR & MapNpcNum & END_CHAR) ' Check for level up Call CheckPlayerLevelUp(Attacker) ' Check for level up party member If Player(Attacker).InParty = True Then For X = 1 To MAX_PARTY_MEMBERS Call CheckPlayerLevelUp(Player(Attacker).Party.Member(X)) Next X End If ' Check for level up party member If Player(Attacker).InParty = True Then Call CheckPlayerLevelUp(Player(Attacker).PartyPlayer) End If ' Check if target is npc that died and if so set target to 0 If Player(Attacker).TargetType = TARGET_TYPE_NPC And Player(Attacker).Target = MapNpcNum Then Player(Attacker).Target = 0 Player(Attacker).TargetType = 0 End If Else ' NPC not dead, just do the damage MapNPC(MapNum, MapNpcNum).HP = MapNPC(MapNum, MapNpcNum).HP - Damage Player(Attacker).TargetNPC = MapNpcNum' Check for a weapon and say damage' Call BattleMsg(Attacker, "You hit a " & Name & " for " & Damage & " damage.", White, 0) If n = 0 Then ' Call PlayerMsg(Attacker, "You hit a " & Name & " for " & Damage & " hit points.", White) Else ' Call PlayerMsg(Attacker, "You hit a " & Name & " with a " & Trim$(Item(n).Name) & " for " & Damage & " hit points.", White) End If ' Check if we should send a message If MapNPC(MapNum, MapNpcNum).Target = 0 And MapNPC(MapNum, MapNpcNum).Target <> Attacker Then If Trim$(NPC(NPCnum).AttackSay) <> vbNullString Then Call PlayerMsg(Attacker, "A " & Trim$(NPC(NPCnum).Name) & " : " & Trim$(NPC(NPCnum).AttackSay) & vbNullString, SayColor) End If End If ' Set the NPC target to the player MapNPC(MapNum, MapNpcNum).Target = Attacker ' Now check for guard ai and if so have all onmap guards come after'm If NPC(MapNPC(MapNum, MapNpcNum).num).Behavior = NPC_BEHAVIOR_GUARD Then For I = 1 To MAX_MAP_NPCS If MapNPC(MapNum, I).num = MapNPC(MapNum, MapNpcNum).num Then MapNPC(MapNum, I).Target = Attacker End If Next I End If End If Call SendDataToMap(MapNum, "npchp" & SEP_CHAR & MapNpcNum & SEP_CHAR & MapNPC(MapNum, MapNpcNum).HP & SEP_CHAR & GetNpcMaxHP(MapNPC(MapNum, MapNpcNum).num) & END_CHAR) ' Reset attack timer Player(Attacker).AttackTimer = GetTickCountEnd Sub```To:```Sub AttackNpc(ByVal Attacker As Long, ByVal MapNpcNum As Long, ByVal Damage As Long) Dim Name As String Dim Exp As Long Dim n As Long Dim I As Long Dim q As Integer Dim X As Long Dim MapNum As Long Dim NPCnum As Long ' Removes one SP when you attack. If SP_ATTACK = 1 Then If GetPlayerSP(Attacker) > 0 Then Call SetPlayerSP(Attacker, GetPlayerSP(Attacker) - 1) Call SendSP(Attacker) Else Call PlayerMsg(Attacker, "You feel exhausted from fighting.", BLUE) Exit Sub End If End If ' Check for subscript out of range If IsPlaying(Attacker) = False Or MapNpcNum <= 0 Or MapNpcNum > MAX_MAP_NPCS Or Damage < 0 Then Exit Sub End If ' Check for weapon If GetPlayerWeaponSlot(Attacker) > 0 Then n = GetPlayerInvItemNum(Attacker, GetPlayerWeaponSlot(Attacker)) Else n = 0 End If ' Send this packet so they can see the person attacking Call SendDataToMapBut(Attacker, GetPlayerMap(Attacker), "ATTACK" & SEP_CHAR & Attacker & END_CHAR) MapNum = GetPlayerMap(Attacker) NPCnum = MapNPC(MapNum, MapNpcNum).num Name = Trim$(NPC(NPCnum).Name) If Damage >= MapNPC(MapNum, MapNpcNum).HP Then ' Check for a weapon and say damage Player(Attacker).Target = 0 ' Call BattleMsg(Attacker, "You killed a " & Name, BrightRed, 0) If SCRIPTING = 1 Then MyScript.ExecuteStatement "Scripts\Main.txt", "OnNPCDeath " & Attacker & "," & MapNum & "," & NPCnum & "," & MapNpcNum End If Dim Add As String Add = 0 If GetPlayerWeaponSlot(Attacker) > 0 Then Add = Add + Item(GetPlayerInvItemNum(Attacker, GetPlayerWeaponSlot(Attacker))).AddEXP End If If GetPlayerArmorSlot(Attacker) > 0 Then Add = Add + Item(GetPlayerInvItemNum(Attacker, GetPlayerArmorSlot(Attacker))).AddEXP End If If GetPlayerShieldSlot(Attacker) > 0 Then Add = Add + Item(GetPlayerInvItemNum(Attacker, GetPlayerShieldSlot(Attacker))).AddEXP End If If GetPlayerLegsSlot(Attacker) > 0 Then Add = Add + Item(GetPlayerInvItemNum(Attacker, GetPlayerLegsSlot(Attacker))).AddEXP End If If GetPlayerRingSlot(Attacker) > 0 Then Add = Add + Item(GetPlayerInvItemNum(Attacker, GetPlayerRingSlot(Attacker))).AddEXP End If If GetPlayerNecklaceSlot(Attacker) > 0 Then Add = Add + Item(GetPlayerInvItemNum(Attacker, GetPlayerNecklaceSlot(Attacker))).AddEXP End If If GetPlayerHelmetSlot(Attacker) > 0 Then Add = Add + Item(GetPlayerInvItemNum(Attacker, GetPlayerHelmetSlot(Attacker))).AddEXP End If If Add > 0 Then If Add < 100 Then If Add < 10 Then Add = 0 & ".0" & Right$(Add, 2) Else Add = 0 & "." & Right$(Add, 2) End If Else Add = Mid$(Add, 1, 1) & "." & Right$(Add, 2) End If End If ' Calculate exp to give attacker If Add > 0 Then Exp = NPC(NPCnum).Exp + (NPC(NPCnum).Exp * Val(Add)) Else Exp = NPC(NPCnum).Exp End If ' Make sure we dont get less then 0 If Exp < 0 Then Exp = 1 End If ' Check if in party, if so divide the exp up by 2 If Player(Attacker).InParty = False Or Player(Attacker).Party.ShareExp = False Then If GetPlayerLevel(Attacker) = MAX_LEVEL Then Call SetPlayerExp(Attacker, Experience(MAX_LEVEL)) Call BattleMsg(Attacker, "You can't gain anymore experience!", BRIGHTBLUE, 0) Else Call SetPlayerExp(Attacker, GetPlayerExp(Attacker) + Exp) Call BattleMsg(Attacker, "You gained " & Exp & " experience.", BRIGHTBLUE, 0) End If Else q = 0 ' The following code will tell us how many party members we have active For X = 1 To MAX_PARTY_MEMBERS If Player(Attacker).Party.Member(X) > 0 Then q = q + 1 End If Next X ' MsgBox "in party" & q If q = 2 Then 'Remember, if they aren't in a party they'll only get one person, so this has to be at least two Exp = Exp * 0.75 ' 3/4 experience ' MsgBox Exp For X = 1 To MAX_PARTY_MEMBERS If Player(Attacker).Party.Member(X) > 0 Then If Player(Player(Attacker).Party.Member(X)).Party.ShareExp = True Then If GetPlayerLevel(Player(Attacker).Party.Member(X)) = MAX_LEVEL Then Call SetPlayerExp(Player(Attacker).Party.Member(X), Experience(MAX_LEVEL)) Call BattleMsg(Player(Attacker).Party.Member(X), "You can't gain anymore experience!", BRIGHTBLUE, 0) Else Call SetPlayerExp(Player(Attacker).Party.Member(X), GetPlayerExp(Player(Attacker).Party.Member(X)) + Exp) Call BattleMsg(Player(Attacker).Party.Member(X), "You gained " & Exp & " party experience.", BRIGHTBLUE, 0) End If Call SendEXP(X) End If End If Next X Else 'if there are 3 or more party members.. Exp = Exp * 0.5 ' 1/2 experience For X = 1 To MAX_PARTY_MEMBERS If Player(Attacker).Party.Member(X) > 0 Then If Player(Player(Attacker).Party.Member(X)).Party.ShareExp = True Then If GetPlayerLevel(Player(Attacker).Party.Member(X)) = MAX_LEVEL Then Call SetPlayerExp(Player(Attacker).Party.Member(X), Experience(MAX_LEVEL)) Call BattleMsg(Player(Attacker).Party.Member(X), "You can't gain anymore experience!", BRIGHTBLUE, 0) Else Call SetPlayerExp(Player(Attacker).Party.Member(X), GetPlayerExp(Player(Attacker).Party.Member(X)) + Exp) Call BattleMsg(Player(Attacker).Party.Member(X), "You gained " & Exp & " party experience.", BRIGHTBLUE, 0) End If Call SendEXP(X) End If End If Next X End If End If ' Drop the items if they earn it. For I = 1 To MAX_NPC_DROPS If NPC(NPCnum).ItemNPC(I).ItemNum > 0 Then n = Int(Rnd * NPC(NPCnum).ItemNPC(I).Chance) + 1 If n = 1 Then Call SpawnItem(NPC(NPCnum).ItemNPC(I).ItemNum, NPC(NPCnum).ItemNPC(I).ItemValue, MapNum, MapNPC(MapNum, MapNpcNum).X, MapNPC(MapNum, MapNpcNum).Y) End If End If Next I ' Now set HP to 0 so we know to actually kill them in the server loop (this prevents subscript out of range) MapNPC(MapNum, MapNpcNum).num = 0 MapNPC(MapNum, MapNpcNum).SpawnWait = GetTickCount MapNPC(MapNum, MapNpcNum).HP = 0 Call SendDataToMap(MapNum, "NPCDEAD" & SEP_CHAR & MapNpcNum & END_CHAR) ' Check for level up Call CheckPlayerLevelUp(Attacker) ' Check for level up party member If Player(Attacker).InParty = True Then For X = 1 To MAX_PARTY_MEMBERS Call CheckPlayerLevelUp(Player(Attacker).Party.Member(X)) Next X End If ' Check for level up party member If Player(Attacker).InParty = True Then Call CheckPlayerLevelUp(Player(Attacker).PartyPlayer) End If ' Check if target is npc that died and if so set target to 0 If Player(Attacker).TargetType = TARGET_TYPE_NPC And Player(Attacker).Target = MapNpcNum Then Player(Attacker).Target = 0 Player(Attacker).TargetType = 0 End If Else ' NPC not dead, just do the damage MapNPC(MapNum, MapNpcNum).HP = MapNPC(MapNum, MapNpcNum).HP - Damage Player(Attacker).Target = MapNpcNum' Check for a weapon and say damage' Call BattleMsg(Attacker, "You hit a " & Name & " for " & Damage & " damage.", White, 0) If n = 0 Then ' Call PlayerMsg(Attacker, "You hit a " & Name & " for " & Damage & " hit points.", White) Else ' Call PlayerMsg(Attacker, "You hit a " & Name & " with a " & Trim$(Item(n).Name) & " for " & Damage & " hit points.", White) End If ' Check if we should send a message If MapNPC(MapNum, MapNpcNum).Target = 0 And MapNPC(MapNum, MapNpcNum).Target <> Attacker Then If Trim$(NPC(NPCnum).AttackSay) <> vbNullString Then Call PlayerMsg(Attacker, "A " & Trim$(NPC(NPCnum).Name) & " : " & Trim$(NPC(NPCnum).AttackSay) & vbNullString, SayColor) End If End If ' Set the NPC target to the player MapNPC(MapNum, MapNpcNum).Target = Attacker ' Now check for guard ai and if so have all onmap guards come after'm If NPC(MapNPC(MapNum, MapNpcNum).num).Behavior = NPC_BEHAVIOR_GUARD Then For I = 1 To MAX_MAP_NPCS If MapNPC(MapNum, I).num = MapNPC(MapNum, MapNpcNum).num Then MapNPC(MapNum, I).Target = Attacker End If Next I End If End If Call SendDataToMap(MapNum, "npchp" & SEP_CHAR & MapNpcNum & SEP_CHAR & MapNPC(MapNum, MapNpcNum).HP & SEP_CHAR & GetNpcMaxHP(MapNPC(MapNum, MapNpcNum).num) & END_CHAR) ' Reset attack timer Player(Attacker).AttackTimer = GetTickCountEnd Sub```Regards, Godlord. Link to comment Share on other sites More sharing options...
Godlord Posted July 29, 2008 Author Share Posted July 29, 2008 Change:```Sub CastSpell(ByVal Index As Long, ByVal SpellSlot As Long) Dim SpellNum As Long, I As Long, n As Long, Damage As Long Dim Casted As Boolean Casted = False ' Prevent player from using spells if they have been script locked If Player(Index).LockedSpells = True Then Exit Sub End If ' Prevent subscript out of range If SpellSlot <= 0 Or SpellSlot > MAX_PLAYER_SPELLS Then Exit Sub End If SpellNum = GetPlayerSpell(Index, SpellSlot) ' Make sure player has the spell If Not HasSpell(Index, SpellNum) Then Call BattleMsg(Index, "You do not have this spell!", BRIGHTRED, 0) Exit Sub End If I = GetSpellReqLevel(SpellNum) ' Check if they have enough MP If GetPlayerMP(Index) < Spell(SpellNum).MPCost Then Call BattleMsg(Index, "Not enough mana!", BRIGHTRED, 0) Exit Sub End If ' Make sure they are the right level If I > GetPlayerLevel(Index) Then Call BattleMsg(Index, "You need to be " & I & "to cast this spell.", BRIGHTRED, 0) Exit Sub End If ' Check if timer is ok If GetTickCount < Player(Index).AttackTimer + 1000 Then Exit Sub End If ' Check if the spell is scripted and do that instead of a stat modification If Spell(SpellNum).Type = SPELL_TYPE_SCRIPTED Then MyScript.ExecuteStatement "Scripts\Main.txt", "ScriptedSpell " & Index & "," & Spell(SpellNum).Data1 Exit Sub End If' End If Dim X As Long, Y As Long If Spell(SpellNum).AE = 1 Then For Y = GetPlayerY(Index) - Spell(SpellNum).Range To GetPlayerY(Index) + Spell(SpellNum).Range For X = GetPlayerX(Index) - Spell(SpellNum).Range To GetPlayerX(Index) + Spell(SpellNum).Range n = -1 For I = 1 To MAX_PLAYERS If IsPlaying(I) = True Then If GetPlayerMap(Index) = GetPlayerMap(I) Then If GetPlayerX(I) = X And GetPlayerY(I) = Y Then If I = Index Then If Spell(SpellNum).Type = SPELL_TYPE_ADDHP Or Spell(SpellNum).Type = SPELL_TYPE_ADDMP Or Spell(SpellNum).Type = SPELL_TYPE_ADDSP Then Player(Index).Target = I Player(Index).TargetType = TARGET_TYPE_PLAYER n = Player(Index).Target End If Else Player(Index).Target = I Player(Index).TargetType = TARGET_TYPE_PLAYER n = Player(Index).Target End If End If End If End If Next I For I = 1 To MAX_MAP_NPCS If MapNPC(GetPlayerMap(Index), I).num > 0 Then If NPC(MapNPC(GetPlayerMap(Index), I).num).Behavior <> NPC_BEHAVIOR_FRIENDLY And NPC(MapNPC(GetPlayerMap(Index), I).num).Behavior <> NPC_BEHAVIOR_SHOPKEEPER Then If MapNPC(GetPlayerMap(Index), I).X = X And MapNPC(GetPlayerMap(Index), I).Y = Y Then Player(Index).Target = I Player(Index).TargetType = TARGET_TYPE_NPC n = Player(Index).Target End If End If End If Next I Casted = False If n > 0 Then If Player(Index).TargetType = TARGET_TYPE_PLAYER Then If IsPlaying(n) Then If n = Index Then Select Case Spell(SpellNum).Type Case SPELL_TYPE_ADDHP ' Call MapMsg(GetPlayerMap(index), GetPlayerName(index) & " casts " & Trim$(Spell(SpellNum).Name) & " on " & GetPlayerName(n) & ".", BrightBlue) Call SetPlayerHP(n, GetPlayerHP(n) + Spell(SpellNum).Data1) Call SendHP(n) Case SPELL_TYPE_ADDMP ' Call MapMsg(GetPlayerMap(index), GetPlayerName(index) & " casts " & Trim$(Spell(SpellNum).Name) & " on " & GetPlayerName(n) & ".", BrightBlue) Call SetPlayerMP(n, GetPlayerMP(n) + Spell(SpellNum).Data1) Call SendMP(n) Case SPELL_TYPE_ADDSP ' Call MapMsg(GetPlayerMap(index), GetPlayerName(index) & " casts " & Trim$(Spell(SpellNum).Name) & " on " & GetPlayerName(n) & ".", BrightBlue) Call SetPlayerMP(n, GetPlayerSP(n) + Spell(SpellNum).Data1) Call SendMP(n) End Select Casted = True Else Call PlayerMsg(Index, "Cannot cast spell!", BRIGHTRED) End If If n <> Index Then Player(Index).TargetType = TARGET_TYPE_PLAYER If GetPlayerHP(n) > 0 And GetPlayerMap(Index) = GetPlayerMap(n) And GetPlayerLevel(Index) >= 10 And GetPlayerLevel(n) >= 10 And (Map(GetPlayerMap(Index)).Moral = MAP_MORAL_NONE Or Map(GetPlayerMap(Index)).Moral = MAP_MORAL_NO_PENALTY) And GetPlayerAccess(Index) <= 0 And GetPlayerAccess(n) <= 0 Then' Call MapMsg(GetPlayerMap(index), GetPlayerName(index) & " casts " & Trim$(Spell(SpellNum).Name) & " on " & GetPlayerName(n) & ".", BrightBlue) Select Case Spell(SpellNum).Type Case SPELL_TYPE_SUBHP Damage = (Int(GetPlayerMAGI(Index) / 4) + Spell(SpellNum).Data1) - GetPlayerProtection(n) If Damage > 0 Then Call AttackPlayer(Index, n, Damage) Else Call BattleMsg(Index, "The spell was to weak to hurt " & GetPlayerName(n) & "!", BRIGHTRED, 0) End If Case SPELL_TYPE_SUBMP Call SetPlayerMP(n, GetPlayerMP(n) - Spell(SpellNum).Data1) Call SendMP(n) Case SPELL_TYPE_SUBSP Call SetPlayerSP(n, GetPlayerSP(n) - Spell(SpellNum).Data1) Call SendSP(n) End Select Casted = True Else If GetPlayerMap(Index) = GetPlayerMap(n) And Spell(SpellNum).Type >= SPELL_TYPE_ADDHP And Spell(SpellNum).Type <= SPELL_TYPE_ADDSP Then Select Case Spell(SpellNum).Type Case SPELL_TYPE_ADDHP ' Call MapMsg(GetPlayerMap(index), GetPlayerName(index) & " casts " & Trim$(Spell(SpellNum).Name) & " on " & GetPlayerName(n) & ".", BrightBlue) Call SetPlayerHP(n, GetPlayerHP(n) + Spell(SpellNum).Data1) Call SendHP(n) Case SPELL_TYPE_ADDMP ' Call MapMsg(GetPlayerMap(index), GetPlayerName(index) & " casts " & Trim$(Spell(SpellNum).Name) & " on " & GetPlayerName(n) & ".", BrightBlue) Call SetPlayerMP(n, GetPlayerMP(n) + Spell(SpellNum).Data1) Call SendMP(n) Case SPELL_TYPE_ADDSP ' Call MapMsg(GetPlayerMap(index), GetPlayerName(index) & " casts " & Trim$(Spell(SpellNum).Name) & " on " & GetPlayerName(n) & ".", BrightBlue) Call SetPlayerMP(n, GetPlayerSP(n) + Spell(SpellNum).Data1) Call SendMP(n) End Select Casted = True Else Call PlayerMsg(Index, "Cannot cast spell!", BRIGHTRED) End If End If Else Player(Index).TargetType = TARGET_TYPE_PLAYER If n = Index Then Select Case Spell(SpellNum).Type Case SPELL_TYPE_ADDHP ' Call MapMsg(GetPlayerMap(index), GetPlayerName(index) & " casts " & Trim$(Spell(SpellNum).Name) & " on " & GetPlayerName(n) & ".", BrightBlue) Call SetPlayerHP(n, GetPlayerHP(n) + Spell(SpellNum).Data1) Call SendHP(n) Case SPELL_TYPE_ADDMP ' Call MapMsg(GetPlayerMap(index), GetPlayerName(index) & " casts " & Trim$(Spell(SpellNum).Name) & " on " & GetPlayerName(n) & ".", BrightBlue) Call SetPlayerMP(n, GetPlayerMP(n) + Spell(SpellNum).Data1) Call SendMP(n) Case SPELL_TYPE_ADDSP ' Call MapMsg(GetPlayerMap(index), GetPlayerName(index) & " casts " & Trim$(Spell(SpellNum).Name) & " on " & GetPlayerName(n) & ".", BrightBlue) Call SetPlayerMP(n, GetPlayerSP(n) + Spell(SpellNum).Data1) Call SendMP(n) End Select Casted = True Else Call PlayerMsg(Index, "Cannot cast spell!", BRIGHTRED) End If If GetPlayerHP(n) > 0 And GetPlayerMap(Index) = GetPlayerMap(n) And GetPlayerLevel(Index) >= 10 And GetPlayerLevel(n) >= 10 And (Map(GetPlayerMap(Index)).Moral = MAP_MORAL_NONE Or Map(GetPlayerMap(Index)).Moral = MAP_MORAL_NO_PENALTY) And GetPlayerAccess(Index) <= 0 And GetPlayerAccess(n) <= 0 Then Else If GetPlayerMap(Index) = GetPlayerMap(n) And Spell(SpellNum).Type >= SPELL_TYPE_ADDHP And Spell(SpellNum).Type <= SPELL_TYPE_ADDSP Then Select Case Spell(SpellNum).Type Case SPELL_TYPE_ADDHP ' Call MapMsg(GetPlayerMap(index), GetPlayerName(index) & " casts " & Trim$(Spell(SpellNum).Name) & " on " & GetPlayerName(n) & ".", BrightBlue) Call SetPlayerHP(n, GetPlayerHP(n) + Spell(SpellNum).Data1) Call SendHP(n) Case SPELL_TYPE_ADDMP ' Call MapMsg(GetPlayerMap(index), GetPlayerName(index) & " casts " & Trim$(Spell(SpellNum).Name) & " on " & GetPlayerName(n) & ".", BrightBlue) Call SetPlayerMP(n, GetPlayerMP(n) + Spell(SpellNum).Data1) Call SendMP(n) Case SPELL_TYPE_ADDSP ' Call MapMsg(GetPlayerMap(index), GetPlayerName(index) & " casts " & Trim$(Spell(SpellNum).Name) & " on " & GetPlayerName(n) & ".", BrightBlue) Call SetPlayerMP(n, GetPlayerSP(n) + Spell(SpellNum).Data1) Call SendMP(n) End Select Casted = True Else Call BattleMsg(Index, "Could not cast spell!", BRIGHTRED, 0) End If End If End If Else Call BattleMsg(Index, "Could not cast spell!", BRIGHTRED, 0) End If Else Player(Index).TargetType = TARGET_TYPE_NPC If NPC(MapNPC(GetPlayerMap(Index), n).num).Behavior <> NPC_BEHAVIOR_FRIENDLY And NPC(MapNPC(GetPlayerMap(Index), n).num).Behavior <> NPC_BEHAVIOR_SHOPKEEPER Then If Spell(SpellNum).Type >= SPELL_TYPE_SUBHP And Spell(SpellNum).Type <= SPELL_TYPE_SUBSP Then ' Call MapMsg(GetPlayerMap(index), GetPlayerName(index) & " casts " & Trim$(Spell(SpellNum).Name) & " on a " & Trim$(Npc(MapNpc(GetPlayerMap(index), n).num).Name) & ".", BrightBlue) Select Case Spell(SpellNum).Type Case SPELL_TYPE_SUBHP Damage = (Int(GetPlayerMAGI(Index) / 4) + Spell(SpellNum).Data1) - Int(NPC(MapNPC(GetPlayerMap(Index), n).num).DEF / 2) If Damage > 0 Then If Spell(SpellNum).Element <> 0 And NPC(MapNPC(GetPlayerMap(Index), n).num).Element <> 0 Then If Element(Spell(SpellNum).Element).Strong = NPC(MapNPC(GetPlayerMap(Index), n).num).Element Or Element(NPC(MapNPC(GetPlayerMap(Index), n).num).Element).Weak = Spell(SpellNum).Element Then Call BattleMsg(Index, "A deadly mix of elements harm the " & Trim$(NPC(MapNPC(GetPlayerMap(Index), n).num).Name) & "!", BLUE, 0) Damage = Int(Damage * 1.25) If Element(Spell(SpellNum).Element).Strong = NPC(MapNPC(GetPlayerMap(Index), n).num).Element And Element(NPC(MapNPC(GetPlayerMap(Index), n).num).Element).Weak = Spell(SpellNum).Element Then Damage = Int(Damage * 1.2) End If End If If Element(Spell(SpellNum).Element).Weak = NPC(MapNPC(GetPlayerMap(Index), n).num).Element Or Element(NPC(MapNPC(GetPlayerMap(Index), n).num).Element).Strong = Spell(SpellNum).Element Then Call BattleMsg(Index, "The " & Trim$(NPC(MapNPC(GetPlayerMap(Index), n).num).Name) & " aborbs much of the elemental damage!", RED, 0) Damage = Int(Damage * 0.75) If Element(Spell(SpellNum).Element).Weak = NPC(MapNPC(GetPlayerMap(Index), n).num).Element And Element(NPC(MapNPC(GetPlayerMap(Index), n).num).Element).Strong = Spell(SpellNum).Element Then Damage = Int(Damage * (2 / 3)) End If End If End If Call AttackNpc(Index, n, Damage) Else Call BattleMsg(Index, "The spell was to weak to hurt " & Trim$(NPC(MapNPC(GetPlayerMap(Index), n).num).Name) & "!", BRIGHTRED, 0) End If Case SPELL_TYPE_SUBMP MapNPC(GetPlayerMap(Index), n).MP = MapNPC(GetPlayerMap(Index), n).MP - Spell(SpellNum).Data1 Case SPELL_TYPE_SUBSP MapNPC(GetPlayerMap(Index), n).SP = MapNPC(GetPlayerMap(Index), n).SP - Spell(SpellNum).Data1 End Select Casted = True Else Select Case Spell(SpellNum).Type Case SPELL_TYPE_ADDHP' MapNpc(GetPlayerMap(Index), n).HP = MapNpc(GetPlayerMap(Index), n).HP + Spell(SpellNum).Data1 Case SPELL_TYPE_ADDMP' MapNpc(GetPlayerMap(Index), n).MP = MapNpc(GetPlayerMap(Index), n).MP + Spell(SpellNum).Data1 Case SPELL_TYPE_ADDSP ' MapNpc(GetPlayerMap(Index), n).SP = MapNpc(GetPlayerMap(Index), n).SP + Spell(SpellNum).Data1 End Select Casted = False End If Else Call BattleMsg(Index, "Could not cast spell!", BRIGHTRED, 0) End If End If End If If Casted = True Then Call SendDataToMap(GetPlayerMap(Index), "spellanim" & SEP_CHAR & SpellNum & SEP_CHAR & Spell(SpellNum).SpellAnim & SEP_CHAR & Spell(SpellNum).SpellTime & SEP_CHAR & Spell(SpellNum).SpellDone & SEP_CHAR & Index & SEP_CHAR & Player(Index).TargetType & SEP_CHAR & Player(Index).Target & SEP_CHAR & Player(Index).CastedSpell & SEP_CHAR & Spell(SpellNum).Big & END_CHAR) Call SendDataToMap(GetPlayerMap(Index), "sound" & SEP_CHAR & "magic" & SEP_CHAR & Spell(SpellNum).Sound & END_CHAR) End If Next X Next Y Call SetPlayerMP(Index, GetPlayerMP(Index) - Spell(SpellNum).MPCost) Call SendMP(Index) Else n = Player(Index).Target If Player(Index).TargetType = TARGET_TYPE_PLAYER Then If IsPlaying(n) Then If GetPlayerName(n) <> GetPlayerName(Index) Then If CInt(Sqr((GetPlayerX(Index) - GetPlayerX(n)) ^ 2 + ((GetPlayerY(Index) - GetPlayerY(n)) ^ 2))) > Spell(SpellNum).Range Then Call BattleMsg(Index, "You are too far away to hit the target.", BRIGHTRED, 0) Exit Sub End If End If Player(Index).TargetType = TARGET_TYPE_PLAYER If GetPlayerHP(n) > 0 And GetPlayerMap(Index) = GetPlayerMap(n) And GetPlayerLevel(Index) >= 10 And GetPlayerLevel(n) >= 10 And (Map(GetPlayerMap(Index)).Moral = MAP_MORAL_NONE Or Map(GetPlayerMap(Index)).Moral = MAP_MORAL_NO_PENALTY) And GetPlayerAccess(Index) <= 0 And GetPlayerAccess(n) <= 0 Then' Call MapMsg(GetPlayerMap(index), GetPlayerName(index) & " casts " & Trim$(Spell(SpellNum).Name) & " on " & GetPlayerName(n) & ".", BrightBlue) Select Case Spell(SpellNum).Type Case SPELL_TYPE_SUBHP Damage = (Int(GetPlayerMAGI(Index) / 4) + Spell(SpellNum).Data1) - GetPlayerProtection(n) If Damage > 0 Then Call AttackPlayer(Index, n, Damage) Else Call BattleMsg(Index, "The spell was to weak to hurt " & GetPlayerName(n) & "!", BRIGHTRED, 0) End If Case SPELL_TYPE_SUBMP Call SetPlayerMP(n, GetPlayerMP(n) - Spell(SpellNum).Data1) Call SendMP(n) Case SPELL_TYPE_SUBSP Call SetPlayerSP(n, GetPlayerSP(n) - Spell(SpellNum).Data1) Call SendSP(n) End Select ' Take away the mana points Call SetPlayerMP(Index, GetPlayerMP(Index) - Spell(SpellNum).MPCost) Call SendMP(Index) Casted = True Else If GetPlayerMap(Index) = GetPlayerMap(n) And Spell(SpellNum).Type >= SPELL_TYPE_ADDHP And Spell(SpellNum).Type <= SPELL_TYPE_ADDSP Then Select Case Spell(SpellNum).Type Case SPELL_TYPE_ADDHP ' Call MapMsg(GetPlayerMap(index), GetPlayerName(index) & " casts " & Trim$(Spell(SpellNum).Name) & " on " & GetPlayerName(n) & ".", BrightBlue) Call SetPlayerHP(n, GetPlayerHP(n) + Spell(SpellNum).Data1) Call SendHP(n) Case SPELL_TYPE_ADDMP ' Call MapMsg(GetPlayerMap(index), GetPlayerName(index) & " casts " & Trim$(Spell(SpellNum).Name) & " on " & GetPlayerName(n) & ".", BrightBlue) Call SetPlayerMP(n, GetPlayerMP(n) + Spell(SpellNum).Data1) Call SendMP(n) Case SPELL_TYPE_ADDSP ' Call MapMsg(GetPlayerMap(index), GetPlayerName(index) & " casts " & Trim$(Spell(SpellNum).Name) & " on " & GetPlayerName(n) & ".", BrightBlue) Call SetPlayerMP(n, GetPlayerSP(n) + Spell(SpellNum).Data1) Call SendMP(n) End Select ' Take away the mana points Call SetPlayerMP(Index, GetPlayerMP(Index) - Spell(SpellNum).MPCost) Call SendMP(Index) Casted = True Else Call BattleMsg(Index, "Could not cast spell!", BRIGHTRED, 0) End If End If Else Call PlayerMsg(Index, "Cannot cast spell!", BRIGHTRED) End If Else If CInt(Sqr((GetPlayerX(Index) - MapNPC(GetPlayerMap(Index), n).X) ^ 2 + ((GetPlayerY(Index) - MapNPC(GetPlayerMap(Index), n).Y) ^ 2))) > Spell(SpellNum).Range Then Call BattleMsg(Index, "You are too far away to hit the target.", BRIGHTRED, 0) Exit Sub End If Player(Index).TargetType = TARGET_TYPE_NPC If NPC(MapNPC(GetPlayerMap(Index), n).num).Behavior <> NPC_BEHAVIOR_FRIENDLY And NPC(MapNPC(GetPlayerMap(Index), n).num).Behavior <> NPC_BEHAVIOR_SHOPKEEPER Then' Call MapMsg(GetPlayerMap(index), GetPlayerName(index) & " casts " & Trim$(Spell(SpellNum).Name) & " on a " & Trim$(Npc(MapNpc(GetPlayerMap(index), n).num).Name) & ".", BrightBlue) Select Case Spell(SpellNum).Type Case SPELL_TYPE_ADDHP MapNPC(GetPlayerMap(Index), n).HP = MapNPC(GetPlayerMap(Index), n).HP + Spell(SpellNum).Data1 Case SPELL_TYPE_SUBHP Damage = (Int(GetPlayerMAGI(Index) / 4) + Spell(SpellNum).Data1) - Int(NPC(MapNPC(GetPlayerMap(Index), n).num).DEF / 2) If Damage > 0 Then If Spell(SpellNum).Element <> 0 And NPC(MapNPC(GetPlayerMap(Index), n).num).Element <> 0 Then If Element(Spell(SpellNum).Element).Strong = NPC(MapNPC(GetPlayerMap(Index), n).num).Element Or Element(NPC(MapNPC(GetPlayerMap(Index), n).num).Element).Weak = Spell(SpellNum).Element Then Call BattleMsg(Index, "A deadly mix of elements harm the " & Trim$(NPC(MapNPC(GetPlayerMap(Index), n).num).Name) & "!", BLUE, 0) Damage = Int(Damage * 1.25) If Element(Spell(SpellNum).Element).Strong = NPC(MapNPC(GetPlayerMap(Index), n).num).Element And Element(NPC(MapNPC(GetPlayerMap(Index), n).num).Element).Weak = Spell(SpellNum).Element Then Damage = Int(Damage * 1.2) End If End If If Element(Spell(SpellNum).Element).Weak = NPC(MapNPC(GetPlayerMap(Index), n).num).Element Or Element(NPC(MapNPC(GetPlayerMap(Index), n).num).Element).Strong = Spell(SpellNum).Element Then Call BattleMsg(Index, "The " & Trim$(NPC(MapNPC(GetPlayerMap(Index), n).num).Name) & " aborbs much of the elemental damage!", RED, 0) Damage = Int(Damage * 0.75) If Element(Spell(SpellNum).Element).Weak = NPC(MapNPC(GetPlayerMap(Index), n).num).Element And Element(NPC(MapNPC(GetPlayerMap(Index), n).num).Element).Strong = Spell(SpellNum).Element Then Damage = Int(Damage * (2 / 3)) End If End If End If Call AttackNpc(Index, n, Damage) Else Call BattleMsg(Index, "The spell was to weak to hurt " & Trim$(NPC(MapNPC(GetPlayerMap(Index), n).num).Name) & "!", BRIGHTRED, 0) End If Case SPELL_TYPE_ADDMP MapNPC(GetPlayerMap(Index), n).MP = MapNPC(GetPlayerMap(Index), n).MP + Spell(SpellNum).Data1 Case SPELL_TYPE_SUBMP MapNPC(GetPlayerMap(Index), n).MP = MapNPC(GetPlayerMap(Index), n).MP - Spell(SpellNum).Data1 Case SPELL_TYPE_ADDSP MapNPC(GetPlayerMap(Index), n).SP = MapNPC(GetPlayerMap(Index), n).SP + Spell(SpellNum).Data1 Case SPELL_TYPE_SUBSP MapNPC(GetPlayerMap(Index), n).SP = MapNPC(GetPlayerMap(Index), n).SP - Spell(SpellNum).Data1 End Select ' Take away the mana points Call SetPlayerMP(Index, GetPlayerMP(Index) - Spell(SpellNum).MPCost) Call SendMP(Index) Casted = True Else Call BattleMsg(Index, "Could not cast spell!", BRIGHTRED, 0) End If End If End If If Casted = True Then Player(Index).AttackTimer = GetTickCount Player(Index).CastedSpell = YES Call SendDataToMap(GetPlayerMap(Index), "spellanim" & SEP_CHAR & SpellNum & SEP_CHAR & Spell(SpellNum).SpellAnim & SEP_CHAR & Spell(SpellNum).SpellTime & SEP_CHAR & Spell(SpellNum).SpellDone & SEP_CHAR & Index & SEP_CHAR & Player(Index).TargetType & SEP_CHAR & Player(Index).Target & SEP_CHAR & Player(Index).CastedSpell & SEP_CHAR & Spell(SpellNum).Big & END_CHAR) Call SendDataToMap(GetPlayerMap(Index), "sound" & SEP_CHAR & "magic" & SEP_CHAR & Spell(SpellNum).Sound & END_CHAR) End IfEnd Sub```To:```Sub CastSpell(ByVal Index As Long, ByVal SpellSlot As Long) ' Rewritten by Godlord. Dim SpellNum As Long Dim I As Long Dim X As Long Dim Y As Long Dim n As Long Dim Damage As Long Dim Casted As Boolean Casted = False ' Prevent player from casting spells if the spells are locked. If Player(Index).LockedSpells = True Then Exit Sub End If ' Prevent accessing the non-existence. If SpellSlot < 1 Or SpellSlot > MAX_PLAYER_SPELLS Then Exit Sub End If ' Get the spell number. SpellNum = GetPlayerSpell(Index, SpellSlot) ' Check if the player has the spell. If HasSpell(Index, SpellNum) = False Then Call BattleMsg(Index, "You don't have this spell!", BRIGHTRED, 0) Exit Sub End If I = GetSpellReqLevel(SpellNum) ' Check if the player has enough mana. If GetPlayerMP(Index) < Spell(SpellNum).MPCost Then Call BattleMsg(Index, "You don't have enough mana to cast this spell!", BRIGHTRED, 0) Exit Sub End If ' Check if the player has the right level. If I > GetPlayerLevel(Index) Then Call BattleMsg(Index, "You need to be level " & I & " to cast this spell!", BRIGHTRED, 0) Exit Sub End If ' Check if a second has been past. If GetTickCount < Player(Index).AttackTimer + 1000 Then Exit Sub End If ' Check if this spell is a scripted spell. If Spell(SpellNum).Type = SPELL_TYPE_SCRIPTED Then Call MyScript.ExecuteStatement("Scripts\Main.txt", "ScriptedSpell " & Index & "," & Spell(SpellNum).Data1) Exit Sub End If ' Check if the spell has area effect enabled. If Spell(SpellNum).AE = 1 Then For I = 1 To MAX_PLAYERS n = -1 Casted = False If IsPlaying(I) = True Then If GetPlayerMap(Index) = GetPlayerMap(I) Then If CInt(Sqr((GetPlayerX(Index) - GetPlayerX(I)) ^ 2 + ((GetPlayerY(Index) - GetPlayerY(I)) ^ 2))) <= Spell(SpellNum).Range Then Player(Index).Target = I Player(Index).TargetType = TARGET_TYPE_PLAYER n = Player(Index).Target End If End If End If If n > 0 Then If GetPlayerHP(n) > 0 And GetPlayerMap(Index) = GetPlayerMap(n) Then Select Case Spell(SpellNum).Type Case SPELL_TYPE_SUBHP If n <> Index And GetPlayerLevel(Index) >= 10 And GetPlayerLevel(n) >= 10 And (Map(GetPlayerMap(Index)).Moral = MAP_MORAL_NONE Or Map(GetPlayerMap(Index)).Moral = MAP_MORAL_NO_PENALTY) Then Damage = (Int(GetPlayerMAGI(Index) / 4) + Spell(SpellNum).Data1) - GetPlayerProtection(n) If Damage > 0 Then Call AttackPlayer(Index, n, Damage) Else Call BattleMsg(Index, "The spell was to weak to hurt " & GetPlayerName(n) & "!", BRIGHTRED, 0) End If Casted = True End If Case SPELL_TYPE_SUBMP If n <> Index And GetPlayerLevel(Index) >= 10 And GetPlayerLevel(n) >= 10 And (Map(GetPlayerMap(Index)).Moral = MAP_MORAL_NONE Or Map(GetPlayerMap(Index)).Moral = MAP_MORAL_NO_PENALTY) Then Call SetPlayerMP(n, GetPlayerMP(n) - Spell(SpellNum).Data1) Call SendMP(n) Casted = True End If Case SPELL_TYPE_SUBSP If n <> Index And GetPlayerLevel(Index) >= 10 And GetPlayerLevel(n) >= 10 And (Map(GetPlayerMap(Index)).Moral = MAP_MORAL_NONE Or Map(GetPlayerMap(Index)).Moral = MAP_MORAL_NO_PENALTY) Then Call SetPlayerSP(n, GetPlayerSP(n) - Spell(SpellNum).Data1) Call SendSP(n) Casted = True End If Case SPELL_TYPE_ADDHP Call PlayerMsg(I, "You've been healed by " & GetPlayerName(Index) & ".", BRIGHTBLUE)``` Link to comment Share on other sites More sharing options...
Godlord Posted July 29, 2008 Author Share Posted July 29, 2008 **Server - modDatabase.bas**Change:```Function GetPlayerTargetNpc(ByVal Index As Long) As Long GetPlayerTargetNpc = Player(Index).TargetNPCEnd Function```To:```Function GetPlayerTargetNpc(ByVal Index As Long) As Long GetPlayerTargetNpc = Player(Index).TargetEnd Function```**Server - clsCommands.cls**Change:```Function GetPlayerTargetNpc(ByVal Index As Long) If Index > 0 Then If Player(Index).TargetType = TARGET_TYPE_NPC Then GetPlayerTargetNpc = Player(Index).TargetNPC Else GetPlayerTargetNpc = -1 End If End IfEnd Function```To:```Function GetPlayerTargetNpc(ByVal Index As Long) If Index > 0 Then If Player(Index).TargetType = TARGET_TYPE_NPC Then GetPlayerTargetNpc = Player(Index).Target Else GetPlayerTargetNpc = -1 End If End IfEnd Function```**Current Known Issues** - Spell animations might not work. - Some messages still need to be added.**Final note**This is not completely finished yet and is only suggested for experienced coders. A source and binary will soon be available.All credits go to me for this fix.Regards, Godlord. Link to comment Share on other sites More sharing options...
ZackFair Posted July 29, 2008 Share Posted July 29, 2008 Thanks Godlord!Btw just found a bug, in your code and in the original EE 2.7 source.@Sub CastSpell``` Case SPELL_TYPE_ADDSP Call PlayerMsg(Index, "You've gained stamina by " & GetPlayerName(Index) & ".", BRIGHTBLUE) Call SetPlayerMP(n, GetPlayerSP(n) + Spell(SpellNum).Data1) Call SendMP(n) Casted = True End Select```Should be:``` Case SPELL_TYPE_ADDSP Call PlayerMsg(Index, "You've gained stamina by " & GetPlayerName(Index) & ".", BRIGHTBLUE) Call SetPlayerSP(n, GetPlayerSP(n) + Spell(SpellNum).Data1) Call SendSP(n) Casted = True End Select``` Link to comment Share on other sites More sharing options...
Godlord Posted July 29, 2008 Author Share Posted July 29, 2008 Yeah thanks I did only look at HP so far.Regards, Godlord. Link to comment Share on other sites More sharing options...
Godlord Posted July 30, 2008 Author Share Posted July 30, 2008 Updated Sub CastSpell.It's now optimized so area spells with a range of 30 will hardly lag.Regards, Godlord. Link to comment Share on other sites More sharing options...
shrig94 Posted July 31, 2008 Share Posted July 31, 2008 Thanks for making this godlord, you always manage to provide useful things to the community. Link to comment Share on other sites More sharing options...
igloo9 Posted August 1, 2008 Share Posted August 1, 2008 When is the 2.7 download link gonna be updated to have this patch? I'm not a scripter so I can't do this…will it be soon? Link to comment Share on other sites More sharing options...
Godlord Posted August 1, 2008 Author Share Posted August 1, 2008 No idea. Still need to check for the other bugs.Regards, Godlord. Link to comment Share on other sites More sharing options...
shrig94 Posted August 17, 2008 Share Posted August 17, 2008 anyone going to finish this, i hope goddie will come back. Link to comment Share on other sites More sharing options...
Anna Comnena Posted October 26, 2008 Share Posted October 26, 2008 Rise from the grave… pulled this out of Trash, don't know how long it was in there though but it's important for those of us who need a working 2.7 and aren't going to the rewritten 2.8. Link to comment Share on other sites More sharing options...
Godlord Posted October 26, 2008 Author Share Posted October 26, 2008 Thanks a bunch, Anna.Not only do I thank you, but I think the community will do too.Regards, Goddie, the Irresistible. Link to comment Share on other sites More sharing options...
Richy420Rich Posted October 29, 2008 Share Posted October 29, 2008 Cool Cool, gonna try it out now. Thanks GodLord Link to comment Share on other sites More sharing options...
Tyr Posted October 29, 2008 Share Posted October 29, 2008 kwl thx :) i was thinking bout fixing it myself, this saves me alot of time :) Link to comment Share on other sites More sharing options...
peekay Posted October 31, 2008 Share Posted October 31, 2008 Any news on the finished code?this works…. but the only problem is after you kill say 1/2 NPC's the animation stops working but you still do the damage Link to comment Share on other sites More sharing options...
Richy420Rich Posted November 1, 2008 Share Posted November 1, 2008 Looks like the animation stops working after 1 hit killing NPC's or Players with a spell?Or is it AoE animations not show hitting all NPC's and Players on the map?EDIT: Hmm, idk :(Ah well, I'll wait for the release fix for it cause I'm still noobish in VB lol.Very nice source fix, thanks again Goddie. Link to comment Share on other sites More sharing options...
Godlord Posted November 6, 2008 Author Share Posted November 6, 2008 Addendum Q: my paperdoll isn't working? What can I do? A: remove all 'old' accounts and try again, the old accounts have another structure, which I changed in the code, this causes problems with paperdoll. Q: my animations aren't working? What can I do? A: there isn't a real solution yet. Try removing all 'old' accounts and try again, the old accounts have another structure, which I change in the code, this may cause problems with the animations as these may affect them. Q: I've got another problem? What can I do? A: you can post it in here, create a new topic, whatever you like, but don't ask me to fix it, as I am responsible for this code but I'm not able to fix anything due a huge limit of my free time. I've seven kids which all need food, go to school, etc. Just joking for the last part :P.Regards, The Nameless One. Link to comment Share on other sites More sharing options...
Tyr Posted November 6, 2008 Share Posted November 6, 2008 great you added that. Link to comment Share on other sites More sharing options...
Nickosarusrex Posted November 18, 2008 Share Posted November 18, 2008 Im confused on what to do. someone please help ;( Link to comment Share on other sites More sharing options...
DrNova Posted November 18, 2008 Share Posted November 18, 2008 You cant use this, as it requires access and knowledge to VB6 Link to comment Share on other sites More sharing options...
Nickosarusrex Posted November 18, 2008 Share Posted November 18, 2008 So I can't fix my spells another way? Link to comment Share on other sites More sharing options...
codemeister1990 Posted November 19, 2008 Share Posted November 19, 2008 Do I just copy paste the code?and where do I copy it if I do Link to comment Share on other sites More sharing options...
Godlord Posted November 19, 2008 Author Share Posted November 19, 2008 @codemeister1990:> Do I just copy paste the code?> and where do I copy it if I doDoesn't deserve an answer as I put it in 24pt or so and you can't still read it.@Nickosarusrex:> So I can't fix my spells another way?Not, unless you can get somebody to compile this.Regards, The Nameless One. Link to comment Share on other sites More sharing options...
tiggilyboo Posted November 20, 2008 Share Posted November 20, 2008 K, ill test this out. Thanks for the fix :cheesy: Link to comment Share on other sites More sharing options...
Akselj Posted November 25, 2008 Share Posted November 25, 2008 That's a HUGE code… Thank you so much for doing this for all of us! This is really useful!Sticky vote! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now