#Custom Enemies Support/Thread

1 messages · Page 2 of 1

safe rover
#

Yeah, you'll have to wait for the patch for the rest of the issues to be resolved I'm afraid

frail matrix
#

i see,

still thank you claythumbsUp

cunning wind
#

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).

frail matrix
#

Are rotations currently supported?

crimson linden
#

rotations, as in? compared to what entity?

frail matrix
#

Rotation as is sprite rotation
Withouth having to manually draw the rotation

crimson linden
#

ah gotcha
hmmm, not that I know of :(

#

that'd be really useful for porting Platypus 2 windmills too

terse stump
#

Is it possible for custom enemies to drop weapon stars when destroyed?

safe rover
#

Yes, but it is done within the level file. Either by

  • Setting fruit_set on the spawn command
  • By using setBonusCounter, setBonusReward and then setting bonus on the spawn command

You can look for those in the existing levels for some examples

frail matrix
#

I was wondering if is posible in lua to add more sprites like squid bottom witch is not a entity but just a sprite

safe rover
#

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"

safe rover
#

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

buoyant lake
frail matrix
#

for now i can do kinda the same effect by just making the bottom as an entity and adding it as a turret

safe rover
#

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 = {}```
frail matrix
#

been trying to use the new get player position but seem that im only getting nil

frail matrix
#

im still quite confused how to use any of this get player

frail matrix
#

i tried using something like the regular get player but seems that didn't worked much

safe rover
#

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()

frail matrix
#

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

frail matrix
#

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

crimson linden
#

what is the squid's sort order?

frail matrix
#

Just 1000

crimson linden
#

Oh I see
then that's quite weird

frail matrix
#

just to be clear

body, regular squid bheaviour 1k order
gun, lua gun i made, no order
bottom a separated lua entity 10k order

crimson linden
#

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

frail matrix
#

hmm could try that

pearl ether
#

can we have an editable player shots?

frail matrix
frail matrix
#

i fixed it by giving the squid the original squid sort order

crimson linden
#

either that or giving the gun a lower order than the body should work claythumbsUp
the lower the sort number, the more "in front" something will be

frail matrix
#

i was wondering, does the particles trails that entities leave
use this function?
or is it other?

safe rover
#

No, the trail is a completely separate system, unfortunately not accessible for lua scripts

frail matrix
#

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?

safe rover
#

CustomBehaviourData is shared among every single instance and set in stone on mod-load, so unfortunately no

frail matrix
#

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?

safe rover
#

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

formal sundial
#

Question. Would giving a squid gun a random spread require a custom behavior?

formal sundial
#

Hmm. Maybe it would be best for me to wait for an example to be made first...?

cunning wind
#

Unrelated to this thread tbh, but will there be a collision sprite for the player ship built in the Platypus Original mod folder?

pearl ether
#

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

safe rover
#

Yes you can, any entity can set the player weapons and timers

pearl ether
#

So we can edit it ourself

safe rover
#

That might be specified in the modmeta, not completely sure though

cunning wind
#

Yes you can. ;3

pearl ether
#

Just add "DefaultGun" : entity_player_shots.json "name"

cunning wind
#

Oh, nvm

pearl ether
#

To ship.json

#

Example
"Defaultgun": "playershotFish"

safe rover
#

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

cunning wind
#

Will most turret entities have configurable first shot delays?

frail matrix
#

some entities have some small time where they can't be damage
is there any function in lua for that? (the invincible part)

pearl ether
frail matrix
buoyant lake
frail matrix
#

how do i use logic layers? fish_dinner

cunning wind
buoyant lake
#

Xmas holidays for the next two weeks but am sure someone will pop in

opaque island
cunning wind
#

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.

safe rover
safe rover
# frail matrix some entities have some small time where they can't be damage is there any funct...

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

cunning wind
#

How about for specific enemies.

#

I am specifically asking for the opposite of "if specific enemy on screen".

safe rover
#

ifSpecificEntityOnScreen

cunning wind
#

Yeah, but inverted.

safe rover
#

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

pearl ether
#

ig it's a future feature ig

#

for the Spring Update

cunning wind
#

Well, I do want to make it so that the particular enemy will force some enemies to not spawn until the former is defeated.

frail matrix
safe rover
#

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:

frail matrix
#

i think the only one that ignores bullets but not the player was
SetLogicLayerPlayerPickupCollider()
but it makes apppear some colllision errors in red text

safe rover
#

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

frail matrix
#

i see, but i guess i do have to wait for a next patch

frail matrix
#

does the engine allow global vars in lua? just for easy var sharing between entities

safe rover
#

It does not

frail matrix
#

i see fish

well atleast i can skip 2 more hours of smashing my head onto the keyboard

safe rover
#

No scripts share an environment

cunning wind
#

@safe rover, is there a way to set a delay for the turrets through lua?

safe rover
#

If you make your own turret you can do pretty much whatever you want, yes

cunning wind
#

I wonder if there is a lua replica of reclayedTurret.

safe rover
#

I'm not aware of any

formal sundial
#

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.

frail matrix
#

i uh have some turrets behaviour

pearl ether
#

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

cunning wind
#

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.

frail matrix
#

seems that the entity position can't be change

frail matrix
#

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

safe rover
#

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

jovial echo
#

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?

crimson linden
#

Not sure if anything like that exists yet but ig the best person to ask rn would be @frail matrix

jovial echo
#

DMed today already

frail matrix
#

👋 i missed the dm anyways

frail matrix
crimson linden
#

So they can't be recreated with lua?
What are we missing, the boss timer?

#

Or can that be triggered by lua? 🤔

frail matrix
jovial echo
crimson linden
jovial echo
frail matrix
jovial echo
crimson linden
#

Someone needs to make one tho, since one doesn't exist yet, sadly

frail matrix
#

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

jovial echo
frail matrix
jovial echo
#

hm

frail matrix
#

i think it would be better for looking at others works and using it as a base

frail matrix
#

there only 1 lua template

jovial echo
#

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?

frail matrix
#

you asign movement with self.movement = { x = something, y = something, z = 0 }

jovial echo
#

could you put an example?
like... saucer connected to a saucer

frail matrix
#

what do you mean

jovial echo
#

if I were to program a bit more complex entity

#

that isn't just one thing like a saucer

frail matrix
#

like multiple entities chained together ?

jovial echo
#

exactly

frail matrix
#

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

jovial echo
#

hm, alright

#

btw, when are you usually available?

frail matrix
#

uhm i really depends since i gotta do studies soon so i might be less available

jovial echo
#

I can relate, studying in college myself

jovial echo
frail matrix
#

if it helps the overall modding scene, i don't mind

formal sundial
#

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.

frail matrix
jovial echo
jovial echo
#

I'm wondering,
Who created the "mine throwing can" enemies?
Th ones that open and throw a mine
is the door a separate entity?

jovial echo
#

I knew it BonSmile

cunning wind
#

The door is defo a turret entity, and shares the same behavior as the squid gun.
But, the mines themselves are lua-coded.

jovial echo
#

hm

#

so no additional lua needed for the door

#

speaking of lua, there are so many versions of it, which one do I pick?

cunning wind
#

The mines?

jovial echo
#

no no

#

I meant the lua program

#

wait,
I clicked LuaRocks instead of Lua itself

cunning wind
#

Try opening .lua file on VSCode.

jovial echo
#

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?

cunning wind
jovial echo
#

saucer.lua

#

I'm trying to find out what command does what

#

there are obvious ones
but some are not

cunning wind
#

Maybe try to change one thing and see what are the changes in-game.

#

It's essentially experimentation.

jovial echo
#

ya

frail matrix
#

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 clay_spiral

safe rover
#

There is an argument you can give to the create turret function, that you can use to change the order if I remember correctly

frail matrix
#

is it this one?

safe rover
#

Nope

frail matrix
#

then just regular child entity?

safe rover
#

Yeah that's the one I think, not sure what the argument in question is though I'm afraid

frail matrix
#

maybe is the same as the spawn spritesheet
orderoffset

safe rover
#

I'd have to dig into the code to tell you, but I can't do it right now

frail matrix
#

it's okay, this is already pretty helpful ^^

jovial echo
#

is there a way to change Submarine's gun position without having to rewrite it's code?

frail matrix
jovial echo
#

has anyone managed to make working child entity?

jovial echo
#

@frail matrix

#

Have you managed to?

frail matrix
#

ah yes
still searching a bit to change it render offset

jovial echo
#

will you include that in the Mod Advanced Pack for others to learn?

frail matrix
#

maybe when i organize my stuff i start making examples

jovial echo
#

oki

jovial echo
#

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

cunning wind
#

Adding a turret to an entity?

jovial echo
#

yes

#

adding a turret to an existing entity
as the turrets have their own codes and behaviours

cunning wind
#

Check the entity data of a gunship as a reference.

jovial echo
#

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

jovial echo
jovial echo
#

me forgot to tell that BonNervous

crimson linden
#

it's ok! lol

jovial echo
cunning wind
#

You can add any type of turret however you want on your custom enemy.

jovial echo
cunning wind
#

And yes, squid guns are included. >:3

jovial echo
#

imma make something that Callisto will LOVE

jovial echo
#

it's not another hardcoded crap now is it.

cunning wind
#
  {
    "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

jovial echo
#

thanks!

jovial echo
#

-# 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.

cunning wind
#

You're making a trailing saucer?

frail matrix
cunning wind
#

Wait a minute...
Has any other modder messed around with behaviours.json with some success?

frail matrix
cunning wind
#

For real.

jovial echo
#

but not every one is there

cunning wind
#

To my observation, I don't think anyone who made custom enemy behaviors have touched behaviours.json.

jovial echo
jovial echo
#

but then I thought it maybe was that "pool" the game was referring to

safe rover
#

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

jovial echo
#

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.

frail matrix
#

any child entity should be glued to your main entity by default, it kinda just works like turrets

jovial echo
#

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?

frail matrix
#

that sounds weird

why not just spawn all those 3 with the main one

jovial echo
#

it's just an example, I plan something bigger than that, like something similar to train, or serpent etc

#

those are connected entities

frail matrix
#

haven't experimented much with child entities so can't help you much

jovial echo
#

well, maybe someday in the future

#

for now you're working on custom turrets, ya?

frail matrix
#

i'm just working on my stuff, not making bases right now

jovial echo
#

when I understand more and more coding, I won't be asking questions and disturbing overall.

frail matrix
jovial echo
#

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

frail matrix
jovial echo
#

ok, so knowing lua basics will help, I'm gonna find somewhere to learn it then

jovial echo
#

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...

jovial echo
#

here we go, gg

cunning wind
jovial echo
#

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

cunning wind
#

Sadly true. ;-;

jovial echo
#

that really kills any idea.

#

is there maybe a way to make the bullets simulate a stream of lightning?

jovial echo
#

@frail matrix I remember seeing custom lightning star in Casinopolis, could you give an advise?

frail matrix
#

of?

jovial echo
frail matrix
#

the bullet?

cunning wind
#

I suspect so.

jovial echo
#

ya

#

I'm planning to recreate these:

frail matrix
#

the regular squid lightning gun is hardcoded

the only custom lightning turret is the star lighting gun

jovial echo
#

the ships will be in one sprite and this is planned to be the bullet

jovial echo
frail matrix
#

i don't think so

jovial echo
#

hm, alright

cunning wind
#

The folks at Platypus 2 Reclayed made smth like that before the lua days, but it's unpolished.

frail matrix
#

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

cunning wind
#

Ye, it's very primitive by today's standards. 😅

jovial echo
#

I can just reuse existing assets and behaviours

jovial echo
frail matrix
#

fish 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

jovial echo
#

well, sounds do-able, but I still don't know how to make a child enti-

#

the turret way seems more like it

frail matrix
#

they are kinda the same thing anyways

of course lua has more flexibility

jovial echo
#

that's for the animation loop?

frail matrix
#

uhm
that is the sprite movement for the saucer, not a loop

all you need for a loop is
self.animator.AnimateToNextFrame(true)

jovial echo
#

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?

frail matrix
#

yes

jovial echo
#

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?

cunning wind
#

I think you can make it play a sound in its lua file.

jovial echo
#

ok,
how do I play a sound in lua?

cunning wind
#

Playsound("s_enemykazap")

jovial echo
#

-# could you be more precise?

#

like where in the line?
I guess under the function OnTick() ?

cunning wind
#

That's where you'll have to figure where. Luckily, lua codes can be edited without the need for reloading the game.

jovial echo
#

oki

#

-# and how to loop the sound?

jovial echo
cunning wind
#

Unfortunately, I'll leave the rest up to you for now. I need to go to sleep now.

jovial echo
#

ok, goodnight

jovial echo
#

@frail matrix could you please check this? I'm so close to finishing that one enemy

#

at least the coding part

frail matrix
#

you wrote the wrong thing in the behaviours name

jovial echo
#

-# if it's the L instead of l in "lua" then I'm gonna-

#

something new

jovial echo
frail matrix
#

it's your lua

jovial echo
#

I've been trying to find out where the sound is supposed to be put

#

removed the sound code

frail matrix
jovial echo
#

hm

frail matrix
#

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

jovial echo
#

ah, I accidentally added it to the laser entity

#

but how do I make so the saucer does not shoot anything

frail matrix
#

take that part of the code

jovial echo
#

and how to spawn saucer to move usually and not get stuck in one place

jovial echo
frail matrix
#

it can if you take it out properly

jovial echo
#

please elaborate

frail matrix
#

just take everything related to the shooting code and just leave the movement logic

frail matrix
jovial echo
#

because og saucer has it

#

and the game has been calling for one

frail matrix
#

i don't think that's where you put it

jovial echo
#

that's the og saucer

#

-# hold up.

frail matrix
#

it is under custom behaviour data, not in turret

jovial echo
#

ya, noticed

#

usually turret is in custom behaviour data I think

#

maybe that's the issue?

frail matrix
#

turret is not in custom behaviour data

jovial echo
#

okay, I think I got that sorted

#

how to get rid of fire patterns at all

jovial echo
#

something happening

jovial echo
#

though I think imma just use spawnentity and focus?

frail matrix
#

you are making me dizzy clay_spiral clay_spiral clay_spiral

anyways to spawn your entitys you use spawnentity
since the rest are just pre made spawn commands for the game which are hardcodded

jovial echo
#

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

frail matrix
jovial echo
#

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

frail matrix
jovial echo
#

it still goes in the function on tick, right?

frail matrix
#

if you want to spam the sound every tick then sure

jovial echo
#

.

#

that doesn't sound like a normal bzzzzz sound I'm trying to achieve

#

there must be something similar to wait command then?

frail matrix
#

i don't think lua has that, so you gotta figure it out on your own

jovial echo
#

ok, it will wait then
how about the fire pattern?

#

is it possible to remove firing completely?

frail matrix
#

yes

jovial echo
#

could you tell me how?
how to make the game stop calling for it?

frail matrix
#

remove that part of the saucer code

jovial echo
#

but it did ask for it last time

frail matrix
#

it won't if you take all of the shooting code

jovial echo
#

ok, removing custombehaviourdata (from saucer)

frail matrix
#

the script will only error if it calls something that has no data of

jovial echo
#

it indeed did

frail matrix
#

there something calling fire data

jovial echo
#

that's what I remvoed

frail matrix
#

then is not any of your entities

check for any entity that you are summoning
that is calling fire data

jovial echo
#

only the saucer

#

and the zaps

frail matrix
#

it can't be either of those

jovial echo
#

everything goes fine when the patterns stay

#

without the patterns, the saucers stop

frail matrix
#

oh yeah since your behaviour is a vanilla one it need that data

jovial echo
#

ah

frail matrix
#

why are you chaging the saucer

jovial echo
#

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

frail matrix
#

also why did you put 0

it would only make it attack even faster

jovial echo
#

ya, noticed.

jovial echo
frail matrix
#

it is recomended to make a copy

jovial echo
#

ok

#

didn't I remove too much?

frail matrix
#

if it works, it works

jovial echo
#

we will see

frail matrix
#

also i didn't knew they update the saucer.lua to add debris on death fish

i guess i gotta add that to everything in my mod now

jovial echo
jovial echo
frail matrix
#

what does it tell you is missing

jovial echo
jovial echo
#

-# yes, the trashcan in the menu is intentional

frail matrix
#

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`

jovial echo
#

but isn't that related to firing, which I'm trying to remove?

frail matrix
#

only the allowedtoshoot and firesfx
and fire pattern

jovial echo
#

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

frail matrix
#

what do you mean

#

what is wrong with it?

jovial echo
frail matrix
#

just make it attack slower

jovial echo
#

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

frail matrix
#

you accidentally override the vanilla one with your custom one

change it name

jovial echo
#

ah, I see.

#

well, success?

#

still asks for the pattern though

frail matrix
#

you forgot to take some code away

jovial echo
#

hm, I guess it's the if CanFire() then ?

frail matrix
#

yes

jovial echo
#

still the same

frail matrix
#

can you take a picture?

jovial echo
#

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.

frail matrix
#

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

jovial echo
#

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

crimson linden
#

GG

cunning wind
cunning wind
#

I don't think anyone else dared to recreate Lightning Saucers in lua until now.

#

-# Correct me if I'm wrong though.

cunning wind
#

@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.

safe rover
#

That's a bit of a tricky one as those patterns are heavily limited by the old sound effect that we are using

safe rover
#

I think that's the one

cunning wind
#

Hmmmm...
Well, at least the SFX seems to be controlled by the duration of the lightning on screen.

safe rover
#

Except that it is only 3 seconds long hmm

cunning wind
safe rover
#

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

cunning wind
#

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.

jovial echo
#

speaking of sfx

cunning wind
#

Furthermore, I would also look forward to additional customizability to all starfish gun turret types.

jovial echo
#

I realised that if you spam a very short sound (add udner Function onTick) then it should work as a zap sound

safe rover
#

The poor audio engine is not going to like that haha

jovial echo
#

oh

cunning wind
#

You can use the PSP version of zap, since it's far shorter. ;3

jovial echo
safe rover
#

You can add a cooldown to the audio clip, that way it doesn't fire every tick

jovial echo
#

I tried setting the lightning as a bullet for the rotating gun, but it ended too soon, so the electricity did not generate

cunning wind
#

Cooldown frames in audio.json.

jovial echo
#

example please?

safe rover
#

Examples are in audio.json

jovial echo
#

-# ok, imma look to it as soon as I can

jovial echo
cunning wind
cunning wind
#

Here's the funni video I'm talking about. :3

cunning wind
jovial echo
#

how long is one cooldown frame?

jovial echo
safe rover
#

One "cooldown frame" is one tick, the game runs at 60 ticks per second, so 1 tick is 1/60 seconds

jovial echo
#

oki

jovial echo
safe rover
#

I think the error message you are getting should help you track it down more.
As a hint: Lua is case sensitive

jovial echo
safe rover
#

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

safe rover
jovial echo
#

now just gotta adjust the cooldown and it should be fine

frail matrix
safe rover
#

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

frail matrix
#

well that's a lot

well atleast is good to know add collider is in init

cunning wind
#

@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.

safe rover
#

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

cunning wind
#

Yes, and I'mma embrace disappointment. :p

cunning wind
safe rover
#

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 👀

cunning wind
#

Interesting...

safe rover
#

Also would allow for things like teleporters, but I'm getting ahead of myself

cunning wind
#

DW, the time is the least of our concerns.

cunning wind
#

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.

cunning wind
#

@safe rover, is there a way to add a changeable speed multiplier to animation frames?

safe rover
#

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

cunning wind
#

Thus, we are currently unable to configure the actual speeds of the animations regardless of their frame count then?

safe rover
#

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

cunning wind
#

So, what could I do with SpriteAnimator.timePerFrame in lua?

safe rover
#

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

cunning wind
#

I do plan to have a dynamic animation speed in Lua.

#

Where certain conditions I set up will change the speed.

safe rover
cunning wind
#

I wonder where to place it?

safe rover
#

Wherever your custom logic decides that it is time to switch to another sprite

cunning wind
#

I assume the integer is the value I have to type, right?

safe rover
#

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

cunning wind
#

i.e. it is currently complicated to do so with the current system we have?

safe rover
#

"Complicated" is rather subjective and depending on your coding background

cunning wind
#

That makes sense.

cunning wind
safe rover
#

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);```
cunning wind
#

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.

safe rover
#

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

cunning wind
#

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
#

speed = 2

#

It kinda works, but looks janky.

safe rover
#

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

cunning wind
#

Gotcha

safe rover
#

There isn't

cunning wind
#

I see.

jovial echo
# frail matrix you are making me dizzy <:clay_spiral:1398846336706678814> <:clay_spiral:1398846...

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.

jovial echo
#

-# I'm so glad to hear that!

cunning wind
# safe rover There isn't

Pardon the late response, but will there be generic entities of trains, boats, and big cannons in the next modding update?

#

@safe rover

frail matrix
#

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

cunning wind
#

I can handle that. :D

#

The train tho.

frail matrix
#

trains and cars should be easy too

really the only issue should be the base and the wheels

cunning wind
#

The wheels are something that's tricky to implement, at least for me.

frail matrix
#

i wonder if the wheel are an entity

cunning wind
#

Hmm... are you on PC rn?

frail matrix
#

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

cunning wind
#

Speaking of which, have you actually converted some of your turret entities to their respective child entities on your mod?

#

Just curious. :3

frail matrix
safe rover
#

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)

cunning wind
#

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.

frail matrix
#

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 fish

cunning wind
#

fish_dinner 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...

safe rover
#

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

cunning wind
cunning wind
crimson linden
jovial echo
cunning wind
cunning wind
jovial echo
#

that's what I already know

jovial echo
cunning wind
#

That's because the Claymatic team is working on a boss replica.

jovial echo
cunning wind
#

OFC it won't be Quadrapus, since it's by far the most complex boss ever made in Platypus Reclayed.

jovial echo
cunning wind
#

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.

safe rover
cunning wind
#

What is the exact name of the "kills player" function?

safe rover
cunning wind
#

Oh, I see.

safe rover
#

It returns a boolean

cunning wind
cunning wind
#

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()?

safe rover
#

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

cunning wind
#

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?

safe rover
#

Not sure I'd use the word static

#
function ShouldKillPlayerOnTouch()
    return self.position.x > 50
end```
cunning wind
#

