Survival Pod

Started by Link327, October 24, 2013, 05:53:47 PM

Previous topic - Next topic

Link327

Well, i'm missing it after all, got no idea whatsoever how to script anything in CRPL, so i gotta ask for it, can anyone make a Script, that would make a CRPL Tower to act just like a survival pod, so it would get damaged by Creeper (it should have a little amount of health... about 2-3 seconds until it would get destroyed.), and the player would lose instantly when it gets destroyed. Also, if it would get connected to a CN, it would get picked up, removing it from the map, maybe even making it a Victory Condition to pick it up. (The Map still has to be cleared of any Creeper/Emitters/etc... to be won, but the CRPL Tower must be collected too.)
Link327

ThirdParty

Try this and let me know if it works.

# survivalpod.crpl
# Created by: ThirdParty
# Created on: 10/24/2013
# ------------------------------------------
$framesToDestroy:90

once
SetUnitAttribute(self CONST_CONNECTABLE True)
SetUnitAttribute(self CONST_AMMO 0)
SetUnitAttribute(self CONST_MAXAMMO 1)
SetUnitAttribute(self CONST_REQUESTPACKETS True)
SetUnitAttribute(self CONST_CANREQUESTAMMO True)

SetUnitAttribute(self CONST_COUNTSFORVICTORY True)
SetUnitAttribute(self CONST_CREATEPZ False)
SetUnitAttribute(self CONST_NULLIFIERDAMAGES False)

SetUnitAttribute(self CONST_MAXHEALTH 1.0)
SetUnitAttribute(self CONST_HEALRATE 0.001)
SetUnitAttribute(self CONST_DESTROYONDAMAGE False)
endonce

if(GetUnitAttribute(self CONST_CONNECTABLE))
if(GetUnitAttribute(self CONST_AMMO) lt (GetUnitAttribute(self CONST_MAXAMMO)))
if(GetCreeper(CurrentCoords) gt(0))
if(GetUnitAttribute(self CONST_HEALTH) gt (div(1.0 <-framesToDestroy)))
SetUnitAttribute(self CONST_SHOWHEALTHBAR True)
Damage(self div(1.0 <-framesToDestroy))
else
SetImage(self "main" "NONE")
SetUnitAttribute(self CONST_CONNECTABLE False)
SetUnitAttribute(self CONST_SHOWHEALTHBAR False)
SetUnitAttribute(self CONST_TAKEMAPSPACE False)
CreateEffect(7 CellToPixel(CurrentCoords) -1 5 5 0.05)
PlaySound("Explosion11")
endif
endif
else
Destroy(self 0)
endif
else
ShowMessage("Survival pod destroyed; you have lost the mission and must restart." 200 50)
endif

Grayzzur

#2
I tried a slightly different approach. Went back and played Corvus on CW1 to see how the survival pods behave.

There doesn't seem to be a way to detect when a CRPL Core is connected to the network, so you have to send at least 1 build packet
(or ammo packet as ThirdParty did).

The FailMission was working for me earlier. Not sure what I changed, but it's not causing the mission fail dialog now.

EDIT: Oops, just noticed the request for the pod to survive in creeper for a bit. This version, they die instantly (just like Corvus).

EDIT: FailMission seems to be working again. I had a test map with a lot of scripts. Made a new map with just this script, and it's happy.
Something else must have conflicted.


# SurvivalPod.crpl
# Created on: 10/24/2013 5:36:44 PM
# Author: Grayzzur
# ------------------------------------------

once
# For lack of a survival pod graphic...
# Make it look like whatever you want
SetImage(self "main" "CustomRunnerNest")
SetImageColor(self "main" 128 192 255 255)
SetImageRotation(self "main" PI 4 div)

SetUnitAttribute(self CONST_ISBUILDING TRUE)
SetUnitAttribute(self CONST_BUILDCOST 1)
SetUnitAttribute(self CONST_CONNECTABLE TRUE)
SetUnitAttribute(self CONST_REQUESTPACKETS TRUE)
SetUnitAttribute(self CONST_PACKETREQUESTDELAY 1)
SetUnitAttribute(self CONST_MAXHEALTH 1)
SetUnitAttribute(self CONST_HEALTH 0)
SetUnitAttribute(self CONST_CREATEPZ FALSE)
SetUnitAttribute(self CONST_NULLIFIERDAMAGES FALSE)
SetUnitAttribute(self CONST_COUNTSFORVICTORY TRUE)
SetUnitAttribute(self CONST_DESTROYONDAMAGE FALSE)
SetUnitAttribute(self CONST_NULLIFIERDAMAGES FALSE)
SetUnitAttribute(self CONST_SNIPERTARGET FALSE)
SetUnitAttribute(self CONST_SUPPORTSDIGITALIS FALSE)

