You are not logged in.
Hi guys! Testing the new version of Open Surge and bringing Speedy the RollerSkater as usual, I remembered a problem I had with Speedy as he swims underwater.
The problem is when Speedy swims and touches an enemy, the enemy gets killed. This also happens with item boxes, while he swims, if he touches them, he breaks them.
Other case is when Speedy uses springs underwater to going up, the swimming sprites stills instead of changing to 'going up' sprite.
What I need to know is how to fix this and make Speedy getting hurt when he touches an enemy swimming, stopping his swim when he lands over an item box, and change his sprite when he goes up thanks to the springs.
Last edited by SynfigMaster91 (2018-08-22 12:42:41)
Offline
Hi SynfigMaster91,
Take a look at your scripts. Disable them and find out which one brings about the undesired behavior.
There's probably a strong_player somewhere.
Offline
Hi SynfigMaster91,
Take a look at your scripts. Disable them and find out which one brings about the undesired behavior.
There's probably a strong_player somewhere.
Hi, Alex. I checked out but there's no strong_player on the swim object. Just in the charge state. Here's the full code.
// ---------------------------------------------------------------------------
// Open speedy Engine
// http://opensnc.sourceforge.net
//
// File: default_companions/speedy.inc
// Desc: speedy's companion
// Author: Alexandre
// Date: 2011-02-09, 2011-02-11, 2012-02-23
// ---------------------------------------------------------------------------
object ".speedy_companion"
{
requires 0.2.0
always_active
state "main"
{
create_child ".speedy_spindash_controller"
create_child ".speedy_nolightwalk_controller"
create_child ".speedy_swim"
destroy
}
}
object ".speedy_spindash_controller"
{
requires 0.2.0
always_active
state "main"
{
hide
observe_player "speedy"
change_state "stand by"
}
state "stand by"
{
on_player_duck "duck"
}
state "duck"
{
let "$p = 0"
on_button_pressed "fire1" "charge"
on_player_duck "duck"
change_state "stand by"
}
state "charge"
{
set_player_animation "SD_speedy" "6"
strong_player
springfy_player // so that the camera won't go down, since the player is ducking
disable_player_movement
play_sample "charge"
let "$p = min($p+2, 8)"
change_state "hold"
}
state "hold"
{
//textout menu.small 0 0 $p
set_player_animation "SD_speedy" "6"
let "$p -= 0.234 * floor(8*$p) * dt()"
// check if there's a platform underneath the player
attach_to_player 0 20
unless "obstacle_exists(0,0)" "cancel"
// create cool particles
let "$_pixelparticle_anim = 1 + random(3)"
let "$_pixelparticle_xvel = -player_direction() * (120 + random(60))"
let "$_pixelparticle_yvel = -60 - random(120)"
create_child .pixelparticle -player_direction()*7 -2
let "$_pixelparticle_anim = 1 + random(3)"
let "$_pixelparticle_xvel = -player_direction() * (120 + random(60))"
let "$_pixelparticle_yvel = -60 - random(120)"
create_child .pixelparticle -player_direction()*7 -2
let "$_pixelparticle_anim = 1 + random(3)"
let "$_pixelparticle_xvel = -player_direction() * (120 + random(60))"
let "$_pixelparticle_yvel = -60 - random(120)"
create_child .pixelparticle -player_direction()*7 -2
// check if the user wants to charge more, or if we can release the player
on_button_pressed "fire1" "charge"
on_button_down "down" "hold"
change_state "release"
}
state "cancel"
{
enable_player_movement
weak_player
change_state "stand by"
}
state "release"
{
play_sample "release"
enable_player_movement
weak_player
set_player_xspeed "(480 + 30 * floor($p)) * player_direction()"
roll_player
change_state "stand by"
}
}
object ".speedy_nolightwalk_controller" // his lighting sneakers can't shine when in the air
{
requires 0.2.0
always_active
state "main"
{
hide
observe_player "speedy"
change_state "stand by"
}
state "stand by"
{
on_player_in_the_air "air"
}
state "air"
{
on_player_walk "walking in the air"
on_player_run "running in the air"
on_player_brake "braking in the air"
on_player_in_the_air "air"
change_state "stand by"
}
state "walking in the air"
{
on_player_spring "stand by"
on_player_jump "stand by"
on_player_gethit "stand by"
on_player_death "stand by"
set_player_animation "SD_speedy" 18
on_player_in_the_air "walking in the air"
change_state "stand by"
}
state "running in the air"
{
on_player_spring "stand by"
on_player_jump "stand by"
on_player_gethit "stand by"
on_player_death "stand by"
set_player_animation "SD_speedy" 19
on_player_in_the_air "running in the air"
change_state "stand by"
}
state "braking in the air"
{
on_player_spring "stand by"
on_player_jump "stand by"
on_player_gethit "stand by"
on_player_death "stand by"
set_player_animation "SD_speedy" 20
on_player_in_the_air "braking in the air"
change_state "stand by"
}
}
object ".speedy_swim"
{
requires 0.2.0
always_active
state "main"
{
hide
observe_player "Speedy"
change_state "wait"
}
state "wait"
{
change_state "up"
}
state "up"
{
change_state "ready"
}
state "ready"
{
on_button_pressed "fire6" "start"
on_player_walk "main"
on_player_run "main"
}
state "start"
{
on_player_underwater "sswim"
change_state "main"
}
state "sswim"
{
set_player_animation "SD_SPEEDY" 21
on_button_pressed "fire6" "swim"
on_player_walk "main"
on_player_run "main"
}
state "swim"
{
set_player_animation "SD_SPEEDY" 21
set_player_yspeed -90
change_state "sswim"
}
}
Offline
I checked out but there's no strong_player on the swim object. Just in the charge state.
Exactly. So you have to debug it. Remove the "charge" state, its triggers and see what is going on.
See also if you have other objects that might be calling strong_player.
If you replace Speedy by Surge, does it work? It works on a clean install.
Offline
SynfigMaster91 wrote:I checked out but there's no strong_player on the swim object. Just in the charge state.
Exactly. So you have to debug it. Remove the "charge" state, its triggers and see what is going on.
See also if you have other objects that might be calling strong_player.
If you replace Speedy by Surge, does it work? It works on a clean install.
I removed the charge state but nothing worked, beside getting an error when trying to do a spin dash.
I don't think replacing Speedy by Surge works because I didn't make Surge swimming neither.
Offline
I don't think replacing Speedy by Surge works because I didn't make Surge swimming neither.
Think at first that you're doing a diagnosis. You're not looking for a solution (just yet), rather, you're doing an investigation to see what is wrong.
In your diagnosis, you run a series of tests. Each test tells you a bit about the actual condition, so you get closer and closer to a correct diagnosis. Once you identify what the problem is, then you can proceed to a solution, but not before.
Offline
SynfigMaster91 wrote:I don't think replacing Speedy by Surge works because I didn't make Surge swimming neither.
Think at first that you're doing a diagnosis. You're not looking for a solution (just yet), rather, you're doing an investigation to see what is wrong.
In your diagnosis, you run a series of tests. Each test tells you a bit about the actual condition, so you get closer and closer to a correct diagnosis. Once you identify what the problem is, then you can proceed to a solution, but not before.
Hmm... how could I do this? Testing other characters? It's the first time I'm doing this and some step by step info would be nice for me.
Offline
I tried with checking the code and changing some things but the problem is still the same.
I wonder why won't I be able to make Speedy get hurt by an enemy while he swims? Is fate wanting me to fail in everything I try?
Offline
If I might suggest something, get a clean install of Open Surge and make Speedy work on that. Do not copy any scripts.
Once you make it work, check the difference between the versions.
I'm sure you can figure that one out
Offline
If I might suggest something, get a clean install of Open Surge and make Speedy work on that. Do not copy any scripts.
Once you make it work, check the difference between the versions.
I'm sure you can figure that one out
You mean... using a clean version of Open Surge and copying my Speedy script and sprites there?
Not sure if it will work but I can try.
Offline
if the player is set to roll or any animation that causes the attack hitbox to be created, it will act as a constant strong_player.
what you want to do is to make a simple object, that is always_active and every frame observes that player and gives them weak_player.
state "main"
{
observe_player "player_name"
weak_player
}
unless this has been changed in the latest revisions, it should work
https://discord.gg/w8JqM7m ---> Open Surge's Discord server
Offline
if the player is set to roll or any animation that causes the attack hitbox to be created, it will act as a constant strong_player.
what you want to do is to make a simple object, that is always_active and every frame observes that player and gives them weak_player.
state "main"
{
observe_player "player_name"
weak_player
}unless this has been changed in the latest revisions, it should work
I tried but nothing works!
Here's my code now:
object ".speedy_companion"
{
requires 0.2.0
always_active
state "main"
{
create_child ".speedy_spindash_controller"
create_child ".speedy_nolightwalk_controller"
create_child ".speedy_swim"
destroy
}
}
object ".speedy_spindash_controller"
{
requires 0.2.0
always_active
state "main"
{
hide
observe_player "speedy"
change_state "stand by"
weak_player
}
state "stand by"
{
on_player_duck "duck"
}
state "duck"
{
let "$p = 0"
on_button_pressed "fire1" "charge"
on_player_duck "duck"
change_state "stand by"
}
state "charge"
{
set_player_animation "SD_speedy" "6"
strong_player
springfy_player // so that the camera won't go down, since the player is ducking
disable_player_movement
play_sample "charge"
let "$p = min($p+2, 8)"
change_state "hold"
}
state "hold"
{
//textout menu.small 0 0 $p
set_player_animation "SD_speedy" "6"
let "$p -= 0.234 * floor(8*$p) * dt()"
// check if there's a platform underneath the player
attach_to_player 0 20
unless "obstacle_exists(0,0)" "cancel"
// create cool particles
let "$_pixelparticle_anim = 1 + random(3)"
let "$_pixelparticle_xvel = -player_direction() * (120 + random(60))"
let "$_pixelparticle_yvel = -60 - random(120)"
create_child .pixelparticle -player_direction()*7 -2
let "$_pixelparticle_anim = 1 + random(3)"
let "$_pixelparticle_xvel = -player_direction() * (120 + random(60))"
let "$_pixelparticle_yvel = -60 - random(120)"
create_child .pixelparticle -player_direction()*7 -2
let "$_pixelparticle_anim = 1 + random(3)"
let "$_pixelparticle_xvel = -player_direction() * (120 + random(60))"
let "$_pixelparticle_yvel = -60 - random(120)"
create_child .pixelparticle -player_direction()*7 -2
// check if the user wants to charge more, or if we can release the player
on_button_pressed "fire1" "charge"
on_button_down "down" "hold"
change_state "release"
}
state "cancel"
{
enable_player_movement
weak_player
change_state "stand by"
}
state "release"
{
play_sample "release"
enable_player_movement
weak_player
set_player_xspeed "(480 + 30 * floor($p)) * player_direction()"
roll_player
change_state "stand by"
}
}
object ".speedy_nolightwalk_controller" // his lighting sneakers can't shine when in the air
{
requires 0.2.0
always_active
state "main"
{
hide
observe_player "speedy"
change_state "stand by"
weak_player
}
state "stand by"
{
on_player_in_the_air "air"
}
state "air"
{
on_player_walk "walking in the air"
on_player_run "running in the air"
on_player_brake "braking in the air"
on_player_in_the_air "air"
change_state "stand by"
}
state "walking in the air"
{
on_player_spring "stand by"
on_player_jump "stand by"
on_player_gethit "stand by"
on_player_death "stand by"
set_player_animation "SD_speedy" 18
on_player_in_the_air "walking in the air"
change_state "stand by"
}
state "running in the air"
{
on_player_spring "stand by"
on_player_jump "stand by"
on_player_gethit "stand by"
on_player_death "stand by"
set_player_animation "SD_speedy" 19
on_player_in_the_air "running in the air"
change_state "stand by"
}
state "braking in the air"
{
on_player_spring "stand by"
on_player_jump "stand by"
on_player_gethit "stand by"
on_player_death "stand by"
set_player_animation "SD_speedy" 20
on_player_in_the_air "braking in the air"
change_state "stand by"
}
}
object ".speedy_swim"
{
requires 0.2.0
always_active
state "main"
{
observe_player "Speedy"
weak_player
change_state "wait"
}
state "wait"
{
change_state "up"
}
state "up"
{
change_state "ready"
}
state "ready"
{
on_button_pressed "fire6" "start"
on_player_walk "main"
on_player_run "main"
}
state "start"
{
on_player_underwater "sswim"
change_state "main"
}
state "sswim"
{
set_player_animation "SD_SPEEDY" 21
on_button_pressed "fire6" "swim"
on_player_walk "main"
on_player_run "main"
}
state "swim"
{
set_player_animation "SD_SPEEDY" 21
set_player_yspeed -90
change_state "sswim"
}
}
No matter how much I try, why is this problem being so persistent?
Offline
Also I made a video showing graphically my problem just in case you need to see more clues.
Offline
No matter how much I try, why is this problem being so persistent?
It's simple, the problem is that when your character jumps, he will become "invincible" until he falls on the ground, or against a spring.
The solution to your problem is to get the character out of the jump state by adding a "springfy_player" code before the swim animation.
Something like this:
state "sswim"
{
springfy_player
set_player_animation "SD_SPEEDY" 21
on_button_pressed "fire6" "swim"
on_player_walk "main"
on_player_run "main"
}
Creating and Editing Sprites.
Offline
SynfigMaster91 wrote:No matter how much I try, why is this problem being so persistent?
It's simple, the problem is that when your character jumps, he will become "invincible" until he falls on the ground, or against a spring.
The solution to your problem is to get the character out of the jump state by adding a "springfy_player" code before the swim animation.
Something like this:state "sswim" { springfy_player set_player_animation "SD_SPEEDY" 21 on_button_pressed "fire6" "swim" on_player_walk "main" on_player_run "main" }
Okay, now the character gets hurt when he touches the enemy but the swimming sprite stays, even touching the ground. Here's a video showing it:
https://drive.google.com/open?id=1m3cEQ … rssZzL0s7T
Here's the code:
object ".speedy_companion"
{
requires 0.2.0
always_active
state "main"
{
create_child ".speedy_spindash_controller"
create_child ".speedy_nolightwalk_controller"
create_child ".speedy_swim"
destroy
}
}
object ".speedy_spindash_controller"
{
requires 0.2.0
always_active
state "main"
{
hide
observe_player "speedy"
change_state "stand by"
weak_player
}
state "stand by"
{
on_player_duck "duck"
}
state "duck"
{
let "$p = 0"
on_button_pressed "fire1" "charge"
on_player_duck "duck"
change_state "stand by"
}
state "charge"
{
set_player_animation "SD_speedy" "6"
strong_player
springfy_player // so that the camera won't go down, since the player is ducking
disable_player_movement
play_sample "charge"
let "$p = min($p+2, 8)"
change_state "hold"
}
state "hold"
{
//textout menu.small 0 0 $p
set_player_animation "SD_speedy" "6"
let "$p -= 0.234 * floor(8*$p) * dt()"
// check if there's a platform underneath the player
attach_to_player 0 20
unless "obstacle_exists(0,0)" "cancel"
// create cool particles
let "$_pixelparticle_anim = 1 + random(3)"
let "$_pixelparticle_xvel = -player_direction() * (120 + random(60))"
let "$_pixelparticle_yvel = -60 - random(120)"
create_child .pixelparticle -player_direction()*7 -2
let "$_pixelparticle_anim = 1 + random(3)"
let "$_pixelparticle_xvel = -player_direction() * (120 + random(60))"
let "$_pixelparticle_yvel = -60 - random(120)"
create_child .pixelparticle -player_direction()*7 -2
let "$_pixelparticle_anim = 1 + random(3)"
let "$_pixelparticle_xvel = -player_direction() * (120 + random(60))"
let "$_pixelparticle_yvel = -60 - random(120)"
create_child .pixelparticle -player_direction()*7 -2
// check if the user wants to charge more, or if we can release the player
on_button_pressed "fire1" "charge"
on_button_down "down" "hold"
change_state "release"
}
state "cancel"
{
enable_player_movement
weak_player
change_state "stand by"
}
state "release"
{
play_sample "release"
enable_player_movement
weak_player
set_player_xspeed "(480 + 30 * floor($p)) * player_direction()"
roll_player
change_state "stand by"
}
}
object ".speedy_nolightwalk_controller" // his lighting sneakers can't shine when in the air
{
requires 0.2.0
always_active
state "main"
{
hide
observe_player "speedy"
change_state "stand by"
weak_player
}
state "stand by"
{
on_player_in_the_air "air"
}
state "air"
{
on_player_walk "walking in the air"
on_player_run "running in the air"
on_player_brake "braking in the air"
on_player_in_the_air "air"
change_state "stand by"
}
state "walking in the air"
{
on_player_spring "stand by"
on_player_jump "stand by"
on_player_gethit "stand by"
on_player_death "stand by"
set_player_animation "SD_speedy" 18
on_player_in_the_air "walking in the air"
change_state "stand by"
}
state "running in the air"
{
on_player_spring "stand by"
on_player_jump "stand by"
on_player_gethit "stand by"
on_player_death "stand by"
set_player_animation "SD_speedy" 19
on_player_in_the_air "running in the air"
change_state "stand by"
}
state "braking in the air"
{
on_player_spring "stand by"
on_player_jump "stand by"
on_player_gethit "stand by"
on_player_death "stand by"
set_player_animation "SD_speedy" 20
on_player_in_the_air "braking in the air"
change_state "stand by"
}
}
object ".speedy_swim"
{
requires 0.2.0
always_active
state "main"
{
observe_player "Speedy"
change_state "wait"
}
state "wait"
{
change_state "up"
}
state "up"
{
change_state "ready"
}
state "ready"
{
on_button_pressed "fire6" "start"
on_player_walk "main"
on_player_run "main"
}
state "start"
{
on_player_underwater "sswim"
change_state "main"
}
state "sswim"
{
springfy_player
set_player_animation "SD_SPEEDY" 21
on_button_pressed "fire6" "swim"
on_player_walk "main"
on_player_run "main"
}
state "swim"
{
set_player_animation "SD_SPEEDY" 21
set_player_yspeed -90
change_state "sswim"
}
}
Offline
Well? Can anyone do something about this?
Offline
In your state sswim, add a check: if the player is not underwater, quit the state.
As it is, the animation will be changed to 21 unless you quit the state.
Offline
In your state sswim, add a check: if the player is not underwater, quit the state.
As it is, the animation will be changed to 21 unless you quit the state.
Is there info about adding a check on the wiki?
Offline
How can I check if the player is not underwater? What API event should I use?
Offline
How can I check if the player is not underwater? What API event should I use?
In the old scripting API, I like to use a technique like this:
state "sswim"
{
springfy_player
set_player_animation "SD_SPEEDY" 21
on_button_pressed "fire6" "swim"
// see below
on_player_underwater "sswim"
change_state "main"
}
The state will be changed to main only if the player is not underwater.
Adapt as needed.
Offline
SynfigMaster91 wrote:How can I check if the player is not underwater? What API event should I use?
In the old scripting API, I like to use a technique like this:
state "sswim" { springfy_player set_player_animation "SD_SPEEDY" 21 on_button_pressed "fire6" "swim" // see below on_player_underwater "sswim" change_state "main" }
The state will be changed to main only if the player is not underwater.
Adapt as needed.
I tried your code but...
Offline
It seems to me this problem doesn't want to be solved and it's beggining to be annoying...
Offline
Here's one thing I noticed on your video:
when the player gets off water, his animation seems to be restored to normal. When he gets underwater again, the swimming animation is played.
I don't know what exactly is "bugged" there, as this gameplay seems fair to me. For us to understand the problem better, can you explain in clear terms what exactly do you expect for this animation? When should it be played, exactly? If he touches the ground?
// Try this
state "sswim"
{
springfy_player
set_player_animation "SD_SPEEDY" 21
on_button_pressed "fire6" "swim"
on_player_walk "main"
on_player_run "main"
on_player_underwater "sswim"
change_state "main"
}
Offline
Here's one thing I noticed on your video:
when the player gets off water, his animation seems to be restored to normal. When he gets underwater again, the swimming animation is played.
I don't know what exactly is "bugged" there, as this gameplay seems fair to me. For us to understand the problem better, can you explain in clear terms what exactly do you expect for this animation? When should it be played, exactly? If he touches the ground?
// Try this state "sswim" { springfy_player set_player_animation "SD_SPEEDY" 21 on_button_pressed "fire6" "swim" on_player_walk "main" on_player_run "main" on_player_underwater "sswim" change_state "main" }
Here's a list of things I want to get:
1) When Speedy swims and touches an enemy, he must be change to the 'hurt' sprite. The one when you get hit by an enemy when you don't attack.
2) When Speedy swims over a item box, he must not destroy it, only when he roll jumps.
3) When Speedy lands on the floor while he swims, he walks like Sonic on the underwater levels of the Sonic games.
4) When he reaches to the surface swimming, he can change to his roll jumping sprite and hit enemies.
Offline
So, basically:
1) If he gets underwater, he should play the swimming animation until: a) he gets off water b) he lands on the floor or c) gets hit
2) When playing the swimming animation, he should not be able to attack baddies nor crash item boxes
Outside the water, just use Surge's behavior.
Is that correct?
Offline