Oh nice!

#

I'm abt to test them real quick.

#

It actually works. anthony_kiwi
Thanks Kroporo!

safe rover
#

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

cunning wind
#

I think it already works accordingly.

#

Even without the custom player response you were alluding to.

safe rover
#

Even better in that case!

#

The default response might already be checking this value

cunning wind
#

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.

safe rover
#

The lua script is your canvas

#

You can tell it exactly when and when not to kill the player with that function

cunning wind
#
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.

safe rover
#

Yeah, that is not valid lua syntax

cunning wind
#

So, does the return syntax only support one at a time?

safe rover
#

It supports returning of a boolean value, however that value is determined is up to you

cunning wind
#

Heya @safe rover, is there a way to offset the position of SpawnAttachedSpriteAnimator?

safe rover
#

Can't look at the documentation until Monday

cunning wind
frail matrix
#

oh yes

i have been messing with it lately

#

core = self.SpawnAttachedSpriteAnimator("Sprites/Enemies/small nautilus bottom", -1) core.position = { x = -20, y = -35 }

cunning wind
#

TY

frail matrix
#

the clay heart should be an server emoji, i thought it was in already, fish

cunning wind
#

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.

cunning wind
frail matrix
#

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.

cunning wind
#

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.

frail matrix
#

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

cunning wind
#

