Starbound

Starbound

Katana Zero's Sword
 This topic has been pinned, so it's probably important
Aikiro42  [developer] 6 Jul, 2022 @ 12:05pm
Technical Discussions
Technical

This section is for those that want to know the inner workings of this mod, or those that want to customize this weapon using JSON parameters, or any other weapon using the assets of this weapon.

Parry-slash
The parrying slash was made to work by adding the following instructions to the `fire` function of `MeleeCombo`:
1. Create a parrybox that's the same shape and position as the hurtbox. Make the shield health 9999 (`activeItem` parameter) 2. Create a `damageListener` that will do the following when the parrybox hits any source of damage to the player: a. Query for entities in a radius around the player, up to where the slash reaches farthest. b. Draw a polygon matching the shape, orientation and location of the parrybox. c. If an entity is a projectile and is located in the drawn polygon, i. Play the "reflect" sound. ii. Determine the direction of the slash. iii. Spawn a "reflect projectile" (projectilereflectfx) that's directed towards the direction of the slash. d. Otherwise, just play the "parry" sound. 3. In the duration of the slash, keep updating the listener. - If you parry something that deals enough damage to deplete the shield health to zero, interrupt the animation. This shouldn't happen because of how a perfect block works in starbound; the slash animation lasts for 0.1s while a perfect block lasts for 0.2s. 4. After the slash duration is done, get rid of the shieldhealth and remove the parrybox.

Slash Momentum
There is a fundamental difference between slashing on the ground and slashing in mid-air: the former adds momentum to you so that it doesn't break your flow if you slash while running, especially if you have a mod/effect that increases your movement speed. The latter sets your velocity to the direction of your slash so that it can break your fall and allow you to hover for a bit by spam-slashing up, like in Katana Zero.

- The `slashCarry` parameter of the `primaryAbility` field of the sword is the velocity/momentum set/added when you slash. By default this is set to 9.

- The `slashLaunchFactor` parameter of the `primaryAbility` field is multiplied to the `slashCarry` when you are slashing for the first time since landing on the ground. By default this is set to 5.

- The `slashStrengthVectorAir` (default: [0.5, 1]) and `slashStrengthVectorGround` (default: [1, 1]) parameters of the `primaryAbility` field are two-element arrays multiplied to the normal vector of your slash direction.

- When you are on the ground, the normal vector is limited to the Y-axis. This is to prevent fast sliding by aiming 45 degrees down.

Teleport Correction Algorithm

The Dragon Dash ability works by first teleporting you around your cursor then shooting a projectile (dragondashfx) from your point of origin at a certain speed such that it reaches your new location.

The teleport algorithm works like this:

1. Draw a line from the player character to the cursor. If it hits any structure with collision (blocks, dynamic) the first colliding structure will be chosen as the teleport base; otherwise, the cursor's position is chosen. 2. Check if the player can teleport to the teleport position without colliding with the environment. If the player won't collide, set that as the teleport location; otherwise, continue. This teleport position will henceforth be called the initial teleport location. 3. Probe for collision upwards, downwards, leftwards and rightwards from the center of the player's standing collisionPoly. The probe origins are offset from the center so that if the center of the collisionPoly is on a floor, wall or ceiling, the algorithm won't think that the collisionPoly is akin to being in a wall. 4. For each direction, - If there is collision towards the direction and no collision in the opposite direction, a. If there is collision on either leftwards or rightwards (but not both), adjust the initial teleport location accordingly. b. Move the (adjusted) initial teleport location upwards accordingly. c. If the new teleport location doesn't collide, set that as the final teleport location; done. d. If new teleport location still collides, attempt automatic poly collision resolution (`resolvePolyCollision`). e. If the resolution is successful, check if the resulting teleport location is still in line of sight (no collision between player position and new teleport position). Otherwise, go to step 5. f. If the resulting location is in Line of Sight, set that as the final teleport location; done. g. Otherwise, go to step 5. 5. Rely on using `resolvePolyCollision` with the initial teleport location to determine the best non-colliding teleport location. It will either set the teleport location to somewhere viable, or nowhere at all. 6. If a teleport location was determined automatically, check if the location is in line of sight. If it is, set that as our final teleport location. Otherwise, we set our final teleport location as `nil`.

