Things I Would Like to See Added to CRPL

Started by Crazycolorz5, October 12, 2013, 05:26:41 PM

Previous topic - Next topic

Silverite

A cool thing I thought about was a sling shot type of spore one that can have say waypoints would be interesting if someone could make that happen. I can see it now, a spore goes way out into the void to come around the back side of the base LOL

MagmaMcFry

Silverite: You can make that happen, but those spores will be CRPLCores instead of regular spores, and as such will have to be taken down with snipers instead of beams:
Code (arcspore.crpl) Select

$GRANULARITY:20
$SPEED:2
$PAYLOAD:10

@flyInAnArc(MapWidth mul(randFloat mul(1.2) sub(0.1))
MapHeight mul(randFloat mul(1.2) sub(0.1))
randUnitCoords)
SetCreeperNoLower(CurrentCoords <-PAYLOAD)
Destroy(Self 3)

:flyInAnArc
# curveMidX curveMidY endX endY :
# Technically, it's a quadratic spline.
->endY ->endX ->curveMidY ->curveMidX
# Calculate spline midpoint
<-curveMidX mul(4) sub(currentX) sub(<-endX) div(2) ->splineMidX
<-curveMidY mul(4) sub(currentY) sub(<-endY) div(2) ->splineMidY
<-GRANULARITY 0 do
I div(asFloat(<-GRANULARITY)) ->t
currentX mul(1 sub(<-t) dup mul)
add(<-splineMidX mul(<-t) mul(1 sub(<-t)))
add(<-endX mul(<-t dup mul))
->waypointX
currentY mul(1 sub(<-t) dup mul)
add(<-splineMidY mul(<-t) mul(1 sub(<-t)))
add(<-endY mul(<-t dup mul))
->waypointY
QueueMove(<-waypointX <-waypointY <-SPEED)
loop
while GetQueuedMoveCount neq0 repeat
delay(1)
endwhile

Code (yourturret.crpl) Select

:FireArcSpore
# speed payload image scale : uid
->scale ->image ->payload ->speed
CreateUnit("CRPLCORE" CurrentCoords) ->spore
SetUnitAttribute(<-spore CONST_SNIPERTARGET true)
SetUnitAttribute(<-spore CONST_NULLIFIERDAMAGES false)
SetUnitAttribute(<-spore CONST_CREATEPZ false)
SetUnitAttribute(<-spore CONST_COUNTSFORVICTORY false)
SetUnitAttribute(<-spore CONST_TAKEMAPSPACE false)
SetUnitAttribute(<-spore CONST_DESTROYMODE 1)
SetImage(<-spore "main" <-image)
SetImagePositionZ(<-spore "main" 0.01)
SetImageScale(<-spore "main" <-scale dup)
SetImageRotation(<-spore "main" randFloat mul(2) mul(PI))
AddScriptToUnit(<-spore "arcspore.crpl")
SetScriptVar(<-spore "arcspore.crpl" "SPEED" <-speed)
SetScriptVar(<-spore "arcspore.crpl" "PAYLOAD" <-payload)
<-spore

Note that I didn't test this code, but it should be fine.

Jacobkolstad

You should be able to script most of it, but I am not the best scripter, I am currently just testing around with things :P

Grayzzur

While we're on the subject of CRPL player unit support -- have you tried moving a CRPL Core that's connected to the player network? It hangs on to its original connections and doesn't make new ones, like a moving player unit would. It hangs on to its connections regardless of distance.

You can cycle CONST_CONNECTABLE on and off to work around this a bit, but that has other side effects, including killing any incoming packets.
"Fate. It protects fools, little children, and ships named 'Enterprise.'" -William T. Riker

Relli

There's a lot involving connections that you can't do with CRPL. In particular I would love to see a way to set connections from a CRPL core. I had an idea for recreating the Beacon tower by having it force a connection between any units in its range and the three Command Nodes. If you could also alpha-out the connection lines, it would look like packets were floating directly to each unit. But that requires fairly specific commands to be introduced. It's also impossible plot-wise, since rift space was closed. But hey, it'd be neat all the same.

Lord_Farin

Looking at the wiki/docs, one thing that strikes me as missing is information about energy.

* How much is generated per second?
* What is the production of this collector? (This could be ill-defined, e.g. if generation is determined only in terms of soylent, overlap would pose some problems.)
* What is the production of this reactor? (Taking upgrades into account.)
* What is the total soylent area on the map?

Most of these could probably be scripted in an ugly and inefficient way, but since the game needs this information anyway, I suppose that it's easier if there were built-in support.

(Context: I was thinking of a custom map where building reactors would be limited to collectors generating the majority of the energy. The SetBuildLimit command deals with one half, but I need to be able to access energy generation information for the other.)
Behold, Nexus! Looketh skywards, for thy obliteration thence nighs, my foul enemy!

MagmaMcFry

Instead of writing CRPL for that, you could just throw some tech packets around the map that allow you to build a few reactors each.

Harkler

#22
GetNearest




ArgumentsResultNotation
X,Y,Unit NameUnit IDx1 y1 s1 - u1

Returns the coordinates of the nearest unit of a specified type.
Putting "Unit" as the Unit Name returns the nearest unit.
Unit names must be one of the follow strings. Names are NOT case sensitive.

Spoiler
UNIT
CRPLCORE
COLLECTOR
RELAY
REACTOR
OREMINE
SIPHON
TERP
GUPPY
PULSECANNON
MORTAR
STRAFER
BOMBER
SPRAYER
NULLIFIER
SHIELD
BEAM
SNIPER
FORGE
BERTHA
POWERZONE
OREDEPOSIT
RESOURCEPACK
SHIELDKEY
TECHARTIFACT
MESSAGEARTIFACT
THOR
CRPLCORE
RESOURCEPACK
TOTEM
EMITTER
SPORETOWER
RUNNERNEST
AETOWER
INHIBITOR
[close]

Edit: Grayzzur was awesome enough to write this code that returns the UID of the emitter closest to the CRPL unit. It can also easily be modified to return the UID of something other than the emitter.
:GetNearestEmitter
-1 ->NearestEmitter
9999 ->NearestDistance
MapWidth 2 div ->cx
MapHeight 2 div ->cy
MapWidth MapHeight max 1 add ->range

<-cx <-cy <-range TRUE GetAllUnitsInRange 0 do
 ->eID
 <-eID GetUnitType "EMITTER" eq if
   <-eID CONST_COORDX GetUnitAttribute ->sx
   <-eID CONST_COORDY GetUnitAttribute ->sy
   CurrentCoords <-sx <-sy Distance ->sd
   <-sd <-NearestDistance lt if
     <-eID ->NearestEmitter
     <-sd ->NearestDistance
   endif
 endif
loop
<-NearestEmitter
return