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

Solved creaturescript onThink() dilemma.

whitevo

Feeling good, thats what I do.
Joined
Jan 2, 2015
Messages
3,452
Solutions
1
Reaction score
626
Location
Estonia
But don't write in this thread (create new :) ).
I though the issue lands on the same ballpark, just you wanted increase interval and I wanted reduce xD.
> [TFS 1.2] Creaturescript onThink interval ignored [thread] <

My question is, which of these options I should choose and why? (unless there is 3rd even better way)
I want to bring normal monster attacks to my monster AI too, but AI is based on onthink() function. Sadly it executes only once per second.
In order to be able to add attack what deals damage every 400 milliseconds I have came up with 2 solutions below.

1st option:
Reducing the onThink interval in source to 100 milliseconds.
If that is better solution then: How I go about it?
It just can't be as simple as changing >this< value to 100.

2nd option:
On the monster hit calculating How many addEvents() I should place on the monster>target and leave the leftover milliseconds for another hit calculation.

small example code:
Code:
addEvent(dealDelayDMG, milliseconds , combatTable)
Code:
function dealDelayDMG(combatTable)
--doing the error escape thing here

    target_in_distance = checkDistance(combatTable)
    if target_in_distance then
        dealDamage(combatTable)
    end
end
 
1st option is not an option. We have not yet testet what can occur if you reduce the delay by ten times. It is a too big reduction to try. You might get away reducing to 500 and relaxing your AI delay to 500 too. Anyway, yes, only changing that value works.

The second option is the way to go, I think.
 

Similar threads

Back
Top