Creating a 'smart' player creature on custom maps

ego533

New member
Joined
May 10, 2011
Messages
91
   So, I don't know if this has been known or previously solved here. I looked and could not find any information:

   When loading a creature for the player on a custom map, either through a 'creature select' script or a simple creation and assignment, I've noticed that the creature seemed to be 'dumb'. It does not really learn any actions and cannot be correctly taught by the player. Using the save/load my_creature commands on the same map will solve this. The resulting loaded creature will be 'smart,' having the regular abilities to learn tasks and learn from the player.

"LANDNUM" refers to the number assigned to the land map.

Code:
Town1 = get town with id 0
creaturePen1 = get building ABODE_NUMBER_CREATURE_PEN in Town1 min built 1.0


tempCreature = create SCRIPT_OBJECT_TYPE_CREATURE CREATURE_TYPE_WOLF at {creaturePen1} using only alignment good neutral evil
set player 0 creature to tempCreature


run map script line "SET_LAND_NUMBER( LANDNUM - 1 )"
wait 1 seconds
save my_creature
wait 3 seconds
run map script line "SET_LAND_NUMBER( LANDNUM )"


delete tempCreature
wait 1 seconds


load my_creature at {creaturePen1}
myCreature = get player 0 creature

-ego533

 
 
Using the save/load my_creature commands on the same map will solve this. The resulting loaded creature will be 'smart,' having the regular abilities to learn tasks and learn from the player.

Yep, that's the way it works. A creature needs to be "assigned" to you. Take a look at my Lion Pride map. It was fun writing that since a player can only have one creature with which he can interact with.
 
  Single father raising kids brings a tear to my eye.


  I don't quite think that's what I'm getting at though. It seems that unless this save/load sequence is run, something about the creature learning is not initiated correctly. I'm not entirely sure how it works since there are a set of a few items the creature will begin 'learning' in any case, but the deficiency does appear to be there. I have played with the commands setting desires, setting the development phase, and the 'teach all' command, but none of these have the effect that the save/load sequence seems to have. For an example, here are steps I do after the map loads

1) Build a field
2) Build a storehouse
3) Wait


Result using standard Lion Pride script:
index.php



Result using modified Lion Pride script:
index.php




  Here is the code I inserted. "+" means this line added:

Code:
...

+global CurrentCreature

...

 set player 0 creature to Creature2
 set player 0 creature to Creature4
 set player 0 creature to Creature3

+run map script line "SET_LAND_NUMBER( 2155 )"
+wait 1 seconds
+save my_creature
+wait 3 seconds
+run map script line "SET_LAND_NUMBER( 2156 )"
+delete Creature3
+wait 2 seconds
+load my_creature at {CreatureHomePos}
+CurrentCreature = get player 0 creature
+Creature3 = CurrentCreature

 begin loop
	if key KB_U down

...

-ego533

 
  I wouldn't have thought of this way to enable multiple player creatures. Very clever and neat, hehe. Interestingly, each creature will retain its own knowledge. As you set to player 0 each creature, watch the learning tab and notice that the lessons follow correctly. You can save/load them appropriately, too. So if you wanted to have a sequence of lands with the same multiple creatures, you could do something like reserve 3 land ID's per actual land and save each creature to it's own creature-mind ID to load on the next map. So Land ID 15 -> 18 -> 21 ... and save the three creatures to (16,17,18) -> (19,20,21) -> (21,22,23) ...


  Adding a bit more.. It seems like a creature created new from a script begins with a 'zero-ed out' learning matrix (as the game's files seem to reference a 'learning matrix'). The creature won't do very much initially. As the player forces interaction through the leash (with fields, buildings, the storehouse, villagers), the creature begins to become aware of the existence of these objects. In contrast, when you do the save/load sequence, the creature acts more like it does during the game. It 'knows' about objects inherently and will interact the first time through its own volition (as much as a simple computer AI has volition..).
  For example, if I create a new creature and assign to me, it will generally just stand there not doing much. If I leash it and tell it to pick up grain from a field, it will then 'know' about the field object. The actions it takes are not restricted the action forced. Rather, the actions appear restricted by object only. Once the creature is told to interact with the field, it will do all sorts of things with the field: Gather grain, water it, poo on it, eat from it. But it will only do these things with the field. If I then tell the creature to gather an ore rock, it will do these same things.. gather ore, eat ore, play with ore, throw ore, poo on ore, attack ore, ....

  This may be interesting in some contexts since the player can control objects interacted with, but the actions taken on the objects are not controlled.

  I ran into some complication from what seems to be a hard-coded restriction I ran into earlier.. if one experiments with lands at low land numbers (1 through 11, say), there are unpredictable conditions applied that I assume are part of making the actual game lands operate. I was testing on a land with number 4, and the creature would never use spells or engage in some of the desires, for instance... So avoid creating or experimenting on custom lands with low land IDs.
   Wrong. Typo caused this. Still probably good not to use low land ID's for either custom lands or testing, though.

  Finally, as I mentioned, I tried playing with all sorts of the documented commands involving teaching actions and setting desires, but none of them seem to have any effect on the 'zero-ed out' learning matrix as described. What I think would be interesting would be to enable teaching the creature in a manner more like B&W 1, requiring the player to engage more to actually 'teach' rather than just 'comment' on various actions. I don't think this is possible with the way the learning is programmed in B&W2, though.

-ego533

 
   As an added note, it appears that there cannot be more than three created creatures assigned to the player. It will work to create the creatures, but there seem to be little glitches with the way the creatures behave and the game may eventually crash.

-ego533

 
 
Back
Top