Jump to content

Photo

(FFC) Check for item, then activate side warp


  • Please log in to reply
13 replies to this topic

#1 Octorockoncrack

Octorockoncrack

    Crystal Warrior

  • Members
  • Real Name:Tyler
  • Location:walking The Path

Posted 20 March 2018 - 03:23 PM

Hello Everyone! I'll get straight to my point:

 

I'm looking for a script that will activate once Link is facing the FFC and presses A (much like the NPC scripts do). From there, the script checks if Link has an item in his inventory before warping. If Link does not have the item, activate side warp A. If Link does have the item, activate side warp B.

 

 

For some better elaboration:

 

I want to try using this for key items in my quest that will trigger cutscenes/secrets. I dont know much on scripting, but I am assuming that if the script was made as an ffc, it would be possible to use D0 or D1, etc. to check the value of the item that the game is looking for. That way, a single script could be used for all of my key items.

 

 

So an example of how it would be used:

 

Key item X is needed to open a stone door blocking a cave entrance. This stone door would have the FFC put on top of it. So Link would walk up to the stone door and press A. Then it would either take him to side warp A if he does not have Key Item X, and side warp B if he does have the item. So side warp B will go to a cutscene of the stone door opening, but side warp A will not.

 

 

Sorry if I sound redundant explaining this. I know its good to be as specific as possible  :toast:



#2 Architect Abdiel

Architect Abdiel

    Kingdom Builder

  • Members
  • Real Name:Michael
  • Location:Florida

Posted 20 March 2018 - 03:57 PM

You should be able to do all this with Moosh's NPC Dialogue Branch Add-On Script. It gives you the option to warp Link and other stuff with string control codes.

https://www.purezc.n...=scripts&id=296

#3 Octorockoncrack

Octorockoncrack

    Crystal Warrior

  • Members
  • Real Name:Tyler
  • Location:walking The Path

Posted 20 March 2018 - 05:10 PM

You should be able to do all this with Moosh's NPC Dialogue Branch Add-On Script. It gives you the option to warp Link and other stuff with string control codes.

https://www.purezc.n...=scripts&id=296

So I just had the opportunity to check that out, and I see this in the Setup Information for the script:

 

Next is the arguments for the two scripts. I'm gonna assume you know how to set up the NPCScript to call add-ons from that script's setup instructions.

At the cost of sounding dumb, I get confused when I read this. Does this mean that I need to download the first NPC script and combine it with the Dialogue Branch script? And would this also mean that at least one string needs to be displayed before warping? That wouldnt necessarily be a problem, I'm just a little clueless when it comes to setting up scripts.


Edited by Octorockoncrack, 20 March 2018 - 05:13 PM.


#4 Avaro

Avaro

    o_o

  • Members
  • Real Name:Robin
  • Location:Germany

Posted 20 March 2018 - 05:27 PM

At the cost of sounding dumb, I get confused when I read this. Does this mean that I need to download the first NPC script and combine it with the Dialogue Branch script? And would this also mean that at least one string needs to be displayed before warping? That wouldnt necessarily be a problem, I'm just a little clueless when it comes to setting up scripts.

 

Yes you'd get the NPC script first and then use the dialogue branch one. Also you probably can set the message string to 0 if you want no string.



#5 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 20 March 2018 - 06:05 PM

You might want to snag Above(), Below(), LeftOf(), RightOf() and Facing() from the updated std.zh for 2.54 for this.

#6 Octorockoncrack

Octorockoncrack

    Crystal Warrior

  • Members
  • Real Name:Tyler
  • Location:walking The Path

Posted 20 March 2018 - 09:05 PM

You might want to snag Above(), Below(), LeftOf(), RightOf() and Facing() from the updated std.zh for 2.54 for this.

See, this is the stuff that confuses me. I have next to no knowledge for adding and combining scripts. Would you be able to give me a bit more context as to what I should do?



#7 Avaro

Avaro

    o_o

  • Members
  • Real Name:Robin
  • Location:Germany

Posted 20 March 2018 - 09:20 PM

See, this is the stuff that confuses me. I have next to no knowledge for adding and combining scripts. Would you be able to give me a bit more context as to what I should do?

That was advice for those who want to write the script.



#8 Octorockoncrack

Octorockoncrack

    Crystal Warrior

  • Members
  • Real Name:Tyler
  • Location:walking The Path

Posted 20 March 2018 - 11:07 PM

That was advice for those who want to write the script.

My apologies then  :blind:

 

Okay, so Im trying to get the NPC script to work by itself before I add in the dialogue box script. I end up getting these errors when I try to compile it in my quest:

 

https://i.imgur.com/nTDR14Y.png

 

I downloaded and put ffcscript.zh and Dialoguebox.zh in my directory, then filled out the constants that were explained in the setup sections. After that, I put the NPC script into my .z file and set the constants for that script too. Am I missing something?



#9 Avaro

Avaro

    o_o

  • Members
  • Real Name:Robin
  • Location:Germany

Posted 21 March 2018 - 10:50 AM

