Hello,
well i may make the full game event later. But here is football code:
Go to movements and add this in the movements.xml
Now go into movements/scripts and create lua and name it: football.lua and paste this:
Now go to talkactions and add this in talkactions.xml
Now in talkactions/scripts and create lua and name it: football.lua and paste this:
Here is the lib:
Commands:
well i may make the full game event later. But here is football code:
Go to movements and add this in the movements.xml
Code:
<movevent event="StepIn" itemid="2109" script="football.lua" />
Now go into movements/scripts and create lua and name it: football.lua and paste this:
Code:
function onStepIn(creature, item, position, fromPosition)
local player = creature:getPlayer()
if player == nil then
return true
end
local nextPosition = player:getPosition()
nextPosition:getNextPosition(player:getDirection())
if nextPosition:isWalkable(false) then
position:sendMagicEffect(CONST_ME_POFF)
item:moveTo(nextPosition)
end
return true
end
Now go to talkactions and add this in talkactions.xml
Code:
<talkaction words="!football" separator=" " script="football.lua" />
Now in talkactions/scripts and create lua and name it: football.lua and paste this:
Code:
function onTargetTile(creature, position)
local tile = Tile(position)
if not tile then
return false
end
local football = tile:getItemById(2109)
if football then
local playerPosition, footballPosition = creature:getPosition(), football:getPosition()
playerPosition:sendDistanceEffect(footballPosition, CONST_ANI_WHIRLWINDCLUB)
footballPosition:sendMagicEffect(CONST_ME_HITAREA)
local distance = playerPosition:getDistance(footballPosition)
local nextPosition = footballPosition
for i = 1, (6 - distance) do
nextPosition:getNextPosition(creature:getDirection())
if nextPosition:isWalkable(false) then
football:moveTo(nextPosition)
else
break
end
end
creature:say("POWER SHOOT!", TALKTYPE_MONSTER_SAY)
end
end
local powerShoot = Combat()
powerShoot:setCallback(CALLBACK_PARAM_TARGETTILE, "onTargetTile")
powerShoot:setArea(createCombatArea(AREA_SHOOTRANGE, AREADIAGONAL_SHOOTRANGE))
function onSay(player, words, param)
local position = player:getPosition()
position:getNextPosition(player:getDirection())
if param == "shoot" then
local tile = Tile(position)
if not tile then
return false
end
local football = tile:getItemById(2109)
if football then
position:sendMagicEffect(CONST_ME_GROUNDSHAKER)
for i = 1, 3 do
position:getNextPosition(player:getDirection())
if position:isWalkable(true) then
football:moveTo(position)
else
break
end
end
player:say("SHOOT!", TALKTYPE_MONSTER_SAY)
end
elseif param == "powershoot" then
powerShoot:execute(player, positionToVariant(position))
end
return false
end
Here is the lib:
Code:
AREA_SHOOTRANGE = {
{1},
{1},
{1},
{3}
}
AREADIAGONAL_SHOOTRANGE = {
{0, 1, 0, 0, 0},
{0, 0, 1, 0, 0},
{0, 0, 0, 1, 0},
{0, 0, 0, 0, 3}
}
function Position.isWalkable(position, playerBlock)
local tile = Tile(position)
if not tile then
return false
end
if playerBlock and tile:getCreatureCount() ~= 0 then
return false
end
local ground = tile:getGround()
if not ground or ground:hasProperty(CONST_PROP_BLOCKSOLID) then
return false
end
local items = tile:getItems()
for i = 1, tile:getItemCount() do
local item = items[i]
local itemType = item:getType()
if itemType:getType() ~= ITEM_TYPE_MAGICFIELD and not itemType:isMovable() and item:hasProperty(CONST_PROP_BLOCKSOLID) then
return false
end
end
return true
end
Commands:
Code:
!football shoot
!football powershoot
Last edited: