PRPL Shield

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

Previous topic - Next topic

GoodMorning

Code in spoilers can render poorly on some devices, so you know.

Here's one that was working before my connection dropped for some hours.


# --CW3 Shield-- 11/13/2016 4:32:48 PM
CurrentCoords 30 0 1 GetParticlesInRange ->particles
do (<-particles GetListCount 0)
<-particles[I] ->PID #Particle ID
<-PID GetParticlePosition ->PY ->PX
#CurrentPixelCoords <-PX <-PY Distance ->Dist
#Self GetUnitPixelCoordX <-PX substance ->Dist
#Self GetUnitPixelCoordY <-PY sub <-Dist div ->SFYist div ->SFX #Multiply this Shield Force X by shield power.

Self GetUnitPixelCoordX <-PX sub ->SFX #Multiply this Shield Force X by shield power.
Self GetUnitPixelCoordY <-PY sub ->SFY
<-PID <-SFY <-SFX atan2 -0.008 SetParticleImmediateForce
#<-PFX <-SFX sub ->PFX <-PFY <-SFY sub ->PFY
#<-PID <-PFX <-PFY SetParticleMotion
loop



-ve 0.008 results in a gentle outward push. Probably you want it to be inversely proportional to the count in range.

Yes, the code is untidy.
A narrative is a lightly-marked path to another reality.

Prof

I couldn't get it to work  :(

GoodMorning

The effect is rather weak with that version. The problem is calibration: too strong and particles bounce off. Too weak, and particles don't notice. The effect at that strength is subtle, not enough to keep particles off a mine, only to change their paths as they travel there.

I attach a map that demonstrates the version attached. Easier to tweak, can be added to a module or a static core. Note that the right-hand shield collapses suddenly when under enough strain, while the left one will gradually be pushed in on against mounting pressure. Also note that the left one needs a far smaller power value.


I hope this helps. It should be easy enough to add code to disable it (or you could drop the power to 0).

Sorrontis, this could be an interesting way to react to an assault: Once the particle count inside the shield drops (or on ship detection?), reverse the field. Destruction is served.

The same kind of code could be used for a box-field.
A narrative is a lightly-marked path to another reality.

Oblivion

#18
So giving the a neg value to SetParticleImmediateForce always applies the force directly opposite to where the particle is heading?
~Memes have been scientifrically proven to be the very essence of life unto itself~

GoodMorning

Umm...

I admit that I built this through a quick look at the wiki and guesswork. However...

I apply the force away from the Core, which on the test map is (usually) directly under the mine that the particle is targeting.

You can apply the force at any angle.
A narrative is a lightly-marked path to another reality.

chwooly

#20
 While the idea is sound, How useful will something like that really be if it pushing only 50 since it seems the maps that are being built are using 3K or more particles especially as you get closer to the emitters? At distance with 1.5k where you have spread particles are not usually a problem unless they are corralled by a field but it seems to me that at the 3k mark and above which seems to be the magic number for most cartographers will render a shield effectively useless.

Right now my biggest gripe with the game is the mass amount of particles the cartographers use combined with the ease with which lathes are destroyed and the constant back and forth of needed to build due to the lack of hot keys. I can see the shields being just another mechanic that is nice in theory but will not be worth using. Just like the maps that require constant building of suicide ships to blow particle away it is just not fun for those of us that don't have a worn out "p" key.

Cheers
I am free, no matter what rules surround me. If I find them tolerable, I tolerate them; if I find them too obnoxious, I break them. I am free because I know that I alone am morally responsible for everything I do."
― Robert A. Heinlein

Oblivion

The shield  itself doesn't have to be particularly helpful, also, because its PRPL code, it can be modified so that based on the map the creator is making the strength of the field can vary, including the range for however he/she chooses to make their map. If anything this would make it so it would be an interesting enemy to deal with or a very helpful "space bubble" for lathes and what not.
~Memes have been scientifrically proven to be the very essence of life unto itself~

GoodMorning

The script I uploaded will work on all particles in range.

The point of a shield is to give a little breathing space, by effectively providing a controllable friendly field.

One mod this takes easily is mounting to a tiny ship which is otherwise unarmed, or a ship which channels particles into a ball, and then kills with lasers.

We won't know the usefulness of the script until we try.
A narrative is a lightly-marked path to another reality.

chwooly

Quote from: GoodMorning on November 13, 2016, 09:07:41 AM
The script I uploaded will work on all particles in range.

The point of a shield is to give a little breathing space, by effectively providing a controllable friendly field.

One mod this takes easily is mounting to a tiny ship which is otherwise unarmed, or a ship which channels particles into a ball, and then kills with lasers.

We won't know the usefulness of the script until we try.

This is very true, I just put up my thoughts for others to consider as they continue to improve and modify the game and make it as fun as possible for everyone and every level.

Cheers
I am free, no matter what rules surround me. If I find them tolerable, I tolerate them; if I find them too obnoxious, I break them. I am free because I know that I alone am morally responsible for everything I do."
― Robert A. Heinlein

Sorrontis

