Another question...

Started by cpaca, July 18, 2017, 01:50:03 AM

Previous topic - Next topic

cpaca

Ok, so I might as well say what i'm trying to do. 
Attached is a script which is supposed to send particles to enemy particles. 
I will deduct how I got my problems [so you can see if maybe the problem exists elsewhere?] 
Createparticle(CurrentPixelCoords Direction[see below] Speed(1) Health(1) IsEnemy)
Works correctly! 
Direction:
<-particley <-playery sub <-particlex <-playerx atan2 ->direction
The way the error appears i *believe* this works as "intended"
Then I have a do loop where I take a list of particles in range...
but it doesn't run (I can tell because I put a trace in there)
So this is where the problem occurs: 
The one line of code I don't fully understand [that and atan2, but that's math-stuff and I mostly know how it works [Basically, tangent]] 
CurrentCoords <-range 0 <-IsEnemy not GetParticlesInRange ->particles 
IsEnemy is self-explanatory
Earlier: 40 ->range 

TL;DR
How does GetParticlesInRange work? 
Can I set it to a variable [e.g. ->particles]
What are the inputs [and the order of the inputs] 
And please don't just go off this TL;DR; The problem may stem off of somewhere else.
To use [OUR] Custom Modules, go to Forums/Knuckle Cracker/PFE/Map Makers, Ship Builders, and Coders, Go to the pinned posts, find the one named "Custom Modules Thread", Open it, Scroll down until you find ShipModule, Apply that into your map, do not apply it into map if one copy already exists, Apply the Adder script (Sometimes named "Master.prpl, sometimes [shipname]Adder, etc.) and the actual used scripts [which i will state in my posts]. If one copy already exists, do not apply another copy. -The CMC :-)

GoodMorning

#1
Let's see...

Your script does not yet turn the module invisible when it is destroyed. Easily fixed by a "<-Exists eq0 if" block before the pause check.

From the post you wrote, I have no idea what your issue is. Directing your new particles?

Inside this spoiler is an (untested) upgraded form. Length.

Spoiler

# --GunnerPRPL--
#Uses Custom0 for Base
#Uses Custom1 for Barrel
#Individually find numbers to change them yourself

once
Self "main" "Custom0" SetImage
Self "main" "Ships" SetImageLayer
Self "main" 1 SetImageOrder
Self "ShipModule.prpl" "Ship" GetScriptVar ->Ship
<-Ship.ShipIsEnemy ->IsEnemy
-1 ->target
endonce

Self "ShipModule.prpl" "ShipAngle" GetScriptVar ->ShipAngle
Self "ShipModule.prpl" "delta" GetScriptVar ->Delta
Self "ShipModule.prpl" "exist" GetScriptVar ->Exist

self "main" <-ShipAngle SetImageRotation

IsPaused if
return
endif

<-Exist 1 eq if
self "main" 255 255 255 128 SetImageColor
self "barrel" 255 255 255 128 SetImageColor
self "barrel" <-ShipAngle SetImageRotation
<-ShipAngle ->BarrelAngle
else
self "main" 255 255 255 255 SetImageColor
self "barrel" 255 255 255 255 SetImageColor
<-Ship GetShipHasAmp ->GemPresent #Used later, for particle cooldown

CurrentCoords 40 <-IsEnemy not 0 0 1 0 GetNearestTarget ->Target
<-Target -1 eq if
return
endif
CurrentPixelCoords ->playery ->playerx
<-Target GetParticlePosition ->targetx ->targety #select the x y of the target particle
# we know our position [GetPixelCoords] and target position [above]
# So now we just atan2 it to get the angle!
<-targety <-playery sub <-targetx <-playerx sub atan2 ->targetAngle
#Angle gotten!
#No gun, don't bother checking if "gun angle" is proper
CurrentCoords GetLand eq0 if #we don't want to fire inside of land
#No energy usage, don't bother checking
#Time to use the gem!
<-cooldown 0 gt if
<-cooldown 1 sub ->cooldown
else
CreateParticle(CurrentPixelCoords <-targetAngle 1 0 <-IsEnemy) ->new #Type 0 is a "SOFT" particle.
<-life ->new.ParticleMaxAge
<-Target ->new.ParticleTarget #Chase the target without further help from us.
<-GemPresent if
3600 ->life
5 ->cooldown
else
1800 ->life
10 ->cooldown
endif
endif
endif
endif
[close]

Edit:

GPAR works (according to the wiki, our go-to source of information) as you seemed to be using it. The atan2 line also looks good. GPAR returns a list of particles, which can be stored.

You will note that I have changed the GPAR and associated code to use GetNearestTarget - this offloads it onto the engine level code, which is much more efficient and can take advantage of V's backend access, making optimisations such as stopping the search as soon as a suitable particle is located.

If this adjusted script does not work for you, I can look at another time. I didn't have time to test, and I noticed two typos when doing this edit, now fixed.
A narrative is a lightly-marked path to another reality.

cpaca

Well then... It has a similar angle problem of where it lands [But using GetNearestTarget is good to know, lol] 
But instead of going to 0,0... 
Well, it goes to somewhere... dunno how it chooses that place, always goes the same direction.
If you want my fun story [but it breaks CW3 lore] open spoiler
Spoiler
My suspicion is that Platius is in this timeline and the particles are attacking Platius
[close]
To use [OUR] Custom Modules, go to Forums/Knuckle Cracker/PFE/Map Makers, Ship Builders, and Coders, Go to the pinned posts, find the one named "Custom Modules Thread", Open it, Scroll down until you find ShipModule, Apply that into your map, do not apply it into map if one copy already exists, Apply the Adder script (Sometimes named "Master.prpl, sometimes [shipname]Adder, etc.) and the actual used scripts [which i will state in my posts]. If one copy already exists, do not apply another copy. -The CMC :-)

GoodMorning

I'll open it up later, then.
A narrative is a lightly-marked path to another reality.