https://www.dropbox.com/s/ymktu7q1dd33u0j/iscript%20demo.7z?dl=1
It makes following changes to units:
- Guardian becomes transparent (like cloaked, without requiring detection), while becoming visible while moving.
- Marines can't attack while stimmed
- Overlords have random player colors
- Archon's color changes depending on mouse x/y coordinates (This one is 1.16.1 only though :l)
- Once cloaked, ghosts can't decloak unless they nuke. I didn't test if they can decloak if their energy runs out but that shouldn't work either
So how is this done? You might think there's some mpqdraft plugin doing code edits, but this all is done with iscript!
Most of these tricks use the little-known iscript command "warpoverlay", which is normally only used in the warp texture iscript. What it does is not limited to the warp texture, it sets the parameter for images.dat draw function. The effect varies on drawfunc set there, here's the (almost) full list:
- Drawfunc 0x0 = Normal draw, may switch to hallucination or cloaking drawfuncs, parameter does nothing
- Drawfunc 0x1 = Normal draw, parameter does nothing
- Drawfunc 0x2 = Enemy unit is starting to cloak, parameter specifies state (in lowest signed byte), and timer (in second lowest unsigned byte). Bw reduces timer by 1 every frame, and once it reaches 0, it is resetted back to 3, and state is increased by 1. Once state is 8 or more and timer exactly 0, bw considers unit to be fully cloaked and switches to drawfunc 0x3 (Fully cloaked enemy). Depending on the state, unit appears to be completely uncloaked (state 0), completely cloaked (state 8), or something inbetween.
I used this on the demo mod's guardian's iscript: every animation expect GuardianWalking runs constantly command "warpoverlay 65344", which in hex is 0xff40. It means that the "timer" is 0xff (255), and the "state" is 0x40 (64), though anything between 8 and 0x80 is same, causing guardian to appear as transparent.
However, GuardianWalking uses "warpoverlay 65408" (0xff80), and bw considers 0x80 (-127) to be less than 0, making guardian completely visible. The "timer" is set to 255, as reaching 0 with state 0x40 would cause drawfunc to be switched to 0x3, making guardian permamently transparent. Even though all this looks like there is cloaking happening, the guardian is always targetable without detection.
HOWEVER! If the drawfunc would be switched to 0x3, unit becomes properly, permamently cloaked. (I haven't tested this but it should work, feel free to prove me right/wrong)
Setting drawfunc from images.dat directly to 0x3 does not make unit cloaked, it has to switch from 0x2 -> 0x3. - Drawfunc 0x3 = Enemy unit is cloaked, parameter does nothing. This makes unit just look transparent without being actually one. All the cool stuff happens in drawfunc 0x2.
- Drawfunc 0x4 = Enemy unit is starting to decloak, paremeter specfies state and timer like in 0x2, but now state counts down from 8 -> 0. Once it reaches state 0, unit becomes visible without detection. I used this in the demo mod's ghost iscript, preventing state from ever reaching 0 (with warpoverlay 65408), causing ghost to be "stuck" in cloaked state.
- Drawfunc 0x5 = Detected unit is starting to cloak: Same as 0x2, but makes image appear as detected
- Drawfunc 0x6 = Same as 0x3, but makes image appear as detected
- Drawfunc 0x7 = Same as 0x4, but makes image appear as detected
- Drawfunc 0x8 = ???, parameter does nothing
- Drawfunc 0x9 = Remap, parameter is pointer to remap table. Sadly warpoverlay can't be used to write pointers (It can use write only 2-byte values), using it here will crash the game.
- Drawfunc 0xa = Shadow, parameter does nothing.
- Drawfunc 0xb = Hp bar, parameter is pointer to owning unit. This requires very specific setup by bw and cannot be used by anything else than the hp bar image. The hp bar image can be changes to something completely unrelated though.
- Drawfunc 0xc = Warp texture, parameter specifies the grp frame. This is the one intented use for the warpoverlay command, but I think it is hardcoded to only work with protoss building warpins. But you can edit the WarpOverlayInit animation and it will work.
- Drawfunc 0xd = Selection circle, parameter specifies player alliance color (0 = red/enemy, 1 = green/own 2 = yellow/ally) or something like that. If you look at the selection circle .grp, you notice it only uses this "unknown/blue" color, more specifically palette entries 1 to 9. These get replaced by red/green/yellow as specified by the drawfunc parameter. However, if you use warpoverlay xxx to set the parameter to something larger than 2, it will overflow to other memory and use them as colors for the image! This overflow is version specific, and as such you might as well code code editing plugin if you need dynamic colors. In theroy you could overflow to colors which are used by terrain animation (color cycling), and create some neat animation. Usually it causes just garbage colors though
The demo exe archon changing colors with mouse position uses this trick, though it uses different drawfunc (Hallucination one) - Drawfunc 0xe = Override player colors, parameter specifies player. This overflows when parameter is greater than 11 (neutral), causing similiar garbage colors in place of player colors. Or you can use it to have every kind of unit look as if it is owned by certain player
- Drawfunc 0xf = ???
- Drawfunc 0x10 = Hallucination, parameter should be 0, or the colors overflow once again
- Drawfunc 0x11 = Warp flash, parameter contains state (in lowest byte), and timer (in second lowest byte). This is the warp flash effect that happens when protoss buildings are warped in, quickly fading away. "State" specifies which horizontal line in ofire.pcx should be used to draw the grp, and "timer" counts down from 3 to 0, increasing state by 1 when timer reaches 0. I can't think any use for this function other than very limited special effects
Alright, that was the warpoverlay command...
I'm not done yet though
gotorepeatattk in iscript may be thought as some sort of command which jumps to GndAttkRpt/AirAttkRpt if the unit is still attacking. In reality it never jumps, it only gives the permission to jump once cooldown (counted from previous AttkRpt) has been finished. This means, that if you would insert gotorepeatattk before attack/attackwith/attackmelee, bw will execute the attack command only if cooldown is high enough to reach it. This is what happens with marines in the demo I linked. If you look at the marine's iscript, I had to remove nobrkcodestart/end and add some waits for it to work though, so it is usually not ideal.
EDIT: It seems that bw resets the return position every time it jumps to different animation
Other miscellaneous little understood iscript opcodes are __2d, which I call hidecursormarker. It hides the cursor marker sprite, the "green circle" appearing when you right click somewhere. And yes, it hides always this single sprite, no matter which image uses this command. Also ignorerest only pauses the script execution as long as unit has target, if it dies suddenly the command following ignorerest is ran.
Sorry for the block of rambling, hope someone finds this useful
tl;dr iscript can be used to one-way permamently cloak units,
Post has been edited 2 time(s), last time on Mar 31 2015, 4:03 pm by Neiv.
None.