• 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!

Action Elemental Powers

aioriusox

New Member
Joined
Apr 8, 2009
Messages
70
Reaction score
0
Elemental Powers

name: Elemental powers
version: 8.4x
type of script: Action
tested server: The forgotten server 0.3.3
author: Pivigu

When one of the elemental powers is used, the player is surrounded by effects, and who are near and fall on purpose, take damage.
The damage is related to the level and magic level of the player who used the elemental power.​

Add in Actions.xml
PHP:
<action itemid="2177" script="elemental power.lua"/>
    <action itemid="5809" script="elemental power.lua"/>
    <action itemid="2176" script="elemental power.lua"/>
    <action itemid="2141" script="elemental power.lua"/>

add in data/actions/scripts

elemental power.lua

PHP:
- Summary
- When the character using the script, will show different effects
- Around him and the monsters or players who are
- The damage will take place on the level and magic level.
- End

local conf = {
chance = 35,
damageOnlyInMonsters = FALSE,
dano = {gelo = 5, fogo = 5, terra = 6, energia = 6, min = 10, max = 0},
ids = {gelo = 2177, fogo = 2141, terra = 2176, energia = 5809},
radius = {gelo = 3, fogo = 3, terra = 4, energia = 4},
intervalo = {gelo = 1, fogo = 1, terra = 1.5, energia = 1.5},
quantidade = {gelo = 5, fogo = 5, terra = 3, energia = 3},
effect = {gelo = CONST_ME_GIANTICE, fogo = CONST_ME_FIREWORK_RED, terra = CONST_ME_BIGPLANTS, energia = CONST_ME_ENERGYAREA},
shot = {gelo = CONST_ANI_ICE, fogo = CONST_ANI_FIRE, terra = CONST_ANI_POISON, energia = CONST_ANI_ENERGYBALL},
color = {gelo = TEXTCOLOR_LIGHTBLUE, fogo = TEXTCOLOR_RED, terra = TEXTCOLOR_GREEN, energia = TEXTCOLOR_BLUE},
mana = {gelo = 100, fogo = 100, terra = 80, energia = 80},
soul = {gelo = 10, fogo = 10, terra = 8, energia = 8},
}


function onUse(cid, item, pos, toPos)
  if getPlayerStorageValue(cid, 34805) > 0 then
    return FALSE
  end
  if item.itemid == conf.ids.gelo then
    if (getPlayerMana(cid) < conf.mana.gelo or getPlayerSoul(cid) < conf.soul.gelo) and getPlayerAccess(cid) < 3 then
      doPlayerSendCancel(cid, "You have no need to use the elemental power.")
      return FALSE
    end
    doRemoveItem(item.uid, 1)
    doCreatureAddMana(cid, conf.mana.gelo * (-1))
    doPlayerAddSoul(cid, conf.soul.gelo * (-1))
    doAddDamageRadius(cid, 1, conf.radius.gelo, conf.shot.gelo, conf.effect.gelo, conf.color.gelo, conf.dano.gelo, conf.intervalo.gelo, conf.quantidade.gelo)
  end
  
  if item.itemid == conf.ids.energia then
    if (getPlayerMana(cid) < conf.mana.energia or getPlayerSoul(cid) < conf.soul.energia) and getPlayerAccess(cid) < 3 then
      doPlayerSendCancel(cid, "You have no need to use the elemental power.")
      return FALSE
    end
    doRemoveItem(item.uid, 1)
    doCreatureAddMana(cid, conf.mana.energia * (-1))
    doPlayerAddSoul(cid, conf.soul.energia * (-1))
    doAddDamageRadius(cid, 1, conf.radius.energia, conf.shot.energia, conf.effect.energia, conf.color.energia, conf.dano.energia, conf.intervalo.energia, conf.quantidade.energia)
  end
  
  if item.itemid == conf.ids.terra then
    if (getPlayerMana(cid) < conf.mana.terra or getPlayerSoul(cid) < conf.soul.terra) and getPlayerAccess(cid) < 3 then
      doPlayerSendCancel(cid, "You have no need to use the elemental power.")
      return FALSE
    end
    doRemoveItem(item.uid, 1)
    doCreatureAddMana(cid, conf.mana.terra * (-1))
    doPlayerAddSoul(cid, conf.soul.terra * (-1))
    doAddDamageRadius(cid, 1, conf.radius.terra, conf.shot.terra, conf.effect.terra, conf.color.terra, conf.dano.terra, conf.intervalo.terra, conf.quantidade.terra)
  end

  if item.itemid == conf.ids.fogo then
    if (getPlayerMana(cid) < conf.mana.fogo or getPlayerSoul(cid) < conf.soul.fogo) and getPlayerAccess(cid) < 3 then
      doPlayerSendCancel(cid, "You have no need to use the elemental power.")
      return FALSE
    end
    doRemoveItem(item.uid, 1)
    doCreatureAddMana(cid, conf.mana.fogo * (-1))
    doPlayerAddSoul(cid, conf.soul.fogo * (-1))
    doAddDamageRadius(cid, 1, conf.radius.fogo, conf.shot.fogo, conf.effect.fogo, conf.color.fogo, conf.dano.fogo, conf.intervalo.fogo, conf.quantidade.fogo)
  end
  
