PRPL Shield

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

Previous topic - Next topic

Prof

An Idea I've had.

Picture the CW3 shield, basically a way to re-create that, so it would repulse Particles in a certain field around itself, unless either there was too many Particles or they were above a certain speed.

So, my challenge to you PRPL savvy users out there, can you program this? I'd assume it would involve some (functions/settings/attributes?) such as SetParticleImmidateForce and getparticlemass.

Or I may just be being stupid and its harder than I think :P

Sorrontis

Find X particles in range.

Find each particle position, speed, and direction.
Reset each particle direction in to be perpendicular to previous direction.
Change speed?

Voila!

Note: Make X a decent size 20-50? so most particles will be pushed out of the region, but not all.
Note: Might require a list, maybe not.
"If you want others to be happy, practice compassion. If you want to be happy, practice compassion."

Prof

#2
I've found GetParticlePosition & GetParticleMotion... I'm not exactly sure what it means by 'Delta X' and 'Delta Y' for motion... probably to do with angles and such. As for how to set it perpendicular... all I can recall is graphs xD (Gradient of 2nd line is equal to negative one over gradient of 1st)

EDIT: on further examination, Delta refers to the speed. (as in the parameters for 'Max Speed' it says 'MAX_DELTA')

Sorrontis

Yeah, it won't be completely easy. I don't have all the parameters in mind, but it's doable. Essentially will work like any other weapon targeting, but on mass. Also, you have to find a way to check that the same particle isn't affected twice in the same frame (hence the list).
"If you want others to be happy, practice compassion. If you want to be happy, practice compassion."

GoodMorning

If you want a CW3 shield, you can apply a force which is a multiple of the particle offset.

Give me a minute at a real keyboard, which will mean a delay.
A narrative is a lightly-marked path to another reality.

Sorrontis

Quote from: GoodMorning on November 13, 2016, 01:12:21 AM
If you want a CW3 shield, you can apply a force which is a multiple of the particle offset.

Give me a minute at a real keyboard, which will mean a delay.

Yay, we got someone who knows what he's doing interested!  :o
"If you want others to be happy, practice compassion. If you want to be happy, practice compassion."

Prof

Going off Sorrontis's idea (cause I've been working on it a bit) here's what I've got currently:
CurrentCoords 5 0 1 GetParticlesInRange ->particles
do (<-particles GetListCount 0)
    <-particles[I] GetParticlePosition ->OPpos
<-particles[I] GetParticleMotion ->OPmot
<-particles[I] SetParticleMotion (neg(<-OPmot))

loop

This is not my natural programming style... I've been doing VB for a semester xD
But I'm good at it though. Top of my class.

GoodMorning

Well, I haven't recently touched particle dynamics, only positioning, but here's an untested back-of-the-envelope modification:

CurrentCoords 5 0 1 GetParticlesInRange ->particles
do (<-particles GetListCount 0)
<-particles[I] ->PID #Particle ID
<-PID GetParticlePosition ->PY ->PX
CurrentPixelCoords <-PX <-PY Distance ->Dist
CurrentPixelX <-PX sub <-Dist div ->SFX #Multiply this Shield Force X by shield power.
CurrentPixelY <-PY sub <-Dist div ->SFY
<-PID GetParticleMotion ->PFY ->PFX
<-PFX <-SFX sub ->PFX <-PFY <-SFY sub ->PFY
<-PID <-PFX <-PFY SetParticleMotion
loop


Essentially, take the displacement, normalize, subtract from velocity. I may have lost a negative, one moment while I test...


Also, Sorrontis?
Quote from: Sorrontis on November 13, 2016, 01:13:48 AM
...who knows what he's doing...

To summarize my opinion of this: ??? (Really?)
A narrative is a lightly-marked path to another reality.

Prof

#8
On testing it, the result is that particles reach the center of the core, before being flung off the map, followed by 'empty stack' warnings in the debug screen.
As for the other one (That I was working on) it makes them bounce off XD Just bounce....

Prof

The trouble I've got now, is getting it to let particles through once there's more than 50 in range... (it now stops and occasionally bounces.)

mirror corparation

you could try throwing a IF statement in it to prevent stack warnings

CurrentCoords 5 0 1 GetParticlesInRange ->particles
<-particles GetListCount 0 eq if
    do (<-particles GetListCount 0)
<-particles[I] ->PID #Particle ID
<-PID GetParticlePosition ->PY ->PX
CurrentPixelCoords <-PX <-PY Distance ->Dist
CurrentPixelX <-PX sub <-Dist div ->SFX #Multiply this Shield Force X by shield power.
CurrentPixelY <-PY sub <-Dist div ->SFY
<-PID GetParticleMotion ->PFY ->PFX
<-PFX <-SFX sub ->PFX <-PFY <-SFY sub ->PFY
<-PID <-PFX <-PFY SetParticleMotion
    loop
endif

don't know how to make it do more than 50 particulate though, probably just not processing all the particles in range in time

Prof

It doesn't have a limit, and that's the problem, although, the way I've got it running seems to be working well.

# --Repulse-- 11/13/2016 4:11:50 PM
once
self MaxHealth

endonce

if (IsPaused)
   return
endif

   CurrentCoords 30 0 1 GetParticlesInRange ->particles
   do (<-particles 0)
  <-particles[I] GetParticleMotion ->OPmotY ->OPmotX
  <-particles[I] SetParticleMotion (<-OPmotY 0.8 mul) (<-OPmotX 0.8 mul)

    loop

mirror corparation

doesn't that only slow them down? or is that what you want?

Prof

It slows them to a virtual standstill, so for simulating a CW3 Shield, which holds creeper back, but it still encroaches on the field, it works quite well.

Prof

Currently I'm trying to create a unit that will act as the shield, will have health and be destroyed etc. And its being dodgy. I put it down to the fact I've got no clue what I'm doing :D

Spoiler
# --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
[close]
Spoiler
# --Repulse-- 11/13/2016 4:11:50 PM
if (IsPaused)
   return
endif
If (<-Shield GetUnitHealth 40 neq)
   <-Shield GetUnitHealth 0.5 add <-Shield SetUnitHealth ->Shield
endif





if (<-Shield GetUnitEnergy 0 gt)
    CurrentCoords 30 0 1 GetParticlesInRange ->particles
    do (<-particles 0)
   <-particles[I] GetParticleMotion ->OPmotY ->OPmotX
   <-particles[I] SetParticleMotion (<-OPmotY 0.8 mul) (<-OPmotX 0.8 mul)
   <-Shield GetUnitEnergy 1 sub <-Shield SetUnitEnergy ->Shield

     loop
endif
[close]