This is a very interesting proposition. I'll answer each question separately, then try to explain how they work together.
First off: the actual teleportation mechanic. This is merely based on my general knowledge of the game. I haven't looked into too much detail on it.
The teleportation script would work in this fashion:
1~ Save the 'teleporting' unit's health and energy to variables, likely named teleportHealth
2~ Remove the 'teleporting' unit from the 'teleporter' tile
3~ Spawn the 'teleporting' unit on the 'destination' tile. (This would be the tricky bit. I can't think
of any way to have the game automatically detect which character was on the space without writing a unique
script and dialog trigger for each unique unit. It's possible, but would be highly time consuming. Hey! No one
ever said programming was the least time consuming thing on earth!)
4~ Set the Health and Energy of the 'teleported' unit equal to the corresponding variables you set in step 1.
There you go! That would be the general process a teleportation mechanic would likely follow.
Now let's move on to the proposed random teleportation mechanic. Seeing as there isn't currently a random number generator built into the game
, I've been working on a random number generator that works by forcing a specially created character to level up, and determine the random number by detecting which stats were altered.
(Ex. Increase in cold resistance = +1 to the total value, increase in heat resistance = +2 to the total value,
increase in light resistance = +3 to the total value, etc.)
Using this method would require inserting a couple steps into the above process.
2.1~ Spawn the randomizer unit.
2.2~ Using the proper dialog action, force the randomizer unit to level up, causing the OnLevelUp stats that you assigned to be changed.
2.3~ Set a variable randomTotal
to 0. This isn't necessary for the first use, but necessary if you plan on allowing more than one unit to ever
2.4~ Using a long series of if/then statements, determine which of the stats are greater than they used to be, then increase the
based on the method I explained in the paragraph above.
2.5~ Reset the randomizer unit's stats to where they were before forcing the levelup. (This allows you to avoid the having to continually
keep track of the randomizer's stats for future use. It's easier if they're consistent.)
2.5~ Using randomTotal
, determine which 'destination' tile the unit will be spawned on.
In theory, this process should work. Unfortunately I've been unable to get the random number generator I designed working correctly, so this part is all theoretical. The downside to implementing a random number generator means you'd need to use more than just scripts. You would need full blown dialog to implement the if/then statements, and you'd need a ton of dialog if you want more than one type of unit to be able to teleport.
I hope this answers your questions.