Knuckle Cracker

Particle Fleet => Map Makers, Ship Builders, and Coders => Topic started by: Keeper Decagon on October 19, 2016, 04:27:01 AM

Title: PRPL question
Post by: Keeper Decagon on October 19, 2016, 04:27:01 AM
I'm in the process of making a map with a PRPL core on it, which I had in mind to be the main objective of the map. When it's captured and filled with energy, however, I want it to do a very specific thing: basically, I want it to explode, killing EVERYTHING on the map at the time; structures, doppels, ships, particles and emergents (benign and hostile), as well as the player's ships and structures. It would then complete the mission.

It's to be part of a series where things go horribly awry when the artefact is activated, with this being the first in the series to kick everything off, you see.

But yeah, as a noob to this whole coding thing, I was wondering if this was possible, and if so, how do I make it do these things?

Oh, and as a bonus question, is it possible to change the colour of the Particulates?
Title: Re: PRPL question
Post by: GoodMorning on October 19, 2016, 05:22:00 AM
I don't think particle colours are mutable.

Something similar to the following code may do what you wish (not spectacularly):


:destroyed
0 0 9999 0 GetAllUnitsInRange ->Units
0 0 9999 0 GetAllShipsInRange ->Ships
0 0 9999 0 GetParticlesInRadius ->Particles #I don't recall what the fourth argument is for...

<-Units GetListCount 0 do
<-Units[I] 0 DestroyUnit
loop

<-Ships GetListCount 0 do
<-Ships[I] 0 DestroyShip
loop

<-Particles GetListCount 0 do
<-Particles[I] 0 DestroyParticle
loop


However, documentation is WIP, so the commands may not be correct. I don't know about Emergent.
Title: Re: PRPL question
Post by: Oblivion on October 19, 2016, 06:55:03 AM
The fourth argument is whether the range is a square or a circle. true or false on the square I believe. If its just for the GetParticlesInRadius I believe its like what planetfall or someone told me, it either finds benign, enemy, or both particulates
Title: Re: PRPL question
Post by: GoodMorning on October 19, 2016, 08:32:57 AM
Thank you, Oblivion. That seems inconsistent, but there is a command GetParticlesInRadius, so I suppose it makes sense.
Title: Re: PRPL question
Post by: Keeper Decagon on October 19, 2016, 09:23:49 AM
Quote from: GoodMorning on October 19, 2016, 05:22:00 AM
I don't think particle colours are mutable.

Something similar to the following code may do what you wish (not spectacularly):


:destroyed
0 0 9999 0 GetAllUnitsInRange ->Units
0 0 9999 0 GetAllShipsInRange ->Ships
0 0 9999 0 GetParticlesInRadius ->Particles #I don't recall what the fourth argument is for...

<-Units GetListCount 0 do
<-Units[I] 0 DestroyUnit
loop

<-Ships GetListCount 0 do
<-Ships[I] 0 DestroyShip
loop

<-Particles GetListCount 0 do
<-Particles[I] 0 DestroyParticle
loop


However, documentation is WIP, so the commands may not be correct. I don't know about Emergent.

Alright, thanks. I will try it out when I get home later.
Title: Re: PRPL question
Post by: Keeper Decagon on October 19, 2016, 02:23:20 PM
Well, looks like it doesn't work, like, at all. No matter what I try, the script refuses to do anything at all. Also, it tells me to put <- or -> in front of the Destroy commands for some reason. Tried that too, but still nothing. I guess I'll have to wait until proper documentation is in place, before messing with the code. Thanks for the help anyways.
Title: Re: PRPL question
Post by: Oblivion on October 19, 2016, 06:55:26 PM
I checked and destroyed is in fact a prebuilt in function, did you test by destroying the object you attached the script to?
Title: Re: PRPL question
Post by: Keeper Decagon on October 20, 2016, 04:20:09 AM
Quote from: Oblivion on October 19, 2016, 06:55:26 PM
I checked and destroyed is in fact a prebuilt in function, did you test by destroying the object you attached the script to?

Yes, I did.
Title: Re: PRPL question
Post by: GoodMorning on October 20, 2016, 05:05:15 AM
Putting <- -> $ or @ in front of the commands are common fixes for when you have forgotten one (most likely reason for an unrecognised word turning up: it is a function or variable name).

DestroyShip is a real command.

:destroyed indicates the code block which runs when the Core is destroyed (in whatever way). In this case, when the Core is killed, it should find everything and then kill it all. DestroyUnit, DestroyParticle and DestroyShip are command names.

Does it say something like "Unrecognised [...] Maybe you meant <-[cmd] or ->[cmd]" and so forth? If so, what exactly is the command it dislikes?
Title: Re: PRPL question
Post by: Keeper Decagon on October 20, 2016, 12:21:18 PM
Quote from: GoodMorning on October 20, 2016, 05:05:15 AM
Putting <- -> $ or @ in front of the commands are common fixes for when you have forgotten one (most likely reason for an unrecognised word turning up: it is a function or variable name).

