Skip to content

Posts from Scripts

4.8 (8 ratings)
User Avatar
Auto-translated
See the manual for functions.
Trigger(OBJECT_TOUCH_TRIGGER,....) – this is for touching a monster.
SetObjectEnabled("script name of the object (monster)", nil) – this is to prevent the monster from attacking.
QuestionBox
Also, check the FAQ in the section here. There is a slightly different example, but it is easy to adapt it.
 

К А
Стикеры GBF в Telegram
Auto-translated
Please help:smile45:. I wrote what seemed like a simple script, but it doesn't work as expected. The idea is simple: if there are creatures in the region, the script does nothing. But if they are killed, the script generates new ones, and this calculation happens every 2 days of the week.
function new_day()
local day = GetDate(DAY_OF_WEEK)
if day == 2 and IsObjectInRegion('kan','kopt')
elseif day == 2 then
CreateMonster( 'kan', 49, 5,81, 122, 0, MONSTER_MOOD_WILD, MONSTER_COURAGE_CAN_FLEE_JOIN, 0)

end

end
Trigger(NEW_DAY_TRIGGER,'new_day')
User Avatar
Auto-translated
if day == 2 and IsObjectInRegion('kan','kopt') then
{this part works when the condition is met}
elseif day == 2 then
That's how it should be.
I don't see any other problems.
 

К А
Стикеры GBF в Telegram
In reply to Ment
Auto-translated
I've rewritten this script a bit.
function new_day() local day = GetDate(DAY_OF_WEEK) if day == 2 and IsObjectInRegion('kan','kopt') then CreateMonster( 'kan', 91, 5,81, 122, 0, MONSTER_MOOD_WILD, MONSTER_COURAGE_CAN_FLEE_JOIN, 0)--creates a phoenix elseif day==2 then CreateMonster( 'kcn', 49, 5,81, 122, 0, MONSTER_MOOD_WILD, MONSTER_COURAGE_CAN_FLEE_JOIN, 0)-- creates druids end end Trigger(NEW_DAY_TRIGGER,'new_day')
However, in the end, neither druids nor phoenixes appear, although, according to the logic, only druids should be created.
In reply to Ment
Auto-translated
So, I need a complex script; I tried to do it myself, but it didn't work. The script should do the following: if a Necropolis castle is captured, you can stand on a tile next to the castle, and a choice will appear: destroy the castle for 30 wood, 30 ore, 10 of each rare resource, and 10,000 gold. If you click "no," nothing happens. If you click "yes," the resources are deducted, the Necropolis castle disappears with a "Holy Word" animation, and a ruined Human castle appears. Next, if you stand on the same tile again, the same choice is offered: build a Human castle for 50 wood and ore and 15 of each rare resource and 20,000 gold. If you click "yes," the ruined castle disappears with the same "Holy Word" animation, and a regular level 1 castle appears. If you don't have enough resources, the action fails, and the ruined castle remains. How can this be implemented?

Added 1 minute ago
I'll mark the tile with a region and put a circle on it so it's visible.
In reply to Ment
Auto-translated
here's what the editor writes; maybe someone knows how else this script can be written:
Attachments 1
1 file attached • Total size: 28.8 KB
User Avatar
Auto-translated
Well, that's about the editor, but I was asking about the console. The game does have something that displays text (you need to activate the console to see it. It seems to be mentioned in the FAQ).
 

К А
Стикеры GBF в Telegram
In reply to Ment
Auto-translated
The console displays the following:
(Script) ERROR: Object "kan" does not exist
and this happens every other day of the week.
User Avatar
Auto-translated
It says that an object with the name "kan" does not exist. That makes sense. You need an IsObjectExists check (or something similar). It seems that the IsObjectInRegion function doesn't check for these things; it immediately tries to find the object's coordinates, but it doesn't exist...
 

К А
Стикеры GBF в Telegram
In reply to Ment
Auto-translated
Can anyone help me with my script?
User Avatar
Auto-translated
Can anyone help me with my script?
Please tell us what you were trying to do...
 

К А
Стикеры GBF в Telegram
In reply to Ment
Auto-translated
Well, something similar was in the scenario "Unity of the Elements," but there, about half of my script was copied from his script, I made a few corrections, but it doesn't work.
In reply to Годрикова впадина
Auto-translated
You were right, after changing `IsObjectInRegion` to `IsObjectExists`, everything started working perfectly. Thank you very much! :smile54:
User Avatar
Auto-translated
Godric's Hollow, well, if you post both your script and the source code, that would be great. Make it easier to help, so we don't have to start from scratch, but can just offer suggestions.
 

К А
Стикеры GBF в Telegram

Statistics

Welcome our newest member: Emil