If a child entity has been set up, will said entity still need to be reflected in entities.json?

frail matrix
#

yeah, child entities works like putting a turret in something, and turrets are entities

however spritesheets don't need an entity

cunning wind
#

What is the syntax for setting up a child entity btw?

#

AFAIK, I haven't seen an example of it yet.

frail matrix
#

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

cunning wind
#

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.

frail matrix
#

those are just the parameters that acepts

entityname, needs a string
parent needs a base entity
positionoffset needs a vector2
arguments need a jsonobject

cunning wind
#

I see. So I reckon all these things are to be written inside the () next to said function.

frail matrix
#

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

cunning wind
#

I see.

#

Anyhow, thanks. clay_heart

frail matrix
#

in args, you can just put NewJSONObject() if you won't do much with it besides just spawning it

cunning wind
#

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?

safe rover
#

nil might work too with a bit better performance

frail matrix
frail matrix
cunning wind
cunning wind
crimson linden
#

Isn't there a way to temporarily deactivate the "has collission" option, tho?

cunning wind
#

Yes, maybe.

#
function HasCollision()
    return timer <= 0
end
safe rover
cunning wind
cunning wind
night stream
cunning wind
#

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.

frail matrix
#

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

cunning wind
#

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.

frail matrix
#

welcome to the spritesheet shenanigans clubfish

cunning wind
#

The spritesheet probably wouldn't keep up without bloating the file size, especially when the animations are smooth, therefore more frames per second.

cunning wind
cunning wind
#

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.

frail matrix
#

Have you messed with the create debri function yet?

cunning wind
#

Not yet. :p

frail matrix
#

It should gives you all the tools for that

cunning wind
#

I'm pretty late with the Lua bandwagon NGL.

#

Where is the updated list of Platypus Lua tools?

frail matrix
#

In streaming folder,
Is type.lua

cunning wind
#

Oh wow! TIL

cunning wind
frail matrix
cunning wind
# cunning wind

But it works nonetheless. :3
-# As demonstrated in the video above.

frail matrix
#

Oh wait that is what the other thing is for

cunning wind
#

Have you watched the full video?

frail matrix
#

My internet connection is poor at the moment fish

cunning wind
#

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.

frail matrix
#

Yeah due the mx <= 0

cunning wind
#

If I were to use and, then both of them must be met, meaning the boat going forwards will never activate the function. :p

frail matrix
#

When my power come backs i will mess with it, i wanna try too

frail matrix
# cunning wind Not yet. :p

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

cunning wind
#

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

frail matrix
cunning wind
#

LMAO

cunning wind
frail matrix
#

Uhm i'm not sure if the game is using that file and either way you couldn't do much