return TRUE
end




function doAddDamageRadius(cid, type, radius, shot, effect, color, danoD, intervalo, quantidade)
if getTilePzInfo(getThingPos(cid)) == TRUE then
  setPlayerStorageValue(cid, 34805, 0)
  return FALSE
end
setPlayerStorageValue(cid, 34805, 1)


pos = {from = {x=getThingPos(cid).x-radius, y=getThingPos(cid).y-radius, z=getThingPos(cid).z, stackpos = 1}, to = {x=getThingPos(cid).x+radius, y=getThingPos(cid).y+radius, z=getThingPos(cid).z, stackpos = 1}}
local getCreature = getThingFromPos(pos.from)
local posNow = pos.from
local mlv = getPlayerMagLevel(cid)
local lvl = getPlayerLevel(cid)
local formula = math.floor(((mlv + 1) * 3 + (lvl + 1) * 2) * danoD * 0.01 + math.random(0,200))

for i = pos.from.x, pos.to.x do
  for n = pos.from.y, pos.to.y do
    if math.random(1,100) < conf.chance then
      if getThingFromPos(getThingPos(cid)).uid ~= cid then
        return FALSE
      end
      posNow = {x=i, y=n, z=pos.from.z, stackpos = 253}
      getCreature = getThingFromPos(posNow)
      formula = math.floor(((mlv + 1) * 3 + (lvl + 1) * 2) * danoD * 0.01 + math.random(0,200))
      if formula < conf.dano.min and conf.dano.min > 0 then
        formula = conf.dano.min
      elseif formula > conf.dano.max and conf.dano.max > 0 then
        formula = conf.dano.max
      end
      if (doTileQueryAdd(cid, posNow) == 1 or isCreature(getCreature.uid) == TRUE) and getTilePzInfo(posNow) == FALSE and isNpc(getCreature.uid) == FALSE then
        if formula > 0 then
          doSendDistanceShoot({x=posNow.x-10, y=posNow.y-10, z=posNow.z}, posNow, shot) 
          if isPlayer(getCreature.uid) == TRUE then
            if conf.damageOnlyInMonsters == FALSE then
              if getPlayerAccess(getCreature.uid) > 1 then
                doSendMagicEffect(posNow, CONST_ME_POFF)
              else
                doSendMagicEffect(posNow, effect)
                if isCreature(getCreature.uid) == TRUE and getCreature.uid ~= cid then
                  doCreatureAddHealth(getCreature.uid, formula * (-1)) 
                  doSendAnimatedText(posNow, formula, color) 
                end
              end
            end
          else
            doSendMagicEffect(posNow, effect)
            if isCreature(getCreature.uid) == TRUE and getCreature.uid ~= cid then
              doCreatureAddHealth(getCreature.uid, formula * (-1)) 
              doSendAnimatedText(posNow, formula, color) 
            end
          end
        else
          doSendMagicEffect(posNow, CONST_ME_POFF)
        end
      end
    end
  end
end


if quantidade > 1 then
  addEvent(doAddDamageRadius, intervalo * 1000, cid, type, radius, shot, effect, color, danoD, intervalo, quantidade-1)
else
  setPlayerStorageValue(cid, 34805, 0)
end

return TRUE
end
 
Last edited:
Its not that great, theres some bugs.

xlcffq.jpg


x2wh8w.jpg


Main bug is that if you use it in PZ, it destroys the item still.
 
wat. Why would u comment your own script XD

I don't get a shit from your explanation of how should it work tho ^_^^
 
