Log in

View Full Version : Player attack alarm go to label



brenimlele
12-09-2016, 11:44 PM
Hi, i need help

Some script for go to label "Pk" if active player attack alarm?

thanks

Dendem
12-10-2016, 09:02 PM
registerEventListener(WALKER_SELECTLABEL, "onWalkerSelectLabel")
isFleeing = false

function onWalkerSelectLabel(labelName)
if (labelName == "endPk") then
Walker.Stop()
isFleeing=false
-- PUT CODE FOR WHAT TO DO WHEN REACH THE END
end

end


function flee(playername)
if(not isFleeing)then
isFleeing = true
Targeting.Stop()
Walker.Start()
gotoLabel("Pk")

end
end

function messageProxyCallback(proxy, message)
damage, creature = string.match(message, 'You lose (%d+) %a+ due to an attack by (.+).')
if Creature.New(creature):isPlayer() then
flee(creature)
end
end

function checkPK()
if(not isFleeing)then
BattleMessageProxy.OnReceive("BattleMessageProxy", messageProxyCallback)
end
end
checkPK()

This is the code I made,
when you have been attacked by a player, it will go to the label "Pk" (even if the walker is stoped) - keep in mind that it will activated whenever you have been attacked by a player - even if is not a Pk attack.

When you reach the label "endPk" it will stop the walker.
It is important to have the "Pk" label and the "endPk" label. So the algorithm knows when you are "fleeing", so, while you're fleeing, it will not trigger the "Pk" label again - if you have more then 1 waypoint below the "Pk" label, it will prevent you to back to the first waypoint on another attack.

That's it
(:

brenimlele
12-11-2016, 02:37 AM
Man, i need edit "function flee(playername)" ?

thanks