ramadeon wrote:hey,
thanks for you answer, i got mostly all working out well.
in my configuration journey i got new questions:
1) i created a new upgrade for a hero. it works fine, but i can do it several times. how can i make the button disappearing when it is used already?
Did you structure your upgrade button similar to how other upgrade buttons are structured?
2) i am trying to limit the player to build an unit just one time. i know there is a max unit value but i really want to enable a player just one time to create a hero. when the hero dies, he shall be gone forever. is it possible to allow the building of the unit only once?
What I did in Wyrmsun for exactly this sort of case was using a trigger which fired if the hero unit existed, and disallowed hiring the hero for all players thereafter. Here is an example:
Code: Select all
AddTrigger(
function()
if (GameCycle == 0) then
return false
end
return true
end,
function()
if (GetNumUnitsAt(-1, "unit-hero-baglur", {0, 0}, {256, 256}) >= 1) then
DefineAllow("unit-hero-baglur", "FFFFFFFFFFFFFFFF")
return false
end
return true
end
)
The trigger should be added to the SinglePlayerTriggers() function or a subfunction of it.
3) is there a possibility to use the players name as a prerequisite for a button? we are a fixed gang of players and i want to enable player johnny to create hero 1 etc.
Yes, but it is a bit complicated. You would need code that looked more or less like this:
Code: Select all
function GetArrayIncludes(array, item)
for key, value in pairs(array) do
if (value == item) then
return true
end
end
return false
end
function GetFactionForbiddenUnits(faction)
if (faction == "Norlund Clan") then
return { "unit-goblin-spearman", "unit-goblin-archer" }
elseif (faction == "Shinsplitter Clan") then
return { "unit-goblin-spearman", "unit-goblin-archer" }
elseif (faction == "Shorbear Clan") then
return { "unit-goblin-spearman", "unit-goblin-archer", "unit-hero-rugnur", "unit-hero-rugnur-steelclad", "unit-hero-baglur", "unit-hero-thursagan", "unit-hero-durstorn" }
elseif (faction == "Kal Kartha") then
return { "unit-goblin-spearman", "unit-goblin-archer", "unit-hero-rugnur", "unit-hero-rugnur-steelclad", "unit-hero-baglur", "unit-hero-durstorn" }
elseif (faction == "Knalga") then
return { "unit-goblin-spearman", "unit-goblin-archer" }
elseif (faction == "Lyr") then
return { "unit-goblin-spearman", "unit-goblin-archer" }
elseif (faction == "Goblins") then
return { "unit-dwarven-axefighter", "unit-dwarven-scout" }
else
return {}
end
end
local PlayerUnitFlag = {}
for i=0,15 do
if (GetArrayIncludes(GetFactionForbiddenUnits(GetPlayerData(i, "Name")), HERO_NAME)) then
PlayerUnitFlag[i] = "F"
else
PlayerUnitFlag[i] = "A"
end
end
flags = PlayerUnitFlag[0] .. PlayerUnitFlag[1] .. PlayerUnitFlag[2] .. PlayerUnitFlag[3] .. PlayerUnitFlag[4] .. PlayerUnitFlag[5] .. PlayerUnitFlag[6] .. PlayerUnitFlag[7] .. PlayerUnitFlag[8] .. PlayerUnitFlag[9] .. PlayerUnitFlag[10] .. PlayerUnitFlag[11] .. PlayerUnitFlag[12] .. PlayerUnitFlag[13] .. PlayerUnitFlag[14] .. PlayerUnitFlag[15]
DefineAllow(HERO_NAME, flags)
"HERO_NAME" should be replaced by the hero's unit name (i.e. "unit-wise-man"), with quotation marks. In the GetFactionForbiddenUnits() function you should replace what I put there with what heroes would be forbidden to each player with a certain player name (the "faction" there is just that, the player name).
4) is it possible to edit the campaign maps? everytime i open them in the editor, it starts the mission briefing and crashs afterward.
It is possible. The campaign maps crash because of this sort of line in the campaign map's .smp file:
Code: Select all
DefineMapSetup("./campaigns/human/level05h_c.sms")
If you delete or comment out the line, the map will open up fine in the editor. Just remember to restore the line to the .smp file afterwards, so that they will run normally in campaign mode.
7) is there a way to add the regeneration flag directly to a unit without giving it via addons?
Yes, I think the field is called "RegenerationRate" (a value of 1 means 1 HP recovered every second IIRC).
thanks guys,
r.
I hope I've helped =)