Jump to content

Photo

I hate diagonal movement.


  • Please log in to reply
12 replies to this topic

#1 Demonlink

Demonlink

    Lurking in the shadows...

  • Members
  • Real Name:Miguel
  • Location:Wouldn't you like to know?

Posted 10 June 2021 - 09:16 PM

s7bKF9A.png

 

So, I was making this cool puzzle for my dungeon, until I realized you could easily avoid the switches by walking diagonally. I don't want loopholes for my dungeon traps, I want the player to suffer! But mostly, for the player to play the game as intended.

 

Basically, steping on the switches turns on/off some tiles that switch between quicksand and a safe floor, They're Step->Secret (Temp). types. I tried changing them to Sensitive (Temp), but that makes the puzzle unsolveable because if Link barely comes close, they are triggered so fast that it's impossible to cross.

 

Does anyone have any ideas on to how to improve this situation? I thought of disabling diagonal movement for this room only, but is that even possible? If so, would it requiere a script? I'm on 2.55 Alpha 92.


  • Anthus likes this

#2 Mani Kanina

Mani Kanina

    Rabbits!

  • Members

Posted 10 June 2021 - 09:22 PM

I guess in this scenario, assuming you want the puzzle to remain exactly as is, would be to either:

1. Script better Step->Secret (Temp) combos. (This would be my recommended method). It shouldn't be *that* hard of a thing to script, especially if you got free FFCs on the screen.

2. Have two identical rooms and set the switches up as direct warps instead, I think that could potentially work?


  • Demonlink likes this

#3 Emily

Emily

    Scripter / Dev

  • ZC Developers

Posted 10 June 2021 - 10:06 PM

A script can toggle diagonal movement for the room, but, the above suggestions are better than that regardless.


  • Demonlink likes this

#4 Anthus

Anthus

    Lord of Liquids

  • Members
  • Location:Ohio

Posted 10 June 2021 - 10:26 PM

So this is a really, really janky solution that I'm not even sure if will work, but, what if you made a corner solid, and had the rest of the lowered peg also be a step next that goes back to the original, flagged non-solid combo? In theory, this would block you from skipping switches, and make the full tile walkable (while the pegs are down) when approached from any other side. I suppose the solid corner tiles would also need to be flagged to react to the star switch too. I dunno if this will work though, tbh.

 

unknown.png

 

Basically this, but it's a step-> next that goes to your original combo?

 

 

EDIT: I looked at the actual screen a bit more, and this wouldn't really work here as there are some lowered pegs you can still approach from the solid corner side. Oof.


  • Jared and Demonlink like this

#5 Jamian

Jamian

    ZC enthusiast

  • Members

Posted 11 June 2021 - 03:16 AM

Rescripting the collision with these combos sounds like the best idea.

 

Disabling diagonal movement for just the one room would work, but it would be weird.


  • Demonlink likes this

#6 Mitchfork

Mitchfork

    no fun. not ever.

  • Contributors
  • Real Name:Mitch
  • Location:Alabama

Posted 14 June 2021 - 11:10 AM

Since you're using 2.55, I think combodata scripts are your friend for this room.  The implementation should be fairly simple - you basically just need a "half sensitive" Step->Secrets combo.  Let's whip something up:

const int BTRIGGER_SFX = 0; //Set to the SFX ID of a sound that plays when you step on the trigger

