Knuckle Cracker

Knuckle Cracker => Support => Topic started by: Grabz on June 05, 2018, 07:08:41 PM

Title: [CW3] CRPL OperateWhilePaused toggle spreads to created cores from other scripts
Post by: Grabz on June 05, 2018, 07:08:41 PM
(https://i.imgur.com/We0HERZ.gif)

Here's what's happening:

The placed cores (bomber pads) contain this script:


#bug.crpl

once
    "CRPLCORE" CurrentCoords CreateUnit ->unitUID
    <-unitUID "ship.crpl" AddScriptToUnit
    <-unitUID "main" "Custom1" SetImage

    <-unitUID CONST_TAKEMAPSPACE         FALSE SetUnitAttribute
    <-unitUID CONST_CREATEPZ             FALSE SetUnitAttribute
    <-unitUID CONST_SUPPORTSDIGITALIS    FALSE SetUnitAttribute
    <-unitUID CONST_COUNTSFORVICTORY     FALSE SetUnitAttribute
    <-unitUID CONST_NULLIFIERDAMAGES     FALSE SetUnitAttribute
endonce

:awake
    Self "main" "Custom0" SetImage
:destroyed
    <-unitUID <-unitUID CONST_DESTROYMODE GetUnitAttribute Destroy


Pretty much all it does is create a child unit on top of itself on frame 1, and when the parent is destroyed, the child is set to be destroyed as well. Similar to how you would want to destroy a bomber if the bomber pad is destroyed.

The child unit script is this:


#ship.crpl

CurrentCoords ->y ->x

:destroyed
    "CRPLCORE" <-x <-y CreateUnit ->bodyUID
    <-bodyUID "rotate.crpl" AddScriptToUnit
    <-bodyUID "main" "Custom2" SetImage

    <-bodyUID CONST_TAKEMAPSPACE         FALSE SetUnitAttribute
    <-bodyUID CONST_CREATEPZ             FALSE SetUnitAttribute
    <-bodyUID CONST_SUPPORTSDIGITALIS    FALSE SetUnitAttribute
    <-bodyUID CONST_COUNTSFORVICTORY     FALSE SetUnitAttribute
    <-bodyUID CONST_NULLIFIERDAMAGES     FALSE SetUnitAttribute


If the child unit is destroyed, it spawns another unit on top of itself. This unit will have the rotate.crpl script which simply rotates the image:


#rotate.crpl

Self "main"   Self "main" GetImageRotation -0.1 add SetImageRotation


Now, if the game is ran with only these three scripts, it will work perfectly fine with no issues. Problems occur when you try to add another script that does something completely unrelated to the bomber pad, which is set to run paused, for example to add a range indicator.

I have created this script and attached it to the bomber pad alongside the bug.crpl script:


#operatepaused.crpl

:awake
    TRUE OperateWhilePaused


Now, when the bomber pads are nullified and the ships destroyed, some of the rotate.crpl cores will rotate, other will not, for undetermined reason.

It would appear that the bomber pad having an unrelated script that operates paused somehow bleeds onto these cores, causing some of them to rotate.

Map attached for convenience.
Title: Re: [CW3] CRPL OperateWhilePaused toggle spreads to created cores from other scripts
Post by: GoodMorning on June 05, 2018, 07:29:13 PM
This is a long-known issue. The best-known workaround is to set it appropriately for all scripts in :awake.

IIRC, it only starts to bleed when a unit with that script is destroyed.
Title: Re: [CW3] CRPL OperateWhilePaused toggle spreads to created cores from other scripts
Post by: Grabz on June 05, 2018, 08:40:18 PM
Ah, I didn't know that. Well, unless you can point me to where the issue was officially responded to (if it was), I'll keep the thread, as I think I've attached a pretty good example were Virgil want to take a look at it.