From 45f2e02bd92ecbb0dca7fe106e2db20f8418b739 Mon Sep 17 00:00:00 2001 From: Lutz Date: Wed, 16 Aug 2017 17:10:33 -0500 Subject: [PATCH 1/3] - Removed checks in 'castSpell()' to determine if Caster is swimming --- src/magic/castSpell.cpp | 43 ----------------------------------------- 1 file changed, 43 deletions(-) diff --git a/src/magic/castSpell.cpp b/src/magic/castSpell.cpp index 301aa48e2..1dac6862e 100644 --- a/src/magic/castSpell.cpp +++ b/src/magic/castSpell.cpp @@ -261,49 +261,6 @@ Entity* castSpell(Uint32 caster_uid, spell_t* spell, bool using_magicstaff, bool } } - //Check if the bugger is levitating. - bool levitating = false; - if (!trap) - { - levitating = isLevitating(stat); - } - - //Water walking boots - bool waterwalkingboots = false; - if (!trap) - { - if (stat->shoes != NULL) - if (stat->shoes->type == IRON_BOOTS_WATERWALKING ) - { - waterwalkingboots = true; - } - } - - node_t* node2; //For traversing the map looking for...liquids? - //Check if swimming. - if (!waterwalkingboots && !levitating && !trap && player >= 0) - { - bool swimming = false; - if (players[player] && players[player]->entity) - { - int x = std::min(std::max(0, floor(caster->x / 16)), map.width - 1); - int y = std::min(std::max(0, floor(caster->y / 16)), map.height - 1); - if (animatedtiles[map.tiles[y * MAPLAYERS + x * MAPLAYERS * map.height]]) - { - swimming = true; - } - } - if (swimming) - { - //Can't cast spells while swimming if not levitating or water walking. - if (player >= 0) - { - messagePlayer(player, language[410]); - } - return nullptr; - } - } - //Right. First, grab the root element, which is what determines the delivery system. //spellElement_t *element = (spellElement_t *)spell->elements->first->element; spellElement_t* element = (spellElement_t*)node->element; From a743525040996868ea949fc659db648a2bedb986 Mon Sep 17 00:00:00 2001 From: Lutz Date: Wed, 16 Aug 2017 17:12:50 -0500 Subject: [PATCH 2/3] + Added checks in 'castSpellInit()' to determine if Caster is swimming --- src/magic/castSpell.cpp | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/src/magic/castSpell.cpp b/src/magic/castSpell.cpp index 1dac6862e..aaddb245d 100644 --- a/src/magic/castSpell.cpp +++ b/src/magic/castSpell.cpp @@ -110,6 +110,39 @@ void castSpellInit(Uint32 caster_uid, spell_t* spell) return; } + // Check to make sure the Caster is not swimming + // If the Caster is not a Magic Trap, they could potentially be in a water tile + // TODO: Currently only Players can swim, this must be expanded if that changes (caster->behavior != &actMagicTrap) + if ( player >= 0 ) // TODOR: Bad check, ambiguious + { + bool bIsCasterLevitating = isLevitating(stat); // If levitating, they can cast + bool bIsCasterWaterWalking = false; // If water walking, they can cast + + if ( stat->shoes != nullptr ) + { + if ( stat->shoes->type == IRON_BOOTS_WATERWALKING ) + { + bIsCasterWaterWalking = true; + } + } + + // If both cases are false, the Caster could potentially be swimming + if ( bIsCasterLevitating != true && bIsCasterWaterWalking != true ) + { + if ( players[player] && players[player]->entity ) + { + int x = std::min(std::max(0, floor(caster->x / 16)), map.width - 1); + int y = std::min(std::max(0, floor(caster->y / 16)), map.height - 1); + if ( animatedtiles[map.tiles[y * MAPLAYERS + x * MAPLAYERS * map.height]] ) + { + // The Caster is in a water tile, so must be swimming + messagePlayer(player, language[410]); // "Cannot cast spells while swimming!" + return; + } + } + } + } + if ( stat->EFFECTS[EFF_PARALYZED] ) { return; From 9f7fc7d603ee8362c0300ed2639059dc3c13284a Mon Sep 17 00:00:00 2001 From: Lutz Date: Wed, 16 Aug 2017 18:15:26 -0500 Subject: [PATCH 3/3] + Added checks in 'castSpell()' to determine if Caster is swimming, before deducting mana --- src/magic/castSpell.cpp | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/src/magic/castSpell.cpp b/src/magic/castSpell.cpp index aaddb245d..e488640b4 100644 --- a/src/magic/castSpell.cpp +++ b/src/magic/castSpell.cpp @@ -237,6 +237,39 @@ Entity* castSpell(Uint32 caster_uid, spell_t* spell, bool using_magicstaff, bool } } + // Check to make sure the Caster did not start swimming after starting the cast + // If the Caster is not a Magic Trap, they could potentially be in a water tile + // TODO: Currently only Players can swim, this must be expanded if that changes (caster->behavior != &actMagicTrap) + if ( player >= 0 ) // TODOR: Bad check, ambiguious + { + bool bIsCasterLevitating = isLevitating(stat); // If levitating, they can cast + bool bIsCasterWaterWalking = false; // If water walking, they can cast + + if ( stat->shoes != nullptr ) + { + if ( stat->shoes->type == IRON_BOOTS_WATERWALKING ) + { + bIsCasterWaterWalking = true; + } + } + + // If both cases are false, the Caster could potentially be swimming + if ( bIsCasterLevitating != true && bIsCasterWaterWalking != true ) + { + if ( players[player] && players[player]->entity ) + { + int x = std::min(std::max(0, floor(caster->x / 16)), map.width - 1); + int y = std::min(std::max(0, floor(caster->y / 16)), map.height - 1); + if ( animatedtiles[map.tiles[y * MAPLAYERS + x * MAPLAYERS * map.height]] ) + { + // The Caster is in a water tile, so must be swimming + messagePlayer(player, language[410]); // "Cannot cast spells while swimming!" + return nullptr; + } + } + } + } + bool newbie = false; if ( !using_magicstaff && !trap) {