cunning wind
#

I see.

frail matrix
#

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 😉

cunning wind
#

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.

cunning wind
#

Attention fellow modders:

Below is the link for the base boat entities which can be used for making custom boat enemies:
#1437926250374103234 message

crimson linden
cunning wind
#

At that point, I am pretty much contributing to all things Platypus 2, well, indirectly. KingTick

#

So...

Y E S

safe rover
#

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

cunning wind
#

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

frail matrix
#

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

frail matrix
cunning wind
#

Prolly because @crimson linden wanted to make homing green fish fighter code using some parts of the mosquito code. :3

cunning wind
#

Oh ya, funny that I actually ended up being the one who made the green fish fighter script using mosquito.lua as a derivative. fish_dinner

cunning wind
#

@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.

safe rover
#

Yeah, I think you got access to all of those!

cunning wind
#

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()⁩⁩

cunning wind
#

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.

frail matrix
#

Well that is because i specifically called for player 1

I could make it so the closest player get the priority

cunning wind
#

I'mma follow suit once you figure it out.

#

I'm currently developing a different entity for a different project ATM.

cunning wind
crimson linden
#

Maybe it could be an optional feature too, in case someone wants the opposite

cunning wind
frail matrix
#

well is because the game never unloads the player while death, so the player is there invisiblefish

