Unit idea + befuddling problem

Started by planetfall, January 29, 2014, 09:37:29 PM

Previous topic - Next topic

planetfall

So, I was tinkering with PZ generators, trying to fix an elusive bug, and also working on a new "builder" unit which can produce CRPL player units, which are a ton of fun to design so I can foresee making at least a few more, essentially expanding the number of buildable units on my maps. #Runonsentence

It begins by building a set pattern on the unit and charging it with a requisite amount of ammo. The orientation of the relays determines in what direction the generator spawns the PZ:


It explodes, according to plan, creates the unit, hands it two scripts, both of which run. One is the actual generator script, the other is an "interface script" for convenience and recordkeeping -- if there's a specific variable a script needs to set, on crplcores of presumably any type, they are all guaranteed to have this one. I know both run because the generator script sets the sprite and the interface script sets CONST_NULLIFIERDAMAGES to false.


Great, and, packets arrive at the structure and... aww.


This baffles me. The direction is properly set for gameplay, but not for drawing the beam. Yet the part of the script where SetImagePosition and SetImageRotation are called is the same as where the PZ coords are set... and THAT seems to work right!

The only difference between this generator and the ones already on the map is that this one's variables are set by scripts and the others in the editor gui. Recompiling all scripts fixes the image issue, but isn't possible mid-level and has the side effect of resetting input variables to the defaults.

So... um... This is me right now  ???
Pretty sure I'm supposed to be banned, someone might want to get on that.

Quote from: GoodMorning on December 01, 2016, 05:58:30 PM"Build a ladder to the moon" is simple as a sentence, but actually doing it is not.

eduran

You have to set the image before you can rotate/scale/position it. To hide the image, you can set its alpha to 0.
Self "beam" "Custom1" SetImage
Self "beam" 255 255 255 0 SetImageColor # set alpha to 0 to make image invisible
<-dir "S" eq if
Self "beam" 0 -28 1 SetImagePosition
Self "beam" 0 SetImageRotation
endif
# more ifs ....


Unrelated, but in your interface script you state 'PZs themselves are difficult to detect'. Both GetUnitsInRange and GetAllUnitsInRange (not GetEnemyUnitsInRange) return PZ uids when they are in range.

planetfall

Quote from: eduran on January 30, 2014, 04:07:28 AM
You have to set the image before you can rotate/scale/position it. To hide the image, you can set its alpha to 0.
Ahh, that makes sense. That's why it got all funky when I set the image to "None".

Quote from: eduran on January 30, 2014, 04:07:28 AM
Unrelated, but in your interface script you state 'PZs themselves are difficult to detect'. Both GetUnitsInRange and GetAllUnitsInRange (not GetEnemyUnitsInRange) return PZ uids when they are in range.
Huh. It didn't when I first made the PZgens, but that was with an older version so it's probably changed. Or it was just a mistake in my original code, which is far more likely.

Thank you! I swear I will actually post a map that uses this, unlike those ships...
Pretty sure I'm supposed to be banned, someone might want to get on that.

Quote from: GoodMorning on December 01, 2016, 05:58:30 PM"Build a ladder to the moon" is simple as a sentence, but actually doing it is not.