H5 Campaign Problem
H5 Campaign Problem
How can you transfer an artifact from a hero in mission1 to mission2. I see that you can carryover heroes but how do you carryover artifacts?
I have tried this many times and none of the set artifacts transfer. Maybe Im missing something but I have not found a way to transfer set artifacts.
There is an option called ImportantArtifacts with a setting called PreservingArtifacts. I added my set artifact under that parameter and nothing changed. The artifact would not transfer with the hero.. Only skills, level , exp and spells transfer.
There is an option called ImportantArtifacts with a setting called PreservingArtifacts. I added my set artifact under that parameter and nothing changed. The artifact would not transfer with the hero.. Only skills, level , exp and spells transfer.
Code: Select all
function MoveArtifacts(Player)
if IsHeroAlive("Freyda") then
SaveArtifacts("Freyda", "Havez");
end;
function SaveArtifacts(heroname, mulename)
if HasArtefact(heroname, ARTIFACT_DRAGON_SCALE_ARMOR) then
TeachHeroSpell(mulename, SPELL_MAGIC_ARROW);
end;
end;
function LoadArtifacts(heroname, mulename)
if KnowHeroSpell(mulename, SPELL_MAGIC_ARROW) then
GiveArtefact(heroname, ARTIFACT_DRAGON_SCALE_ARMOR, 0);
end;
end;
LoadArtifacts("Freyda", "Havez");
Guys, you do it wrong way Here is the right way:
Use functions SetGameVar & GetGameVar. The values stored in game variables are transferred between campaign scenarios. This way you can transfer *anything* using flags. And even better: you can make player pay for his actions on previous campaign maps!
Cheers!
P.S. Say if you need futher explanations, I'll provide an example.
Use functions SetGameVar & GetGameVar. The values stored in game variables are transferred between campaign scenarios. This way you can transfer *anything* using flags. And even better: you can make player pay for his actions on previous campaign maps!
Cheers!
P.S. Say if you need futher explanations, I'll provide an example.
Yes, I was thinking of those functions as well, but I didn't know those variables are transferred between games in a campaign.
Something like:
SetGameVar("Variable", 5)
and then call on the next map's script:
variable = GetGameVar("Variable")
Something like:
SetGameVar("Variable", 5)
and then call on the next map's script:
variable = GetGameVar("Variable")
No matter how powerful one becomes, there is always someone stronger. That's why I'm in a constant pursuit of power, so I can be prepared when an enemy tries to take advantage of me.
Right, though you should note 2 important things:
1) Values stored as string, so
GetGameVar('Variable')==5
will always return nil (false).
You should use
GetGameVar('Variable')=='5'
or
(0+GetGameVar('Variable'))==5
2) All the games (campaigns *and* singleplayer maps) of one profile (player) share the same GameVars file. So if any two maps use a game variable with the same name values may be overwritten. To avoid this, use long names Or better - prefixes. Example:
prefix = 'Campaign_MyFirstCampaign_map1_ver_1_01012009_';
SetGameVar(prefix..'Variable1',1);
SetGameVar(prefix..'Variable2',5);
1) Values stored as string, so
GetGameVar('Variable')==5
will always return nil (false).
You should use
GetGameVar('Variable')=='5'
or
(0+GetGameVar('Variable'))==5
2) All the games (campaigns *and* singleplayer maps) of one profile (player) share the same GameVars file. So if any two maps use a game variable with the same name values may be overwritten. To avoid this, use long names Or better - prefixes. Example:
prefix = 'Campaign_MyFirstCampaign_map1_ver_1_01012009_';
SetGameVar(prefix..'Variable1',1);
SetGameVar(prefix..'Variable2',5);
-
- Leprechaun
- Posts: 10
- Joined: 23 Jan 2009
Oh~this is what I am looking for, thank Frazy.
and I have another problem with pass the hero between campaign maps.
if the human player is the same color in all the campaign maps(lt's say the human player is always the red player), this is OK, but if not , a error would be reported when the campaing map is loading, I cant find out the reason.
and I have another problem with pass the hero between campaign maps.
if the human player is the same color in all the campaign maps(lt's say the human player is always the red player), this is OK, but if not , a error would be reported when the campaing map is loading, I cant find out the reason.
I believe it is implied that the player should keep its color throu out the campaign (or else how would the game know which player gamer plays for?)
If you REALLY need to change color, use WarpToMap function to load next map in the campaign. With it you can specify the player th gamer will play for.
If you REALLY need to change color, use WarpToMap function to load next map in the campaign. With it you can specify the player th gamer will play for.
Who is online
Users browsing this forum: No registered users and 0 guests