Skip to content

Posts from Scripts

4.8 (8 ratings)
7 years ago
Auto-translated
According to my code above: with dwellings in the Dungeon that are rebuilt into peasant houses, there's a problem – they shift and become inaccessible... How can I fix this?
User Avatar
7 years ago
Auto-translated
Are the dwarven dwellings being rebuilt? If so, their blocked tiles differ from those of other level 1 dwellings, which is why this problem occurs. I don't know for sure how to solve it; either modify these tiles for the dwarven dwelling, or don't rebuild it, but destroy the old dwelling (RazeBuilding) and create a new one (CreateDwelling).
In reply to Gerter
7 years ago
Auto-translated
Gerter
Are the dwarven dwellings being rebuilt?
Yes, it's them.
Gerter
If so, their blocked tiles differ from other level 1 dwellings, which is why this problem occurs. I don't know exactly how to solve it; either change these tiles for the dwarven dwelling, or don't rebuild it, but destroy the old dwelling (RazeBuilding) and create a new one (CreateDwelling).

And how can I determine in my code that these are level 1 dwellings? (Others are rebuilt normally)
User Avatar
7 years ago
Auto-translated
Change the tiles to those of the Dwarf dwellings. I did this in The Price of Loyalty.
In reply to AstralLein
7 years ago
Auto-translated
AstralLein
Change the tiles to those of the Dwarf dwellings. I did this in The Price of Loyalty.

Got it.
User Avatar
7 years ago
Auto-translated
In principle, I can send you the already modified files for the gnome dwellings.

Added 57 seconds later
So, how does random work?

More precisely,

random (3) - what is the range? From 0 to 2 or from 0 to 3?
In reply to AstralLein
7 years ago
Auto-translated
AstralLein
Change the tiles for the dwarven dwellings. I did this in "A Price for Love."

