Lineage 2 Tower Forum

Full Version: Which skill a User is casting ?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Is it possible to find out which skill a User is casting ?

The User data struct, does not seem to have a method which returns now_casting skill, just a bool IsUsingMagic()

What I want to achieve is making a function that waits until a skill is done, and
I thought the following way :

Code:
function CastAndWaitFinish( skill )
    UseSkillRaw(skill, false, false);
    while( GetMe():XXX() == skill ) do
        Sleep(5);
    end;
end;

Where XXX() returns the Skill ID a user is casting.
in plugins
    LUA Programming
function OnMagicSkillLaunched(user, target, skillId)
	--Event called when some npc/player/user casted magic skill on someone other. 
	--For AOE skills this event will be called for every target.
end;
 
function OnMagicSkillUse(user, target, skillId)
	--Event called when some npc/player/user start cast magic skill on someone other. 
end;

(01-15-2015 07:55 AM)TheQQmaster Wrote: [ -> ]in plugins
    LUA Programming
function OnMagicSkillLaunched(user, target, skillId)
	--Event called when some npc/player/user casted magic skill on someone other. 
	--For AOE skills this event will be called for every target.
end;
 
function OnMagicSkillUse(user, target, skillId)
	--Event called when some npc/player/user start cast magic skill on someone other. 
end;


Thanks but, is there any other way (eg. by iterating through the player list and checking each player)?
This is when a specific packet is received.
I see no use for that, really.

But onmagicskilluse is the best way you can do it, you don't need to check each player because onmagicskilluse checks the packet itself, which contains the data.

User, target, skillid, skillvl. You just need to put a filter inside the function to be called only when your requirements are met.
(01-15-2015 16:10 PM)Vinter Wrote: [ -> ]I see no use for that, really.

But onmagicskilluse is the best way you can do it, you don't need to check each player because onmagicskilluse checks the packet itself, which contains the data.

User, target, skillid, skillvl. You just need to put a filter inside the function to be called only when your requirements are met.

What I want to achieve is, a function that casts a skill and returns only after the skill has completed casting (or interrupted). Not like UseSkillRaw which casts the skill (in fire-and-forget fashion) and returns immediately. I do not like that I have to do Sleep(1000); for all skills when using UseSkillRaw (what if a skill takes more than that to complete cast, something possible with different kind of buffs). I want something that does that for me automatically.

And to account for both cases (casting completed success or interrupted) I thought the best way to do it is check if GetMe():IsCastingSkill( skill ) and loop around it (and even better, return false in case cast was not completed successfully AKA interrupt)

Maybe someone else has solved that problem and wants to share.

Thanks
OnMagicSkillLaunched calls when you finish casting a skill, unlike OnMagicSkillUse that calls when you start casting a skill.

You could always create a coroutine inside the plugin and use useskill instead of useskillraw.
Reference URL's