#24
Quote from: chwooly on November 13, 2016, 08:46:21 AM
While the idea is sound, How useful will something like that really be if it pushing only 50 since it seems the maps that are being built are using 3K or more particles especially as you get closer to the emitters? At distance with 1.5k where you have spread particles are not usually a problem unless they are corralled by a field but it seems to me that at the 3k mark and above which seems to be the magic number for most cartographers will render a shield effectively useless.

Right now my biggest gripe with the game is the mass amount of particles the cartographers use combined with the ease with which lathes are destroyed and the constant back and forth of needed to build due to the lack of hot keys. I can see the shields being just another mechanic that is nice in theory but will not be worth using. Just like the maps that require constant building of suicide ships to blow particle away it is just not fun for those of us that don't have a worn out "p" key.

Cheers

Yep, that is a problem in general. That is why V gave use the ability to change the health of particles, to encourage the use of lower particle counts. Easier on the CPUs after all.

Quote from: GoodMorning on November 13, 2016, 07:00:26 AM
[...]
Sorrontis, this could be an interesting way to react to an assault: Once the particle count inside the shield drops (or on ship detection?), reverse the field. Destruction is served.
[...]

Interesting thought  ;)
"If you want others to be happy, practice compassion. If you want to be happy, practice compassion."

Prof

Ok, part 1 is complete, I'm happy with the function of the shield, what I need to do now is, make it a Unit that requests energy, uses energy, has health, and is destroyed on contact with particles.

Also, for some reason this bit of code:

#If (<-Shield GetUnitHealth 40 neq)
  # <-Shield GetUnitHealth 0.5 add <-Shield SetUnitHealth ->Shield
#endif


Causes Amp gem factories to self-destruct  ???

GoodMorning

That could be because you have calculated a health value, and then passed it as the UID, with the intended UID as the value.

I.e. Swapping the arguments for SetUnitHealth.

I don't even know why you are trying to ->Shield thereafter.

Have a look at planetfall's shield, then. Particle contact destroy is similar.

Also, which code are you using? I found an interesting effect using SetParticleMotion to small values, and then putting an Emitter some way into the field, which did some asymmetrical particle funnelling.
A narrative is a lightly-marked path to another reality.

Oblivion

Would be amazing if you could constantly slightly adjust the field strength and range outwards and downwards, making a spiral. Lots of patterns possibly found from this
~Memes have been scientifrically proven to be the very essence of life unto itself~

GoodMorning

I had the same thought, try this. It can make a spiral.


# --CW3 Shield-- 11/13/2016 4:32:48 PM

$Range:50
$Power:1.0
$PerParticle:0
$TwistAngle:0.0

CurrentCoords <-Range 0 1 GetParticlesInRange ->Particles
<-Particles GetListCount ->ParticleCount

<-ParticleCount 0 do
<-Particles[I] ->PID #Particle ID
<-PID GetParticlePosition ->PY ->PX

Self GetUnitPixelCoordX <-PX sub ->SFX
Self GetUnitPixelCoordY <-PY sub ->SFY
<-SFY <-SFX atan2 <-TwistAngle add ->ForceAngle

<-Power neg ->Force
<-PerParticle if
<-Force <-ParticleCount div ->Force
endif

<-PID <-ForceAngle <-Force SetParticleImmediateForce
loop


TwistAngle will turn the force somewhat before applying it.

3.14: Reverse
+/- 1.57: Sideways
+/- 0.76: Spiral. (Tuning and attraction source required.)
A narrative is a lightly-marked path to another reality.

Prof

#29
This is the script for the shield itself.
# --Repulse-- 11/13/2016 4:11:50 PM

$Range:30
$Slowness:0.8

if (IsPaused)
   return
endif
#If (<-Shield GetUnitHealth 40 neq)
  # <-Shield GetUnitHealth 0.5 add <-Shield SetUnitHealth ->Shield
#endif




#CurrentCoords 30 0 1 GetParticleCountInRadius ->count
#if (<-Shield GetUnitEnergy 0 gt)
    CurrentCoords <-Range 0 1 GetParticlesInRange ->particles
    do (<-particles 0)
   <-particles[I] GetParticleMotion ->OPmotY ->OPmotX
   <-particles[I] SetParticleMotion (<-OPmotY <-Slowness mul) (<-OPmotX <-Slowness mul)
#    <-Shield GetUnitEnergy 1 sub <-Shield SetUnitEnergy ->Shield
     loop
#endif

The trouble I'm having is working out how to run it as a unit.
# --Create-- 11/13/2016 8:44:47 PM
once
    "PRPLCORE" 93 28 CreateUnit ->Shield
    <-Shield self "Repulse.prpl" AddScriptToUnit 
    <-Shield "main" "Custom0" SetImage
    <-Shield "main" "Ships" SetImageLayer
    <-Shield "main" 1 SetImageOrder
    <-Shield self SetUnitIsEnemy (0)
    <-Shield self SetUnitMaxHealth (20)
    <-Shield self SetUnitHealth (10)
    <-Shield self SetUnitParticlesDamage (1)
    <-Shield self SetUnitReceivesPackets (1)
    <-Shield self SetUnitHasEnergyBar (1)
    <-Shield self SetUnitHasHealthBar (1)
    <-Shield self SetUnitMaxEnergy (40)
    <-Shield self SetUnitEnergyPackDelay (10)
endonce

Also, planetfalls shield?