It didn't work. I'm going back to the question:
how do I determine in my code that these are level 1 dwellings?
(Don't pay attention to the fact that these are elven structures)
function dwellings()
for i, dw_type in {"FAIRIE_TREE", "WOOD_GUARD_QUARTERS", "HIGH_CABINS", "PRESERVE_MILITARY_POST"} do
for j, dw in GetObjectNamesByType(dw_type) do
ELF_DWLS[dw] = "off"
SetObjectEnabled(dw, nil)
Trigger(4, dw, "TransformDwelling")
end
end
startThread(dwellings2)
end

startThread(dwellings)

function dwellings2()
while 1 do
repeat
sleep()
until IsPlayerCurrent(1)
for dwelling, state in ELF_DWLS do
if state == "on" then
ELF_DWLS[dwelling] = "off"
SetObjectEnabled(dwelling, nil)
Trigger(4, dwelling, "TransformDwelling")
end
end
repeat
sleep()
until not IsPlayerCurrent(1)
for dwelling, state in ELF_DWLS do
if state == "off" then
ELF_DWLS[dwelling] = "on"
SetObjectEnabled(dwelling, 1)
Trigger(4, dwelling, nil)
end
end
end
end

function TransformDwelling(hero, hut)
if GetCurrentPlayer() == 1 then
QuestionBox (path.."transformd.txt" , 'transformnok("'..hut..'")' );
end
end

function transformnok(hut)
if not (GetPlayerResource(1, CRYSTAL) >= 15 and GetPlayerResource(1,GEM) >= 10) then
ShowFlyingSign(path.."nores.txt",hut,-1,10)
return
end
SetPlayerResource(1,CRYSTAL, (GetPlayerResource(1,CRYSTAL) - 15))
SetPlayerResource(1,GEM, (GetPlayerResource(1,GEM) - 10))
PlayVisualEffect('/Effects/_(Effect)/Spells/Bless.xdb#xpointer(/Effect)', hut)
sleep(5)
Trigger(4, hut, nil)
ELF_DWLS[hut] = nil
ReplaceDwelling(hut,TOWN_HEAVEN)
sleep(1)
SetObjectOwner(hut,1)
SetObjectEnabled(hut,true)
sleep(1)
return function()
end
end
User Avatar
7 years ago
Auto-translated
random (3) - what is the range? From 0 to 2 or from 0 to 3?
0-2

regarding dwellings - FORTRESS_DEFENDERS - if I'm not mistaken, this is a type of dwarven dwelling.
In reply to Gerter
User Avatar
7 years ago
Auto-translated
Gerter
0-2

regarding dwellings - FORTRESS_DEFENDERS - this is, if I'm not mistaken, a type of dwarven 1-dwelling.

Thank you.
7 years ago
Auto-translated
I tried to write it like this, but nothing happens:
function TransformDwelling(hero, hut)
if GetCurrentPlayer() == 1 then
if hut =="FORTRESS_DEFENDERS" then
QuestionBox (path.."transform.txt" , 'transformnok("'..hut..'")' )
end
end
end
User Avatar
7 years ago
Auto-translated
No, here "hut" is the name of the object. You can categorize it within the dwellings() function and assign a different trigger to objects of the type FORTRESS_DEFENDERS than to the rest. If you check it within the transformation function itself, it would be something like this: `
if contains(GetObjectNamesByType('FORTRESS_DEFENDERS'), hut) then
`
In reply to Gerter
7 years ago
Auto-translated
Gerter
No, here 'hut' is the name of the object. You can categorize it within the dwellings() function and assign a different trigger to objects of the type FORTRESS_DEFENDERS than to the rest. If you check it within the transformation function itself, it would be something like this:
if contains(GetObjectNamesByType('FORTRESS_DEFENDERS'), hut) then

It works! Thank you very much :smile20:
User Avatar
7 years ago
Auto-translated
I'm trying to implement the following feature: 1. At a certain point, save the map using Save(). 2. Launch another map using WarpToMap(). 3. From the second map, load the saved game. When loading the saved game, whether manually or using Load(), the game crashes without any errors; it simply crashes to the desktop. Maybe someone knows if this is an intended mechanic or if there's a way to fix it? Manually saved games or autosaves load perfectly fine. I thought the issue might be that the save file needs to be specified in the map's resources, but that doesn't change anything.
7 years ago
Auto-translated
Here is the code:
Ornel=0
Ornel_d=0
--
Gl=0
Gl_d=0
--
Dug=0
Dug_d=0
--
Airi=0
Airi_d=0

Mive=0
Mive_d=0

function DeathHavenHero(hero)
if hero== Ornella then
Ornel_d=1
Ornel=GetDate(DAY)
MakeHeroReturnToTavernAfterDeath(Ornella,0)
print("Gloria is dead")
end
if hero==Glen then
Gl_d=1
Gl=GetDate(DAY)
MakeHeroReturnToTavernAfterDeath(Glen,0)
end
--
if hero=="Orrin" then
Dug_d=1
Dug=GetDate(DAY)
MakeHeroReturnToTavernAfterDeath("Orrin",0)
end

if hero=="Ving" then
Airi_d=1
Airi=GetDate(DAY)
MakeHeroReturnToTavernAfterDeath("Ving",0)
end
if hero=="Maeve" then
Mive_d=1
Mive=GetDate(DAY)
MakeHeroReturnToTavernAfterDeath("Maeve",0)
end
end

Trigger (PLAYER_REMOVE_HERO_TRIGGER, PLAYER_2, "DeathHavenHero")

dayd={8,7,6,5}

function NewDay()
if GetDate(MONTH)==2 and GetDate(WEEK)==2 then
coef={1.5,2,2.5,3}
end
if Ornel_d==1 and GetDate(DAY)-Ornel== dayd[diff] then
MakeHeroReturnToTavernAfterDeath(Ornella,1,1)
Ornel_d=0
print("Gloria is ready")
end

if Gl_d==1 and GetDate(DAY)- Gl== dayd[diff] then
MakeHeroReturnToTavernAfterDeath(Glen,1,1)
Gl_d=0
print("Glen is ready")
end

if Dug_d==1 and GetDate(DAY)- Dug== dayd[diff] then
MakeHeroReturnToTavernAfterDeath("Orrin",1,1)
Dug_d=0
print("Dugald is ready")
end

if Airi_d==1 and GetDate(DAY)- Airi== dayd[diff] then
MakeHeroReturnToTavernAfterDeath("Ving",1,1)
Airi_d=0
print("Airis is ready")
end

if Mive_d==1 and GetDate(DAY)- Mive== dayd[diff] then
MakeHeroReturnToTavernAfterDeath("Maeve",1,1)
Mive_d=0
print("Maeve is ready")
end
end

Trigger(0,"NewDay")

I tried to make it so that heroes would be resurrected in the tavern after some time, but now no hero is resurrected. There are no errors in the console... What is the problem?
In reply to AlekseyS
User Avatar
7 years ago
Auto-translated
AlekseyS
Here is the code:
Ornel=0
Ornel_d=0
--
Gl=0
Gl_d=0
--
Dug=0
Dug_d=0
--
Airi=0
Airi_d=0

Mive=0
Mive_d=0

function DeathHavenHero(hero)
if hero== Ornella then
Ornel_d=1
Ornel=GetDate(DAY)
MakeHeroReturnToTavernAfterDeath(Ornella,0)
print("Gloria is dead")
end
if hero==Glen then
Gl_d=1
Gl=GetDate(DAY)
MakeHeroReturnToTavernAfterDeath(Glen,0)
end
--
if hero=="Orrin" then
Dug_d=1
Dug=GetDate(DAY)
MakeHeroReturnToTavernAfterDeath("Orrin",0)
end

if hero=="Ving" then
Airi_d=1
Airi=GetDate(DAY)
MakeHeroReturnToTavernAfterDeath("Ving",0)
end
if hero=="Maeve" then
Mive_d=1
Mive=GetDate(DAY)
MakeHeroReturnToTavernAfterDeath("Maeve",0)
end
end

Trigger (PLAYER_REMOVE_HERO_TRIGGER, PLAYER_2, "DeathHavenHero")

dayd={8,7,6,5}

function NewDay()
if GetDate(MONTH)==2 and GetDate(WEEK)==2 then
coef={1.5,2,2.5,3}
end
if Ornel_d==1 and GetDate(DAY)-Ornel== dayd[diff] then
MakeHeroReturnToTavernAfterDeath(Ornella,1,1)
Ornel_d=0
print("Gloria is ready")
end

if Gl_d==1 and GetDate(DAY)- Gl== dayd[diff] then
MakeHeroReturnToTavernAfterDeath(Glen,1,1)
Gl_d=0
print("Glen is ready")
end

if Dug_d==1 and GetDate(DAY)- Dug== dayd[diff] then
MakeHeroReturnToTavernAfterDeath("Orrin",1,1)
Dug_d=0
print("Duggal is ready")
end

if Airi_d==1 and GetDate(DAY)- Airi== dayd[diff] then
MakeHeroReturnToTavernAfterDeath("Ving",1,1)
Airi_d=0
print("Airis is ready")
end

if Mive_d==1 and GetDate(DAY)- Mive== dayd[diff] then
MakeHeroReturnToTavernAfterDeath("Maeve",1,1)
Mive_d=0
print("Mive is ready")
end
end

Trigger(0,"NewDay")

I tried to make it so that the heroes would be resurrected in the tavern after a while, but now no hero is resurrected. There are no errors in the console... What is the problem?
The MakeHeroReturnToTavernAfterDeath function only sets an internal flag for the hero so that he returns to the tavern immediately after death. In your case, at the moment of death, the flag is in its default state, i.e., "do not return to the tavern." After the specified time has passed, setting the flag to "return" will not magically create a hero for anyone in the tavern, at least because the game doesn't even understand which player's tavern to place this hero in; he is dead and doesn't belong to anyone.

If you need heroes to be resurrected after some time after their death, you can reserve them for a player and deploy them as needed using the DeployReserveHero function.

Statistics

Welcome our newest member: recijeb