Saw this script and it was interesting so I decided to rewrite it a little and I managed to reduce it by 33% and it does not destroy the item when in PZ:
Lua:
local cfg = {
chance = 35,
damageOnlyInMonsters = false,
min = 10,
max = 0
}
local elmnt = {
	[2177] = {d = 5, r = 3, int = 1, a = 5, e = CONST_ME_GIANTICE, s = CONST_ANI_ICE, c = TEXTCOLOR_LIGHTBLUE, m = 100, so = 10, n = "Ice"}, --Ice
	[2141] = {d = 5, r = 3, int = 1, a = 5, e = CONST_ME_FIREWORK_RED, s = CONST_ANI_FIRE, c = TEXTCOLOR_RED, m = 100, so = 10, n = "Fire"}, --Fire
	[2176] = {d = 6, r = 4, int = 1.5, a = 3, e = CONST_ME_BIGPLANTS, s = CONST_ANI_POISON, c = TEXTCOLOR_GREEN, m = 80, so = 8, n = "Earth"}, --Earth
	[5809] = {d = 6, r = 4, int = 1.5, a = 3, e = CONST_ME_ENERGYAREA, s = CONST_ANI_ENERGYBALL, c = TEXTCOLOR_BLUE, m = 80, so = 8, n = "Energy"}  --Energy
}
function onUse(cid, item, pos, toPos)
	local E = elmnt[item.itemid]
	if getPlayerStorageValue(cid, 34805) > 0 or getTileInfo(getCreaturePosition(cid)).pz == true then
		doPlayerSendCancel(cid, (getPlayerStorageValue(cid, 34805) > 0 and getTileInfo(getCreaturePosition(cid)).pz == true and "An element is already in use and you are in a Pz zone" or getTileInfo(getCreaturePosition(cid)).pz == true and "You are in PZ zone." or getPlayerStorageValue(cid, 34805) > 0 and "An element is in use." or ""))
		return false
	end
	if E then
		if (getPlayerMana(cid) < E.m or getPlayerSoul(cid) < E.so) and getPlayerAccess(cid) < 3 then
			doPlayerSendCancel(cid, "You have no need to use the "..E.n.." elemental power.")
		return false
		end
		doRemoveItem(item.uid, 1)
		doCreatureAddMana(cid, E.m * (-1))
		doPlayerAddSoul(cid, E.so * (-1))
		doAddDamageRadius(cid, 1, E.r, E.s, E.e, E.c, E.d, E.int, E.a)
	end  
return true
end
function doAddDamageRadius(cid, type, radius, shot, effect, color, damage, interval, amount)
	if getTilePzInfo(getThingPos(cid)) == TRUE then
		setPlayerStorageValue(cid, 34805, 0)
	return false
	end
	setPlayerStorageValue(cid, 34805, 1)
	local pos = {from = {x=getThingPos(cid).x-radius, y=getThingPos(cid).y-radius, z=getThingPos(cid).z, stackpos = 1}, to = {x=getThingPos(cid).x+radius, y=getThingPos(cid).y+radius, z=getThingPos(cid).z, stackpos = 1}}
	local getCreature = getThingFromPos(pos.from)
	local posNow = pos.from
	local mlv = getPlayerMagLevel(cid)
	local lvl = getPlayerLevel(cid)
	local formula = math.floor(((mlv + 1) * 3 + (lvl + 1) * 2) * damage * 0.01 + math.random(0,200))
	for i = pos.from.x, pos.to.x do
		for n = pos.from.y, pos.to.y do
			if math.random(1,100) < conf.chance then
				if getThingFromPos(getThingPos(cid)).uid ~= cid then
					return false
				end
				posNow = {x=i, y=n, z=pos.from.z, stackpos = 253}
				getCreature = getThingFromPos(posNow)
				formula = math.floor(((mlv + 1) * 3 + (lvl + 1) * 2) * damage * 0.01 + math.random(0,200))
				if formula < cfg.min and cfg.min > 0 then
					formula = cfg.min
				elseif formula > cfg.max and cfg.max > 0 then
					formula = cfg.max
				end
				if (doTileQueryAdd(cid, posNow) == 1 or isCreature(getCreature.uid) == true) and getTilePzInfo(posNow) == false and isNpc(getCreature.uid) == false then
					if formula > 0 then
						doSendDistanceShoot({x=posNow.x-10, y=posNow.y-10, z=posNow.z}, posNow, shot) 
						if isPlayer(getCreature.uid) == true then
							if cfg.damageOnlyInMonsters == false then
								if getPlayerAccess(getCreature.uid) > 1 then
									doSendMagicEffect(posNow, CONST_ME_POFF)
								else
									doSendMagicEffect(posNow, effect)
									if isCreature(getCreature.uid) == true and getCreature.uid ~= cid then
										doCreatureAddHealth(getCreature.uid, formula * (-1)) 
										doSendAnimatedText(posNow, formula, color) 
									end
								end
							end
						else
							doSendMagicEffect(posNow, effect)
							if isCreature(getCreature.uid) == true and getCreature.uid ~= cid then
								doCreatureAddHealth(getCreature.uid, formula * (-1)) 
								doSendAnimatedText(posNow, formula, color) 
							end
						end
					else
						doSendMagicEffect(posNow, CONST_ME_POFF)
					end
				end
			end
		end
	end
	if amount > 1 then
		addEvent(doAddDamageRadius, interval * 1000, cid, type, radius, shot, effect, color, damage, interval, amount-1)
	else
		setPlayerStorageValue(cid, 34805, 0)
	end

return true
end  --total lines before rewrite = 139, total lines after rewrite = 92, reduced by 33%
 
Last edited:
We know how to edit this script when i want use this effect for Spells?
 
Back
Top