save/load my_creature

ego533

New member
Joined
May 10, 2011
Messages
91
  There is another topic that covers some points of this command, but it is 4 years old.

  I have noticed that [ save my_creature ] and [ load my_creature ] will not work correctly if used between maps that are not consecutive. In other words, if I am running a map that has land ID 5, save the player's creature, then load a map with ID 9, the creature will not load correctly. However, if I load a map with ID 6, it will work correctly. Is there a way around this?

-ego533
 
 
   I ironically discovered a solution minutes after posting this.. thanks anyway, hehe.

-ego533
 
Could you post the solution for people having the same issue? :)

Welcome to kayssplace!
 
  These are notes I've made to myself about the game's related behavior. Some of the statements are assumptions.. like the the last paragraph. These may turn out to be wrong:

-ego533




Creature saves, land changes:
  To save a creature mind use the command [ save my_creature ] (my_creature is actually a reserved word, not a variable, always refers to player 0). It creates a mind save in ~/My Documents/B&W2/Persistent Data/CreatureMind/XXXX prepended by the ID of the map NEXT in line (if the current map ID is 4, the prepend is "5-"). If you load the creature on the same map, it won't work since it will try to load the mind with prepend of the current map.

  The load command is [ load my_creature at {X,Y,Z} ].This will load the creature mind with the prepend of the CURRENT map.

  I found that a creature mind is automatically saved when loading a new map (also the next ID in line), there is not necessarily the need to 'save' a creature between maps.

  The load map command is [ load map "./Data/landscape/BW2/LandX.bwe" ]. This will end the current map, wipe scripts, and start the new map

  The .CHL and .BWE are hardcoded to be 'together'. (This is found in white.exe as something like "land%d.chl"). The file names don't have to match, it's just that the .chl file name must be "LandX.chl" where X is the land number specified in the .bwe

  A solution to the map ID and creature mind problem above is to change the current map ID in the running script.. This will mess with some map functions, so it should be done directly before changing a map (or be set back to the correct ID before proceeding). The command is [ run map script line "SET_LAND_NUMBER(X)" ]. (This causes a small glitch in the running game.. The load screen flashes up for just a split second when this command is run) As mentioned above, you do not necessarily need to save the creature before switching maps since it saves automatically. So, directly before running the command to load an out-of-sequence map, run: [ run map script line "SET_LAND_NUMBER(X)" / wait 1 seconds ] where X is the [(upcoming map ID number) - (1)]. So, if you are on map 4, want to go to map 9, X would be 8, and the automatic save of the creature mind will prepend "9-" to the save from this map. If you want to save and load the creature on the same map for some reason, you would need to set the map ID to one less than the actual ID, save my_creature, then set the ID back to the original ID (have waits of 1-3 seconds between the ID changes so the save can complete correctly).

  I have noticed that there are some odd hard-coded behaviors in the retail land scripts.. Not all the lands actually adhere to these rules. Either they do something odd in the scripts or they ran out of time and hardcoded oddness into the .exe (I'm guessing oddness..). For instance, simply set the land ID to 2, and suddenly, the map cannot be 'lost'. Set the land ID to 3 or above and the map can be 'lost' again. Or on Land 3, the creature mind ACTUALLY loaded is creature mind "2-" instead of of "3-"... what? why? The creature is never loaded on land 2, so it makes sense, but it seems like they could have just loaded it, then saved it to keep the game's technical behavior consistent..

 
how did you find out about this? was there any complete decompiler?
 
  It was mainly through experimentation. Also, the statement, "Some of the statements are assumptions.." is telling. Some of the statements describe what I'm guessing is correct from the results of experiments and intuition. The only real discovery beyond what was mentioned here was that the mind saves are placed in files. The filename having a format "X-NUMSAVE.erc" was the main clue.

  Someone was working on a script decompiler found here, but it looks like the work stopped and the source code is no longer available.


  I tried playing around with the command that 'loads a creature from a file' to see if it was possible to load a pre-loaded mind from a file, as was possible in Black and White 1. I could not get this to work, however. Wrapping white.exe in an analyzer, I never see the process even look for the named creature file, so it looks like this command actually does nothing in B&W 2.

  I was wondering how the computer's creatures worked. I thought that they must be loading a mind from somewhere. Looking through the scripts, though, it looks like the creatures are just scripted. Is this true? Open Land4.chl in a hex or text editor and look for "Wolf" to see what look like references to a creature AI script..

-ego533
 
Back
Top