cunning wind
#

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?

safe rover
#

Unload? No

frail matrix
#

not sure if you want to unload the player fish

that can lead to stuff, like the game breaking

cunning wind
#

Oh man

frail matrix
#

just a way to know if the player is invulnerable seems about right

cunning wind
#

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.

cunning wind
#

@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.

frail matrix
#

hmmmmm

cunning wind
#

Maybe this is the solution. anthony_kiwi

frail matrix
#

@cunning wind try this

cunning wind
frail matrix
#

let me see the code 1 second

cunning wind
#

Actually, is there anything to replace?

frail matrix
#

is just that part

#

, but maybe you are mixing the 2
since i change some order

cunning wind
#

Either way, this is how it looks like right now.

frail matrix
cunning wind
#

I see.

frail matrix
#

i change the order so 2 is above

cunning wind
#

Alright, it works.

frail matrix
#

🎉

cunning wind
#

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?

cunning wind
cunning wind
frail matrix
#

nautilus

cunning wind
frail matrix
#

who the hell is playing as the second player alone

cunning wind
#

IKR, but this is what happens when the first player dies and can't continue, but the second player still lives.

safe rover
#

There is a function to get a random active player that the game makes use of a lot

frail matrix
#

well this one, uses the closest player, and so it tend to grab the unactive player too clay_spiral

