June 8, 20169 yr I was just wondering if there was a better way to detect if i am in combat because when using if(myPlayer().isincombat) it will detect it most of the time but if i am not getting attacked ,like if i was in a safe spot, than it doest really work that well.
June 14, 20169 yr I was just wondering if there was a better way to detect if i am in combat because when using if(myPlayer().isincombat) it will detect it most of the time but if i am not getting attacked ,like if i was in a safe spot, than it doest really work that well. If you found out could you PM me or comment back on this post ? Would be much appreciated, I'm having the same problem and have been trying to fix it all together for awhile now
June 14, 20169 yr If you found out could you PM me or comment back on this post ? Would be much appreciated, I'm having the same problem and have been trying to fix it all together for awhile now getCombat().isFighting()
June 14, 20169 yr if myPlayer().getInteracting() != null --> player is interacting with someone (NPC, player)
June 14, 20169 yr I usually spam the Scripting Help topics faster than this, the isUnderAttack() and isFighting() methods are a bit vague in my opinion and they aren't exacly what scripters expect, same for getInteracting() as when you stop interacting you are still in combat. There is, however, a more reliable method, namely Character#getCombatTime(). You will have to work with client cycles instead of raw time and instead verify for a given diference in client cycles since last hitsplat which determines if a given Character (don't forget Player extends Character, not only NPC). I know this works for ranged and melee which always yield a hitsplat onhit therefore updating the combat time of that Character instance. For magic however (range too if you want maximum accuracy), you can rely on the Projectiles class. If a projectile is sent from a Character, means that Character is definately attacking someone and their target is locked in combat.
June 14, 20169 yr Author I usually spam the Scripting Help topics faster than this, the isUnderAttack() and isFighting() methods are a bit vague in my opinion and they aren't exacly what scripters expect, same for getInteracting() as when you stop interacting you are still in combat. There is, however, a more reliable method, namely Character#getCombatTime(). You will have to work with client cycles instead of raw time and instead verify for a given diference in client cycles since last hitsplat which determines if a given Character (don't forget Player extends Character, not only NPC). I know this works for ranged and melee which always yield a hitsplat onhit therefore updating the combat time of that Character instance. For magic however (range too if you want maximum accuracy), you can rely on the Projectiles class. If a projectile is sent from a Character, means that Character is definately attacking someone and their target is locked in combat. i will definitely look into the more in depth way instead of just using underattack as you are right they are a bit vague. thanks for the responce, hopefully i can make my script as perfect as possible for the community!
June 17, 20169 yr As others mentioned: getCombat().isFighting() works great, even works for other types of combat than melee
Create an account or sign in to comment