combodata script BetterTrigger {
	void run() {
		while(true) {
			if ((BetterTriggerDetect(this->X,this->Y) and (Hero->Z == 0)) {
				Screen->TriggerSecrets();
                                Audio->PlaySound(BTRIGGER_SFX);
			}
			Waitframe();
		}
	}
}

bool BetterTriggerDetect(int comboX, int comboY) {
	int heroX = Round(Hero->X);
	int heroY = Round(Hero->Y);
	if (
		((heroX - comboX) < 8) and
		((comboX - heroX) <= 8) and 
		((heroY - comboY) < 8) and
		((comboY - heroY) <= 8)
	){
		return true;
	}

	return false;
}

EDIT: Fixed sound effect oversight (thanks Emily) and added check for Z as well.

 

This script:

  • Rounds the player's position when it checks so that it's compatible with New Hero Movement.
  • Checks the player's position on a grid-based system so that only one of these combos may be triggered per frame.
  • Has a configurable sound effect that you set globally when it triggers.

 

This is not tested and may need some tweaks, particularly if the quicksand collision is more or less sensitive than these.  But it should compile and it's simple enough that I don't predict major issues, except that the current latest 2.55 alpha has several combodata script bugs that may affect this script.  I have worked with the dev team to try to identify and fix these and they should be completely fixed in the next released build.   Let me know if there are any issues and I should be able to tell if this is an engine bug or a script bug.


Edited by Mitchfork, 14 June 2021 - 01:49 PM.

  • Demonlink likes this

#7 Emily

Emily

    Scripter / Dev

  • ZC Developers

Posted 14 June 2021 - 11:49 AM

^ You could improve that by making the '8' a variable instead, as a parameter passed into the function, which could be an InitD on the combo script.

Also, you forgot to play the SFX, and some of the logic could be simplified.

const int BTRIGGER_SFX = 0; //Set to the SFX ID of a sound that plays when you step on the trigger

combodata script BetterTrigger
{
	void run(int sens)
	{
		unless(sens) sens = 8;
                else sens = Abs(Round(sens));
		while(true)
		{
			if ((Abs(this->X - Round(Hero->X)) <= sens) and
			    (Abs(this->Y - Round(Hero->Y)) <= sens))
			{
				Screen->TriggerSecrets();
				if(BTRIGGER_SFX>0) Audio->PlaySound(BTRIGGER_SFX);
			}
			Waitframe();
		}
	}
}

  • Mitchfork and Demonlink like this

#8 Mitchfork

Mitchfork

    no fun. not ever.

  • Contributors
  • Real Name:Mitch
  • Location:Alabama

Posted 14 June 2021 - 12:52 PM

The problem I had when doing this in my head is that if you set "sens" to 8 then you can end up triggering two different combos on the same frame, which would break the puzzle behavior.  That's why I think you need to use four conditionals instead of two with Abs().

 

The alternate thing to do would be to combine this script with a a broader scope variable / function so that it can disable triggering additional combos after the first combo triggers on the frame, which gets more troublesome of course.

 

Good note on the Audio thing though, totally missed that.

 

EDIT: Also, damn, forgot to add a check for Hero->Z == 0, so added that and the audio fix to the original posted script.


Edited by Mitchfork, 14 June 2021 - 12:57 PM.


#9 Demonlink

Demonlink

    Lurking in the shadows...

  • Members
  • Real Name:Miguel
  • Location:Wouldn't you like to know?

Posted 14 June 2021 - 01:08 PM

Thanks for everyone's suggestions! The help is much appreciated! :D

 

I tried Mitch's and Emily's scripts, and it doesn't seem to have any behavior at all... I've also tried to set the sensitivity as low as 4 and as high as 16, and again, I don't see any effect at all. Of course, I'm not that familiar with 2.55's new features, but what I did was compile the script, and attach it to the "Step->Trigger (Temporary)" combo. Here's a quick demonstration:

 

nbdb02h.png

Whatever value the sensitivity is, I see no difference at all.

 

Maybe it's an engine bug like Mitch mentioned? 



#10 Mitchfork

Mitchfork

    no fun. not ever.

  • Contributors
  • Real Name:Mitch
  • Location:Alabama

Posted 14 June 2021 - 01:13 PM

Attach it to a (None) combo, first off - this script handles all of the triggering so you don't want any conflicts.
 
One of the bugs with combodata scripts is that this->Y can return bad values.... maybe try this?  I changed how the combo gets its own Y position.
 
2.55 a92 fix:

Spoiler

 
And one for Emily's version too:
 
Spoiler

Edited by Mitchfork, 14 June 2021 - 01:49 PM.


#11 Demonlink

Demonlink

    Lurking in the shadows...

  • Members
  • Real Name:Miguel
  • Location:Wouldn't you like to know?

Posted 14 June 2021 - 01:23 PM

Attach it to a (None) combo, first off - this script handles all of the triggering so you don't want any conflicts.
 
One of the bugs with combodata scripts is that this->Y can return bad values.... maybe try this?  I changed how the combo gets its own Y position.
 
2.55 a92 fix:

Spoiler

 
And one for Emily's version too:
 
Spoiler

 

Thanks for the quick reply! I tried out the new version, set the combo type to None, and now it doesn't do anything at all.  :confused: Btw, you left out a right parenthesis on this line:

if ((BetterTriggerDetect(this->X,fixedY) and (Hero->Z == 0)) {

What could be wrong? D:



#12 Mitchfork

Mitchfork

    no fun. not ever.

  • Contributors
  • Real Name:Mitch
  • Location:Alabama

Posted 14 June 2021 - 01:50 PM

I just loaded mine up for a quick test and it's working for me - after I fixed a small typo on my collision detection.

 

Here's a test quest file with the entire script in the buffer.  I added some Trace() statements for debugging but didn't end up needing them.  Let me know if this works for you and helps you see what's going on.

 

https://discordapp.c...069749989113866


  • Demonlink likes this

#13 Demonlink

Demonlink

    Lurking in the shadows...

  • Members
  • Real Name:Miguel
  • Location:Wouldn't you like to know?

Posted 14 June 2021 - 01:56 PM

I just loaded mine up for a quick test and it's working for me - after I fixed a small typo on my collision detection.

 

Here's a test quest file with the entire script in the buffer.  I added some Trace() statements for debugging but didn't end up needing them.  Let me know if this works for you and helps you see what's going on.

 

https://discordapp.c...069749989113866

Can you send that again Mitch please? Discord says they're no text channels there. You can find me in Discord as Demonlink #8363 btw.


Edited by Demonlink, 14 June 2021 - 01:57 PM.



1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users