cunning wind
#

⁨```
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.

frail matrix
#

uh well get random player returns a player value
those go in the get player position

cunning wind
#

-# Except for the fact that they all despawn once no player is onscreen. clay_spiral

frail matrix
#

now is constantly switching between the 2 players fish

cunning wind
#

Ye, I noticed.

cunning wind
#

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.

cunning wind
cunning wind
#

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?

cunning wind
frail matrix
cunning wind
#

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?

frail matrix
#

which barrel fish

cunning wind
#

The one used on your food dispenser.

#

Specifically the one shown in the enemy showcase video.

frail matrix
#

yeah static

#

or animated, i'm mixing stuff fish_dinner

cunning wind
#

Okay, I just thought it was just a moving barrel sprite with damage frame support.

frail matrix
#

it shouldn't be hard to do that

cunning wind
#

Anyhow, ty for the info.

cunning wind
#

Or at least, try doing so...

#

Oh btw, is there a needed set of functions for OnInitialise()?
-# For the cannon fire pattern.

frail matrix
#

just

startAngle = 90
cunning wind
#

How about for the endAngle?

frail matrix
#

i thikn end angle is no longer used fish

#

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
cunning wind
#

Oh boy, it seems ClayBot now has beef towards snippets of Lua code lately. clay_grimacing

frail matrix
#

is the in the snippets

cunning wind
frail matrix
#

jailed

don't know why i can grab pfps

cunning wind
#

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.

frail matrix
#

is just startAngle fish

that is what happens when you don't rename your vars

cunning wind
#

Okay thanks. clay_heart

frail matrix
#

did you set bullets?

cunning wind
#

Yes, 7 to be precise.

frail matrix
#

there 3 bullets vars

the last 2 makes the arc flexible with the ammount of bullets

i wonder how that happend anyways

cunning wind
frail matrix
#

i can give you the file itself

cunning wind
#

Sure thing. :D

frail matrix
cunning wind
#

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

pearl ether
cunning wind
#

The cannon squid?

pearl ether
#

Yep

#

Will be on Remam

pearl ether
cunning wind
pearl ether
#

He shoots only once btw

cunning wind
#

Yeah, IK. :p

pearl ether
#

how it can move like cannon boat?

cunning wind
pearl ether
#

yep

cunning wind
#

My current progress with the barrel recoil animation via movement.

pearl ether
#

lemme just make it kinda... move

cunning wind
frail matrix
#

oh right forgot to tell you that fish

maybe see if the coordinates offset can be updated in real time
so it simulates movement

cunning wind
pearl ether
#

at least I tried

cunning wind
#
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
cunning wind
pearl ether
#

"sortOrder": 10000,

frail matrix
cunning wind
#

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
frail matrix
#

rip

pearl ether
#

sortorder

cunning wind
#

It doesn't work either.

#

Welp, at least the Lua cannon entity is feature complete.

pearl ether
#

well... kinda

cunning wind
#

Remove this

    timer = timer - 1
    if timer < 0 then
        timer = 149
        my = -30
    end
#

Add my = -30 right below timer = 45

pearl ether
pearl ether
#

What u do?

cunning wind
#
    "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.

pearl ether
#

Certified Sortorder

pearl ether
pearl ether
cunning wind
#

@safe rover, is there currently a Lua function that overrides the fire cooldown of attached turret or child entities?

safe rover
#

Not that I'm aware of

cunning wind
#

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.

safe rover
#

That's not done by overriding, turrets ask their parents if they can fire before they fire themselves

cunning wind
#

Thus, the child entities have a function that asks their parent entities the consent then?

safe rover
#

No, but they too call CanFire on their parent

cunning wind
#

So, if I set up a CanFire function to a base entity, will any attached child entity abide by it?

cunning wind
#

Now I'mma give 'em more flexibility.

cunning wind
#

Actually, what is the sample syntax for both parent and turret entity?

cunning wind
#
---@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?

cunning wind
#

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.

cunning wind
#

Oh BTW, how does this work?

---@return integer
function FirePattern.GetTicksTillFire() end
pearl ether
#

Like those thrusterships or gunship

#

On flyby phase btw players can walkthrough them tho

pearl ether
#

Or those midboss enemies

cunning wind
#

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.

pearl ether
#

Yep

#

Like those squidguns stuff

#

Btw what is lua randomized method?

#

Math.random?

cunning wind
#

Yeah

pearl ether
#

Math.random(integers)?

cunning wind
#

Ex: math.random(0, 100)

pearl ether
#

Oh ok...

cunning wind
#

I made it so the Lua Missile Boats can have configurable missile launch timers.

#

As you can see, they fire every 100 ticks.

safe rover
#
  • 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)
cunning wind
#

FirePattern.GetTicksTillFire() is something I have figured out later down the line BTW. :D

safe rover
#

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

cunning wind
cunning wind
safe rover
#

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();```
cunning wind
#

