• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

making a spell with multiple effects only hit once?

Ahilphino

Excellent OT User
Joined
Jun 5, 2013
Messages
1,667
Solutions
1
Reaction score
734
alright so let's assume i have a spell similiar to this
TDdEtA_l6.gif

now this is just some random spell i did with spellcreator for this thread so the script isn't that important I just want some advice on how I can get it to work as I want

right now it would deal insane damage if it hit all of the explosions on the target, but I want to make it so that if the spell has already hit the target once, and it gets hits by another explosion it won't deal any damage to the target again.

I was wondering what would be the best way to achieve this? I guess I could set some kind of storagevalue on the target using ostime but would it then work on monsters, and if two players used the spell it would cause some problems too I guess. Any better ideas on how to do this?
 
I was wondering what would be the best way to achieve this? I guess I could set some kind of storagevalue on the target using ostime but would it then work on monsters, and if two players used the spell it would cause some problems too I guess. Any better ideas on how to do this?
instead of player storage values, use global storage values for the spell itself where keys are player ID's who cast the spell and table has values of player ID's who it hits.
There is no better way imo.

EDIT: clear the table with addEvent()
 
alright so let's assume i have a spell similiar to this

now this is just some random spell i did with spellcreator for this thread so the script isn't that important I just want some advice on how I can get it to work as I want

right now it would deal insane damage if it hit all of the explosions on the target, but I want to make it so that if the spell has already hit the target once, and it gets hits by another explosion it won't deal any damage to the target again.

I was wondering what would be the best way to achieve this? I guess I could set some kind of storagevalue on the target using ostime but would it then work on monsters, and if two players used the spell it would cause some problems too I guess. Any better ideas on how to do this?

1 word... well 2 words mashed together :p
hasCondition
 
Yeah I was thinking maybe I could use condition:getSubId() and the subid could be the attackers playerID? or something since thats a number right?
or could I just use hascondition? :eek:
 
Yeah I was thinking maybe I could use condition:getSubId() and the subid could be the attackers playerID? or something since thats a number right?
or could I just use hascondition? :eek:
but this way you still making it so that if 1 player hits with spell then the other player same spell damage will be ignored..

Code:
local spellMap = {}

function yourSpellFunctionWhatDealsDamage(player, target)
local cid = player:getId()
   
    if checkSpellMap(cid, target) then return true end
    -- rest of your spell
end

function checkSpellMap(cid, target)
local targetID = target:getId()
    if spellMap[cid] then
        for i, map in pairs(spellMap[cid]) do
            if isInArray(map, targetID) then
                return true
            end
        end
        table.insert(spellMap[cid], targetID)
    end
    spellMap[cid] = {targetID}
end
 
Last edited by a moderator:
Code:
local spellMap = {}

function yourSpellFunctionWhatDealsDamage(player, target)
local cid = player:getId()
  
    if checkSpellMap(cid, target) then return true end
    -- rest of your spell
end

function checkSpellMap(cid, target)
local targetID = target:getId()
    if spellMap[cid] then
        for i, map in pairs(spellMap[cid]) do
            if isInArray(map, targetID) then
                return true
            end
        end
        table.insert(spellMap[cid], targetID)
    end
    spellMap[cid] = {targetID}
end

looks good doode ill try this later
 
Okay, i'll be the one to put it out there. Why make it so that the rest of the spell is even a damagespell? Just have it as a sendMagicEffect and you'll need no storages no nothing
 
Okay, i'll be the one to put it out there. Why make it so that the rest of the spell is even a damagespell? Just have it as a sendMagicEffect and you'll need no storages no nothing
because he wants custom spell what has several chances to hit?
 
Okay, i'll be the one to put it out there. Why make it so that the rest of the spell is even a damagespell? Just have it as a sendMagicEffect and you'll need no storages no nothing
I could do that but that is much more lame and wouldn't be sexy with the spells I have in mind, also I could configure it so each time the spell hits it for example does half of it's damage and more cool stuff

still haven't tried whitevo's solution but hopefully i can do it today :)
 
I could do that but that is much more lame and wouldn't be sexy with the spells I have in mind, also I could configure it so each time the spell hits it for example does half of it's damage and more cool stuff

still haven't tried whitevo's solution but hopefully i can do it today :)
I really don't understand what you mean by that it wouldn't be "sexy". Because for the player it would look in the exact same way using a spell with no damage and just normal magic effects
 
I really don't understand what you mean by that it wouldn't be "sexy". Because for the player it would look in the exact same way using a spell with no damage and just normal magic effects
it looks the same but doesn't work the same.
 
it looks the same but doesn't work the same.
Yeah that's true. Might be that i have completely misunderstood the request here and if so i apologize for that. But isn't the whole point of this thread having, lets say for example 5 different effects on a spell but only the first one actually dealing damage? if so wouldn't it be easiest to just do

doCombat(spellstuff)
doSendMagicEffectArea(effectstuff)
 
Yeah that's true. Might be that i have completely misunderstood the request here and if so i apologize for that. But isn't the whole point of this thread having, lets say for example 5 different effects on a spell but only the first one actually dealing damage? if so wouldn't it be easiest to just do

doCombat(spellstuff)
doSendMagicEffectArea(effectstuff)

Nah , he wants the spell to be AoE with multiple AoE combats, but if a single one of them deals damage to a person, the spell can not deal damage again to the same person during its execution.

EDIT: I agree, what whitevo suggested would probably the most efficient way of doing it.
 
Nah , he wants the spell to be AoE with multiple AoE combats, but if a single one of them deals damage to a person, the spell can not deal damage again to the same person during its execution.

EDIT: I agree, what whitevo suggested would probably the most efficient way of doing it.
Oooh, my bad then. Guess i got lost somewhere on the road, then yeah whiteevo's solution should be the right approach
 
Back
Top