• 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!
  • If you're using Gesior 2012 or MyAAC, please review this thread for information about a serious security vulnerability and a fix.

Solved [TFS 1.2] Non aggressive dmg

hellboy

Intermediate OT User
Joined
Apr 6, 2008
Messages
500
Solutions
4
Reaction score
101
Location
player:getTown()
I tried do sth like this:

Code:
function doDmg(player)
   local conditionInFightBeforeHungerDmg = player:getCondition(CONDITION_INFIGHT, CONDITIONID_DEFAULT)
   doTargetCombatHealth(0, player, COMBAT_UNDEFINEDDAMAGE, -hunger.dmgAmount, -hunger.dmgAmount, CONST_ME_NONE)
   --- doSendAnimatedText(getCreaturePosition(cid), dmgAmount, TEXTCOLOR_RED)

   if conditionInFightBeforeHungerDmg == nil then
     print('Remove condition')
     player:removeCondition(CONDITION_INFIGHT)
   else
     --- IN FUTURE change infight time to value before target combat dmg
     print(math.floor(conditionInFightBeforeHungerDmg:getTicks() / 1000))
   end

     --- player:removeCondition()
     --- player:addCondition()
   return true
end

When player don't have any infight condition then script should print in console "Remove condition" and remove it. But it only print string, nothing less, nothing more.

It's possible to damage player without creating (or prolong) INFIGHT condition?
Or sombody know how fix first part of my workaround?
Or if there no better solution, use combat dispell like there https://github.com/otland/forgottenserver/blob/master/data/spells/scripts/healing/cure burning.lua ?

##EDIT##

Dispell don't work too
 
Last edited:
Solution
Solved, non aggressive dmg is player:addHealth(-1)

Propably I'll post report on github about player:removeCondition(CONDITION_INFIGHT)

Codex NG

Recurrent Flamer
Joined
Jul 24, 2015
Messages
2,994
Solutions
12
Reaction score
1,654
Have you tried printing out the value of conditionInFightBeforeHungerDmg, if it comes back nil its best to also check if player is a player.

Code:
   if conditionInFightBeforeHungerDmg == nil && player:isPlayer() then

Or possibly run a for loop over conditionInFightBeforeHungerDmg to see if its a table and if so what values it may or may not contain.

Code:
if type(conditionInFightBeforeHungerDmg) == "table" then
    for key, value in pairs(conditionInFightBeforeHungerDmg) do
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "key ".. key .. " value " .. value .. "\n")
    end
end
 
OP
OP
hellboy

hellboy

Intermediate OT User
Joined
Apr 6, 2008
Messages
500
Solutions
4
Reaction score
101
Location
player:getTown()
Thanks for tips.

1. variable player is always player (I use doDmg only inside onThink registered when player login).
2. I will try iterate all keys in metatable later (after 24h, after some concerts :) )
 

RazorBlade

Retired Snek
Joined
Nov 7, 2009
Messages
2,015
Solutions
3
Reaction score
627
Location
Canada
If it's userdata then it isn't nil. So it's doing what it's supposed to. I'm not 100% sure what getCondition returns whether the player has that condition or not.
 
OP
OP
hellboy

hellboy

Intermediate OT User
Joined
Apr 6, 2008
Messages
500
Solutions
4
Reaction score
101
Location
player:getTown()
If it's userdata then it isn't nil. So it's doing what it's supposed to. I'm not 100% sure what getCondition returns whether the player has that condition or not.

Nope it's don't work at all.
If player don't have condition, then it return nil else it return userdata.

I should put issue in github about player:removeCondition(CONDITION_INFIGHT)?
 
OP
OP
hellboy

hellboy

Intermediate OT User
Joined
Apr 6, 2008
Messages
500
Solutions
4
Reaction score
101
Location
player:getTown()
Solved, non aggressive dmg is player:addHealth(-1)

Propably I'll post report on github about player:removeCondition(CONDITION_INFIGHT)
 
Last edited:
Solution
OP
OP
hellboy

hellboy

Intermediate OT User
Joined
Apr 6, 2008
Messages
500
Solutions
4
Reaction score
101
Location
player:getTown()
That's all you wanted? I didn't understand the first post at all or I would've suggested that cause I use that in my systems xD
Yep I wrote:

It's possible to damage player without creating (or prolong) INFIGHT condition?

#EDIT#
Now I'll try put my functions inside Player metatable/userdata
 

RazorBlade

Retired Snek
Joined
Nov 7, 2009
Messages
2,015
Solutions
3
Reaction score
627
Location
Canada
How to kill player without having pz lock (can't enter protection).
Example Last Man Standing winner.
Well, you can make it a pvp zone... But if they deal any sort of DoT and the player is hit after being removed from the pvp zone, the attacker will get pz still. I mean, after exiting you can just remove the pz condition. That'd be easiest probably.
 
Top