SUCCESSOR
03-23-2015, 08:50 PM
https://dl.dropboxusercontent.com/u/94061979/ZC/scripts/items.zh
Updated link: https://1drv.ms/u/s!Anx-XGRXU_d2gsxpd1bZWFoFLq6x_Q
Update 3/26/14
-some function name fixes
-added GetActiveEquipmentOfFamily()
-added demo script EquipmentSlotX
A header for managing and using Equipment as well as other item related functions.
This is a header I have been working on for a while. It started out as just some functions I made for my quest but when interest in those functions grew(and the quest died) I decided to make it into a header. It is still a WIP. Also even though I am pretty sure there is no items.zh already the name could change if needed.
The biggest part of this header is the ability to use Equipment on Inputs other than A and B. I wanted to make that very simple to do. I really want this to get plenty of testing so if you try it out please post some feedback. I am also sorry for it's state. Some organization, commenting, refining, and possibly renaming of some functions are still in order. I am also working on some example scripts to help people who are not scripters get some use out of this.
This script allows you to use
All Extra inputs including L & R have been hardcoded to use an item if acquired
import "items.zh"
import "std.zh"
global script UseEquipmentOnExInput{
void run(){
while(true){
//UseEquipmentOnExInput(Ex1, Ex2, Ex3, Ex4, L, R);
UseEquipmentOnExInput(I_CANDLE2, I_BRANG1, I_WAND, I_HOOKSHOT1, I_ARROW1, I_BOMB);
Waitframe();
}
}
}
Pressing Ex1 will use the Roc's Feather making Link Jump
import "items.zh"
import "std.zh"
global script UseEquipment{
void run(){
while(true){
ResetEquipment();
UseEquipmentOnInput(I_ROCSFEATHER, EQP_INPUT_EX1);
Waitframe();
}
}
}
Script that creates an Ex1 Equipment slot that functions like A and B
This one is a little more involve. You will need to make a new equipment slot
on you subscreen and then figure out the coordinates for Zscript and put it in the constants.
To select equipment for Ex1 press L and R. Demo file (https://dl.dropboxusercontent.com/u/94061979/ZC/scripts/EquipmentX.qst)
import "items.zh"
import "std.zh"
const int XSLOT_X = 100;
const int XSLOT_Y = -24;
//Equipment Slot Ex1
int EquipmentX[4];
const int EX1_ID = 0;
const int EX1_OLDID = 1;
const int EX1_TILE = 2;
const int EX1_CSET = 3;
global script EquipmentSlotX{
void run(){
while(true){
ResetEquipment();
EquipmentX();
Waitframe();
}
}
bool EquipmentXIsValid(){
return (EquipmentX[EX1_ID] > 0 && EquipmentX[EX1_ID] < 256);
}
void ShiftEquipmentX(int dir){
if(EquipmentXIsValid()){
int storeB = EquipmentB(); //save EquipmentB value
SwapEquipmentB(EquipmentX[EX1_ID]); //Change EquipmentB to EquipmentX[EX1_ID]
Link->SelectBWeapon(dir); //Adjust EquipmentB as directed
if(EquipmentB() == storeB)Link->SelectBWeapon(dir); //make sure we don't set X to B
EquipmentX[EX1_ID] = EquipmentB(); //set X
SwapEquipmentB(storeB); //reset B
}
}
void UpdateEqupimentX(){
//Makes sure the value of EquipmentX is in inventory or another item of the same family is in inventory
if(EquipmentXIsValid()){
int get = GetActiveEquipment(EquipmentX[EX1_ID]); //Confirm EquipmentX or Equipment in the same family is in inventory
if(get == -1) get = GetActiveEquipmentOfFamily(EquipmentX[EX1_ID]); //Link does not have that Equipment try Equipment of Family
if(get == -1) EquipmentX[EX1_ID] = 0; //Link does not have that Equipment
else if(get != EquipmentX[EX1_ID]) EquipmentX[EX1_ID] = get; //Equipment found set it to X
}
//If EquipmentX has no value
else if(CountActiveEquipment() > 2) {
EquipmentX[EX1_ID] = EquipmentB();
}
//change EquipmentX if it it already on A or B and we are not using EquipmentX
if( (EquipmentX[EX1_ID] == EquipmentB() || EquipmentX[EX1_ID] == EquipmentA()) && !Link->Misc[EQP_LINK_MISC]){
ShiftEquipmentX(DIR_RIGHT);
}
//if EquipmentX has changed update draw variables
if(EquipmentX[EX1_ID] != EquipmentX[EX1_OLDID]){
GetItemTileAndCSet(EquipmentX[EX1_ID]);
EquipmentX[EX1_OLDID] = EquipmentX[EX1_ID];
}
}
//get tile and cset of our equipment to draw
void GetItemTileAndCSet(int it){
item get = Screen->CreateItem(it);
EquipmentX[EX1_CSET] = get->CSet;
EquipmentX[EX1_TILE] = get->Tile;
Remove(get);
}
void EquipmentX(){
//makes sure we have a good equipment ID and it's not a duplicate
UpdateEqupimentX();
//Press L or R to change EquipmentX
if(Link->PressL && CanUseEquipment()) ShiftEquipmentX(DIR_LEFT);
else if(Link->PressR && CanUseEquipment()) ShiftEquipmentX(DIR_RIGHT);
if(EquipmentXIsValid()){
//draw item tile to subscreen
Screen->FastTile(7, XSLOT_X, XSLOT_Y, EquipmentX[EX1_TILE], EquipmentX[EX1_CSET], 128);
//Use our equipment with with the right input
UseEquipmentOnInput(EquipmentX[EX1_ID], EQP_INPUT_EX1);
}
}
}
Updated link: https://1drv.ms/u/s!Anx-XGRXU_d2gsxpd1bZWFoFLq6x_Q
Update 3/26/14
-some function name fixes
-added GetActiveEquipmentOfFamily()
-added demo script EquipmentSlotX
A header for managing and using Equipment as well as other item related functions.
This is a header I have been working on for a while. It started out as just some functions I made for my quest but when interest in those functions grew(and the quest died) I decided to make it into a header. It is still a WIP. Also even though I am pretty sure there is no items.zh already the name could change if needed.
The biggest part of this header is the ability to use Equipment on Inputs other than A and B. I wanted to make that very simple to do. I really want this to get plenty of testing so if you try it out please post some feedback. I am also sorry for it's state. Some organization, commenting, refining, and possibly renaming of some functions are still in order. I am also working on some example scripts to help people who are not scripters get some use out of this.
This script allows you to use
All Extra inputs including L & R have been hardcoded to use an item if acquired
import "items.zh"
import "std.zh"
global script UseEquipmentOnExInput{
void run(){
while(true){
//UseEquipmentOnExInput(Ex1, Ex2, Ex3, Ex4, L, R);
UseEquipmentOnExInput(I_CANDLE2, I_BRANG1, I_WAND, I_HOOKSHOT1, I_ARROW1, I_BOMB);
Waitframe();
}
}
}
Pressing Ex1 will use the Roc's Feather making Link Jump
import "items.zh"
import "std.zh"
global script UseEquipment{
void run(){
while(true){
ResetEquipment();
UseEquipmentOnInput(I_ROCSFEATHER, EQP_INPUT_EX1);
Waitframe();
}
}
}
Script that creates an Ex1 Equipment slot that functions like A and B
This one is a little more involve. You will need to make a new equipment slot
on you subscreen and then figure out the coordinates for Zscript and put it in the constants.
To select equipment for Ex1 press L and R. Demo file (https://dl.dropboxusercontent.com/u/94061979/ZC/scripts/EquipmentX.qst)
import "items.zh"
import "std.zh"
const int XSLOT_X = 100;
const int XSLOT_Y = -24;
//Equipment Slot Ex1
int EquipmentX[4];
const int EX1_ID = 0;
const int EX1_OLDID = 1;
const int EX1_TILE = 2;
const int EX1_CSET = 3;
global script EquipmentSlotX{
void run(){
while(true){
ResetEquipment();
EquipmentX();
Waitframe();
}
}
bool EquipmentXIsValid(){
return (EquipmentX[EX1_ID] > 0 && EquipmentX[EX1_ID] < 256);
}
void ShiftEquipmentX(int dir){
if(EquipmentXIsValid()){
int storeB = EquipmentB(); //save EquipmentB value
SwapEquipmentB(EquipmentX[EX1_ID]); //Change EquipmentB to EquipmentX[EX1_ID]
Link->SelectBWeapon(dir); //Adjust EquipmentB as directed
if(EquipmentB() == storeB)Link->SelectBWeapon(dir); //make sure we don't set X to B
EquipmentX[EX1_ID] = EquipmentB(); //set X
SwapEquipmentB(storeB); //reset B
}
}
void UpdateEqupimentX(){
//Makes sure the value of EquipmentX is in inventory or another item of the same family is in inventory
if(EquipmentXIsValid()){
int get = GetActiveEquipment(EquipmentX[EX1_ID]); //Confirm EquipmentX or Equipment in the same family is in inventory
if(get == -1) get = GetActiveEquipmentOfFamily(EquipmentX[EX1_ID]); //Link does not have that Equipment try Equipment of Family
if(get == -1) EquipmentX[EX1_ID] = 0; //Link does not have that Equipment
else if(get != EquipmentX[EX1_ID]) EquipmentX[EX1_ID] = get; //Equipment found set it to X
}
//If EquipmentX has no value
else if(CountActiveEquipment() > 2) {
EquipmentX[EX1_ID] = EquipmentB();
}
//change EquipmentX if it it already on A or B and we are not using EquipmentX
if( (EquipmentX[EX1_ID] == EquipmentB() || EquipmentX[EX1_ID] == EquipmentA()) && !Link->Misc[EQP_LINK_MISC]){
ShiftEquipmentX(DIR_RIGHT);
}
//if EquipmentX has changed update draw variables
if(EquipmentX[EX1_ID] != EquipmentX[EX1_OLDID]){
GetItemTileAndCSet(EquipmentX[EX1_ID]);
EquipmentX[EX1_OLDID] = EquipmentX[EX1_ID];
}
}
//get tile and cset of our equipment to draw
void GetItemTileAndCSet(int it){
item get = Screen->CreateItem(it);
EquipmentX[EX1_CSET] = get->CSet;
EquipmentX[EX1_TILE] = get->Tile;
Remove(get);
}
void EquipmentX(){
//makes sure we have a good equipment ID and it's not a duplicate
UpdateEqupimentX();
//Press L or R to change EquipmentX
if(Link->PressL && CanUseEquipment()) ShiftEquipmentX(DIR_LEFT);
else if(Link->PressR && CanUseEquipment()) ShiftEquipmentX(DIR_RIGHT);
if(EquipmentXIsValid()){
//draw item tile to subscreen
Screen->FastTile(7, XSLOT_X, XSLOT_Y, EquipmentX[EX1_TILE], EquipmentX[EX1_CSET], 128);
//Use our equipment with with the right input
UseEquipmentOnInput(EquipmentX[EX1_ID], EQP_INPUT_EX1);
}
}
}