• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!
  • 2026 staff recruitment is open! Check it out and consider applying!

TFS 1.X+ Is there a better way to add combat check?

Lopaskurwa

Well-Known Member
Joined
Oct 6, 2017
Messages
936
Solutions
2
Reaction score
57
Right now im using this logic
LUA:
    if player:getCondition(CONDITION_INFIGHT, CONDITIONID_DEFAULT) then
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You are in combat!")
        return false
    end
But this got a flaw if player fought a monster he gets a condition in fight so thats not what i want i want to apply this only if the player attacked skull player which he gets infight condition aswell, but if he fought monsters it should ignore it, so not sure if its even possible
 
Use this event.



The only downside is damage has actually start to occur, if it's a blocked hit it wouldn't trigger... if you need a way to always tell you could use this event


and for checking if the creature has a target with creature:getTarget() should do the trick!
 
Does it really require such an approach just to create an NPC action block? Im trying to prevent NPC actions from executing when a player is in combat, but using CONDITION_INFIGHT causes issues. For example even if a player kills a monster just seconds before, they still get CONDITION_INFIGHT, which prevents them from interacting with the NPC. Thats a problem, because I only want to block NPC actions when a player targets a skulled player and gets CONDITION_INFIGHT from that. But from what I understand, it seems impossible to impossible to achieve it because there is no function in src for it, or im wrong?
 
such an approach
Oh you want to edit sources then? Cause that's what you have to do otherwise... Use the events that I mentioned, check if target is player and has a skull (in area check for creatures on the tile), create temporary table where you hold last timestamp per player id and when they did such thing (myTable[cid] = os.time()). You can then compare in your NPC script if they attacked player with a skull in last idk 30 seconds or something (or ever in this case).
 
Oh you want to edit sources then? Cause that's what you have to do otherwise... Use the events that I mentioned, check if target is player and has a skull (in area check for creatures on the tile), create temporary table where you hold last timestamp per player id and when they did such thing (myTable[cid] = os.time()). You can then compare in your NPC script if they attacked player with a skull in last idk 30 seconds or something (or ever in this case).
Uch okay if thats the only way gonna try it. Thanks
 
Back
Top