PRPL Shield

Started by Prof, November 13, 2016, 12:23:04 AM

Previous topic - Next topic

GoodMorning

planetfall built a shield using a set of fixed particles, in a ring.

I advise looking at Inception and planetfall's Exchange maps. Inception has some PRPL custom modules (and probably the shield unit), Exchange has the shield and some more custom modules. There's also a dedicated thread for custom modules.

A module that interacts directly be detecting mouse clicks is harder, but can be done.


Also, does this do what you wish for power use?

#<-Shield GetUnitEnergy 1 sub <-Shield SetUnitEnergy ->Shield
<-Shield.UnitEnergy 1 sub ->Shield.UnitEnergy
A narrative is a lightly-marked path to another reality.

Prof

Unfortunately, it doesn't work for power use. And I'm not quite planning on using it as a custom module yet, more like the cannons in story mode type units.

GoodMorning

#32
I'll take a closer look at some point. I'll try for the fixed form.

Edit:
Here we are, burning power nicely. Also:


  • Shuts down when empty

    • Recharges, to make sure ther's enough power available
    • Bursts power to make a tiny space
    • Gradually opens out to full size, preventing repeat shutdown.

  • Internal reactor

    • Can drain power (constant load)
    • Can behave differently when shut down.
  • Can be set (by mapmaker) not to request energy packets.
  • Can work for free

    • Can require a certain initial power level to boot up
  • Field can be angled or inward
  • Setting to be shutdown or not initially
  • Option for whether to show the power bar (for hidden instances)

Yes, feature creep. It all works, but beware of lag if you use it to contain a large number of particles.

It's probably a good idea to make the field work less on high-health particles, but I will not add that now...
A narrative is a lightly-marked path to another reality.

Prof

#33
Too much XD

Thanks, but I'm looking for just a simple way to add power drain into the code I've already got :P
I can't really pinpoint how to do that however :/

Other than that, I think I can figure out how to get rid of it once its destroyed, and if there's any other problems I find, I can always return to ask :)

Also, on the topic of custom modules. Would it be better to wait for the upcoming support rather than try to use current methods?

-Edit-

I've actually found it, I think, so I'll be testing out power drain once more.

GoodMorning

Yes, I overdid. Hopefully others will find a use for that, though.

For custom modules, it's up to you. The integrated support will result in tighter integration, so that we do not have to use the global store, for instance, but the template that planetfall has built is available now.

Good luck with your project, I'm interested to see the finished product.
A narrative is a lightly-marked path to another reality.

Prof

#35
Currently, I've pretty much finished. Just a mixture of tweaking, and of course, working out how to manage it being destroyed xP
I was going to try and go overboard myself, adding the ability to turn it on & off for rebuilding during runtime... but a UI is beyond my level of... everything XD

Oblivion

The final inception map has code related to when a mouse hovers over a specific coord, or in the case of the map, the PRPL Core itself, and someone did make a particle editing map that involved clicking on cores to adjust settings, you could look at those if you wanted to user-interactive UI with your shield, click on and off.
~Memes have been scientifrically proven to be the very essence of life unto itself~

Prof

How hard would it be to write a bit of code that only affected, say, every other particle, or a random particle?

GoodMorning

Using
mod 2 eq if
and

<-Particles[0 <-Particles GetListCount RandInt]
A narrative is a lightly-marked path to another reality.

Prof

#39
I have no idea what this will do... but that's the point?
-edit-
Well, the 'mod 2 eq if' doesn't seem to work :/
Nor does '2 mod eq if'
# --Randomiser-- 11/15/2016 2:23:28 PM

if (IsPaused)
   return
endif

once
RandInt(2 20) ->VelX
RandInt(3 19) ->VelY
RandInt(2 3) ->Strength
SetTimer0 (50)
endonce


if (GetTimer0 eq0)
   mod 2 eq if
     neg(RandInt(2 20)) ->VelX
     neg(RandInt(3 19)) ->VelY
   endif
   RandInt(2 20) ->VelX
   RandInt(3 19) ->VelY
   RandInt(2 3) ->Strength
   SetTimer0 (50)
endif


CurrentCoords 2 0 1 GetParticlesInRange ->particles
<-particles GetListCount 0 do
   mod 2 eq if
     <-particles[I] GetParticleHealth ->Health
<-particles[I] <-Health <-Strength mul SetParticleHealth
   endif
   <-particles[0 <-particles GetListCount RandInt] ->RandParticle
   mod 2 eq if
      <-particles[<-RandParticle] GetParticleMotion ->OPmotY ->OPmotX
  <-particles[<-RandParticle] SetParticleMotion (<-OPmotY <-VelY mul) (<-OPmotX <-VelX mul)
   else
      <-particles[<-RandParticle] SetParticleMotion (<-VelY) (<-VelX)
   endif



loop

GoodMorning

I made a typo, but this is what I had in mind. (Adapted onto the above).


# --Randomiser-- 11/15/2016 2:23:28 PM

if (IsPaused)
   return
endif

once
RandInt(2 20) ->VelX
RandInt(3 19) ->VelY
RandInt(2 3) ->Strength
SetTimer0 (50)
endonce


if (GetTimer0 eq0)
   neg(RandInt(2 20)) ->VelX
   neg(RandInt(3 19)) ->VelY
   endif
   RandInt(2 20) ->VelX
   RandInt(3 19) ->VelY
   RandInt(2 3) ->Strength
   SetTimer0 (50)
endif


CurrentCoords 2 0 1 GetParticlesInRange ->particles
<-particles GetListCount 0 do

   I 2 mod eq0 if #Affecting every second particle
<-particles[I] GetParticleHealth ->Health
<-particles[I] <-Health <-Strength mul SetParticleHealth
   endif
loop

<-particles[0 <-particles GetListCount RandInt] ->RandParticle #Extract a random particle UID from the list.
<-RandParticle GetParticleMotion ->OPmotY ->OPmotX

0 2 RandInt if #Flip a notional coin
   <-RandParticle SetParticleMotion (<-OPmotY <-VelY mul) (<-OPmotX <-VelX mul)
else
   <-particles[<-RandParticle] SetParticleMotion (<-VelY) (<-VelX)
endif
A narrative is a lightly-marked path to another reality.

Prof

I still don't get how the mod would work, and it seems to effect all of them. Mod just pushes the remainder of I divided by 2.

GoodMorning

#42
Mod does. If there is no remainder, it pushes 0. This will happen on every other execution. I.e. every second time.

If you wish for a given particle to be affected at all (or not) over multiple frames, then you will have more difficulty. This takes every second particle in range during a single frame, and ignores such things as past frames.

Replacing I with <-particles[ I ] will use the UID, which will result in the same frames being affected from frame to frame, but may have unexpected effects resulting from correlations in particle creation order.

Edit: There's an I in square brackets after the <-particles, which I had forgotten would be interpreted by the forum software as italics.
A narrative is a lightly-marked path to another reality.

Prof

hmm.... Well, It'll be interesting then, because otherwise I'll have exponential health particles

GoodMorning

There are tricks to use for stopping the exponential runaway. The least expensive will sometimes cause the script to heal a damaged particle as a side effect: Change health iff it will not go over some limit.

However, health boosting will be problematic to balance at the best of times.
A narrative is a lightly-marked path to another reality.