Map Database  •  FAQ  •  RSS  •  Login

Saving info for later missions

<<

The Dark Lord

User avatar

King Karolus Servant

Posts: 2154

Joined: 29 Aug 2007, 22:00

KaM Skill Level: Veteran

Location: In his dark thunderstormy castle

Post 27 Aug 2015, 18:50

Saving info for later missions

Since we will probably never have siege weapons in the Remake (a little part of me dies now that I admit it :'( ) and TNL will never be as epic as it could have been, I have to replace a mission that is all about these machines. It is mission 14 (out of 16), and I was thinking to make it some 'sneak mission' where the player can choose to infiltrate a specific base for a (variety of) reward(s) in the final mission. However, I would need to translate the player's choice into information which needs to be stored until the start of mission 16. Is that possible? I knew there was some discussion about it, but if I remember correctly nothing came out of it (which is a shame :P).
<<

Krom

User avatar

Knights Province Developer

Posts: 3281

Joined: 09 May 2006, 22:00

KaM Skill Level: Fair

Location: Russia

Post 27 Aug 2015, 18:58

Re: Saving info for later missions

This is possible in KaM Remake dynamic scripts in r6720. You need to use some special record which is carried over to next missions scripts iirc.
Please see https://github.com/Kromster80/kam_remak ... paign-data

Lewin may add more details.
Knights Province at: http://www.knightsprovince.com
KaM Remake at: http://www.kamremake.com
Original MBWR/WR2/AFC/FVR tools at: http://krom.reveur.de
<<

Strangelove

User avatar

Crossbowman

Posts: 230

Joined: 30 Jul 2013, 06:32

KaM Skill Level: Fair

Post 27 Aug 2015, 19:02

Re: Saving info for later missions

This looks pretty interesting. My brain is already working on a possible usage-scenario. :D
<<

The Dark Lord

User avatar

King Karolus Servant

Posts: 2154

Joined: 29 Aug 2007, 22:00

KaM Skill Level: Veteran

Location: In his dark thunderstormy castle

Post 27 Aug 2015, 20:39

Re: Saving info for later missions

This is possible in KaM Remake dynamic scripts in r6720. You need to use some special record which is carried over to next missions scripts iirc.
Please see https://github.com/Kromster80/kam_remak ... paign-data

Lewin may add more details.
Ah, that is splendid news. :) When the moment is there I will try it. First I have to finish mission 10 and 13. :)
<<

Strangelove

User avatar

Crossbowman

Posts: 230

Joined: 30 Jul 2013, 06:32

KaM Skill Level: Fair

Post 07 Sep 2015, 14:54

Re: Saving info for later missions

This is all nice and good, but i've played around with this stuff a few hours now and it still doesnt work at all. Can somebody please provide a valid example on how to use that?
<<

Krom

User avatar

Knights Province Developer

Posts: 3281

Joined: 09 May 2006, 22:00

KaM Skill Level: Fair

Location: Russia

Post 07 Sep 2015, 16:45

Re: Saving info for later missions

IIRC newer campaigns in KMR r6720 used that.
Knights Province at: http://www.knightsprovince.com
KaM Remake at: http://www.kamremake.com
Original MBWR/WR2/AFC/FVR tools at: http://krom.reveur.de
<<

Strangelove

User avatar

Crossbowman

Posts: 230

Joined: 30 Jul 2013, 06:32

KaM Skill Level: Fair

Post 07 Sep 2015, 17:11

Re: Saving info for later missions

IIRC newer campaigns in KMR r6720 used that.
I couldnt find the file in any of campaigns that come with r6720. Which campaign exactly uses this feature?
Funniely enough it sometimes works, but when i try to use more than 1 array the map crashes after it finished loading. Maybe I am doing something wrong, but like i said, i wasn't able to find any documentation (beside the one that you linked) or other use-case of this feature.
<<

Krom

User avatar

Knights Province Developer

Posts: 3281

Joined: 09 May 2006, 22:00

KaM Skill Level: Fair

Location: Russia

Post 07 Sep 2015, 17:23

Re: Saving info for later missions

I'm sure someone tested it when we have implemented that. Maybe Lewin can shed some light on this.
Knights Province at: http://www.knightsprovince.com
KaM Remake at: http://www.kamremake.com
Original MBWR/WR2/AFC/FVR tools at: http://krom.reveur.de
<<

Strangelove

User avatar

Crossbowman

Posts: 230

Joined: 30 Jul 2013, 06:32

KaM Skill Level: Fair

Post 07 Sep 2015, 17:34

Re: Saving info for later missions

I'm sure someone tested it when we have implemented that. Maybe Lewin can shed some light on this.
Thanks for your response again. I will try some stuff again and see if i can get it to work. I will post my attempts later on. Maybe you guys have some feedback.
Also, do you have any plans to extend the possibilities of this feature? Like supporting types for example.
<<

dicsoupcan

Moorbach's Guard

Posts: 1314

Joined: 12 Feb 2012, 21:36

KaM Skill Level: Fair

Post 08 Sep 2015, 07:36

Re: Saving info for later missions

I'm sure someone tested it when we have implemented that. Maybe Lewin can shed some light on this.
i had it planned for future missions, but as far as i know no campaign ever implemented this yet. i had a few pm's to and form lewin about this, but i cannot find it atm.
You have enemies? Good. That means you've stood up for something, sometime in your life. ~ Winston Churchill
<<

