Joyce Posted March 1, 2011 Author Share Posted March 1, 2011 Right, as some MIGHT have noticed that (When used on a target, self-castable spells work fine) Heal MP, Heal HP and Damage MP do not actually work properly, they don't initiate a cooldown regardless of cooldown settings, and they do not ever actually take any MP away from the player..The easiest fix is, well.. To replace your Sub CastSpell(Server-Sided) with the following:```Public Sub CastSpell(ByVal index As Long, ByVal spellslot As Long, ByVal target As Long, ByVal targetType As Byte) Dim spellnum As Long Dim MPCost As Long Dim LevelReq As Long Dim mapNum As Long Dim Vital As Long Dim DidCast As Boolean Dim ClassReq As Long Dim AccessReq As Long Dim I As Long Dim AoE As Long Dim Range As Long Dim VitalType As Byte Dim increment As Boolean Dim x As Long, y As Long Dim Buffer As clsBuffer Dim SpellCastType As Long DidCast = False ' Prevent subscript out of range If spellslot <= 0 Or spellslot > MAX_PLAYER_SPELLS Then Exit Sub spellnum = GetPlayerSpell(index, spellslot) mapNum = GetPlayerMap(index) ' Make sure player has the spell If Not HasSpell(index, spellnum) Then Exit Sub MPCost = Spell(spellnum).MPCost ' Check if they have enough MP If GetPlayerVital(index, Vitals.MP) < MPCost Then Call PlayerMsg(index, "Not enough mana!", BrightRed) Exit Sub End If LevelReq = Spell(spellnum).LevelReq ' Make sure they are the right level If LevelReq > GetPlayerLevel(index) Then Call PlayerMsg(index, "You must be level " & LevelReq & " to cast this spell.", BrightRed) Exit Sub End If AccessReq = Spell(spellnum).AccessReq ' make sure they have the right access If AccessReq > GetPlayerAccess(index) Then Call PlayerMsg(index, "You must be an administrator to cast this spell.", BrightRed) Exit Sub End If ClassReq = Spell(spellnum).ClassReq ' make sure the classreq > 0 If ClassReq > 0 Then ' 0 = no req If ClassReq <> GetPlayerClass(index) Then Call PlayerMsg(index, "Only " & CheckGrammar(Trim$(Class(ClassReq).Name)) & " can use this spell.", BrightRed) Exit Sub End If End If ' find out what kind of spell it is! self cast, target or AOE If Spell(spellnum).Range > 0 Then ' ranged attack, single target or aoe? If Not Spell(spellnum).IsAoE Then SpellCastType = 2 ' targetted Else SpellCastType = 3 ' targetted aoe End If Else If Not Spell(spellnum).IsAoE Then SpellCastType = 0 ' self-cast Else SpellCastType = 1 ' self-cast AoE End If End If ' set the vital Vital = Spell(spellnum).Vital AoE = Spell(spellnum).AoE Range = Spell(spellnum).Range Select Case SpellCastType Case 0 ' self-cast target Select Case Spell(spellnum).Type Case SPELL_TYPE_HEALHP SpellPlayer_Effect Vitals.HP, True, index, Vital, spellnum DidCast = True Case SPELL_TYPE_HEALMP SpellPlayer_Effect Vitals.MP, True, index, Vital, spellnum DidCast = True Case SPELL_TYPE_WARP SendAnimation mapNum, Spell(spellnum).SpellAnim, 0, 0, TARGET_TYPE_PLAYER, index PlayerWarp index, Spell(spellnum).Map, Spell(spellnum).x, Spell(spellnum).y SendAnimation GetPlayerMap(index), Spell(spellnum).SpellAnim, 0, 0, TARGET_TYPE_PLAYER, index DidCast = True End Select Case 1, 3 ' self-cast AOE & targetted AOE If SpellCastType = 1 Then x = GetPlayerX(index) y = GetPlayerY(index) ElseIf SpellCastType = 3 Then If targetType = 0 Then Exit Sub If target = 0 Then Exit Sub If targetType = TARGET_TYPE_PLAYER Then x = GetPlayerX(target) y = GetPlayerY(target) Else x = MapNpc(mapNum).Npc(target).x y = MapNpc(mapNum).Npc(target).y End If If Not isInRange(Range, GetPlayerX(index), GetPlayerY(index), x, y) Then PlayerMsg index, "Target not in range.", BrightRed SendClearSpellBuffer index End If End If Select Case Spell(spellnum).Type Case SPELL_TYPE_DAMAGEHP DidCast = True For I = 1 To Player_HighIndex If IsPlaying(I) Then If I <> index Then If GetPlayerMap(I) = GetPlayerMap(index) Then If isInRange(AoE, x, y, GetPlayerX(I), GetPlayerY(I)) Then If CanPlayerAttackPlayer(index, I, True) Then SendAnimation mapNum, Spell(spellnum).SpellAnim, 0, 0, TARGET_TYPE_PLAYER, I PlayerAttackPlayer index, I, Vital, spellnum End If End If End If End If End If Next For I = 1 To MAX_MAP_NPCS If MapNpc(mapNum).Npc(I).Num > 0 Then If MapNpc(mapNum).Npc(I).Vital(HP) > 0 Then If isInRange(AoE, x, y, MapNpc(mapNum).Npc(I).x, MapNpc(mapNum).Npc(I).y) Then If CanPlayerAttackNpc(index, I, True) Then SendAnimation mapNum, Spell(spellnum).SpellAnim, 0, 0, TARGET_TYPE_NPC, I PlayerAttackNpc index, I, Vital, spellnum End If End If End If End If Next Case SPELL_TYPE_HEALHP, SPELL_TYPE_HEALMP, SPELL_TYPE_DAMAGEMP If Spell(spellnum).Type = SPELL_TYPE_HEALHP Then VitalType = Vitals.HP increment = True ElseIf Spell(spellnum).Type = SPELL_TYPE_HEALMP Then VitalType = Vitals.MP increment = True ElseIf Spell(spellnum).Type = SPELL_TYPE_DAMAGEMP Then VitalType = Vitals.MP increment = False End If DidCast = True For I = 1 To Player_HighIndex If IsPlaying(I) Then If GetPlayerMap(I) = GetPlayerMap(index) Then If isInRange(AoE, x, y, GetPlayerX(I), GetPlayerY(I)) Then SpellPlayer_Effect VitalType, increment, I, Vital, spellnum End If End If End If Next For I = 1 To MAX_MAP_NPCS If MapNpc(mapNum).Npc(I).Num > 0 Then If MapNpc(mapNum).Npc(I).Vital(HP) > 0 Then If isInRange(AoE, x, y, MapNpc(mapNum).Npc(I).x, MapNpc(mapNum).Npc(I).y) Then SpellNpc_Effect VitalType, increment, I, Vital, spellnum, mapNum End If End If End If Next End Select Case 2 ' targetted If targetType = 0 Then Exit Sub If target = 0 Then Exit Sub If targetType = TARGET_TYPE_PLAYER Then x = GetPlayerX(target) y = GetPlayerY(target) Else x = MapNpc(mapNum).Npc(target).x y = MapNpc(mapNum).Npc(target).y End If If Not isInRange(Range, GetPlayerX(index), GetPlayerY(index), x, y) Then PlayerMsg index, "Target not in range.", BrightRed SendClearSpellBuffer index Exit Sub End If Select Case Spell(spellnum).Type Case SPELL_TYPE_DAMAGEHP If targetType = TARGET_TYPE_PLAYER Then If CanPlayerAttackPlayer(index, target, True) Then If Vital > 0 Then SendAnimation mapNum, Spell(spellnum).SpellAnim, 0, 0, TARGET_TYPE_PLAYER, target PlayerAttackPlayer index, target, Vital, spellnum DidCast = True End If End If Else If CanPlayerAttackNpc(index, target, True) Then If Vital > 0 Then SendAnimation mapNum, Spell(spellnum).SpellAnim, 0, 0, TARGET_TYPE_NPC, target PlayerAttackNpc index, target, Vital, spellnum DidCast = True End If End If End If Case SPELL_TYPE_DAMAGEMP, SPELL_TYPE_HEALMP, SPELL_TYPE_HEALHP If Spell(spellnum).Type = SPELL_TYPE_DAMAGEMP Then VitalType = Vitals.MP increment = False DidCast = True ' <--- Fixed! ElseIf Spell(spellnum).Type = SPELL_TYPE_HEALMP Then VitalType = Vitals.MP increment = True DidCast = True ' <--- Fixed! ElseIf Spell(spellnum).Type = SPELL_TYPE_HEALHP Then VitalType = Vitals.HP increment = True DidCast = True ' <--- Fixed! End If If targetType = TARGET_TYPE_PLAYER Then If Spell(spellnum).Type = SPELL_TYPE_DAMAGEMP Then If CanPlayerAttackPlayer(index, target, True) Then SpellPlayer_Effect VitalType, increment, target, Vital, spellnum End If Else SpellPlayer_Effect VitalType, increment, target, Vital, spellnum End If Else If Spell(spellnum).Type = SPELL_TYPE_DAMAGEMP Then If CanPlayerAttackNpc(index, target, True) Then SpellNpc_Effect VitalType, increment, target, Vital, spellnum, mapNum End If Else SpellNpc_Effect VitalType, increment, target, Vital, spellnum, mapNum End If End If End Select End Select If DidCast Then Call SetPlayerVital(index, Vitals.MP, GetPlayerVital(index, Vitals.MP) - MPCost) Call SendVital(index, Vitals.MP) ' send vitals to party if in one If TempPlayer(index).inParty > 0 Then SendPartyVitals TempPlayer(index).inParty, index TempPlayer(index).SpellCD(spellslot) = GetTickCount + (Spell(spellnum).CDTime * 1000) Call SendCooldown(index, spellslot) SendActionMsg mapNum, Trim$(Spell(spellnum).Name) & "!", BrightRed, ACTIONMSG_SCROLL, GetPlayerX(index) * 32, GetPlayerY(index) * 32 End IfEnd Sub ```Now for those with custom calculations in it, the problem lies in the following:```If Spell(spellnum).Type = SPELL_TYPE_DAMAGEMP Then VitalType = Vitals.MP increment = False DidCast = True ' <--- Fixed! ElseIf Spell(spellnum).Type = SPELL_TYPE_HEALMP Then VitalType = Vitals.MP increment = True DidCast = True ' <--- Fixed! ElseIf Spell(spellnum).Type = SPELL_TYPE_HEALHP Then VitalType = Vitals.HP increment = True DidCast = True ' <--- Fixed! End If```By default the lines commented with ' <–- Fixed! are not in the source, meaning that these spells will NEVER reach the bottom of the sub properly where the MP gets substracted and the cooldown gets initiated.. Adding those three lines will fix this issue. :) Link to comment Share on other sites More sharing options...
Markz88 Posted March 1, 2011 Share Posted March 1, 2011 Case SPELL_TYPE_DAMAGEHP DidCast = True For I = 1 To Player_HighIndex If IsPlaying(I) Then If I <> index Then If GetPlayerMap(I) = GetPlayerMap(index) Then If isInRange(AoE, x, y, GetPlayerX(I), GetPlayerY(I)) Then If CanPlayerAttackPlayer(index, I, True) Then SendAnimation mapNum, Spell(spellnum).SpellAnim, 0, 0, TARGET_TYPE_PLAYER, I PlayerAttackPlayer index, I, Vital, spellnum End If End If End If End If End If**Compile errorVariable not defined**' send vitals to party if in one If TempPlayer(index).InParty > 0 Then SendPartyVitals TempPlayer(index).InParty, index**Compile errorSub or Function not defined** Link to comment Share on other sites More sharing options...
Guest Posted March 1, 2011 Share Posted March 1, 2011 You need atleast EO 1.3.0, I think thats when HighIndexing was added. But, change Player_HighIndex to MAX_PLAYERS and it'll work the same way. Link to comment Share on other sites More sharing options...
Joyce Posted March 1, 2011 Author Share Posted March 1, 2011 I did mention it was for EO 2.0.. :) Link to comment Share on other sites More sharing options...
Guest Posted March 1, 2011 Share Posted March 1, 2011 Well.. It could work for anything 1.1.0 upwards. Just anything under needs to use MAX_PLAYERS instead of Player_HighIndex. Link to comment Share on other sites More sharing options...
Joyce Posted March 1, 2011 Author Share Posted March 1, 2011 I don't see why people would want to use those versions though, but hey. :) Anyways, the fix is written for 2.0.0, for any other version you'll need to port it over yourself. :) (Or use the second code snippet and manually edit it, rather then blatantly copy pastaing.) Link to comment Share on other sites More sharing options...
Guest Posted March 1, 2011 Share Posted March 1, 2011 Cause they started their game before 2.0.0 mebbe O_o? Link to comment Share on other sites More sharing options...
Robin Posted March 1, 2011 Share Posted March 1, 2011 @Sekaru:> Cause they started their game before 2.0.0 mebbe O_o?Then they're not going to have a fun time in the future. Link to comment Share on other sites More sharing options...
Guest Posted March 1, 2011 Share Posted March 1, 2011 Yup :/. Spending 3 hours porting stuff over and breaking your whole source by doing so is a drag :) Link to comment Share on other sites More sharing options...
Helladen Posted March 2, 2011 Share Posted March 2, 2011 Can you show us what you edited? Some of us can't just replace the entire sub like that… :P Link to comment Share on other sites More sharing options...
Joyce Posted March 2, 2011 Author Share Posted March 2, 2011 Look at the bottom code section and learn to read pl0x. Link to comment Share on other sites More sharing options...
Helladen Posted March 2, 2011 Share Posted March 2, 2011 I thought it said replace your entire sub earlier, weird… (I had fixed this months ago sorry for wasting your time. :P) Link to comment Share on other sites More sharing options...
Joyce Posted March 2, 2011 Author Share Posted March 2, 2011 It does, at the top.. For the easy fix. :P The other way would just take a few minutes longer. hehe 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