TFMurphy
Level: Smitemaster
Rank Points: 3118
Registered: 06-11-2007
IP: Logged
|
Gamestate Changes from Clone Switching (+3)
Switching clones is not as safe or as without consequence as it should be. There are a number of things that happen simply from changing clones, even if you switch back to the clone you had at the start of the turn. Here's three events in particular I've found.
1. Switching with a clone swaps the position of the player and the clone. This necessarily changes the movement order of the clones, since your 'old' position will take the movement order of the clone you displaced. If you then switch with another clone and then back to your old position, you will have swapped the movement order of those two clones.
Clone Movement Order is important for character scripts that use "Move to Double" and for priority of sword orientations for Aumtlich Gaze reflection. (Also, this means that some movement order changes are impossible to do without using the mouse, since Tab will only cycle through the placed clones in a specific order.)
2. Clone switching causes bridges to fall immediately. On Turn 0, this causes bridge graphics to not be updated (though you still see the falling effect), and any critical hero on the bridge will be killed, causing an assertion.
3. Clone switching causes Aumtlich Gazes to be recalculated. Again, this can cause things to be frozen on Turn 0 when they normally would not be.
A lot of these are Turn 0 problems, which isn't too difficult to fix, but I'm not entirely sure where the best place to handle this would be. Not sure why clone switching needs to run a ProcessTurn at all, since all the stuff it does should either not happen, or should've happened at the end of the last turn.
The movement order thing is finicky, but it's not the only thing that has strange movement order changes within a room (Fegundos being another example), so it could just be left in as a quirk of the system. But it does mean that the gamestate can be changed simply by switching to a set of clones and then switching back to your old position without making a single move, but at least if only movement order changes, it won't take effect until the next turn. (Good thing demos record all this.)
EDIT: Figured out one of the reasons why Clone Switching calls ProcessTurn: it's because the clone you're switching with might be frozen by an Aumtlich gaze, or vice versa. However, that's more to do with not swapping some of the important attributes with clones rather than a need for a ProcessTurn call. In this case, all that needs to be done is swapping the bFrozen states of clone and player.
EDIT 2: Surprisingly, Clones don't actually get frozen by Aumtlich until you switch to them. In order to prevent having to run ProcessAumtlichGaze to be run after CloneSwitching (which may freeze or unfreeze Aumtlich that were not frozen at the end of the last move), it's probably a good idea to have Clones follow the same rules as Mimics in this case, and make them able to be frozen. GetNextGaze and ProcessAumtlichGaze would need to be updated for this (GetNextGaze to set bFrozen, ProcessAumtlichGaze to unset it).
Note that this change would cause CID_PlayerFrozen to be fired whenever a clone is frozen. This may or may not be desirable: the noise could be distracting, and scripting waiting on the "Player frozen by gaze" event would fire immediately. (That said, that piece of scripting is also fired if Mimics or Stalwarts are frozen, not just the player....)
To preserve current sound/scripting, we could prevent the CueEvent from firing when it hits clones, and fire the CueEvent ourselves if the player is frozen after a use of SwitchToCloneAt.
EDIT 3: ...and this still doesn't solve the problem of Aumtlich gazes not appearing on screen after a clone switch if ProcessAumtlichGaze isn't used. Meh. Maybe pass ProcessAumtlichGaze a boolean telling it whether it should update bFrozen or not so that it can at least draw the gazes? Unsure.
[Last edited by TFMurphy at 11-26-2010 04:35 PM]
|