Jump to content

Photo

Better than a lens


  • Please log in to reply
26 replies to this topic

#1 jsm116

jsm116

    Script kludger

  • Members
  • Location:The 301

Posted 20 September 2018 - 04:12 PM

Trying to think through the best way to do this. What I'm looking for is a passive equipment item that when you have it a combo is displayed over any combos that have certain flags. I can make it work with a very very simple ffc script:

ffc script Glow
{
	void run()
	{
		if(Link->Item[155])
		{
			this->Data = GLOW_COMBO;
			this->CSet = GLOW_CSET;
		}
	}
}

And then just attaching this script to an FFC at the correct location, but that method has two problems: 1) it will a pain to account for triggered secrets and 2) it's going to be a pain to find EVERY secret trigger in the quest and slap the same FFC over it.

 

The psuedocode I'm looking for would be in the global (I think):

Screen Loads
If Link has the right item
  Scan each combo on the screen
  If combo flag = 1 OR 2 OR 6
    Create FFC at that combo's location with Data = GLOW_COMBO
  If a secret is triggered
    Remove FFC over that combo

I don't know if what I'm describing is possible without scanning every combo every frame (which would bog things a bit, I'd think).


Edited by jsm116, 20 September 2018 - 04:13 PM.


#2 Saffith

Saffith

    IPv7 user

  • ZC Developers

Posted 20 September 2018 - 04:25 PM

Nah, going over each combo every frame is fine. That's exactly what I'd do. Although I'd probably just have the global script draw the tile directly rather than set up an FFC. Doesn't use up FFC slots, and you don't need to clean them up afterward. Lets you draw over higher layers, too.

If you do want to use FFCs, I'd suggest you make the FFC script watch for the secret to be triggered and clean itself up rather than making the global script do it. Assuming you're not adding new FFCs as secrets are triggered, you could also limit your combo scan to once per screen.

#3 Emily

Emily

    Scripter / Dev

  • ZC Developers

Posted 20 September 2018 - 04:36 PM

I would certainly scan over every combo and use DrawTile/Fast tile/DrawCombo/Fast combo (Don't know if any particular one is "better") to draw the glow over it. Using opacity "OP_TRANS" should make it translucent.

#4 jsm116

jsm116

    Script kludger

  • Members
  • Location:The 301

Posted 20 September 2018 - 05:29 PM

Thanks for the quick replies. This is what I put in my global:

if(Link->Item[155])
{
	for(int i = 0; i < 192; i++)
	{
		if(Screen->ComboF[i] == 3)
		{
			Screen->FastCombo(7, ComboX(i), ComboY(i), GLOW_COMBO, GLOW_CSET, OP_OPAQUE);
		}
	}
}

It functions perfectly well, but I when I check the uninhibited frame rate it drops from around 890 to 650 as soon as Link picks up the relevant item, which is a pretty significant performance hit (the game holds at 60 FPS when I limit framerate). I'm concerned about performance for players who don't have as ridiculously overpowered of a computer as I have, since this was a problem in my first quest.



#5 Emily

Emily

    Scripter / Dev

  • ZC Developers

Posted 20 September 2018 - 06:02 PM

I never get over 300fps XD It should be fine, but you might want to make it toggleable (i.e. give the player a usable item, and using it toggles this effect)

#6 jsm116

jsm116

    Script kludger

  • Members
  • Location:The 301

Posted 20 September 2018 - 06:35 PM

This is for very late game and there's a penalty for having it equipped, but it's not toggleable (part of the quest design). It can be equipped or unequipped at specific points, but not toggled during regular gameplay.

 

Yeah, for you if you're maxing out at 300 and take a 25% hit, you're still able to run at 225. With ZC capping the framerate at 60 you won't notice a difference. But for players who are maxing at 60 (or less) and then there's a 25% framerate hit, I don't want them to be 90% through with the quest and suddenly have the game be unplayable.


Edited by jsm116, 20 September 2018 - 06:38 PM.


#7 Russ

Russ

    Caelan, the Encouraging

  • Administrators
  • Location:Washington

Posted 20 September 2018 - 06:54 PM

The easiest way around that would be to only scan once per screen. That might look something like this (assuming this is a global script; it could also be done as an FFC that's launched every screen):

- There is a global array size 176 (or realistically smaller; it'd only need to be this large if you had a screen with a secret flag on literally every combo), initialized to all -1s.
- Global variables keep track of the current screen you're on.
- When the screen changes (that is, when current screen no longer equals stored screen), first, clear the global array (set everything to -1). Then, scan through the screen, assigning any combo's position with a secret flag to the next available slot in the array (for instance, if a screen has three combos with secrets, position 10, 72, and 111, then Array[0]=10, Array[1]=72,Array[2]=111).
- On every frame now that secrets aren't triggered, have a for loop go through your array. It draws GLOW_COMBO with Screen->FastCombo at every position. If it hits -1, the loop breaks.

This way, you're not looping through every combo on screen every frame, just once on screen init. It's, I believe, the most efficient way of doing it, short of placing an FFC over every combo at screen init, which could cause you to pretty quickly run out of FFCs, so it's hardly recommended.

#8 Saffith

Saffith

    IPv7 user

  • ZC Developers

Posted 20 September 2018 - 06:56 PM

	for(int i = 0; i < 192; i++)

That should be 176, not 192. Giving it invalid values could slow it down significantly, especially if error logging is enabled.

Anyway, I can't give you solid numbers or anything, but my experience has been that changes in uncapped framerate don't tell you much about regular gameplay. It doesn't take much to make a big dent in uncapped framerate, but capped is much harder to touch.

#9 jsm116

jsm116

    Script kludger

  • Members
  • Location:The 301

Posted 20 September 2018 - 07:01 PM

@Saffith d'oh! I had 176 in my head at first, then I thought I should check my math and did 16*12 instead of 16*11. Tried it with 176 and the uncapped performance hit is down to around 10% which, if as you say isn't indicative of potential performance issues capped, shouldn't be too bad.

 

I may also move it to a toggleable item and have the equippable be something else entirely.

 

Thanks everyone!



#10 jsm116

jsm116

    Script kludger

  • Members
  • Location:The 301

Posted 20 September 2018 - 07:34 PM

I realized it would be somewhat game breaking to have it be equippable and always showing secrets, even with a penalty so I made it into an item that costs 10MP/sec and overlays only when you hold the button down.

 

Thanks again to everyone!



#11 jsm116

jsm116

    Script kludger

  • Members
  • Location:The 301

Posted 20 September 2018 - 09:55 PM

I worked up the code to be more universally applicable and submitted it to the database. https://www.purezc.n...=scripts&id=317


Edited by jsm116, 20 September 2018 - 09:59 PM.


#12 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 21 September 2018 - 05:12 AM

Thanks for the quick replies. This is what I put in my global:

if(Link->Item[155])
{
	for(int i = 0; i < 192; i++)
	{
		if(Screen->ComboF[i] == 3)
		{
			Screen->FastCombo(7, ComboX(i), ComboY(i), GLOW_COMBO, GLOW_CSET, OP_OPAQUE);
		}
	}
}

It functions perfectly well, but I when I check the uninhibited frame rate it drops from around 890 to 650 as soon as Link picks up the relevant item, which is a pretty significant performance hit (the game holds at 60 FPS when I limit framerate). I'm concerned about performance for players who don't have as ridiculously overpowered of a computer as I have, since this was a problem in my first quest.

 

 

Do yourself a huge favour, and go into Quest->Rules->Oher->2.

 

Enable:

Log Script Errors to Allegro.log

 

..and...

 

in zc.cfg/ag.cfg, (in the [zeldada] header), add:

debug_console = 1

 

This will give you the debugging console (there's a menu option for this in 2.53.0 and above), which acts as a live error reporting mechanism. It would have indicated this error immediately.

 

It'll also alert you to other errors in your scripts that you might have overlooked.  

 

There might be a constant for the max combo positions, but if not, that my oversight. 

 

It's probably also a good idea to shift out of using hardcoded literals for your combo flags and item IDs here, but that's another discussion entirely. 



#13 Rocksfan13

Rocksfan13

    Looks best in Blue

  • Members
  • Real Name:Doug
  • Location:Earth

Posted 21 September 2018 - 07:27 AM

I was tinkering with an idea similar to this except in reverse.

 

Collecting a specific item removes combos instead of adding them.

Would it be just a simple script tweak to do that with this one?

 

I'm looking to make a forest that is UN-navgitable unless you have the correct "Compass"



#14 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 21 September 2018 - 04:50 PM

I was tinkering with an idea similar to this except in reverse.

 

Collecting a specific item removes combos instead of adding them.

Would it be just a simple script tweak to do that with this one?

 

I'm looking to make a forest that is UN-navgitable unless you have the correct "Compass"

 

You can use layers, then hide layers with the lens. Removing or adding combos in any case, is pretty simple. I typically use layer 2 for that sort of effect. You can also do funny things, such as making moving blocks appear. 

 

I personally like to use the lens to show past events, as a temporal looking glass. 



#15 jsm116

jsm116

    Script kludger

  • Members
  • Location:The 301

Posted 21 September 2018 - 06:33 PM

@Rocksfan13, I'm not sure what you're looking to do. Is the forest just a very difficult maze? Are there trees that Link can walk through? Are there solid trees that cannot be burned but need to be triggered another way?




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users