#Custom Enemies Support/Thread
1 messages · Page 2 of 1
i see,
still thank you 
Alright, so apparently the FlipPlane behavior has this weird quirk that is determined by the mod's isLegacy flag. Because there is only one version of it that is used in both Reclayed and Classic mods, what happens is that in Reclayed, it can receive knockback and uses turrets under ReclayedTurret behavior, whereas in Classic, it is immune to knockback, and uses turrets under Turret behavior (i.e. the the legacy variant).
Are rotations currently supported?
rotations, as in? compared to what entity?
Rotation as is sprite rotation
Withouth having to manually draw the rotation
ah gotcha
hmmm, not that I know of :(
that'd be really useful for porting Platypus 2 windmills too
Is it possible for custom enemies to drop weapon stars when destroyed?
Yes, but it is done within the level file. Either by
- Setting
fruit_seton the spawn command - By using
setBonusCounter,setBonusRewardand then settingbonuson the spawn command
You can look for those in the existing levels for some examples
I was wondering if is posible in lua to add more sprites like squid bottom witch is not a entity but just a sprite
This function is what the main game uses for things like the squid bottomlua ---@param spriteSheetName string ---@param orderOffset integer ---@param globalOrderOffset boolean? ---@return SpriteAnimator function BaseEntity.SpawnAttachedSpriteAnimator(spriteSheetName, orderOffset, globalOrderOffset) end
You can call:
---@return Collider2D
function SpriteAnimator.AddCollider() end```
and then pass that collider to:
```lua
---@param collider Collider2D
---@param playerCollisionCallback function?
---@param bulletCollisionCallback function?
function BaseEntity.CheckCollision(collider, playerCollisionCallback, bulletCollisionCallback) end```
If you want to detect collision on the "attached sprite animator"
Thanks
Though I'm not sure if you can actually set the offset of that SpriteAnimator now that I look at it closer. That interface doesn't look like it is exposed to the LUA environment..
@buoyant lake Is this something I'm allowed to expose? Should not be that big of a change
The more the merrier honestly
for now i can do kinda the same effect by just making the bottom as an entity and adding it as a turret
Untested, but the new definition for SpriteAnimator will be:
---@class SpriteAnimator
---@field totalFrames integer
---@field currentFrame integer
---@field timePerFrame integer
---@field totalRows integer
---@field totalColumns integer
---@field currentRow integer
---@field currentColumn integer
---@field currentSheet string
---@field position Vector2
SpriteAnimator = {}```
been trying to use the new get player position but seem that im only getting nil
im still quite confused how to use any of this get player
i tried using something like the regular get player but seems that didn't worked much
Player is not a global, it is a type of variable that you get from another function. I believe that function was called GetPlayer, so you would call it and then use the resulting object to access the position
GetPlayer(0).GetWorldPosition()
i notice, one of the few things that have sprite rotations are lightning star guns, to rotate the lightning sprite
haven't seen if rotation for sprite is posible for lua
i have noticed with lua entities when used as turrets
sometimes they might get behind for some reason despite the bottom part
being in sort rder 10000, and the gun just being a regular squid gun
-# also hi psychosquid
what is the squid's sort order?
Just 1000
Oh I see
then that's quite weird
just to be clear
body, regular squid bheaviour 1k order
gun, lua gun i made, no order
bottom a separated lua entity 10k order
Ah, I see hmmm
wait, isn't the order supposed to be below 1k? of the bottom, I mean
for it to be on top of the squid body
hmm could try that
can we have an editable player shots?
that worked ^^
however there stil the gun who is still rendering behind
i fixed it by giving the squid the original squid sort order
either that or giving the gun a lower order than the body should work 
the lower the sort number, the more "in front" something will be
i was wondering, does the particles trails that entities leave
use this function?
or is it other?
No, the trail is a completely separate system, unfortunately not accessible for lua scripts
that's unfortunate, but i guess having an invisible turret entity do the trail could be a work around
also another question
is it posible to give
custombehaviourdata (like stars hangtime and other)
from lua?
CustomBehaviourData is shared among every single instance and set in stone on mod-load, so unfortunately no
my bad for the anmount of question
but does this actually mean that you can use the data from the json for shard generation
or is it for making it from 0?
No worries, I am supper happy that people are using the interface so I do not mind answering questions
EntityDataProxy.damageEffects is an array of DamageEffectData
You should be able to access it like so: self.data.damageEffects
I'm not currently seeing how one would get CustomBehaviourData, but all the other valid fields within entities.json are found within self.data.
Not being able to access CustomBehaviourData does look like a bit of an oversight
Question. Would giving a squid gun a random spread require a custom behavior?
Hmm. Maybe it would be best for me to wait for an example to be made first...?
Unrelated to this thread tbh, but will there be a collision sprite for the player ship built in the Platypus Original mod folder?
can we make players equip their custom default weapons?
@safe rover
so we can make custom players in the future
with different weapons they were started with
Yes you can, any entity can set the player weapons and timers
Can you add their default skins on the ships.json
So we can edit it ourself
That might be specified in the modmeta, not completely sure though
Yes you can. ;3
Like make them not just shoot a normal projectile but like they normally equiprocket stars forever
Just add "DefaultGun" : entity_player_shots.json "name"
Oh, nvm
Something you can do is spawn a Lua entity that does that at the start of a level, but for that actual behavior, I think you will need to ask @buoyant lake for it
Will most turret entities have configurable first shot delays?
some entities have some small time where they can't be damage
is there any function in lua for that? (the invincible part)
Yeah like your bouncy bullet
They can be hit althought it just a projectiles
@buoyant lake will you allow us to had no collision on lua coding?
you need a logic layer for that
i haven't put one onto it because i haven't tounched that entity in a while
@safe rover is tracking what can and can't be done
how do i use logic layers? 
@safe rover, @solemn nest, @opaque island?
Xmas holidays for the next two weeks but am sure someone will pop in
I will check when I’m back at my PC in a day or so. Feel free to remind me if you don’t hear back 🙂
This is moreso about the level data files themselves, but is there some sort of an opposite for "if enemy is on screen" arguments?
This also includes a variation for specific enemy on screen.
Since the code that drives the turrets is different from eachother with some being more complicated than others. That's most likely going to be a no, all turrets should ask their parents if they can fire though so you can control turrets that don't have that flag that way
You can define a func OnHitByBullet(bulletEntity: BaseEntity) function on your lua behaviour that will be called when a bullet hits it, the main game simply doesn't apply the damage if something is supposed to be invincible, but it looks like it will still call the base...
That seems like a bit of an oversight, but fixing it retroactively might change some script behaviours.. Not quite sure what to do about that
waitForNoEnemies
How about for specific enemies.
I am specifically asking for the opposite of "if specific enemy on screen".
ifSpecificEntityOnScreen
Yeah, but inverted.
That one doesn't exist at the moment
Best you can do right now is chain a bunch of ifSpecificEntityOnScreen checks that wait just for a bit of time
Well, I do want to make it so that the particular enemy will force some enemies to not spawn until the former is defeated.
great
on another thing, what about self.SetLogicLayerEnemyShot()
i tried putting on initialize or tick, but didn't work,
mostly want it to player bullets to ignore it
EnemyShot and PlayerShot do collide because of the Sonic Pulse weapon
I've let Stu know that the image on the documentation website doesn't load, but here it is:
i think the only one that ignores bullets but not the player was
SetLogicLayerPlayerPickupCollider()
but it makes apppear some colllision errors in red text
Best would be to change the behaviour so that defining a function in lua stops it from calling the base, that's how the main game does these things
i see, but i guess i do have to wait for a next patch
does the engine allow global vars in lua? just for easy var sharing between entities
It does not
i see 
well atleast i can skip 2 more hours of smashing my head onto the keyboard
No scripts share an environment
@safe rover, is there a way to set a delay for the turrets through lua?
If you make your own turret you can do pretty much whatever you want, yes
I wonder if there is a lua replica of reclayedTurret.
I'm not aware of any
Yeah I think the best way we can really get the ball rolling is to figure out how to make a lua turret.
would open up all sorts of custom enemy making.
i uh have some turrets behaviour
Lua ahh
All I can make with Lua is backwards saucer
Which will be on Level 6 Dessert Mission
And they're coloured Green referencing Platypus 2 green fish
It would be nice if entities have a universal tag for setting up their default fruit drops, so we don't have to use the ser fruit drop commands in .plat files.
seems that the entity position can't be change
it would be nice if you could change the entity position instead of adding velocity for position
well atleast i can just use spawn entity to just get it to be on a pos i want
That is a bit more complicated as you can only set that position during logic updates, this velocity is used for interpolation
Though that said, you can set the the velocity to be the delta between the current position and the position you want for pretty much that effect
could someone tell me where can I find the bosses' codes and create custom boss behaviour?
and maybe how to set up things in lua?
Not sure if anything like that exists yet but ig the best person to ask rn would be @frail matrix
DMed today already
👋 i missed the dm anyways
there no custom boss behaviour
all bosses are just enemies
and you can't really access the base game code anyways
really the only thing that makes a boss, a boss
is 2 parameters being boss timer and end boss timer on death
which can be setup in entity . json
So they can't be recreated with lua?
What are we missing, the boss timer?
Or can that be triggered by lua? 🤔
boss timer is in entity . json
also you can always use guesswork
but lua has limitations still
you may hit some walls
-# oh. Sorry I guess
Is there a way to call entity.json from a lua sprite tho? Haven't messed with it yet so I got no idea 🤔
then where is the bosses' behaviour?
Sillytuna mentioned lua
you make them from 0 
kinda?
1 second
with no experience it would be much easier for me to use existing thing as a template
Someone needs to make one tho, since one doesn't exist yet, sadly
you can access a lot of data from the json itself
but if i remenber you can't make custom behaviours fields
like some behaviours have
this is in lua, right?
yeah stuff you can acess from the json into lua
hm
you have 1 templace
the saucer 
i think it would be better for looking at others works and using it as a base
there only 1 lua template
ah I see
.
gahhh I don't even know how to start
-# just like with my essay today
how does movement work? how to define if something is connected with another thing?
you asign movement with self.movement = { x = something, y = something, z = 0 }
could you put an example?
like... saucer connected to a saucer
what do you mean
if I were to program a bit more complex entity
that isn't just one thing like a saucer
like multiple entities chained together ?
exactly
haven't tried it myself,
but i think using a spawn spritesheet and adding it an offset, then passing it trought a collider, and passing the collider to the entity might work
but again that is just in theory and haven't tried myself
uhm i really depends since i gotta do studies soon so i might be less available
I can relate, studying in college myself
Also, you don't mind me asking for help that frequently, right?
if it helps the overall modding scene, i don't mind
I think it's just a waiting game at the moment until people start to recreate more things we can utilize with lua like turrets and enemies.
I did see a bit ago someone recreated a green big-un.
at least partially.
that was mine
im still working on it
but im a bit stuck in the shard system
well, I'm not exactly sure what you mean, but I think it of: If I know more, then I can spread the knowledge too, so more people know?
I'm wondering,
Who created the "mine throwing can" enemies?
Th ones that open and throw a mine
is the door a separate entity?
@frail matrix
I knew it 
The door is defo a turret entity, and shares the same behavior as the squid gun.
But, the mines themselves are lua-coded.
hm
so no additional lua needed for the door
speaking of lua, there are so many versions of it, which one do I pick?
The mines?
Try opening .lua file on VSCode.
ok, it's open-able in VSCode
this is for movement?
first one is command to start moving and the speed,
the second one is to define the movement pattern?
What file is that?
saucer.lua
I'm trying to find out what command does what
there are obvious ones
but some are not
Maybe try to change one thing and see what are the changes in-game.
It's essentially experimentation.
ya
i keep getting this issue that when i put turrets on an lua entity they keep rendering behind the entity itself
something it doesn happpen, sometimes it does
and i don't know why does it keep hapening, and doesn't seem to be anything about the sort order either
is kinda driving me insane 
There is an argument you can give to the create turret function, that you can use to change the order if I remember correctly
is it this one?
Nope
then just regular child entity?
Yeah that's the one I think, not sure what the argument in question is though I'm afraid
maybe is the same as the spawn spritesheet
orderoffset
I'd have to dig into the code to tell you, but I can't do it right now
it's okay, this is already pretty helpful ^^
is there a way to change Submarine's gun position without having to rewrite it's code?
i think any turret that is tied to a behaviour is hard codded, so can't be modified
same with the uns turret in high difficulties
has anyone managed to make working child entity?
ah yes
still searching a bit to change it render offset
will you include that in the Mod Advanced Pack for others to learn?
maybe when i organize my stuff i start making examples
oki
how does implementing a turret work?
can I just add a ChildTurretEntity and call it a day?
or do I have to mess with behaviour
Adding a turret to an entity?
yes
adding a turret to an existing entity
as the turrets have their own codes and behaviours
Check the entity data of a gunship as a reference.
How can I recreate gunship mk II behaviour code?
it moves, changes between some sprites, spawns turrets and moves back, shooting it causes it to move forward, like Ticks
by the way, thanks, it worked!
Mk2 is fliplane, right?
me forgot to tell that 
it's ok! lol
will that work with squid guns too?
You can add any type of turret however you want on your custom enemy.

And yes, squid guns are included. >:3
imma make something that Callisto will LOVE
how is ti possible that I can't find (via search) laserSquidGun in my entities_turrets.json?
it's not another hardcoded crap now is it.
{
"name": "laserSquidGun",
"sprite": "Sprites/Enemies/squid gun red",
"behaviour": "LaserSquidGun",
"customBehaviourData": {
"shotOffX": -25,
"shotOffY": 10
}
}
Even though it doesn't actually exist in the modkit, you can just copy what I just sent. ;3
thanks!
-# nevermind, I think I got it, sorry for the ping
sigh I've been trying to implement a test behaviour into an entity
I thought it was naming issue
Then I thought it was an issue with Behaviours.json
no idea now.
You're making a trailing saucer?
Can you send the json for the entity?
Wait a minute...
Has any other modder messed around with behaviours.json with some success?
I don't even understand what that file is for anyways 
For real.
it looks just like animations.json, each behaviour has it's entry
but not every one is there
To my observation, I don't think anyone who made custom enemy behaviors have touched behaviours.json.
DMed it
I didn't touch it at first
but then I thought it maybe was that "pool" the game was referring to
It's a bit of an older file that hasn't been extended much during development, the main thing stored in there is that pool, which is the amount of instances the game pre-allocates for any given behaviour
It does dynamically add more if the game uses more instances than specified though, so modders shouldn't really need to change it
Could someone tell how to make a saucer trail?
as a beginning of making child entities
-# or any kind of example, anything
just. how. to. attach. any. thing. to. an. entity.
any child entity should be glued to your main entity by default, it kinda just works like turrets
that's all? it just needs to be done like gunship's turret for example?
yu know, I'm talking about an example of 3 saucers connected one to another
is it possible to make child entity of a child entity?
that sounds weird
why not just spawn all those 3 with the main one
it's just an example, I plan something bigger than that, like something similar to train, or serpent etc
those are connected entities
haven't experimented much with child entities so can't help you much
i'm just working on my stuff, not making bases right now
I know you're not making bases.
I just wanted to know what have you experiemented already with
when I understand more and more coding, I won't be asking questions and disturbing overall.
i forgot 
gotta organize my stuff
does lua coding work everywhere the same? or Platypus has stuffs working specifically?
-# probably not, it would be too easy.
-# I'm considering just finding a course school whatever and fully dive into that thing
tecnically the basics are the same as your average lua
but i think the functions itself are custom made for the platypus engine
ok, so knowing lua basics will help, I'm gonna find somewhere to learn it then
I'm planning to make a new enemy
-# and before I ask for any help, I'll try myself.
Ah, I know
I'm planning to make a custom lightning sprite
So I'll have to make a copy of the gun
but, how do I assign my custom lightning to the gun?
maybe setting a bullet entity will do...
here we go, gg
Have a variant of an enemy lightning effect?
yes
so the og effect stays, but my enemy uses a different one
that just has different shape
It seems that the lightning is another hard-coded crap
or the laser squid gun
I could copy it, but it doesn't state the "bullet" it shoots
Sadly true. ;-;
that really kills any idea.
is there maybe a way to make the bullets simulate a stream of lightning?
@frail matrix I remember seeing custom lightning star in Casinopolis, could you give an advise?
of?
I want to make a variant of lightning effect
the bullet?
I suspect so.
the regular squid lightning gun is hardcoded
the only custom lightning turret is the star lighting gun
the ships will be in one sprite and this is planned to be the bullet
is it possible to create something like this with star guns?
i don't think so
hm, alright
The folks at Platypus 2 Reclayed made smth like that before the lua days, but it's unpolished.
you may make it more easily with lua
really you would only need like 2 entities
or 1 if you pass the lightning as a spritesheet with a collider
lua =/= easy for me at the moment
I can just reuse existing assets and behaviours
that looks pretty cool
tecnically you have everything you need for that in the saucer example
you only need to make the looping lightning which
is just 2 lines
and add it as a child entity to the saucer
-# you can even skip this step if you add it as a turret
well, sounds do-able, but I still don't know how to make a child enti-
the turret way seems more like it
they are kinda the same thing anyways
of course lua has more flexibility
that's for the animation loop?
uhm
that is the sprite movement for the saucer, not a loop
all you need for a loop is
self.animator.AnimateToNextFrame(true)
sigh it sounds simple, but as you can see, I still don't know how to make that
a
so if I change the sprite a little bit so it loops (lightning on and lighting off and repeat)
that should be it? I assign the sprite and the colission sprite and I can attach it to everything as a turret?
yes
ok, imma just show the data from animations, entities to make sure I didn't mess somethin' up
entity for the saucer
entity for the lightning
sprite for the lightning
oh I'd forget, is it possible to add some sound?
I think you can make it play a sound in its lua file.
ok,
how do I play a sound in lua?
Playsound("s_enemykazap")
-# could you be more precise?
like where in the line?
I guess under the function OnTick() ?
That's where you'll have to figure where. Luckily, lua codes can be edited without the need for reloading the game.
maybe that's a separate function?
Unfortunately, I'll leave the rest up to you for now. I need to go to sleep now.
ok, goodnight
@frail matrix could you please check this? I'm so close to finishing that one enemy
at least the coding part
you wrote something in your entity json wrong
you wrote the wrong thing in the behaviours name
maybe something's wrong here
it's your lua
I've been trying to find out where the sound is supposed to be put
removed the sound code
it was supposed to be simple
are you sure? this seems to be coming from another lua script
hm
seems that it is the main saucer one
it is missing it fire pattern data
so the lua script of the saucer crashes due not having that data in the entity json
ah, I accidentally added it to the laser entity
but how do I make so the saucer does not shoot anything
take that part of the code
and how to spawn saucer to move usually and not get stuck in one place
but it cannot be missing
it can if you take it out properly
just take everything related to the shooting code and just leave the movement logic
why is firepattern there
i don't think that's where you put it
it is under custom behaviour data, not in turret
ya, noticed
usually turret is in custom behaviour data I think
maybe that's the issue?
turret is not in custom behaviour data
and that, most saucers use commands as randsaucer and saucer
something happening
that's literally the last piece
though I think imma just use spawnentity and focus?
you are making me dizzy

anyways to spawn your entitys you use spawnentity
since the rest are just pre made spawn commands for the game which are hardcodded
I am sorry.
As I mentioned, when I have enough knowledge I won't be asking anyone again.
one last thing
how do I implement the sound?
after that I should be able to do stuffs around this code as my base
-# so no disturbing from me
you already have the function in your lua
last time I tried putting it inside the code, it didn't work.
also, I remember someone planning to make a squid with wave pattern bullets
are you sure is an valid sound name?
well, maybe I should've checked that
it still goes in the function on tick, right?
if you want to spam the sound every tick then sure
.
that doesn't sound like a normal bzzzzz sound I'm trying to achieve
there must be something similar to wait command then?
i don't think lua has that, so you gotta figure it out on your own
ok, it will wait then
how about the fire pattern?
is it possible to remove firing completely?
yes
could you tell me how?
how to make the game stop calling for it?
remove that part of the saucer code
but it did ask for it last time
it won't if you take all of the shooting code
ok, removing custombehaviourdata (from saucer)
the script will only error if it calls something that has no data of
it indeed did
there something calling fire data
that's what I remvoed
then is not any of your entities
check for any entity that you are summoning
that is calling fire data
it can't be either of those
oh yeah since your behaviour is a vanilla one it need that data
ah
why are you chaging the saucer
used as a base (it's a copy btw)
og saucers exist on their own. I'll now copy the behaviour of saucer lua and remove the fire pattern
also why did you put 0
it would only make it attack even faster
ya, noticed.
is there an easier way to disable that or do I have to make a copy of saucer's lua
it is recomended to make a copy
if it works, it works
we will see
also i didn't knew they update the saucer.lua to add debris on death 
i guess i gotta add that to everything in my mod now
and it does not
what does it tell you is missing
your forgot everything in
`function OnInitialise()
if self.commandArgs.HasField("speedY") then my = self.commandArgs.GetFieldFloat("speedY") else my = self.data.speed end
if self.commandArgs.HasField("maxSpeedY") then myMax = self.commandArgs.GetFieldFloat("maxSpeedY") else myMax = self.data.speed * 1.25 end
if self.commandArgs.HasField("fireSFX") then fireSFX = self.commandArgs.GetFieldString("fireSFX") else fireSFX = "s_laser2" end
allowedToShoot = math.random(0, 100) < Globals.firingChanceSaucer.Get()
firePattern = NewFirePatternFromEntityData(self.data)
yAcceleration = myMax / 25
end`
but isn't that related to firing, which I'm trying to remove?
only the allowedtoshoot and firesfx
and fire pattern
okay, what about the trash can? I've been messing up with the new entity and stuffs to avoid getting mistaken with the default lightning
this
just make it attack slower
trash can uses the custom lightning, it's not intended for it
it was intended for the custom enemy only
the main reason the custom lightning is made a separate entity
you accidentally override the vanilla one with your custom one
change it name
you forgot to take some code away
hm, I guess it's the if CanFire() then ?
yes
still the same
can you take a picture?
I can even send the whole thing
though I think I see another suspect
local my
local myMax
local yAcceleration
local shootMinX = 60
local shootMaxX = 620
function OnInitialise()
if self.commandArgs.HasField("speedY") then my = self.commandArgs.GetFieldFloat("speedY") else my = self.data.speed end
if self.commandArgs.HasField("maxSpeedY") then myMax = self.commandArgs.GetFieldFloat("maxSpeedY") else myMax = self.data.speed * 1.25 end
if self.commandArgs.HasField("fireSFX") then fireSFX = self.commandArgs.GetFieldString("fireSFX") else fireSFX = "s_laser2" end
allowedToShoot = math.random(0, 100) < Globals.firingChanceSaucer.Get()
firePattern = NewFirePatternFromEntityData(self.data)
yAcceleration = myMax / 25
end
function OnTick()
if math.abs(my) >= myMax then
yAcceleration = -yAcceleration
end
my = my + yAcceleration
self.movement = { x = -4, y = my, z = 0 }
local spriteIndex = round((1 + (my / myMax)) * (self.animator.totalFrames - 1) * 0.7)
spriteIndex = clamp(spriteIndex, 0, self.animator.totalFrames - 1)
self.animator.AnimateTo(spriteIndex);
if self.position.x < -160 then
self.Deactivate()
end
end
function OnKill()
self.SpawnShipShards(10, -6, 0, -15, 5, 0, 0, 0, 0, 0, 0)
end
function CanFire()
return allowedToShoot and self.position.x > shootMinX and self.position.x < shootMaxX
end
function HasCollision()
return true
end
function ShouldKillPlayerOnTouch()
return true
end
-# ugh. I see another thing.
if self.commandArgs.HasField("fireSFX") then fireSFX = self.commandArgs.GetFieldString("fireSFX") else fireSFX = "s_laser2" end
allowedToShoot = math.random(0, 100) < Globals.firingChanceSaucer.Get()
firePattern = NewFirePatternFromEntityData(self.data
this
oh
ladies and gentlemen, I think a milestone has been hit in Bananawar
@frail matrix ,
I want to thank you A LOT
and I mean it.
You've guided me literally by each step
And I am sorry for exhausting you, that was the last of the last of my intentions
Thank you for all your help
GG
GG! You are on the verge of making a spiritual successor to an earlier iteration of the PSP Lightning Saucers. 
I don't think anyone else dared to recreate Lightning Saucers in lua until now.
-# Correct me if I'm wrong though.
@safe rover, @solemn nest, @opaque island
I hereby request for more flexibility to enemy lightning attack patterns, such as having the durations for on and off states.
That's a bit of a tricky one as those patterns are heavily limited by the old sound effect that we are using
The enemy kazap SFX?
I think that's the one
Hmmmm...
Well, at least the SFX seems to be controlled by the duration of the lightning on screen.
Except that it is only 3 seconds long hmm
Is it because of the awkward looping when its sound duration is shorter than certain lightning attacks like Purple Batoids and Octopus Lightning arms?
I remember there being something about the length that made it hard to adjust, but looking at the sound file I don't quite see what it was
Well, good thing the sound file is totally customizable.
Some of the already published workshop add-ons feature custom lightning SFX that are able to cover the entire length to enemies with the longest lightning attack duration.
speaking of sfx
Furthermore, I would also look forward to additional customizability to all starfish gun turret types.
I realised that if you spam a very short sound (add udner Function onTick) then it should work as a zap sound
The poor audio engine is not going to like that haha
oh
You can use the PSP version of zap, since it's far shorter. ;3
well, imma test it anyways
it would be nice
You can add a cooldown to the audio clip, that way it doesn't fire every tick
I tried setting the lightning as a bullet for the rotating gun, but it ended too soon, so the electricity did not generate
no idea how
Cooldown frames in audio.json.
example please?
Examples are in audio.json
-# ok, imma look to it as soon as I can
so currently there isn't a way to achieve that, ya?
I'm on phone, sry.
But I do have something funny to share.
thanks 
So this quirky behavior seems unique to laser hoverships.
how long is one cooldown frame?
could I get a little help on how to implement the code for playing the sound? I tried to implement it and whole thing broke.
One "cooldown frame" is one tick, the game runs at 60 ticks per second, so 1 tick is 1/60 seconds
oki
and about the code, what did I mess up here?
I think the error message you are getting should help you track it down more.
As a hint: Lua is case sensitive
Hmm, yeah that's not as helpful
It's PlaySound not Playsound
If you use the lua language server extension, VSC will give you warnings for these things
gotta try that
thanks, it works now 
now just gotta adjust the cooldown and it should be fine
been wondering but how do you exacly you stetup this
specifically the checkcollision part
haven't got how to check the collision properly
the moment it has to check the collision of the sprite sheet it crashes
Oh, that's not good... Maybe there is a bug there
The object you are adding the collider to should not already have one, though I think it just returns the existing one
AddCollider is also not meant to be called super often, check collision you'd do in the tick while the adding of the collider you'd do in the init function
well that's a lot
well atleast is good to know add collider is in init
@safe rover, I wonder if there is a lua function where the collision does not kill the player, but disallows the player from going through it.
If I understand correctly you want some kind of wall that you can go all the way up against? If so I gotta disappoint you
Yes, and I'mma embrace disappointment. :p
I think it is something the cave walls in PSP level 4 do.
I've not made official support for it since it wasn't in Reclayed's specification, but there may be a way to hack it together if we expose Player.SetPosition
I wouldn't expect official support for a non-hack solution, but I can sneak "exposing SetPosition" into the spreadsheet Alex is chosing things from 👀
Interesting...
Also would allow for things like teleporters, but I'm getting ahead of myself
DW, the time is the least of our concerns.
I'm kinda curious if there already are such things as GenericBoat and GenericTrain behaviours.
IIRC, some folks at Platypus 2 Reclayed project requested for these entity behaviors months ago.
@safe rover, is there a way to add a changeable speed multiplier to animation frames?
No, the game usually handles animations that need more fine tuning by setting the sprite to exactly what it needs to be in code
Squid Guns and Fish Fighters for example
Thus, we are currently unable to configure the actual speeds of the animations regardless of their frame count then?
Oh, if it is the constant value that you want to change then that's "updateCounter" within animations.json that you can adjust.
Pretty sure that's also the value you find in SpriteAnimator.timePerFrame
So, what could I do with SpriteAnimator.timePerFrame in lua?
timePerFrame could be the same as updateCounter, but I am not 100% sure it is.
updateCounter represents the amount of ticks an animator waits before evaluating their next step, so for a looping animations 1, would mean that the animation advances ever game tick
Probably safe to assume it is the same, though of note is that this is read only
I do plan to have a dynamic animation speed in Lua.
Where certain conditions I set up will change the speed.
We used SpriteAnimator.GoTo(index: integer) extensively for anything that isn't constant
I wonder where to place it?
Wherever your custom logic decides that it is time to switch to another sprite
I assume the integer is the value I have to type, right?
It expects an integer from 0 (inclusive) to SpriteAnimator.totalFrames (exclusive)
I know this breaks Lua conventions, but during development lua was dismissed, so the current implementation has to sit ontop of what is there
i.e. it is currently complicated to do so with the current system we have?
"Complicated" is rather subjective and depending on your coding background
That makes sense.
Nevertheless, is there an example of it?
You can take a look at saucer.lua, there it does something similar, but instead of using GoTo to set the sprite, it uses AnimateTo
Which is essentially the same, except that it uses that updateCounter delay to go to the target frame so we don't skip any frames
This is how the hatch on boss1 is controlled for instance:
firewait being a number that decreases by one every frame
int hatchFrame = 3;
if (firewait < 20 || firewait > 90) hatchFrame = 4;
if (firewait > 24 && firewait < 86 || firewait > 124) hatchFrame = 2;
if (firewait > 27 && firewait < 83 || firewait > 127) hatchFrame = 1;
if (firewait > 30 && firewait < 80 || firewait > 130) hatchFrame = 0;
missileAnimator.GoTo(hatchFrame);```
Interesting.
Anyway, my plan for the animations of a custom entity I am working on is the animation runs faster the higher its movement speed and vice versa.
Certainly doable!
My advice would be that you get a variable in your script that you continuously increment, incrementing it faster on higher speeds and slower on lower speeds. Then you'll just have to convert that number into a usable frame index (just that integer between 0 and the amount of frames you have) and you're set
This is how it currently looks like:
local speed
local timer
local forwardTimer
function OnInitialise()
timer = 50
forwardTimer = 400
speed = 0.5
end
function OnTick()
timer = timer - 1
if forwardTimer >= 0 then
if timer <= 0 then
timer = 50
speed = speed * 1.2
end
end
if forwardTimer <= 0 then
if timer <= 0 then
timer = 25
if speed >= 0.5 then
speed = speed * 0.8
end
end
end
self.animator.LoopAnimation()
self.animator.AnimateTo(speed, true)
if self.position.x < -200 then
self.Deactivate()
end
end
function HasCollision()
return true
end
function ShouldKillPlayerOnTouch()
return true
end
This is the result:
speed = 2
It kinda works, but looks janky.
Two big things, you don't want to be looping your animation anymore, you are telling it what frame you want directly
Also speed is just the speed, you want to change another value with speed that represents where in the animation you are
Gotcha
There isn't
I see.
Tary, I really am very, truly sorry for pressuring, disturbing you on that day.
Please tell me, are you still mad at me?
You have a reason to be, I know it.
I really can't stop thinking about that, day and night.
I really am sorry, I wish I could make up for what I did.
-# I'm considering never talking about lua again, never asking for anything.
Please tell me, please respond to this message.
?
Am not mad
-# I'm so glad to hear that!
Pardon the late response, but will there be generic entities of trains, boats, and big cannons in the next modding update?
@safe rover
boats wouldn't be that hard to make, since they are an linear entity
of course you need to add an spritesheet for the moving water
trains and cars should be easy too
really the only issue should be the base and the wheels
The wheels are something that's tricky to implement, at least for me.
i wonder if the wheel are an entity
Hmm... are you on PC rn?
yeah
they indeed are
i wonder if you can attach them as a child entity
talking about child entities i wonder if kroporo found the way so they always render above or behind the parent entity
Speaking of which, have you actually converted some of your turret entities to their respective child entities on your mod?
Just curious. :3
is just like 1 extra line
, but the result was the same as using it as a turret
of course i may be able to do more fun stuff later with it
There exists a list of things that we want to get into the next update which includes more Lua examples, but work on it hasn't started yet (at least not from my side)
I wonder what are the planned sample Lua entities.
Would be interested to see Lua replicas of reclayedTurret, squidGun, and a few more related entities I can't think of right now.
it would be appreciated an turret replica, of course since it would have ported all turret data into lua,
also so i don't have to keep reusing the same gas pipe code for every turret 
and have those unneeded lines of code for certain entities, lol.
Well, I did review most of your Lua files over the past few days, and yeah...
That one is up to me actually, but the idea will be to get objects that use many of the reoccurring concepts
And 1 boss, who is absolutely not going to be boss 5 :)
Implementing inverse kinematics in Lua will have to be done by someone else haha
I understand. :3
-# Quadrapus is like the most complex boss ever.
what about this one?
Oh btw, @jovial echo is going to thank you a lot.
A Sky Serpent example would be great
I mean we already got BigThruster ships, so the idea is there 
It'd be like building Lego's, but with Sky Serpent parts

waaaaiiit 
have I read it right? A one boss will be soft-coded?
Or atleast in a new DLC there will be a softcoded boss using other bosses' behaviours?
I feel like Sky Serpent would make the most sense, since I personally think it is surprisingly the simplest boss in terms of the codebase. It doesn't have any twists like the Submarine or Squid Mother.
All the DLC-exclusive bosses are made under the GenericSquid behaviour, which is already built-in to the game.
that's what I already know
I kinda don't get this one yet?
That's because the Claymatic team is working on a boss replica.

OFC it won't be Quadrapus, since it's by far the most complex boss ever made in Platypus Reclayed.
duuh!
Well, you were right! I'd be over the moon if that was released 
Has anyone made some sort of grace periods for enemy collision activation, where they are initially immune to player collision but not player shots?
@safe rover
I'm planning the said collision activation to be based on position.
The video below demonstrates my lua generic boat despawning at the exact position where the vanilla missile boat activates its collision sprite.
To anyone curious, below is the X position where the lua boat despawns for demonstration purposes.
OFC, I want it to have the collision sprite disabled until it reaches the given threshold.
You can make that happen with the "kills player" function and a custom player collision function that just doesn't apply damage, can't tell you what those are called exactly right now, but they should both be overridable functions
What is the exact name of the "kills player" function?
I'd probably rate that guy as second or third most complicated enemy, it's a close race with the train :)
Oh, I see.
Something like "KillsPlayerOnCollision" or something, you'll have to look at the list
It returns a boolean
Thanks.
-# Didn't know there is a list of params.
Apparently, it is called ShouldKillPlayerOnTouch.
Now all I have to do is to make it set to true once the X coordinate threshold is reached.
I think I'm getting this wrong.
It is under function OnTick() btw.
Oh, and another thing...
Is it possible to give the entity a default spawn position under function OnInitialise()?
Spawn position is determined by the caller, so not really
ShouldKillPlayerOnTouch is a function just like OnTick, it is called for you if it exists
I see. So is it static, and therefore cannot be changed directly by other ticking functions?
And instead, is there a separate argument that toggles the ability to kill the player on touch on and off?
Not sure I'd use the word static
function ShouldKillPlayerOnTouch()
return self.position.x > 50
end```
Note that this will still damage the enemy when you're colliding with it, so you'll have to make a custom response to colliding with the player in a similar way
I think it already works accordingly.
Even without the custom player response you were alluding to.
Anyway, since I plan the generic boat entity to also be able to move backwards through configurable x speed, I want to make it so when it goes backwards, the ability to kill players on touch is always on regardless of the x threshold.
The lua script is your canvas
You can tell it exactly when and when not to kill the player with that function
function ShouldKillPlayerOnTouch()
return if mx <= 0 then self.position.x > -10
end
I don't think the above is right, since I tested it, and failed.
Yeah, that is not valid lua syntax
So, does the return syntax only support one at a time?
It supports returning of a boolean value, however that value is determined is up to you
Heya @safe rover, is there a way to offset the position of SpawnAttachedSpriteAnimator?
Can't look at the documentation until Monday
@frail matrix, have you figured out how?
oh yes
i have been messing with it lately
core = self.SpawnAttachedSpriteAnimator("Sprites/Enemies/small nautilus bottom", -1) core.position = { x = -20, y = -35 }
TY
the clay heart should be an server emoji, i thought it was in already, 
IDK why it still isn't...
But yeah, I rendered it available for use on Discord, but I'm not an admin of Claymatic Discord Server, so I can't make it official here.
Gotta ping @night stream for this.
also the spawned spritesheet can be used as a regular animator thing
like core.AnimateToNextFrame(true)
first time i used it was to shown the damage phases of boss 3, so anything that can be applied to the self animator, can be applied to the spritesheet
also another note
self.animator is to acess the animator field of the base entity
but since core is alreaady that you only need to do core.
About the damage frames of the core, I know why there are 8 duplicates of bossquito's core damage frames.
Because apparently, the core frames should share the same amount of frames as the parent entity.
kinda, is that the function that handles that molds with the entity max sprites
you could manually make the function yourself if you want to about that
If a child entity has been set up, will said entity still need to be reflected in entities.json?
yeah, child entities works like putting a turret in something, and turrets are entities
however spritesheets don't need an entity
What is the syntax for setting up a child entity btw?
AFAIK, I haven't seen an example of it yet.
SpawnEntityChild("spiralTurretTriple", self, { x = 0, y = 0 }, args)
kinda similar to regular entity
---@param entityName string ---@param parent BaseEntity ---@param positionOffset Vector2 ---@param arguments JSONObject function SpawnEntityChild(entityName, parent, positionOffset, arguments) end
theoretically you could parent a child with another child, but haven't tested
Are these below needed to be written right above the function SpawnEntityChild?
---@param entityName string
---@param parent BaseEntity
---@param positionOffset Vector2
---@param arguments JSONObject
I remember the child entity thingy is supposed to be just one line.
those are just the parameters that acepts
entityname, needs a string
parent needs a base entity
positionoffset needs a vector2
arguments need a jsonobject
I see. So I reckon all these things are to be written inside the () next to said function.
you can see in SpawnEntityChild("spiralTurretTriple", self, { x = 0, y = 0 }, args)
where spirtalturret is a string, self is a base entity, the vector is a vector, and args is a json entity
in args, you can just put NewJSONObject() if you won't do much with it besides just spawning it
DW, I've been using NewJSONObject() and there are absolutely no issues. :3
Oh btw, have you managed to configure some sort of initial delay for the turrets as child entities?
nil might work too with a bit better performance
only to hand made turrets, haven't find if is posible to regular ones
that's good to know
I hope there is a Lua replica for GunShipReclayed and Squid, both of which give their respective turrets the initial cooldown.
Replace NewJSONObject() with nil, is that what you mean?
Isn't there a way to temporarily deactivate the "has collission" option, tho?
Not 100% sure, but it might beat creating it
Something like this maybe?
There's a bit more to do than just that, so if it doesn't work, let us know.
Noted
So I did manage to make it actually work (all I did is to use the same system as the timer bomb script @frail matrix made). But there is a caveat...
Once sprite exceeds the amount of available frames on a given spritesheet, it stops animating, so I tried to make it loop by having the value reset to 0 once the threshold is it.
But here's the problem...
Once set back to 0, it sort of quickly rewinds the entire sprite animation back to the start before it can start the cycle again, which is something I do not want.
oh yeah, that is something that was about to say,
the game never snaps instanly onto a sprite
nor foward or backward, it will go trought all sprites in 1 tick till the said value
So for the time being, I had to make copies of the frames and add more of them in the same spritesheet.
Which is a pretty chonky workaround, since the spritesheet contains more frames, therefore bigger file size.
welcome to the spritesheet shenanigans club
However, this is theoretically just not feasible if the planned entity would stay on screen indefinitely.
The spritesheet probably wouldn't keep up without bloating the file size, especially when the animations are smooth, therefore more frames per second.
I think one of my custom enemies in the works have a spritesheet containing a whopping 200 frames, with 20 frames forming a loop, thus, there are a total ten loops within the entire spritesheet.
Alright, so I managed to have the ShouldKillPlayerOnTouch work on the following conditions:
- If the entity is moving to the right and its
self.position.xexceeds the given threshold. - If the entity is moving to the left regardless of its
self.position.x.
Here's the syntax:
function ShouldKillPlayerOnTouch()
return self.position.x > 10 or mx <= 0
end
-# Excerpt from genericBoatSmall.lua.
By this point, all the generic boat entities are functionally complete.
-# The only thing left now is to figure how to recreate the exact same dispersion of debris upon death as their vanilla counterparts.
Have you messed with the create debri function yet?
Not yet. :p
It should gives you all the tools for that
I'm pretty late with the Lua bandwagon NGL.
Where is the updated list of Platypus Lua tools?
In streaming folder,
Is type.lua
Oh wow! TIL
Thx 
So here you are basically giving it a false value all the time till the condition is met
Since that function always need a boolean
But it works nonetheless. :3
-# As demonstrated in the video above.
There only 1 issue here i could see and is that if the boat returns backward, the thing will lose it hitbox again
Oh wait that is what the other thing is for
Have you watched the full video?
My internet connection is poor at the moment 
Because in the video, I demonstrated the reverse boat still killing the player despite already conforming to self.position.x > 10.
So basically, if the boat is reverse, it will override the position condition, and if not, then the position condition will be the only one to control the function.
Yeah due the mx <= 0
If I were to use and, then both of them must be met, meaning the boat going forwards will never activate the function. :p
When my power come backs i will mess with it, i wanna try too
Also there 2 spawnshard functions
1 is for ship shards, the greys ones
And 1 for the color shards
It will use the main and secondary shard of the entity json field
That's nice to know.
Yeah, types.lua is definitely a must-see file for any Lua modders out there.
And like you said, it can be found here at: C:\Program Files (x86)\Steam\steamapps\common\Platypus Reclayed\Platypus_Data\StreamingAssets
Tecnically you aren't suposed to read it 
Is for programs autocompletioms
LMAO
What happens if I mess up the file? 😏
Uhm i'm not sure if the game is using that file and either way you couldn't do much
I see.
I only mess with new functions once i get to work on an entity that needs it
I think there a layer changing function, that surely will be handy 😉
Once I finish the code for the boat entities, I'll publicly post them in the server for anyone to use.
And OFC, include them as part of Mod Advanced Pack.
Attention fellow modders:
Below is the link for the base boat entities which can be used for making custom boat enemies:
#1437926250374103234 message
Can I use it on my Platypus2 port if needed? Credit will be given, ofc
At that point, I am pretty much contributing to all things Platypus 2, well, indirectly. 
So...
Y E S
I use the types file all the time, it functions as documentation, though functions don't have written descriptions
The game itself does not use it, but it is generated from the game and therefore a pretty good indicator of what's there
Alright, so I managed to get it to loop without the janky rewind animation.
Apparently, I had to set the loopFrames param to true, as seen below in the excerpt from types.lua.
```
---@param index integer
---@param loopFrames boolean?
function SpriteAnimator.AnimateTo(index, loopFrames)
Thus, with that kind of knowledge, it should be fully possible to create a Lua-based train wheel animation whose animation speed is tied to the parent entity's move speed.
Oh, and I discovered an example of that from Tar's mosquito.lua. LOL
i actually kinda used loopFrames for the og nautilis miniboss
so after the frame ends it doesn't go trought every frame to 0
and it goes instantly to 0
oh right , that too 
-# why is mosquito lua so popular in dissecting?
Prolly because @crimson linden wanted to make homing green fish fighter code using some parts of the mosquito code. :3
Oh ya, funny that I actually ended up being the one who made the green fish fighter script using mosquito.lua as a derivative. 
@safe rover, is there a way to integrate Globals.fishFire onto allowedToShoot = math.random(0, 100) < Globals.firingChanceRandomFishFighter.Get()?
-# I intend to have a Lua-based fish fighter enemy to be controlled by both fishFire and firingChanceRandomFishFighter globals.
Yeah, I think you got access to all of those!
Well, I do, thanks to types.lua.
All I have to do is to have them well-executed.
The syntax I made below is wrong for sure as I have tested:
allowedToShoot = math.random(0, 100) < Globals.firingChanceRandomFishFighter.Get() and Globals.fishFire()
Apparently, the custom fish fighter only targets the first player, which is something I do not want. I intend to have the enemy target either of them, then switch targets once the original target has been destroyed. Oh, and on a similar note, I also want the enemy to just go on its last trajectory when all players are dead, just like vanilla homing missiles.
Similarly, a lot of the Casinopolis enemies that track down the player's position exclusively takes the first player into account, and will absolutely ignore the second player no matter what.
Well that is because i specifically called for player 1
I could make it so the closest player get the priority
I'mma follow suit once you figure it out.
I'm currently developing a different entity for a different project ATM.
Oh, BTW, like what MAKYUNI said before for the green fish fighter behaviour, it would be ideal if enemies that normally home towards the player continue with their current trajectory when no player is onscreen, just like vanilla homing missiles.
Maybe it could be an optional feature too, in case someone wants the opposite
well is because the game never unloads the player while death, so the player is there invisible
Oh boi
I took a look on types.lua, and AFAIK, I don't see any function that checks the presence of the player.
@safe rover, is there a way to have the Lua script unload the player when the player is dead?
Unload? No
not sure if you want to unload the player 
that can lead to stuff, like the game breaking
Oh man
just a way to know if the player is invulnerable seems about right
Sounds like it, but if this is the case for vanilla homing missiles, then they won't target the player while invulnerable.
Normally, the missiles will continue where they left off whenever no player is onscreen until a player respawns, which then causes the missiles to retarget said player.
Latest iteration of the green fish fighter code.
@frail matrix, with how the current iteration of our player targeting system works, I can imagine some of your Casinopolis enemies would exhibit this janky ass behavior.
Maybe this is the solution. 
@cunning wind try this
Copying it as is causes them to only target player 2. :p
let me see the code 1 second
Actually, is there anything to replace?
Either way, this is how it looks like right now.
I see.
i change the order so 2 is above
Alright, it works.
🎉
I'll be asking a random question here:
Is it possible for Lua to give a sprite a rotation, just like how enemy lightning can be rotated?
Oh btw, thanks a lot. :D
Curious as to which Lua file was it excerpted from.
nautilus
Ah shit, here we go again...
who the hell is playing as the second player alone
IKR, but this is what happens when the first player dies and can't continue, but the second player still lives.
There is a function to get a random active player that the game makes use of a lot
well this one, uses the closest player, and so it tend to grab the unactive player too 
I guess that explains the ReclayedTurret turrets randomly switching targets.
```
if length1 > length2 and GetRandomActivePlayer() then
dx = vx2 / length2
dy = vy2 / length2
else
dx = vx1 / length1
dy = vy1 / length1
end
^ This doesn't change anything. :33333
Also, those schools of green fish are being funny AF.
uh well get random player returns a player value
those go in the get player position
Okay, this is going pretty well...
-# Except for the fact that they all despawn once no player is onscreen. 
now is constantly switching between the 2 players 
Ye, I noticed.
I made it so when no player is onscreen, they will continue where they have left off, tho it only works when no player is ACTUALLY ACTIVE.
Tried recreating the big gun fire pattern from the cannon boat. The red bullet represents the Lua cannon boat, whereas the blue one is the vanilla one. As you can see, the Lua one is far from perfect.
Also, as I experimented with the two entities, I found some interesting data about the vanilla cannon boat. Its initial fire cooldown is 1350 ticks long, with a fire pattern of 150 ticks.
Definitely Claymatic Wiki material if you ask me. :3
Either way, @safe rover, will there be an official standalone turret entity behaviour for big guns, the ones used by cannon boats?
@frail matrix, curious as to what math functions did you use to achieve this sort of attack pattern for your food dispenser enemies?
i think is
local t = (bullets > 1) and (i / (bullets - 1)) or 0.5
local angleDeg = startAngle - 120 / 2 + t * 120
local angleRad = math.rad(angleDeg)
local mxb = math.cos(angleRad) * speed
local myb = math.sin(angleRad) * speed
tho it might be inneficient
Oh no, I saw what ClayBot did...
I see.
Hope you didn't get muted, but anyway, now I'll ask about the barrel animation.
Is the barrel a static sprite that "animates" according to movement just like the vanilla big guns?
which barrel 
The one used on your food dispenser.
Specifically the one shown in the enemy showcase video.
Okay, I just thought it was just a moving barrel sprite with damage frame support.
it shouldn't be hard to do that
Anyhow, ty for the info.
I might as well code that for myself.
Or at least, try doing so...
Oh btw, is there a needed set of functions for OnInitialise()?
-# For the cannon fire pattern.
just
startAngle = 90
How about for the endAngle?
i thikn end angle is no longer used 
anyways the whole thing is
for i = 0, bullets - 1 do
timer = 45
local t = (bullets > 1) and (i / (bullets - 1)) or 0.5
local angleDeg = startAngle - 120 / 2 + t * 120
local angleRad = math.rad(angleDeg)
local mxb = math.cos(angleRad) * speed
local myb = math.sin(angleRad) * speed
local pos = { x = self.worldPosition.x, y = self.worldPosition.y + 40}
local args = NewJSONObject()
args.AddFieldFloat("mx", mxb * 0.8)
args.AddFieldFloat("my", myb)
SpawnEntityWorld("enemyshot_food", pos, args)
end
Oh boy, it seems ClayBot now has beef towards snippets of Lua code lately. 
is the in the snippets

jailed
don't know why i can grab pfps
Anyway, so previously, I used the same angular system as the barrage goldfish turret entity. :p
Which explains the imperfections behind the angular alignment of the shots.
What is the syntax you used for local angle in particular?
Seeing that endAngle is unused according to you.
is just startAngle 
that is what happens when you don't rename your vars
did you set bullets?
Yes, 7 to be precise.
there 3 bullets vars
the last 2 makes the arc flexible with the ammount of bullets
i wonder how that happend anyways
Well, surely this was ripped straight from the file right?
i can give you the file itself
Sure thing. :D
Okay, it seems I forgot to rename the following:
FROM
local mxb = math.cos(angle) * speed - 0.5
local myb = math.sin(angle) * speed + 3.5
TO
local mxb = math.cos(angleRad) * speed - 0.5
local myb = math.sin(angleRad) * speed + 3.5
This is what happens when I manually copied the syntax instead of straight up using Ctrl C+V. 🙃
Once again, TY
Good for platypus 2 spinning turret
The cannon squid?
Cannon fins actually
how it can move like cannon boat?
This?
yep
My current progress with the barrel recoil animation via movement.
lemme just make it kinda... move
Apparently, movement isn't supported on attached sprite animator.
oh right forgot to tell you that 
maybe see if the coordinates offset can be updated in real time
so it simulates movement
But at least the position can directly be modified OnTick.
I did it.
function OnTick()
barrel.position = { x = 0, y = my }
if my <= 0 then
my = my + 1
end
timer = timer - 1
if timer < 0 then
timer = 149
my = -30
end
end
Now I just need to figure how to force the barrel to load behind the base entity.
"sortOrder": 10000,
is it a spritesheet right?, in the summon spritesheet there a 1 there, you can set it to -1
for it to go behind
Let me try it then. :D
It didn't work.
function OnInitialise()
barrel = self.SpawnAttachedSpriteAnimator("Sprites/Boss 1/big barrel", -1)
barrel.position = { x = 0, y = 0 }
end
rip
sortorder
Remove this
timer = timer - 1
if timer < 0 then
timer = 149
my = -30
end
Add my = -30 right below timer = 45
At last...
What u do?
"name": "luaCannonBoat",
"sprite": "Sprites/Enemies/cannon boat",
"behaviour": "Lua",
"customBehaviourData": {
"luaScript": "genericBoatBig"
},
"turrets" : [
{
"turretEntity": "boatCannon",
"turretX": -65,
"turretY": 30
}
],
"explosionEntity": "explosionBig",
"explosionX": 0,
"explosionY": 0,
"mainDebrisEntity": "debris_grey_1",
"secondaryDebrisEntity": "debris_grey_2",
"sortOrder": 100,
"isEnemy": true,
"shieldPenetrating": true,
"maxHitPoints": 600,
"highlightPoints": true,
"points": 1000,
"primaryTargetValue": 5
},
{
"name": "boatCannon",
"sprite": "empty",
"behaviour": "Lua",
"customBehaviourData": {
"luaScript":"boatCannon"
},
"sortOrder": -100
}
Boat entity's sort order is 100, whereas the cannon itself is set to -100.
Also this:
barrel = self.SpawnAttachedSpriteAnimator("Sprites/Boss 1/big barrel", -100, false)
-# in its Lua file.
Certified Sortorder
cool
close
@safe rover, is there currently a Lua function that overrides the fire cooldown of attached turret or child entities?
Not that I'm aware of
Enemies like flip planes for example do not fire their turrets when positioned at far left.
And then we also have gunships and squids that have initial fire cooldowns.
That's not done by overriding, turrets ask their parents if they can fire before they fire themselves
Thus, the child entities have a function that asks their parent entities the consent then?
No, but they too call CanFire on their parent
So, if I set up a CanFire function to a base entity, will any attached child entity abide by it?
@safe rover, do custom Lua turret entities need to have if CanFire() then function for it to ask for the attached parent entity's CanFire() conditions?
Actually, what is the sample syntax for both parent and turret entity?
---@class TurretData
---@field bulletCount DiffDictInt
---@field bulletSpawnDistance number
---@field bulletOriginOffX number
---@field bulletOriginOffY number
---@field bulletSpeed DiffDictFloat
---@field bulletSpreadAngle number
---@field bulletEntity string
TurretData = {}
So I tried tinkering with TurretData in Lua. ^^
And so far, only bulletCount and bulletSpeed worked. I couldn't get anything else to work, including bulletEntity and bulletSpreadAngle.
turretData = NewTurretDataFromEntityData(self.data)
bulletCount = turretData.bulletCount.Get()
bulletSpeed = turretData.bulletSpeed.Get()
@safe rover, sorry for the several pings lately, but what does FireParams do and how to apply to Lua entities?
Also, is there a way for Lua args to force the missile to briefly travel along a set path before it starts using its homing behaviour?
I've been trying to replicate the exact missile launch behaviour from the vanilla counterpart.
Oh BTW, how does this work?
---@return integer
function FirePattern.GetTicksTillFire() end
Time before the entity fire
Like those thrusterships or gunship
On flyby phase btw players can walkthrough them tho
Usefull when you play remam
Or those midboss enemies
As I was tinkering with it, I found out that it simply gets the ticks needed before firing, which is useful for creating turret animation before actually firing.
Yeah
Math.random(integers)?
Ex: math.random(0, 100)
Oh ok...
I made it so the Lua Missile Boats can have configurable missile launch timers.
As you can see, they fire every 100 ticks.
- Turret data is pretty much read-only data
FirePattern.GetTicksTillFire()Does what it says on the tin, it returns the number of ticks until the fire pattern thinks it should fire again (assuming it is updated every tick)
FirePattern.GetTicksTillFire() is something I have figured out later down the line BTW. :D
Depends on how you implement your entity, all Claymatic entities probably check the parent firing within their own CanFire for convenience
GetTicksTillFire is mostly there to allow you to adjust animations without having to assume the fire pattern, take the squid guns for instance, they play their whole gun animation a little bit before they start firing
By the time FirePattern.CanFire() returns true, you're too late
Which is exactly what I did to the softcoded boat missile launcher. :3
I wonder what is the sample for these?
Not lua, but this is a common setup:
public override void OnTick() {
if (CanFire()) {
firePattern.Tick();
if (firePattern.CanFire() && CanFire()) {
firePattern.MarkFired();
Fire();
}
}
}
public override bool CanFire() => parent.CanFire();```
What's with &&?
is public override equivalent to function in Lua?
Me when override
Also, this doesn't seem to work, unless there is something else I should consider:
function CanFire()
return parent.CanFire()
end
-# Worth noting that the fire pattern function on my Lua missile launcher works as intended.
&& is just and
Also, that one is actually a turret entity.
We treat you defining the CanFire function as overriding it
This?
public override is not generally equivalent, but in our implementation, when you define a CanFire function, we no longer call the default CanFire function (which always returns true) but instead call your CanFire function instead
I assume it is local then?
Okay, I found out that I have to put self prefix to parent.CanFire().
I did it. 
function CanFire()
return self.parent.CanFire()
end
I'd have to go into more technical details, but I believe that would be more confusing than helping
DW, I got it to work.
Either way, thank you for this sample script. :D
Now moving on, how about the args that force the homingMissile entity to not home for a brief period of time?
So these ones work on my end:
turretData = NewTurretDataFromEntityData(self.data)
bullets = turretData.bulletCount.Get()
speed = turretData.bulletSpeed.Get()
And then these do not:
spreadAngle = turretData.bulletSpreadAngle.Get()
entity = turretData.bulletEntity.Get()
Basically, any of the TurretData fields that use string or number as seen in this replied message just do not work.
I think they are asking for indexed numeric values.
@frail matrix, I now know how to make any custom turret entity abide by the parent entity's CanFire() function.
lua saucer has this
tho i'm not sure myself
This is for its fire patterns.
welp, it may be worth waiting for that lua turret
since i moved with lua i haven't mess with vanilla entities that much
So the boat behavior I used is the Lua version.
Normally, any attached turret will fire immediately after spawning.
But with this:
function CanFire()
return self.position.x >= 154.5 and mx > 0 or self.position.x <= 770.5 and mx < 0
end
The turrets' fire patterns will be on halt until the conditions for the CanFire function are met.
Before this knowledge, any custom Lua turret did not have the functionality of their own, which meant regardless of the parent entity's CanFire condition, it will always bypass the condition and therefore keep on firing regardless.
But thanks to self.parent.CanFire(), now it will pause their fire patterns until conditions are met, just like most vanilla turret entities.
I hope you get my point @frail matrix.
Stuff like homing squids would benefit from this, since they'd typically use vanilla squid gun turret entities:
function CanFire()
return fireCooldown <= 0
end
hmm
Just a funny demo of vanilla squid gun turrets asking their parents for consent with the CanFire function. 
Lua Green Big Un in the works.
A couple months ago, Tartaz attempted to recreate Green Big Un in Lua, but couldn't complete it.
Anyway, I got it to produce smoke trail, but...
Alr, I got the smoke trail working perfectly.
What smoke trail does it use?
Now, only the damage effects are left, which is apparently one of the main reasons Tartaz gave up back then.
This might make had an idea
You know those Jellyfish from platypus 2
The bigger one not the smaller ones
Ye
It is.
@safe rover, are these below needed for applying damage effects to a Lua entity?
---@field damageEffects DamageEffectData
EntityData = {}
---@class DamageEffectData
---@field frame integer
---@field parachuterChance number
---@field parachuterX integer
---@field parachuterY integer
---@field shards ShardData
DamageEffectData = {}
I've been trying to make it so the damage effects from its JSON entity data would work.
Successfully recreated the Missile Ship in Lua.
-# ||Oh, and I too made Zippers in Lua!||
The bottom one is the Lua variant.
You'll notice that the way it fires its missiles is off, even when the launch positions are perfectly replicated.
Oh BTW, I forgot to mention that I added a functionality where any turret attached to the Lua green big un cannot fire until the enemy moves past the X position threshold. This meant the turrets won't ever fire immediately after spawning.
Vanilla green uns don't have this function.
Peak