Script stop working when i load the game

Started by wolkiewicz, July 06, 2015, 11:34:39 AM

Previous topic - Next topic

wolkiewicz

As the subject says. There's the code:

$payload:-400

#-------------------------------------------

once
SetUnitAttribute(Self CONST_REQUESTACPACKETS TRUE)
SetUnitAttribute(Self CONST_MAXAMMOAC 25)
SetUnitAttribute(Self CONST_CONNECTABLE TRUE)
SetUnitAttribute(Self CONST_DESTROYONDAMAGE TRUE)
SetUnitAttribute(Self CONST_CREATEPZ FALSE)
SetUnitAttribute(Self CONST_COUNTSFORVICTORY FALSE)
SetUnitAttribute(Self CONST_NULLIFIERDAMAGES FALSE)
endonce

GetUnitAttribute(Self CONST_MAXAMMOAC) ->MaxAmmo
GetUnitAttribute(Self CONST_AMMOAC) ->Ammo

if(<-MaxAmmo eq(<-Ammo))
@CreateBomb
SetUnitAttribute(Self CONST_AMMOAC 0)
endif



:CreateBomb
PlaySound("Weapons1")
"CRPLCore" CurrentX CurrentY CreateUnit ->unit
<-unit "Blast.crpl" AddScriptToUnit
<-unit "Blast.crpl" "targetX" RandXCoord SetScriptVar
<-unit "Blast.crpl" "targetY" RandYCoord SetScriptVar
<-unit "Blast.crpl" "payload" <-payload SetScriptVar
<-unit "main" "Custom1" SetImage
<-unit "main" 100 255 230 255 SetImageColor
<-unit "main" 0.5 0.5 SetImageScale
<-unit "main" -0.01 SetImagePositionZ
#End

warren

You are not using any features that do not persist across saves. As is always the case, in the event of inexplicably malfunctioning scripts, recompile the scripts, save scenario from the edit screen, then reload the scenario from the edit screen.

wolkiewicz

Yea, but it's finalized map. In editor they work fine. On finalized map too, but when i load the game, they just stop reciving AC.

Tyler21

This is strange, these attributes should apply after save/load.
Did you test whether the other attributes still apply? I mean for instance the core can't be destroyed by a nullifier,etc.?
Have you tried to trace AMMOAC and MAXAMMOAC to see what happens after loading?
"Enjoyment appears at the boundary between boredom and anxiety, when the challenges are just balanced with the person's capacity to act."
― Mihaly Csikszentmihalyi

Check my collection of the 30 most difficult and challenging maps in Colonial Space!

wolkiewicz

It's strange. On 1st play Connectable ,MaxAmmo and RequestPackets work correctly, others don't. I need to off them manualy in CRPL core. When i load the game, nothing works but only Connectable. TraceLog shows 0 at GetUnitAttribute(Self CONST_ACAMMO) and 25 at GetUnitAttribute(Self CONST_MAXACAMMO). After loading save, it doesn't show. That's the part of new code:

SetUnitAttribute(Self CONST_AMMOAC 0)
endif

once
ShowTraceLog
GetUnitAttribute(Self CONST_AMMOAC) Trace
GetUnitAttribute(Self CONST_MAXAMMOAC) Trace
endonce


:CreateBomb
PlaySound("Weapons1")

warren

Please post a zipped version of your scenario folder so that scripts may be examined in situ.

wolkiewicz

That's the 2nd version of arleady uploaded map so you can see it on CS arleady.

Tyler21

#7
I made a quick test and this seems to be a genuine bug that affects REQUESTACPACKETS only.
The corresponding CONST doesn't seem to persist accross saves (even if you set it in the editor, without a script).
Normal packet request and all the other CONSTs seem to work fine after save/load.
However, I have already experienced the issue in the editor, even before finalizing the map.

I have no clue why this happens, but if you put the CONST setting part in the :gameLoaded call, it will solve the current issue in future maps.
"Enjoyment appears at the boundary between boredom and anxiety, when the challenges are just balanced with the person's capacity to act."
― Mihaly Csikszentmihalyi

Check my collection of the 30 most difficult and challenging maps in Colonial Space!

warren

Hmmm. It just occurred to me I never use AC packets. Anyway, that seems to be the problem.

knucracker

REQUESTACPACKETS was added pretty late in the dev cycle for CW3 so I can easily believe that I forgot to persist it on the units.

Setting it in :gameLoaded, as Tyler21 mentioned, is the workaround.