H5 Campaign Problem

Maps and the art of mapmaking.
Cyanight
Leprechaun
Leprechaun
Posts: 28
Joined: 26 Dec 2006

H5 Campaign Problem

Unread postby Cyanight » 02 Jan 2009, 00:36

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?

User avatar
durin
Leprechaun
Leprechaun
Posts: 20
Joined: 06 Jan 2006

Unread postby durin » 02 Jan 2009, 17:17

I think that only artifacts that are part of a set (Deaths Embrace, Power of Dragons) are carried over from map to map.

Cyanight
Leprechaun
Leprechaun
Posts: 28
Joined: 26 Dec 2006

Unread postby Cyanight » 02 Jan 2009, 20:21

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.

Cyanight
Leprechaun
Leprechaun
Posts: 28
Joined: 26 Dec 2006

Unread postby Cyanight » 02 Jan 2009, 20:29

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");


This is what I have been using so far but it has its downsides. It will transfer artifacts. Call Move Artifacts on win condition objective and Load Artifacts is called at the begining of the game. You have to make a mule hero that sits in a blocked off area and make sure this hero is transferable. I just wondered if ther was a more conventional way.

Franzy
War Dancer
War Dancer
Posts: 362
Joined: 07 Sep 2007
Location: Moscow, Russia
Contact:

Unread postby Franzy » 13 Jan 2009, 08:43

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.

User avatar
Asheera
Round Table Knight
Round Table Knight
Posts: 4506
Joined: 06 Jul 2008
Location: The Shadows
Contact:

Unread postby Asheera » 13 Jan 2009, 12:43

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")
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.

Franzy
War Dancer
War Dancer
Posts: 362
Joined: 07 Sep 2007
Location: Moscow, Russia
Contact:

Unread postby Franzy » 13 Jan 2009, 13:06

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);

edwin_yang
Leprechaun
Leprechaun
Posts: 10
Joined: 23 Jan 2009

Unread postby edwin_yang » 06 Feb 2009, 15:12

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.

Franzy
War Dancer
War Dancer
Posts: 362
Joined: 07 Sep 2007
Location: Moscow, Russia
Contact:

Unread postby Franzy » 09 Feb 2009, 08:33

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.


Return to “Mapmaking Guild”

Who is online

Users browsing this forum: No registered users and 0 guests