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

Lua [Creaturescripts for TFS 1.0] "onCombat" alternative?

Sheinen Highfive

In a hot scale.
Joined
Oct 26, 2008
Messages
1,255
Solutions
1
Reaction score
70
Location
Deutschland
Is there any alternative for "onCombat", I am using TFS 1.0. Like 6 months ago or so I used TFS 0.4 and everything was fine.



Code:
function onCombat(cid, target)
    if isPlayer(target) then
        if not getPlayerParty(cid) or not getPlayerParty(target) then
            return true
        end
        if getPlayerParty(cid) == getPlayerParty(target) then
            return false
        end
    end
    return true
end
 
Are you sure it's gone? I hope not - I found it by accident a couple of days ago and I want to use it later :s

Maybe it's not registered correctly?

IIRC my example had this in creaturescripts.xml:
<event type="combat" name="Attk" event="script">
and this in login.lua:
player:registerEvent("Attk")
 
It's not added (yet), so you have three options:
1) Give up on it.
2) Add it by yourself.
3) Wait until somebody make a pull request including this creatureevent...

:p
 
It's not added (yet), so you have three options:
1) Give up on it.
2) Add it by yourself.
3) Wait until somebody make a pull request including this creatureevent...

Does it require C++ code to add an event?

I want another one even more than onCombat():
I'd like an event that fires exactly once every "server cycle" (where, for example, onCombat() between players would fire twice at the start of combat, once per player).
 
I've already coded it for my server, I will post it it will be 100% tested.
 
I'd like an event that fires exactly once every "server cycle" (where, for example, onCombat() between players would fire twice at the start of combat, once per player).
@gunz:

Could you make this one too? Here's a lightweight spec (probably enough to run with if you have done onCombat() already):

I'd like it exactly once per cycle with no explicit trigger.

I'd like to have support via XML
(i.e. this kind of thing: <event type="serverTick" name="PetControl" event="script" />)
so it could (if necessary) initiate different scripts.
If that makes it too much trouble to implement, a single call to a standard script would be ok - AFAIK there's no loss of capability, because I can call other scripts from that.

The "onServerTick()" API doesn't need any parameters.
If I need references to in-game objects or state I'll use OT "Storage" or the existing "getXxxByYyy()" function calls.
If the server already counts "server cycles" it would be ok as a parameter, but if not I can easily implement what I actually need in Lua.

NB: I'll almost certainly request this from the official TFS project sooner or later, but I want it now :)
 
Back
Top