This algorithm allows players to reliably dash along even ground and prevents sequence-breaking exploits. This algorithm is ineffective with sloped blocks, though; I'm working on a fix for that. This algorithm is now almost always effective on sloped blocks.

This algorithm is executed constantly while channeling the ability. The ability has no wind-up time and can be instantly cast, but will function normally if a charge time is added.

Weapon Assets
The following are the assets of the weapon, should you want to make a custom JSON weapon based on this one:
Inventory Icon/Handle: /items/active/weapons/melee/broadsword/katanazero.png /items/active/weapons/melee/broadsword/katanafifteen.png Weapon animation: /items/active/weapons/melee/broadsword/katanazerocombo.animation Script for Parrying Slashes with Momentum: /items/active/weapons/melee/meleecombozero.lua Dragon Dash: /items/active/weapons/melee/abilities/broadsword/dragondash/dragondash.weaponability - weaponability file /items/active/weapons/melee/abilities/broadsword/dragondash/dragondash.lua - weaponability script /items/active/weapons/melee/abilities/broadsword/dragondash/dragondashanimation.lua - script for ability indicator /items/active/weapons/melee/abilities/broadsword/dragondash/dragondashindicator.png - image for ability indicator SFX: /sfx/melee/katanazero_slash1.ogg /sfx/melee/katanazero_slash2.ogg /sfx/melee/katanazero_parry.ogg /sfx/melee/katanazero_reflect.ogg /sfx/melee/kronos_windup.ogg /sfx/melee/dragondash_slash.ogg /sfx/melee/dragondash_ready1.ogg /sfx/melee/dragondash_ready2.ogg Projectiles: /projectiles/activeitems/dragondashfx /projectiles/activeitems/projectilereflectfx

Current Known Bugs
- All damage sources are parriable and will spawn projectiles.
- Dragon Dash does not let you teleport to some where it makes sense to teleport.
- This may be likely due to the teleport algorithm failing the line of sight checks. Problem commonly observed when teleporting through and to small spaces.
- Dragon Dashing against a ceiling/elevated floor while crouched will clip you through the ceiling/floor. Ceiling bug can be remedied by maintaining your crouch so you can drop down. Related to teleport placement algorithm. Teleport correction algorithm now only uses the player's standing poly.
- You can't teleport to some places from certain angles even though it would make perfect sense to be able to go there, e.g. Sloped blocks.
- (Rare bug) Hurtbox/Parrybox persists after Dragon Dashing. Can be remedied by attacking.
- (Rare bug) Line indicator may disappear. Observed in the Advanced Logistics Frigate mod. Harmless bug.

Current Limitations
- Cannot parry projectiles. (Why did I put this here?) Projectiles can be parried and cause the swords to fire back a projectile of their own. Projectiles usually die when they hit shields, but those that can penetrate don't (and can thus be parried mutiple times).
- Only has a static image of Zero's silhouette as an indicator.
- Known limitation on dash effectiveness over extreme ranges. The slash projectile's speed is relative to the duration of the ability, which is 0.1s. At large enough distances it's possible that the speed required to travel to the new location in time cannot be handled by the engine. Shouldn't be a problem unless you play at less than 1x zoom.
- Wall latching makes you stop holding your weapon and hence makes you stop channeling the ability/force-casting the ability.

To-do
- Separate Wall-jump tech that launches you off the wall harder and allows you to attack while latched.
- Lamp/Bottle throwable weapons.
- Fifteen's instant trailing dash ability. Done!
- Parry projectiles and melee attacks only, including projectiles coming from objects.
- Spawn energy kunai only when parrying a projectile.
- Deal no damage when parrying melee attacks and apply a stun effect.
- Improve teleport placement algorithm even more.
- Prism sword (new swoosh, new pixel art, new sfx)
- Sword of Masters (new swoosh, new pixel art, new sfx, new ability/altered combo, new projectile)
- Savant Knife (new pixel art, adjusted hurtbox and parrybox, adjusted stats)
- Claymore Prototype (new pixel art, adjusted hurtbox and parrybox, adjusted stats)
- Phoenix Edge (new swoosh, new pixel art, new sfx, new ability.altered combo, new projectile)
Last edited by Aikiro42; 11 Jul, 2022 @ 8:06pm
< >
Showing 1-7 of 7 comments
Aikiro42  [developer] 9 Jul, 2022 @ 8:44am 
Note to self:

1. Use `entityQuery` to query for projectiles within the radius of your slash.
2. Use `world.polyContains()` on the queried projectiles with the hurtbox to check if a projectile is parried.
Aikiro42  [developer] 12 Jul, 2022 @ 11:48pm 
Will put development on hold for now, I wanna work on something personal and take care of life stuff.
Aikiro42  [developer] 12 Jul, 2022 @ 11:54pm 
Note to self:

Dragon dash: set a damage area from origin to destination. Projectile should deal no more damage, and only fire for purposes of visual effects.

local playerCollisionPoly = mcontroller.baseParameters().standingPoly
Last edited by Aikiro42; 13 Jul, 2022 @ 6:49am
ReiTheTrap 25 Aug, 2022 @ 6:59am 
if i will change the size of katanafifteen.png 27x44 to 32x140 what will happen?
im bad with json stuff so i just unpacked the mod and trying to change the sprites to The Only Thing I Know For Real from the stars above terraria mod and some sfx to red so it matches the blade

also where is the swoosh? where can i edit sprites of it
Last edited by ReiTheTrap; 25 Aug, 2022 @ 7:27am
Aikiro42  [developer] 25 Aug, 2022 @ 8:09am 
Originally posted by ReiTheTrap:
if i will change the size of katanafifteen.png 27x44 to 32x140 what will happen?
im bad with json stuff so i just unpacked the mod and trying to change the sprites to The Only Thing I Know For Real from the stars above terraria mod and some sfx to red so it matches the blade

also where is the swoosh? where can i edit sprites of it

not sure myself, haven't worked with sprites bigger than what was given yet, but according to a fellow modder you had to offset the thing

the swoosh is just
/items/active/weapons/melee/broadsword/swoosh2/electricswoosh.png
with image directives: https://starbounder.org/Modding:Image_Processing_Directives
ReiTheTrap 25 Aug, 2022 @ 8:19am 
Originally posted by Aikiro42:
Originally posted by ReiTheTrap:
if i will change the size of katanafifteen.png 27x44 to 32x140 what will happen?
im bad with json stuff so i just unpacked the mod and trying to change the sprites to The Only Thing I Know For Real from the stars above terraria mod and some sfx to red so it matches the blade

also where is the swoosh? where can i edit sprites of it

not sure myself, haven't worked with sprites bigger than what was given yet, but according to a fellow modder you had to offset the thing

the swoosh is just
/items/active/weapons/melee/broadsword/swoosh2/electricswoosh.png
with image directives: https://starbounder.org/Modding:Image_Processing_Directives

its my first time modding something on starbound and trying to upload mod in workshop. Could ya help me when you will be free with finding out how to edit sprites easier and later uploading to workshop? Trying to learn by myself is very hard. I want to upload later that skin/resprite of katana fifteen to workshop (ofc also i will credit everyone who needs to be credited). Can add on discord
Last edited by ReiTheTrap; 25 Aug, 2022 @ 8:19am
Aikiro42  [developer] 25 Aug, 2022 @ 8:31am 
@ReiTheTrap Other modders and I may be able to help you over at #mod-dev in the community discord server: https://discord.gg/starbound

For easy sprite editing I personally use Aseprite but there exists Libresprite, which is free but may have dated features

If you wanna do what you wanna do I recommend making a patch file for

/items/active/weapons/melee/broadsword/katanafifteen.activeitem

that changes the "animationParts" field; (and the "icon" field, so that the inventory icon changes look too)

i.e. make a file named katanafifteen.activeitem.patch in the same directory as katanafifteen.activeitem and edit the patch file - refer to https://json-patch-builder-online.github.io/
Last edited by Aikiro42; 25 Aug, 2022 @ 8:41am
< >
Showing 1-7 of 7 comments
Per page: 1530 50