Moving Emitter test

Started by Jackeea, November 01, 2013, 10:56:55 PM

Previous topic - Next topic

Jackeea

Okay, so I'm trying to make a moving emitter, which basically moves through the map, making creeper wherever it goes, and it gets damaged by AC and Snipers. The only problem that I have is with one of the codes. What's meant to happen is that when it is destroyed, it releases a ton of AC, makes AC rain and fails the mission. However, when it is destroyed, it makes all of the AC, but the mission isn't failed. What's happening?
Edit: Sorry for not explaining this, but in this map, you're playing AS the Creeper, so your goal is to wipe out the CNs without yourself being destroyed :P
# creeper.crpl
# Created on: 11/2/2013 12:52:33 AM
# ------------------------------------------
GetTimer0 eq0 if
CurrentCoords 1 AddCreeper
3 SetTimer0
endif
CurrentCoords GetCreeper 0 lt if
Self CONST_HEALTH GetUnitAttribute 1 sub ->Health
Self CONST_HEALTH <-Health SetUnitAttribute
endif
Self CONST_HEALTH GetUnitAttribute 0 lte if
0 EnableAlternateControlMode
FailMission
25 -100 MakeRain
Destroy(self 2)
endif
:destroyed
CurrentCoords -10000000 SetCreeper
FailMission

Grauniad

Just as a matter of curiosity, how will the mission be won if the mission fails when the unit is destroyed, but while it is alive it creates creeper?
A goodnight to all and to all a good night - Goodnight Moon

Jackeea

Quote from: Grauniad on November 01, 2013, 11:16:46 PM
Just as a matter of curiosity, how will the mission be won if the mission fails when the unit is destroyed, but while it is alive it creates creeper?
Ah, sorry, I mustn't have explained what the purpose of the map is, I'll explain in more detail.
Basically, you control the moving emitter, and your goal is to destroy the player-made structures (pre-placed on the map). So basically, what I want to happen is for the mission to fail when this unit is destroyed, and for the mission to be won when there are no CNs left on the map. Sorry for not clearing that up :P

Relli

I copied your code exactly, and the mission failed like it should. I saw the AC rain as well. So on that point, I don't know what to tell you. I did notice a couple things that would mess you up later, but it's likely you just haven't gotten around to doing that yet. But just in case: Snipers cannot shoot this emitter. You would have to change that in GetUnitAttribute. And it loses one health per frame when anticreeper is over it, but it only has one health to begin with, so it dies instantly. If that's your intention, great. If not, you should either increase the health or lower the damage. And I'm sorry I couldn't help with the problem you actually asked about. Maybe...check for any differences between the code in your game and the code you posted here?

Jackeea

#4
Quote from: Riluna on November 01, 2013, 11:28:28 PM
I copied your code exactly, and the mission failed like it should. I saw the AC rain as well. So on that point, I don't know what to tell you. I did notice a couple things that would mess you up later, but it's likely you just haven't gotten around to doing that yet. But just in case: Snipers cannot shoot this emitter. You would have to change that in GetUnitAttribute. And it loses one health per frame when anticreeper is over it, but it only has one health to begin with, so it dies instantly. If that's your intention, great. If not, you should either increase the health or lower the damage. And I'm sorry I couldn't help with the problem you actually asked about. Maybe...check for any differences between the code in your game and the code you posted here?
Yeah, I added the Constants in another code, along with the movement code, because I prefer code when it's clearer. Makes it a little more difficult to add to units, but much easier to code.
Here're the constants, btw:
# constants.crpl
# Created on: 11/2/2013 12:53:26 AM
# ------------------------------------------
once
1 EnableAlternateControlMode
Self CONST_NULLIFIERDAMAGES TRUE SetUnitAttribute
Self CONST_MAXHEALTH 1000 SetUnitAttribute
Self CONST_HEALTH 1000 SetUnitAttribute
Self CONST_HEALRATE 0.1 SetUnitAttribute
Self CONST_SUPPORTSDIGITALIS 1 SetUnitAttribute
Self CONST_COUNTSFORVICTORY 0 SetUnitAttribute
Self CONST_CREATEPZ 0 SetUnitAttribute
Self CONST_SNIPERTARGET 0 SetUnitAttribute
endonce

Grayzzur

I have a couple of test/scratchpad projects where FailMission doesn't work, but if I create a new project and copy the CRPL script over that has FailMission not working in one project, it works fine in another. I'm starting to think there may be an intermittent bug with FailMission.
"Fate. It protects fools, little children, and ships named 'Enterprise.'" -William T. Riker

Jackeea

Quote from: Grayzzur on November 02, 2013, 12:59:04 AM
I have a couple of test/scratchpad projects where FailMission doesn't work, but if I create a new project and copy the CRPL script over that has FailMission not working in one project, it works fine in another. I'm starting to think there may be an intermittent bug with FailMission.
Thanks, I just tried that, and it's working perfectly. ^^ Thanks!
One other thing that I need to find out- how does the "SetCameraPosition" or whatever work? I've tried the obvious "CurrentCoords SetCameraPosition" , but that just set the camera to the bottom-left hand corner. :\ Then, trying "CurrentCoords 1 SetCameraPosition", assuming that the 1 would be the Z coordinate, that did the same thing. So... any help?

eduran

SetCameraPosition takes pixel coordinates, not cell coordinates. Try
CurrentPixelCoords SetCameraPosition