- Joined
- Nov 17, 2010
- Messages
- 6,832
- Solutions
- 586
- Reaction score
- 5,414
Untested, but this would replace the default way of sending area effects, via the combat system
So instead of this..
You would just do this
Below is some green text explanation, and the function.
Let me know if you test it out.
put into
So instead of this..
Lua:
local gfbEffect = Combat()
gfbEffect:setArea(createCombatArea(AREA_CIRCLE3X3))
local positions = gfbEffect:getPositions(0, {
type = 2, -- # VARIANT_POSITION
pos = player:getPosition()
})
for i = 1, #positions do
positions[i]:sendMagicEffect(11)
end
Lua:
sendAreaEffect(player:getPosition(), AREA_CIRCLE3X3, 11)
Below is some green text explanation, and the function.
Let me know if you test it out.
Lua:
--[[
-> centrePosition = centre of area
Example;
Position(1000, 1000, 7)
-> effectTable = determines area. Modular. Must be uniform rectangle
Example;
AREA_WAVE3 = {
{1, 1, 1},
{1, 1, 1},
{0, 3, 0}
}
3 = centre + effect
2 = centre
1 = effect
0 = no effect
-> magicEffect = effect to use
Example;
CONST_ME_POFF
-> direction = direction of spell (assumes effectTable is north) (rotates spell on x/y plane)
Example;
DIRECTION_NORTH or 0
DIRECTION_EAST or 1
DIRECTION_SOUTH or 2
DIRECTION_WEST or 3
--]]
Lua:
--[[
Example Usage;
local AREA_WAVE3 = {
{1, 1, 1},
{1, 1, 1},
{0, 3, 0}
}
sendAreaEffect(Position(1000, 1000, 7), AREA_WAVE3, CONST_ME_POFF) -- direction omitted, defaults north
sendAreaEffect(Position(1000, 1000, 7), AREA_WAVE3, CONST_ME_POFF, 1) -- south (mirror/rotate 180 degree)
sendAreaEffect(Position(1000, 1000, 7), AREA_WAVE3, CONST_ME_POFF, DIRECTION_EAST) -- east (rotate 90 degree clockwise)
]]--
data/lib
as a custom function
Lua:
function sendAreaEffect(centrePosition, effectTable, magicEffect, direction)
local centre = 0
local length = #effectTable -- north/south (amount of arrays in main array)
local width = #effectTable[1] -- west/east (amount of items in each array)
for _length = 1, length do
if centre ~= 0 then
break
end
for _width = 1, do
if effectTable[_length][_width] > 1 then
centre = {length = _length, width = _width}
break
end
end
end
if centre == 0 then
print("Lua Error: no centre found for effectTable. (3 = centre + effect | 2 = centre | 1 = effect | 0 = no effect)")
return
end
local x_offset = length - centre.length -- 0
local y_offset = width - centre.width -- 1
if not Position(centrePosition) then -- Idk if this works or not. Would have to test lol
print("Lua Error: a valid position was not used.")
return
end
for _length = 1, length do
for _width = 1, width do
if effectTable[_length][_width] == 1 or effectTable[_length][_width] == 3 then
local effectPosition = Position(centrePosition.x + ((_width - width) + x_offset), centrePosition.y + ((_length - length) + y_offset), centrePosition.z)
if direction then
if direction == DIRECTION_NORTH then
-- do nothing
elseif direction == DIRECTION_SOUTH then
effectPosition = Position(effectPosition.x * -1, effectPosition.y * -1, effectPosition.z)
elseif direction == DIRECTION_EAST then
effectPosition = Position(effectPosition.y, effectPosition.x * -1, effectPosition.z)
elseif direction == DIRECTION_WEST then
effectPosition = Position(effectPosition.y * -1, effectPosition.x, effectPosition.z)
else
print("Lua Error: not a valid direction. use 0,1,2,3 or DIRECTION_SOUTH / WEST / EAST / NORTH")
return
end
end
effectPosition:sendMagicEffect(magicEffect)
end
end
end
end