What's with &&?

cunning wind
pearl ether
#

Me when override

cunning wind
#

-# Worth noting that the fire pattern function on my Lua missile launcher works as intended.

safe rover
#

&& is just and

cunning wind
safe rover
#

We treat you defining the CanFire function as overriding it

safe rover
#

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

cunning wind
#

I assume it is local then?

#

Okay, I found out that I have to put self prefix to parent.CanFire().

cunning wind
safe rover
#

I'd have to go into more technical details, but I believe that would be more confusing than helping

cunning wind
#

DW, I got it to work.

cunning wind
#

Now moving on, how about the args that force the homingMissile entity to not home for a brief period of time?

cunning wind
#

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()
cunning wind
#

I think they are asking for indexed numeric values.

cunning wind
frail matrix
cunning wind
#

This is for its fire patterns.

frail matrix
#

fish welp, it may be worth waiting for that lua turret

#

since i moved with lua i haven't mess with vanilla entities that much

cunning wind
#

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.

cunning wind
#

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.

cunning wind
frail matrix
#

hmm

cunning wind
#

Just a funny demo of vanilla squid gun turrets asking their parents for consent with the CanFire function. fish_dinner

frail matrix
#

that can be useful

#

time to rework all entities again fish_dinner

cunning wind
#

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.

cunning wind
#

Alr, I got the smoke trail working perfectly.

pearl ether
#

What smoke trail does it use?

cunning wind
#

Now, only the damage effects are left, which is apparently one of the main reasons Tartaz gave up back then.

pearl ether
#

This might make had an idea

#

You know those Jellyfish from platypus 2

#

The bigger one not the smaller ones

cunning wind
#

Ye

pearl ether
#

I wonder if it's possible to remake it

#

Cuz the jellyfish is animated

cunning wind
cunning wind
#

@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.

cunning wind
#

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.

cunning wind
# cunning wind

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.

cunning wind