Strangelove

User avatar

Crossbowman

Posts: 230

Joined: 30 Jul 2013, 06:32

KaM Skill Level: Fair

Post 08 Sep 2015, 07:56

Re: Saving info for later missions

I'm sure someone tested it when we have implemented that. Maybe Lewin can shed some light on this.
i had it planned for future missions, but as far as i know no campaign ever implemented this yet. i had a few pm's to and form lewin about this, but i cannot find it atm.
Thanks for checking. I am playing around with it just now and it seems to work with single varibales, but as soon as i try to use arrays, i get error messages ingame or the map crashes just before its done loading.
Maybe I am just handling the arrays wrong? I ve already started to doubt myself lol.

Only the fallowing seems to work:
  Code:
procedure OnPlayerVictory(aIndex: Integer); begin CampaignData.Mission1.RemainingUnits := 30; end;
  Code:
record Mission1: record RemainingUnits: Integer; end; end;
When i do it as this, i get a crash while loading the map: (sometimes...)
  Code:
var aHouse: array of Integer; procedure OnPlayerVictory(aIndex: Integer); var H: Integer; begin aHouse := States.PlayerGetAllHouses(1); for H := 0 to Length(aHouse)-1 do begin CampaignData.Mission1.iType[H] := 1; end; end;
  Code:
record Mission1: record iType: array of Integer; end; end;
Image

EDIT: Finally figured it out. I had i right a lot of times already it seems. Problem is that whenever you change pretty much anything, you have to close KaM and delete the Campaigns.dat-File in the Save-Folder...
<<

Lewin

User avatar

KaM Remake Developer

Posts: 3822

Joined: 16 Sep 2007, 22:00

KaM Skill Level: Skilled

ICQ: 269127056

Website: http://lewin.hodgman.id.au

Yahoo Messenger: lewinlewinhodgman

Location: Australia

Post 08 Sep 2015, 22:54

Re: Saving info for later missions

EDIT: Finally figured it out. I had i right a lot of times already it seems. Problem is that whenever you change pretty much anything, you have to close KaM and delete the Campaigns.dat-File in the Save-Folder...
It should do that automatically... if you change the format of the campaign data (modify the campaigndata.script file) it should reset the stored data for that campaign from Saves/Campaign.dat.
When i do it as this, i get a crash while loading the map: (sometimes...)
  Code:
var aHouse: array of Integer; procedure OnPlayerVictory(aIndex: Integer); var H: Integer; begin aHouse := States.PlayerGetAllHouses(1); for H := 0 to Length(aHouse)-1 do begin CampaignData.Mission1.iType[H] := 1; end; end;
  Code:
record Mission1: record iType: array of Integer; end; end;
You haven't set the length of the iType array. Try this:
  Code:
aHouse := States.PlayerGetAllHouses(1); SetLength(CampaignData.Mission1.iType, Length(aHouse)); for H := 0 to Length(aHouse)-1 do begin CampaignData.Mission1.iType[H] := 1; end;
<<

Strangelove

User avatar

Crossbowman

Posts: 230

Joined: 30 Jul 2013, 06:32

KaM Skill Level: Fair

Post 09 Sep 2015, 07:47

Re: Saving info for later missions

Thanks for you reply, Lewin. I didn't think that it would make a difference to set the length of the array in this case. However, I finally got it to work with multidimensional arrays now. The code isnt that easy to read anymore, but it works like a charm now!

You meantioned that the campaign.dat should delete itself automaticly, however, it never did that for me. I was stuck in a loop of changing code for hours before i deleted it myself and suddenly it worked. Does KAM delete the whole campaign.dat or just the specific lines and information in it? And at what point does it do that?
<<

Lewin

User avatar

KaM Remake Developer

Posts: 3822

Joined: 16 Sep 2007, 22:00

KaM Skill Level: Skilled

ICQ: 269127056

Website: http://lewin.hodgman.id.au

Yahoo Messenger: lewinlewinhodgman

Location: Australia

Post 09 Sep 2015, 10:40

Re: Saving info for later missions

Thanks for you reply, Lewin. I didn't think that it would make a difference to set the length of the array in this case. However, I finally got it to work with multidimensional arrays now. The code isnt that easy to read anymore, but it works like a charm now!
You always have to initialise dynamic arrays, they begin with a size of zero.
You meantioned that the campaign.dat should delete itself automaticly, however, it never did that for me. I was stuck in a loop of changing code for hours before i deleted it myself and suddenly it worked. Does KAM delete the whole campaign.dat or just the specific lines and information in it? And at what point does it do that?
What I meant to say was that it should ignore the saved campaign script data if you change the format of campaigndata.script. It won't delete campaign.dat.
<<

Strangelove

User avatar

Crossbowman

Posts: 230

Joined: 30 Jul 2013, 06:32

KaM Skill Level: Fair

Post 09 Sep 2015, 11:47

Re: Saving info for later missions

You always have to initialise dynamic arrays, they begin with a size of zero.
I didnt know that, thanks again!

Return to “Dynamic Scripting”

Who is online

Users browsing this forum: No registered users and 1 guest