Flipping with PRPL

Started by GameGlitch, October 21, 2016, 12:34:34 PM

Previous topic - Next topic

GoodMorning

A little testing, and I find that the attached script does almost exactly what you wish.

There are a few PRPL issues to be overcome:
1) Doppel "cores" will remain blue and hold the previous particle "ship", but gradually build a red particle "ship" over this. This may cause some damage, as the old blue particles are destroyed and replaced.
2) Player ships are still bound to the ship slots, and can be selected by this means. While the UI "DESTROY" button vanishes, the "DESTROY" hotkey can still cause them to self-destruct.

A previous discussion on map "surprises" leads me to say: If this is not the end of the mission, provide plenty of warning.

For the script input "WinMapOnCollection", use either 0 (aka FALSE) or 1 (aka TRUE). If you set it to 1, the mission will instantly be won when the cache is collected.
A narrative is a lightly-marked path to another reality.

GameGlitch

Good Morning, which script do you mean by attached script?

Builder17


once
  CurrentCoords 0 1 GetAllUnitsInRange ->units
  <-units GetListCount 0 do
    <-units[I] ->uid
    <-uid Self neq if
      break
    endif
  loop
  --units
  <-uid ->Cache
  --uid
endonce

<-Cache.UnitIsDestroyed if
  Self 0 DestroyUnit #This has no further use when the cache is finished with.
endif

:destroyed
  CurrentCoords 0 9999 GetAllUnitsInRange ->units
  <-units GetListCount 0 do
    <-units[I] GetUnitType "OMNI" neq if #Spare the Omnis, better hope you brought an "Omni Reactors" upgrade to the table.
      <-units[I] ->Unit
      1 ->Unit.UnitIsEnemy #Made a mistake before, this will make them "enemy"...
    endif
loop


This script?

GameGlitch

That's what I thought. If GoodMorning got it to work, there's nothing wrong with the script. I must be doing something wrong instead.

To recap what I'm doing, in the map editor, I go to scripts. I created a script named "Flip Script." After clicking edit, copy-pasting the script to notepad, and saving, I compiled it. There were no errors (making the adjustment that Oblivion suggested).

So, I added "File Script" to the PRPL Core and hit "Apply"  then placed the Core atop the Info Cache. I proceeded to Lathe the Cache, and when I do the Core disappears. But nothing on the map happens. I do have the Ticon Defense Cannons, Benign Emitters, and friendly Energy Mines on the map at the time of testing.


Oblivion

#19
I believe I found what was wrong

once
  CurrentCoords 0 1 GetAllUnitsInRange ->units
  <-units GetListCount 0 do
    <-units[I] ->uid
    <-uid Self neq if
      break
    endif
  loop
  --units
  <-uid ->Cache
  --uid
endonce

<-Cache.UnitIsDestroyed if
  Self 0 DestroyUnit #This has no further use when the cache is finished with.
endif

:destroyed
  CurrentCoords 0 9999 GetAllUnitsInRange ->units
  <-units GetListCount 0 do
    <-units[I] GetUnitType "OMNI" neq if #Spare the Omnis, better hope you brought an "Omni Reactors" upgrade to the table.
      <-units[I] ->Unit
      1 ->Unit.UnitIsEnemy #Made a mistake before, this will make them "enemy"...
    endif
loop


Its not CurrentCoords 0 9999 its CurrentCoords 9999 0 GetAllUnitsInRange, it had a range of zero and a size of a square, reverse the numbers and it should be fine. That should be it I think.
~Memes have been scientifrically proven to be the very essence of life unto itself~

GoodMorning

No, I made the mistake of testing an idea I had while writing the post, and so detached the old script. I then forgot to attach the new one. When I am using that machine again I shall upload it.

Apologies. The version in code blocks here will not touch ships, so you might extrapolate that I had something else in mind.
A narrative is a lightly-marked path to another reality.

GameGlitch

Okay. I hadn't in mind that it would touch ships anyway. Perhaps I wasn't clear about that...

GoodMorning

Well, the script as it stands will flip everything but Omnis.

However, it should be possible to safeguard or ignore whatever you wish, using the script as a base (when I get that machine out again to upload the file).
A narrative is a lightly-marked path to another reality.