DestroyShip is a real command.

:destroyed indicates the code block which runs when the Core is destroyed (in whatever way). In this case, when the Core is killed, it should find everything and then kill it all. DestroyUnit, DestroyParticle and DestroyShip are command names.

Does it say something like "Unrecognised [...] Maybe you meant <-[cmd] or ->[cmd]" and so forth? If so, what exactly is the command it dislikes?

Ok, I tried it again just now, and here is what happened: so it says "Invalid Token: DestroyShip" and then with the "Perhaps you meant <-DestroyShip, ->DestroyShip, "DestroyShip" or @DestroyShip?" straight off the bat when I try to compile it, and that seems to be the only command it seems to dislike. Putting any of those "<-" or whatever in, makes the script compile alright, but when applied to a core that then is destroyed, it will kill all of the structures (Emitters, Energy Sources, Spawners, etc), but will not destroy any ships or particles. It also gives an error in the debug window: "WARNING: Taking item from an empty stack: GETPARTICLESINRADIUS at line 6".

Title: Re: PRPL question
Post by: Oblivion on October 20, 2016, 06:11:25 PM
This means that either A. DestroyShip is not a real command, and its destroy units or B. It is a real command, but worded differently, and if so, you would have to ask someone with access to all the PRPL scripts (I think its all map makers and admins) for it. As for the taking an item from an empty stack, you didn't give it all the information it needed to carry out the command. Could try GetParticlesInRange. No difference really since your covering the whole map in the range/radius.
Title: Re: PRPL question
Post by: GoodMorning on October 20, 2016, 08:38:58 PM
Agreed. I have seen the (full?) list, and was fairly sure that DestroyShip was on there, but if it won't compile...

It is quite possible I used the wrong arguments for GetParticlesInRadius.
Title: Re: PRPL question
Post by: Oblivion on October 21, 2016, 04:05:48 PM
For destroying all ships there is another method for it. From what I understand the CM can't take a hit from any? health particle or at least a medium/high one.

0 0 9999 0 GetAllShipsInRange ->Ships
<-Ships.listcount 0 do
Ships ->CurrentShip
<-CurrentShip GetShipCoords ->Y ->X #Seems like it gives Y first, took me awhile to learn that
<-X <-Y 0 0 1 1 CreateParticle #Spawn a particle right on the CM
loop

#Granted this would have to be reworked a bit if you have enemy ships on your map.
Title: Re: PRPL question
Post by: GoodMorning on October 21, 2016, 08:26:58 PM
That would take another frame, because you need to kill your new particles too.

You need the to get a ship UID from the list.

GetCoords pushes X to the stack, then Y on top of it. So when you extract them, you get Y off the top, then X. In your code snippet, you can drop X and Y vars, and just use the return of GetCoords.

It should work, but so should DestroyShip...
Title: Re: PRPL question
Post by: Oblivion on October 21, 2016, 08:37:04 PM
I swear I typed in I guess it just doesn't show up for some reason. Also, doesn't the CM absorb the particle like the hull? Never really saw what happens since usually theres a mass of particles that destroy it in maps.

[ I ] I typed this in. I guess you did too lol.
Title: Re: PRPL question
Post by: GoodMorning on October 21, 2016, 09:28:20 PM
Ah, yes... BB code uses an I in square bracketing to denote italics, and we weren't using a code block for this latest section...

CM will die when hull under it is broken, same as for other modules, but it takes the whole ship with it. Particle takes damage from hull contact, but may be tougher than the hull. It needs to be tough to be sure of killing the ship if it is amped or an adjusted enemy.
Title: Re: PRPL question
Post by: Oblivion on October 22, 2016, 05:02:02 PM
I guess the best way then would be to find the name of the command that destroys ships with its UID.
Title: Re: PRPL question
Post by: GoodMorning on October 22, 2016, 08:44:37 PM
According to the WIP docs, it's DestroyShip...
Title: Re: PRPL question
Post by: Oblivion on October 23, 2016, 12:15:13 AM
WIP as in, going to be implemented? or WIP as in, we plan on making the code for the code (if that makes any sense) and have just laid it out so far?
Title: Re: PRPL question
Post by: GoodMorning on October 23, 2016, 01:07:17 AM
WIP meaning that the docs are a work in progress. The actual PRPL API should be working now (as far as I know).
Title: Re: PRPL question
Post by: PhailRaptor on October 23, 2016, 03:46:36 AM
Quote from: Oblivion on October 23, 2016, 12:15:13 AM
WIP as in, going to be implemented? or WIP as in, we plan on making the code for the code (if that makes any sense) and have just laid it out so far?

In context, it would mean the PRPL command catalog is still being constructed.  The code itself is complete, but the dictionary, if you will, is not yet done.
Title: Re: PRPL question
Post by: GoodMorning on October 23, 2016, 04:48:23 AM
A good summary.