FALSE ->IsSaved # Have we been saved?
endonce

#If no longer building but not yet saved
not(GetUnitAttribute(self CONST_ISBUILDING))
not(<-IsSaved)
if (and)
SetTimer0(60) # timer for the image pulse post-save
TRUE ->IsSaved
"Survivors rescued!" "Continue" "" ShowMessageDialog
PauseGame
endif

# Pulse the image for a bit when saved before removing pod
if (<-IsSaved)
# Use the timer value to feed a sine wave that goes from 1.0 to 1.5 and back
GetTimer0 15 add asfloat 4 div sin 1 add 4 div 1 add ->pulse
SetImageScale(self "main" <-pulse <-pulse)
# Destroy object so the mission can succeed, but silently
if (GetTimer0 eq0)
Destroy(self 0)
endif
endif

#If there's creeper here and not yet flagged IsSaved
GetCreeper(CurrentCoords) 0 gt
not(<-IsSaved)
if (and)
# A "SURVIVORS DESTROYED" dialog doesn't seem to work here. CW1 combines it into the
# failed mission dialog with Restart Mission / Exit Mission buttons.
# Don't think we can do that. Settle for the standard mission failure.
FailMission
Destroy(self 2)
return
endif
"Fate. It protects fools, little children, and ships named 'Enterprise.'" -William T. Riker

ThirdParty

Ah, nicely done.  (I sent an ammo packet because it didn't work when I tried to send a build packet.  I figured I was misunderstanding how CONST_ISBUILDING worked, but it looks like you're doing exactly what I thought I'd tried, so I don't know what I did wrong.)

By the way, I have to admit that I'm jealous when you beta-tester types pull magic commands out of your hats like "FailMission", "PauseGame", and "ShowMessageDialog", that aren't listed in the wiki.  (If someone would smuggle me a copy of the beta testers' secret documentation files, and give my account the authority to create wiki pages, I'd be willing to spend some time helping to port it over onto the wiki where everyone could access it.)

eduran

Quote from: ThirdParty on October 25, 2013, 12:50:46 AM
By the way, I have to admit that I'm jealous when you beta-tester types pull magic commands out of your hats like "FailMission", "PauseGame", and "ShowMessageDialog", that aren't listed in the wiki.  (If someone would smuggle me a copy of the beta testers' secret documentation files, and give my account the authority to create wiki pages, I'd be willing to spend some time helping to port it over onto the wiki where everyone could access it.)

I don't think there are any secret documentation files. What you can do is find a Alpha Sector or Campaign mission that does what you want to do and check its scripts by doing this:
Quote from: virgilw on October 21, 2013, 07:54:29 PM
You can start the credits mission, save it, then create a new project in the editor and replace the 'save.cw3' file in your new project with the save you created from the credits.  When you do this, the editor will auto extract out all of the scripts for the mission and put them in files for you.  This way you can look at everything in the credits.

Link327

Alright, Grayzzur's works mighty fine... might not have some health to survive 2 seconds, but well, that's just going to make the map's I'll use it in a little harder... they're not too challenging after all.
Well, thanks very much for helping me out :)
Link327

Grayzzur

Quote from: ThirdParty on October 25, 2013, 12:50:46 AM
By the way, I have to admit that I'm jealous when you beta-tester types pull magic commands out of your hats like "FailMission", "PauseGame", and "ShowMessageDialog", that aren't listed in the wiki.  (If someone would smuggle me a copy of the beta testers' secret documentation files, and give my account the authority to create wiki pages, I'd be willing to spend some time helping to port it over onto the wiki where everyone could access it.)
Actually, I just got thrown into the beta group so I would have permissions to work on the wiki when I volunteered to fix a few things. I didn't play with the game or CRPL until after launch. There's no secret documentation that I can find, just this forum. I use Notepad++, and grabbed the syntax highlight and auto-complete plugins for it available on the wiki. The auto-complete list there has a few commands that don't show up on the wiki yet. That's where I found "FailMission" and "ShowMessageDialog" and experimented with them.
"Fate. It protects fools, little children, and ships named 'Enterprise.'" -William T. Riker

Grauniad

I will add a post with known CRPL commands that are not yet in the wiki...
A goodnight to all and to all a good night - Goodnight Moon

knucracker

Yeah, I apologize for not getting the wiki in better shape for CRPL.  There isn't an intention to not document things, just not the time. The FailMission command is a good example of a very useful command that isn't there.  You have to look at the scripts in the Farbor mission to see it in use.  And it of course is 'necessary' for implementing a survival pod (there are other things you could do I suppose that would also effectively end the map).

The list the G posted were all of the commands that I added in the final weeks of development.  I was in such a hurry that I stopped taking the time to put them in the wiki and just made notes of the commands I added.