Aled
Active Member (probably)
- Joined
- Mar 30, 2017
- Messages
- 215
- Solutions
- 17
- Reaction score
- 130
Just a little fun:
Monster picks up item from ground and throws it at the player.
Put
in the monster xml
and in creaturescripts.xml
and in rockthrow.lua
Nice little function itemnear in there too
Can be done with any item but rock works well cause there is an appropriate distance effect and they cannot be removed from the hunting ground. For the same reason it is very abusable because you cannot walk over them so players can effectively make their own physical walls.
Have fun!
Monster picks up item from ground and throws it at the player.
Put
XML:
<script>
<event name="rockthrow"/>
</script>
and in creaturescripts.xml
XML:
<event type="think" name="rockthrow" script="rockthrow.lua" />
Lua:
local rockid = 1285
function itemnear(pos,itemid)
local tiles
local n = 1
for i=-1,1 do
for j=-1,1 do
tile = Tile(pos.x+i,pos.y+j,pos.z)
n=n+1
local item = tile:getItemById(itemid) or false
if item then
return item
end
end
end
return false
end
function onThink(cid, interval)
local rock = itemnear(cid:getPosition(),rockid)
local target = cid:getTarget()
if rock and target and not hasrock then
local pos = cid:getPosition()
rock:remove()
local hasrock = true
addEvent(function()
if cid:getTarget() then
cid:getPosition():sendDistanceEffect(cid:getTarget():getPosition(), CONST_ANI_LARGEROCK)
doTargetCombatHealth(cid, cid:getTarget(), COMBAT_PHYSICALDAMAGE, -10, -70, CONST_ME_DRAWBLOOD)
Game.createItem(rockid,1,target:getPosition())
else
Game.createItem(rockid,1,cid:getPosition())
end
end,math.random(100,2000))
end
end
Can be done with any item but rock works well cause there is an appropriate distance effect and they cannot be removed from the hunting ground. For the same reason it is very abusable because you cannot walk over them so players can effectively make their own physical walls.
Have fun!