StoreUnit

Parameters
cachegamecache
missionKeystring
keystring
whichUnitunit
comment

Stores a description of a (hero) unit in a game cache that can be later retrieved with RestoreUnit, e.g. on the next campaign level.

The saved attributes of the unit are:

  • unit type ID
  • control groups the unit was assigned to, for example CTRL+3 is control group 3

additionally for heroes (as part of the 'AHer' hero attributes ability):

  • hero level, experience, unused skill points, hero proper name (as index)
  • for both weapons: damage, range, attack speed as deltas
  • base strength/agility/intelligence and separately their bonus
  • armor & move speed as deltas
  • for life and mana: current, max, and regen values as deltas (can be adjusted individually using tome abilities)
    • life is stored adjusted for player's handicap
  • sight range (day) (can be adjusted with UNIT_RF_SIGHT_RADIUS)
  • hero abilities: ability type ID, current level

Unit's inventory items with these attributes:

  • item type ID, charges
  • item flags: drop upon death, perishable, invulnerable, pawnable, used on acquire (powerup), droppable, actively usable.

See also the unit entry in the following Kaitai Struct file describing the w3v format (gamecaches file): https://github.com/WaterKnight/Warcraft3-Formats-KaitaiStruct/blob/main/w3-w3v.ksy

bug

When a unit obtains armor from a research and is then stored in a game cache, restoring it will retain the armor increment without the research, so if the research is done again, the unit will benefit doubly.

bug

If a hero unit was stored under some key pair and later the key pair is overwritten with a non-hero unit, the previous hero attributes ('AHer') will not be overwritten, i.e., they will remain and be merged with the non-hero attributes. This can be observed in the persisted .w3v file. Ingame, it would not make a difference because the restored non-hero unit normally would not use the hero attributes.

bug

When a EVENT_PLAYER_HERO_LEVEL adds bonus Str, Agi or Int (green number), then the Restored Hero will have incorrect base values.

patch

1.00

Source
common.j (raise an issue to discuss on Github or submit a PR)
return type
boolean
Source code
native  StoreUnit						takes gamecache cache, string missionKey, string key, unit whichUnit returns boolean