• 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!

TFS 1.X+ TFS 1.4 LUA or C++, after start server add random damage for all monsters

lexus21

Active Member
Joined
Dec 14, 2022
Messages
88
Reaction score
25
Hi, how to in LUA or C++ get all spawned monsters and add random damage for each.
damage shouldn't be more than maxhealth

how to get all spawned monsters in lua?


I tried something like this

i set
Code:
<event class="Monster" method="onSpawn" enabled="1" />
and add in monster.lua
Lua:
function Monster:onSpawn(position, startup, artificial)
    if hasEventCallback(EVENT_CALLBACK_ONSPAWN) then
    local condition = Condition(CONDITION_FIRE)
    condition:setParameter(CONDITION_PARAM_DELAYED, true)
    condition:addDamage(5, 3000, -25)
    condition:addDamage(1, 5000, -666)
        return EventCallback(EVENT_CALLBACK_ONSPAWN, self, position, startup, artificial)
    else
        return true
    end
end



any hint ?

thank's
 
Last edited:
Maybe?

Lua:
local condition = Condition(CONDITION_FIRE)
condition:setParameter(CONDITION_PARAM_DELAYED, true)
condition:addDamage(5, 3000, -25)
condition:addDamage(1, 5000, -666)

function Monster:onSpawn(position, startup, artificial)

    if not artificial then
        self:addCondition(condition)
    end

    if hasEventCallback(EVENT_CALLBACK_ONSPAWN) then
        return EventCallback(EVENT_CALLBACK_ONSPAWN, self, position, startup, artificial)
    else
        return true
    end
    
end
 
Lua:
local condition = Condition(CONDITION_FIRE)
condition:setParameter(CONDITION_PARAM_DELAYED, true)
condition:addDamage(5, 3000, -25)

function Monster:onSpawn(position, startup, artificial)

    if (artificial or startup == true or false) then
        self:addCondition(condition)
    end

    if hasEventCallback(EVENT_CALLBACK_ONSPAWN) then
        return EventCallback(EVENT_CALLBACK_ONSPAWN, self, position, startup, artificial)
    else
        return true
    end
    
end
 
im trying add again this script: and dosen't work,
Lua:
self:addCondition(condition)

do nothing, why? something was changed ?
Post automatically merged:

Lua:
self:addHealth(-10)
it working but why condition dosen't work?
 
Last edited:
condition can be added to combat
Code:
combat:addCondition(condition)
also can be added to creature using
Code:
creature:addCondition(condition[, force = false])

your code is adding condition to creature, which means that the creature will take damage for sometime when it spawns
if you want the creature to hit those conditions, you need to add it to some combat that all creature uses
 
Back
Top