GoodMorning

Here we are...

Note: You can place a Core carrying this over any unit, not just an info cache. Ships and particles are not deemed "units" by GetAllUnitsInRange, however. Use comments to remove any undesired functionality.

Perhaps I should check what happens if I try to turn Omnis to the red team... and would they still count against the build cap?
A narrative is a lightly-marked path to another reality.

GameGlitch

All right, we're making progress! The script did flip all the structures; I can even tell you what happens when the Omnis turn to the red team. I just... don't know how to turn that off. Despite the script, they did convert as well. Fascinatingly, I could still control the Omnis and they would still Lathe targets for me, but they would mire the land red instead of blue. I'm sure some map maker out there could use that to make some interesting maps.

In any case, I'll copy the script as I used it, just in case I botched one of the lines. Any idea why the Omnis flipped as well?

# --CacheFlip-- 10/29/2016 12:25:13 PM
$FinishMapOnCollection:0

once
ClearTraceLog
CurrentCoords 0 1 GetAllUnitsInRange ->Units
<-Units GetListCount 0 do
<-Units[I] ->UID
<-UID Self neq if
break
endif
loop
--Units
<-UID ->Cache
--UID

Self "main" "NONE" SetImage #Do not show up
Self ->Self
0 ->Self.UnitLatheTargets #Do not lathe
0 ->Self.UnitIsEnemy #Do not consider this opposition
0 ->Self.UnitMissionGoal
endonce

<-Cache.UnitIsDestroyed if
@MakeEnemy
<-FinishMapOnCollection if
WinMission
endif
Self 0 DestroyUnit #This Core has no further use when the cache is finished with.
endif

:MakeEnemy #[-] Turns all units to the enemy side.
CurrentCoords 9999 1 GetAllUnitsInRange ->Units
<-Units GetListCount 0 do
<-Units[I] GetUnitType "OMNI" neq if #Spare the Omnis, better hope you brought an "Omni Reactors" upgrade to the table.
<-Units[I] ->Unit
1 ->Unit.UnitIsEnemy
#<-Unit <-Unit GetUnitType Trace2
endif
loop

GoodMorning

#25
It's not impossible that where it says "OMNI" it needs to say "Omni". If you look at that section, you will see that I have attempted to exclude them based on GetUnitType. However, PRPL seems to differ from CRPL in that it does not return strings in "ALL CAPS", rather in either "Cobracase" or "CamelCase" (I don't recall a multi-word string return, so I cannot yet tell which). I assumed that the all-caps CRPLish form would work, but it seems to be otherwise.

I'll test:

(Edit): Yes, changing that does make it work. I'm now curious about the behaviour w.r.t. Emergent or particles. More testing to do.

(Edit): It seems that it is only the lathe and controls which remain loyal to the player. Enemy Omnis find particles and Emergent harmless. Omnis also remain counted toward the build limit. Box select fails, but doubleclick and normal click work to select them. Standard destruction methods work, the button isn't even hidden.
A narrative is a lightly-marked path to another reality.

GameGlitch

Worked like a charm! Mission is complete. If you're curious how your script turned out, here's the link to the mission. I don't know if I gave sufficient warning for the cache or not, but we'll see how it goes. Thanks everyone for all your help. It's really appreciated!

GameGlitch

As noted by some people playing, the script grabs the ship pickups and the amp gem factory, making it impossible to use them if the cache was grabbed early. GoodMorning, the only things that need to be selected are the cannons, energy sources, and emitters. If you can adjust the script for that, that would be awesome.

GoodMorning

I encourage you to fix it yourself. In the section where you changed "OMNI" to "Omni", you will see that the line in question reads: <-Units[I] GetUnitType "Omni" neq if

What is required is to change this to something like:

<-Units[I] GetUnitType ->Type
<-Type "EnergyMine" eq
<-Type "TiconDefence" eq or
<-Type "Emitter" eq or if


I do not recall the exact names needed, however. If you can fill them in, good. I won't have time to test them for a while, I think.
A narrative is a lightly-marked path to another reality.

GameGlitch

I'll give it a shot, and I'll let you know how things turn out.