Jump to content

Photo

Boss Keys In ZScript?


  • Please log in to reply
9 replies to this topic

#1 AdmiralJaden

AdmiralJaden

    Experienced Forumer

  • Members

Posted 20 March 2016 - 10:36 PM

Ok, so I decided to start up with zscript, and for my first script I decided I wanted to give link the boss key for a specific level, since I need to do that for my quest (in my case, level 0, which is my overworld), but I can't seem to find anything on what the index value and/or array command to do that, would be.

 

I've been looking through some starting tutorials, and have seen:

Game->LKeys[LevelNumber] += Number of Keys To Give;

But that doesn't seem to be for the boss key (since there's only one, and would make no sense to give the player multiple boss keys).

 

I also looked at some documentation included with ZC, but the closest thing I can find is "LItem", which stores the various values for each level's compass, map, and boss key. I thought that I might be able to use that, like with LKeys, but it doesn't say anything about the boss key's index value, so does that mean it goes by the item index itself?

 

So my question is, what's the command to give link the boss key for a specific level?



#2 Lejes

Lejes

    Seeker of Runes

  • Members
  • Location:Flying High Above Monsteropolis

Posted 20 March 2016 - 10:57 PM

Game->LItems[LevelNumber] |= LI_BOSSKEY;
You got unlucky and picked something a little obtuse for your first foray into ZSscript. All the level items except level specific keys are stored as flags within one number, and they're accessed with bitwise operations. std.zh has a function that simplifies it for you, though.

SetLevelItem(int level, int itm, bool state)
It's a separate header, not one of the default ZScript functions, so you have to import it first, like so:

import "std.zh"

  • AdmiralJaden likes this

#3 AdmiralJaden

AdmiralJaden

    Experienced Forumer

  • Members

Posted 20 March 2016 - 11:12 PM

Game->LItems[LevelNumber] |= LI_BOSSKEY;
You got unlucky and picked something a little obtuse for your first foray into ZSscript. All the level items except level specific keys are stored as flags within one number, and they're accessed with bitwise operations. std.zh has a function that simplifies it for you, though.

SetLevelItem(int level, int itm, bool state)
It's a separate header, not one of the default ZScript functions, so you have to import it first, like so:

import "std.zh"

Lol leave it to me to pick something odd for my first go at it lol. I'll type up my first draft and paste it here in the topic (just to make sure I'm doing it right). The concept I'm doing is giving link the boss key for level 0 when he gets his 12th heart. I'm figuring on using an if case to check maxhp, and if it's >= 12, then give the player said key. If there's a better way to do it though, I'm open to advice. :)



#4 AdmiralJaden

AdmiralJaden

    Experienced Forumer

  • Members

Posted 20 March 2016 - 11:35 PM

Ok, so I set an extremely rough draft. Let me know if I'm doing this wrong, or if I forgot something lol

This would go into the Heart Container's Pickup Script Box. I decided that would be easiest, since I already have globals running in my script file (imported scripts for the quest, not made by me).

I drew some ideas from a topic surrounding a similar type of script (give item at heart container) that didn't seem to have a resolution, but I'm not sure how close I got the concept.

 

EDIT: I forgot to specify ReqHearts as an integer (facepalm, fixed)

EDIT 2: Error 1: Unexpected float on int. (no idea on that one, there shouldn't be a float in that statement, as far as I understand it, since they're all solid numbers) (fixed as well, took out 'int' on each section of that line)

 

 

In any case, I definitely need to revise this, since it's technically two different actions that calls for arguments for no reason.

 

EDIT 3: (Doing a lot of these) I changed the arguments for D0 to specify the number of heart containers required (I think, if I'm understanding it right), and can compile it fine, but Allegro is saying:

"Invalid pointer (0) passed to array (don't change the values of your array pointers)

Invalid pointer ( 8 ) passed to array (don't change the values of your array pointers)" (repeats). So, I'm stuck lol.
//Give Link Boss Key On 12th Heart Container (D0 = Required Heart Containers)

//import "std.zh" (I already have this imported in my list of scripts)

item script LevelZeroBKey{
	void run(int ReqHearts){
		if(Link->MaxHP >= 16 * ReqHearts){
			Game->LItems[0] |= LI_BOSSKEY;
		}
	}
}

Edited by AdmiralJaden, 21 March 2016 - 12:05 AM.


#5 Lejes

Lejes

    Seeker of Runes

  • Members
  • Location:Flying High Above Monsteropolis

Posted 21 March 2016 - 12:00 AM

That script should do what you need it to. Both lines in the conditional do the same thing, though.
  • AdmiralJaden likes this

#6 AdmiralJaden

AdmiralJaden

    Experienced Forumer

  • Members

Posted 21 March 2016 - 12:08 AM

That script should do what you need it to. Both lines in the conditional do the same thing, though.

Oops. Good to know, will change that.


Doesn't give the boss key for level 0, edit 3 errors mentioned in previous post still occur.

"Invalid pointer (0) passed to array (don't change the values of your array pointers)

Invalid pointer ( 8 ) passed to array (don't change the values of your array pointers)" (repeats)

 

Not sure where to go from here with it. Any suggestions?


Edited by AdmiralJaden, 21 March 2016 - 12:20 AM.


#7 Lejes

Lejes

    Seeker of Runes

  • Members
  • Location:Flying High Above Monsteropolis

Posted 21 March 2016 - 12:40 AM

I'm guessing it's an error in one of your other scripts. I copied the script exactly into a test quest, and it gives the boss key for level 0 and logs no errors. Did you remember to attach the item script to the heart container's Pickup Script slot?

#8 AdmiralJaden

AdmiralJaden

    Experienced Forumer

  • Members

Posted 21 March 2016 - 01:03 AM

I'm guessing it's an error in one of your other scripts. I copied the script exactly into a test quest, and it gives the boss key for level 0 and logs no errors. Did you remember to attach the item script to the heart container's Pickup Script slot?

Yep. It's possible it may be another script, I'm using a few of them:
FFC Ledge Script (to jump off ledges)

FFC Hole & Lava Script (HoleLava)

My Global runs a script that lights a room when it detects a lit torch combo (and it also uses ghost for a custom boss)

FFC NPC Dialog Script (real_npcV2)

FFC Armos Knights (the custom boss I mentioned)

FFC Mace Enemy (gives a ball and chain to an enemy on screen)

FFC Enemy Music

The aforementioned Item Message Script (usually goes in pickup slot)

FFC Signpost Script

 

That's all the ones I use. (a lot though lol)

 

If you would like, I could copy/paste the whole file into a spoiler tag to see if you can find the conflict.


EDIT: Wait, nevermind, I got it lol. (facepalm number two)

 

I forgot that 12 hearts is the minimum, so if I wanted to get it on the 12th one, I had to put down 11 in the D0 (not sure why it's doing that instead of after 12 as well, but I got it to work).


Edited by AdmiralJaden, 21 March 2016 - 01:04 AM.


#9 Lejes

Lejes

    Seeker of Runes

  • Members
  • Location:Flying High Above Monsteropolis

Posted 21 March 2016 - 01:10 AM

Must not be updating Link's life total until after the item script has run. Good to hear you got it to work, though.
  • AdmiralJaden likes this

#10 AdmiralJaden

AdmiralJaden

    Experienced Forumer

  • Members

Posted 21 March 2016 - 01:19 AM

I think I'm going to submit it to the database, since I got it to work (and I'll add a note to the script about the update and numbers, once I get it cleaned up a little (not much to clean up, either way)).

 

Thanks for the help :)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users