roguehippo Posted June 8, 2016 Share Posted June 8, 2016 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. 1 Quote Link to comment Share on other sites More sharing options...
Chris Posted June 8, 2016 Share Posted June 8, 2016 My player.isinteracting#NPC Quote Link to comment Share on other sites More sharing options...
Acerd Posted June 8, 2016 Share Posted June 8, 2016 getCombat().isFighting() Quote Link to comment Share on other sites More sharing options...
Strange_Fk Posted June 14, 2016 Share Posted June 14, 2016 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 Quote Link to comment Share on other sites More sharing options...
Acerd Posted June 14, 2016 Share Posted June 14, 2016 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() Quote Link to comment Share on other sites More sharing options...
Woody Posted June 14, 2016 Share Posted June 14, 2016 if myPlayer().getInteracting() != null --> player is interacting with someone (NPC, player) Quote Link to comment Share on other sites More sharing options...
Token Posted June 14, 2016 Share Posted June 14, 2016 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. 1 Quote Link to comment Share on other sites More sharing options...
roguehippo Posted June 14, 2016 Author Share Posted June 14, 2016 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! Quote Link to comment Share on other sites More sharing options...
xabdullahx Posted June 17, 2016 Share Posted June 17, 2016 As others mentioned: getCombat().isFighting() works great, even works for other types of combat than melee Quote Link to comment Share on other sites More sharing options...