For a spell to be MUI, it has to store its data in different memory spaces.
Simple example: Everytime the spell is being cast, the caster shall be attached its current intelligence amount. This means that each caster needs its own designated variable. GetHandleId
provides a different integer value for each unit, a unique marker. You can use this marker/index in a hashtable
SaveInteger(<table>, GetHandleId(<caster>), <key>, <intelligence>)
so the hashtable field is dependent on the caster, like we wanted it.
MPI is not necessarily easier but there was no hashtable in GUI before, nor the GetHandleId
. That is why some mapmakers stored the data that should actually belong to the unit to the owner of the unit instead and used that player's player number as an index for arrays.
Do not grasp what your third point is about. There is no GetTriggerUnit()
when variables are being declared. GetTriggerUnit()
is an event response for unitevents, playerunitevents and some more. Global variables do not have to be initialized in declaration but they should have some value before you try to read something out of them.