Do you have import "ffcscript.zh" at the top of your script file? Will need to do the same with dialoguebox too.


Edited by Avataro, 21 March 2018 - 10:51 AM.


#10 Octorockoncrack

Octorockoncrack

    Crystal Warrior

  • Members
  • Real Name:Tyler
  • Location:walking The Path

Posted 21 March 2018 - 11:23 AM

Do you have import "ffcscript.zh" at the top of your script file? Will need to do the same with dialoguebox too.

It was a stupid error that made a lot more sense once I fixed it lol. I forgot to import the files into my .z file.

 

I was going to post again to see if I could get some help with my String Control Codes, but it appears that I was able to fix it. Not sure if Im out of the woods yet when it comes to scripting issues, but everything seems to be working pretty well now. 

 

Thanks so much guys! I really appreciate your help and patience with my scripting illiteracy


  • Anthus likes this

#11 Octorockoncrack

Octorockoncrack

    Crystal Warrior

  • Members
  • Real Name:Tyler
  • Location:walking The Path

Posted 21 March 2018 - 05:41 PM

Sorry for the double post, but now I am getting one last problem while trying to get my key items to work properly.

 

The last thing I need to do is make sure I can remove the NPC after the proper cutscene has played when Link has the item. So heres how things play out in my quest:

 

There is a stone door blocking a cave entrance. The NPC script is placed on top of the stone door. When Link has the corresponding item, you are warped to a cutscene showing Link hold up the item, and the stone door disappears. From there, you are warped back to the original screen with secrets activated. But since the NPC is placed over top of where the cave entrance is, the cave/stair combo for the stairs is overidden with the FFC.

 

Now i know you can remove NPCs if you have a specified item, but thats where I run into my problem. None of the Custom Item Subclasses seem to work for this, and I've just about run out of Normal Item Types to use for dummy item purposes. And I cant use one item class for these "check" items because they can be done in any order.

 

Any ideas on how I can fix this?



#12 James24

James24

    Adept

  • Banned
  • Real Name:James
  • Location:Australia

Posted 21 March 2018 - 09:24 PM

I think your initial request should be relatively simple to do without any add-ons.  There is already an NPC script that can check for facing the FFC and pressing a certain key.  Link->Item can check for items and I remember there are functions that activate side warps in std.zh.  But it sounds to me like you are new to scripting.
 
Learning to script is not something for the faint of heart and a lot of time and effort is going to have to be spent learning to script before you get your first viable scripts working.  Is it going to be worth it?  Can you make some non-scripted solution that is going to be cheap and nasty but saves you the effort of learning to script?


#13 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 22 March 2018 - 04:53 AM

I think your initial request should be relatively simple to do without any add-ons. There is already an NPC script that can check for facing the FFC and pressing a certain key. Link->Item can check for items and I remember there are functions that activate side warps in std.zh. But it sounds to me like you are new to scripting.

Learning to script is not something for the faint of heart and a lot of time and effort is going to have to be spent learning to script before you get your first viable scripts working. Is it going to be worth it? Can you make some non-scripted solution that is going to be cheap and nasty but saves you the effort of learning to script?


They aren't add-ons James, they're functions that simplify the syntax and lighten the stack load by popping off instructions and variables, increasing both efficiency and legibility.


Instead of something like this:


if ( Link->Y > this-> Y )     //Here you would check this first,  
                              //as you would otherwise waste a variable
                              //(stack space) to determine if Link is
                              //facing the ffc.
{     
     if ( Link->Dir == DIR_UP )     
     {
          //INSTRUCTIONS
     }
}

...you have this:


if ( Facing(this) ) //facing has priority here, as instructions
                    //are more likely to be direction-specific,
                    //and you need only check for facing one time
                    //then check for position, 
                    
                    //In theory, this produces fewer statement evals.
{
     if ( Below(this) )
     {
          //INSTRUCTIONS
     }
}

This clarifies the intent of the statements by using clear identifiers, rather than piling in comments.


How you prioritise the statements is also interesting here. I'd probably put priority on Facing().


By using function calls, the variables needed to determine facing direction pop off the stack. This is a critical concept with ZScript, that it is best to learn early. Learning to design scripts withing the limitations of the stack will save an unholy amount of time debugging stuff, later; and starting out with very legible code will put the user in a mode, where their code is much easier to read, and thus debug, as they develop more-and-more complex scripts.

#14 Octorockoncrack

Octorockoncrack

    Crystal Warrior

  • Members
  • Real Name:Tyler
  • Location:walking The Path

Posted 22 March 2018 - 02:53 PM

Hey guys! So I played around with this a little more and I figure out how to work around the problem that I was having! 

 

It looks like everything works as intended if I add an auto warp to my screen secret in the original room. That way, it can just warp to a copy of the room without the NPC there once the cutscene has played. Everything seems to carry over and transition to the copy screen invisibly, so Im all set. I can now do this with the other key items in my quest to finally give them actual uses. The hardest part now is building the cutscenes, which is more time-consuming than it is difficult.

 

Thanks for the help everyone! Im 99.99% sure that I've gotten everything working properly.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users