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

[NPC - LUA] Advanced stuff (for me atleast :D )

Exoltes

Novia OTserv Developer
Joined
Jul 2, 2009
Messages
563
Reaction score
47
Location
Belgium
I'm working on a 8.54 Open Tibia Server using The Forgotten Server - Version 0.2.7 (Mystic Spirit).


Basicly the idea is combined with a large script I wrote to change my semi snow island into a full snow/ice island. But I want it that the npc triggers it.

What I'm looking for exactly is the following:
by saying 3x hi to this npc you will trigger the change and everything resets after 10 minutes. (the change and the reset part of all tiles is scripted allready)
also the npc will respond different to each of these greetings. (the npc will only respond to any kind of greetings and not to other words - so chatting near it without greeting it wont be a problem)
Ex: 1x -> (Normal State) Please leave me alone, I'm in no mood for a chat. (This will happen if NO person talked to her in the last 5 minutes or longer)
2x (Agitated State) -> I want to be alone, so please leave! (This will happen is you greet her twice within less then 10 min from eachother OR when someone else spoke to her within the last 5 min)
3x (Full Rage State) -> I SAID LEAVE ME ALONE!!! (This happens if you say 3x hi within 10 min or if you triggered the 2nd and 3rd state by urself within the last 5min)

When the 3rd state is activated the npc will cast an ice spell with the large ice icon on the player dealing between 500 and 1000 dmg at random. (single shot in ice dmg)
This will also trigger the change and turn the entire island into ice/snow. Also 4 Ice Golems will spawn within the ice castle on certain fixed locations.
Once the change is triggerd the npc will ignore all players untill the change is reset (10min) and for 5 minutes longer making it a total of 15min.

If there are any more questions please don't hesitate to contact me.

Thanks in advance.
 
The 3 responses to the npc can be handled normally as you would any conversation however the execution of the event that takes place after the 3 responses must be stored.

Does your server have global storage?

If it does then you could set the global storage to the current time plus 10 minutes, then have the npc execute the ice script, at the same time call an addEvent to execute another function 10 minutes from the time the global storage was set to reset the global storage.

The npc portion of setting an addEvent for 10 minutes plus the current time won't crash the server since the addEvent is only being called 1 time.

Then when the player talks to the npc again you can check current time to that of the global storage, if the global storage is greater then the current time you can return false e.g. not execute the remaining portion of the npc script.

If you want to increase the duration til the time is reset you could apply more time by simply updating the global storage value and then check to make sure the time does not exceed a certain value.

The reason we use global storage rather than player storage is so that you don't have 100 players executing the ice change script which can put a damper on your server.
 
The 3 responses to the npc can be handled normally as you would any conversation however the execution of the event that takes place after the 3 responses must be stored.

Does your server have global storage?

If it does then you could set the global storage to the current time plus 10 minutes, then have the npc execute the ice script, at the same time call an addEvent to execute another function 10 minutes from the time the global storage was set to reset the global storage.

The npc portion of setting an addEvent for 10 minutes plus the current time won't crash the server since the addEvent is only being called 1 time.

Then when the player talks to the npc again you can check current time to that of the global storage, if the global storage is greater then the current time you can return false e.g. not execute the remaining portion of the npc script.

If you want to increase the duration til the time is reset you could apply more time by simply updating the global storage value and then check to make sure the time does not exceed a certain value.

The reason we use global storage rather than player storage is so that you don't have 100 players executing the ice change script which can put a damper on your server.
I fear that global storage doesn't excists within tfs 0.2.7 :(
But it is the idea that any player can trigger it and the script can only run once untill it is fully reset again (so working with a player storage doesn't seem like the way to go here).
 
Back
Top