Skip to content

Posts from Scripts

4.8 (8 ratings)
In reply to KioM
14 years ago
Auto-translated
KioM
This function also doesn't work... In general, this is implemented in my "Throne" map; if you want, take a look – maybe I missed something after all. For now, I hacked it and completely removed the ability to hire anyone in the tavern.

P.S. My main goal was to prevent building taverns in cities.

Throne 1.2
I took a look. You messed up something there that isn’t very good :D
setBuildingsLevel(TOWN01, 1, 3, 2); You write this, but then assign level1=1 through a function (although for prohibition, level1 should be 0).
DestroyTownBuildingToLevel(townName, TOWN_BUILDING_TAVERN, level1, 0); (i.e., you allow the construction of a tavern, although you supposedly wanted to prohibit building a tavern after transformation :confused: ).
Furthermore, you can use the same function for dwellings as well (it's easier with a loop - I provided an example, which is working - I repeat :) Moreover, there's also a reverse example - after capturing a city by AI, taverns and dwellings were allowed to be built again).
And you even created aliases :eek: That's crazy :smile33:. Maybe the problem lies in them – I don't really understand them.
Will you say it doesn't work again?? ;)
In reply to JonnyP
User Avatar
14 years ago
Auto-translated
JonnyP
took a look. You've messed something up there. :D
setBuildingsLevel(TOWN01, 1, 3, 2); You write this, but then you assign level1=1 (although for a ban, level1=0 should be).
DestroyTownBuildingToLevel(townName, TOWN_BUILDING_TAVERN, level1, 0); (i.e., you allow the construction of a tavern, although you wanted to ban the tavern after the transformation :confused: ).
Furthermore, you can also use this function for dwellings (it's easier to use a loop - I provided an example, which is working - I'm telling you again :) Besides, there's a reverse example there - after the computer captures a town, the tavern and dwellings are allowed to be built again).
And you've also messed up with aliases :eek: that's crazy :smile33: maybe the problem is in them - I don't really understand them.
Will you say it doesn't work again?? ;)

a fresh look) thank you: setBuildingsLevel(TOWN01, 1, 3, 2); the mistake was here...
14 years ago
Auto-translated
Hello everyone!
Recently, I encountered a question: how to "enable" an object using the SetObjectEnabled command?
When I try to set it to "not nil" or 'true', I get an error in the console saying that there is no such variable. The same thing happens when I remove the command altogether.
Sincerely.
User Avatar
14 years ago
Auto-translated
Is it giving an error? That's strange, I've always used "true" and it worked fine. I'm sure I'm not mistaken: I often need to use it when interacting with monsters, etc.
14 years ago
Auto-translated
I suspected what had happened, but I only realized it after taking a sober look at the console. I had typed the command incorrectly. Thanks for your help, anyway. Best regards.
14 years ago
Auto-translated
Hello everyone!
I have two questions:
1) I'm trying to create a check for the presence of an artifact and then execute a task, but either `startThread` or `while ... do` stubbornly causes the game to freeze. I've tried everything, but nothing works. Here are the function options:
function RingF()
while HasArtefact('Giovanni',ARTIFACT_NECROMACER_PENDANT) == not nil do
SetObjectiveState('Amulet', OBJECTIVE_COMPLETED)
MessageBox(dir..'Posoh_naiden.txt')
end;
end;
startThread(RingF)

function RingF()
if HasArtefact('Giovanni', ARTIFACT_NECROMANCER_PENDANT) then
SetObjectiveState('Amulet', OBJECTIVE_COMPLETED)
MessageBox(dir..'Amulet_founded.txt')
end;
end;
startThread(RingF)
I've tried everything. What's the problem?
2) What does UnitName mean in a combat script?
Sincerely.
In reply to djulian13
User Avatar
14 years ago
Auto-translated
djulian13
Good afternoon everyone!
I have two questions:
1) I'm trying to create a check for the presence of an artifact and then execute a task, but either startThread or while...do stubbornly causes the game to freeze.
while HasArtefact('Giovanni',ARTIFACT_NECROMACER_PENDANT) == not nil do
:eek: while definitely shouldn't be there
And does this work?:
if HasArtifact("Giovanni",ARTIFACT_NECROMACER_PENDANT) == true ...

What does the console say?
In reply to djulian13
User Avatar
14 years ago
Auto-translated
Maybe we should add a semicolon after `StartThread`?
14 years ago
Auto-translated
Found a solution. Thanks to everyone for the help! The function should look like this: function RingF() while 1 do if HasArtefact('Giovanni', ARTIFACT_NECROMANCER_PENDANT) == true then SetObjectiveState('Amulet', OBJECTIVE_COMPLETED) MessageBox(dir..'Amulet_founded.txt') end; sleep(1) end; end; startThread(RingF); Sincerely.
14 years ago
Auto-translated
Hello everyone!
I'm currently trying to learn CombatScript. My question is: what does the variable UnitName mean?
Best regards.
In reply to djulian13
User Avatar
14 years ago
Auto-translated
djulian13
Hello everyone!
I'm currently trying to learn CombatScript. My question is: what does the variable UnitName mean?
Best regards.
It's the unit's name.
Perhaps, it refers to a specific unit or squad.
14 years ago
Auto-translated
Thank you. Does the unit name refer to something like CREATURE_IMP, or is it assigned in some other way?
Sincerely.
User Avatar
14 years ago
Auto-translated
I would like to know why this piece of script is not working. It seems like I did everything correctly... ``` function ask1 () MessageBox ("/Maps/SingleMissions/Illusion Castle/ask1F.txt"); then QuestionBox ("/Maps/SingleMissions/Illusion Castle/ask1.txt", 'yes', 'no'); end; function yes () SetObjectiveState('obj_5', OBJECTIVE_ACTIVE); SetObjectiveVisible( 'obj_5', true, PLAYER_1 ); Trigger(OBJECT_TOUCH_TRIGGER, "hat", nil); end; Trigger(OBJECT_TOUCH_TRIGGER, "hat" "ask1" );
In reply to djulian13
14 years ago
Auto-translated
djulian13
Does the unit name refer to something like CREATURE_IMP?
Best regards.
No. In tactical mode, unit names differ from the names on the global map. Check the function GetUnitNames (or something like that, it's best to check the manual, as it contains more details and some specific information).
AkaR, simply check the syntax in your script.
14 years ago
Auto-translated
Incorrect script construction. It should be: function ask1 () MessageBox ("/Maps/SingleMissions/Illusion Castle/ask1F.txt"); sleep(5) QuestionBox ("/Maps/SingleMissions/Illusion Castle/ask1.txt", 'yes', 'no'); Trigger(OBJECT_TOUCH_TRIGGER, "hat", nil); end; Trigger(OBJECT_TOUCH_TRIGGER, "hat" "ask1" ); function yes () SetObjectiveState('obj_5', OBJECTIVE_ACTIVE); SetObjectiveVisible( 'obj_5', true, PLAYER_1 ); end; I also recommend using GetMapDataPath()..'filename.txt' instead of the folder path. P.S. Have you checked the encoding of the .txt file? Is it Unicode? Check the GetUnitNames function (or something like that, it's better to check the manual, there are more details and some specifics). Thank you! Sincerely.

Statistics

Welcome our newest member: recijeb