whitevo
Feeling good, thats what I do.
This script checks if you are confronting the target (you are looking in the direction where is target creature)
In my server i wanted that you can't shoot projectiles while you are looking away from target or running away.
(makes a bit harder for paladins)
For some this script is a cake, but i struggled with this quite some time and only thanks to Ninja i was able to complete it.
I made this thread so other people will have an example how to call for x and y positions or simply would like to have same script.
this is script.lua
i changed my enchanted spear so this is why i chose these parameters.
If you want to make this a "global script" so it will choose parameters automatically.
I guess you would have to do huge for loop (i didn't feel like it, instead i'm using 10+slightly different scripts for each projectile)
function
don't forget to change your weapons.xml file
<distance id="7367" breakchance="0" unproperly="1" level="1" script="script.lua" />
In my server i wanted that you can't shoot projectiles while you are looking away from target or running away.
(makes a bit harder for paladins)
For some this script is a cake, but i struggled with this quite some time and only thanks to Ninja i was able to complete it.
I made this thread so other people will have an example how to call for x and y positions or simply would like to have same script.
this is script.lua
i changed my enchanted spear so this is why i chose these parameters.
If you want to make this a "global script" so it will choose parameters automatically.
I guess you would have to do huge for loop (i didn't feel like it, instead i'm using 10+slightly different scripts for each projectile)
Code:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_BLOCKARMOR, 1)
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
combat:setParameter(COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_ENCHANTEDSPEAR)
combat:setFormula(COMBAT_FORMULA_SKILL, 1, 1, 1.0, 1)
Code:
function onUseWeapon(cid, var)
local player = Player(cid)
local target = player:getTarget()
if not target then
return false
end
local targetPos = player:getTarget():getPosition()
local playerPos = player:getPosition()
local CreatureXpos = targetPos.x
local CreatureYpos = targetPos.y
local PlayerXpos = playerPos.x
local PlayerYpos = playerPos.y
local PlayerDir = player:getDirection()
local shoot = true
if PlayerDir == 0 then
if PlayerYpos <= CreatureYpos then
shoot = false
end
elseif PlayerDir == 1 then
if PlayerXpos >= CreatureXpos then
shoot = false
end
elseif PlayerDir == 2 then
if PlayerYpos >= CreatureYpos then
shoot = false
end
elseif PlayerDir == 3 then
if PlayerXpos <= CreatureXpos then
shoot = false
end
end
if shoot then
return combat:execute(cid, var)
end
return false
end
don't forget to change your weapons.xml file
<distance id="7367" breakchance="0" unproperly="1" level="1" script="script.lua" />