Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- float CallBacks[1024]; //0 is NULL, and the current callback index; the rest are array pointers.
- item script Pickup_Chest_Callback{
- void run(int message){
- SetScreenDBit(Game->GetCurScreen(), CHEST_REGISTER, bit, true);
- int ptr = GetCurrentCallBack();
- //Callback messages.
- int item_id = ptr[0];
- int bit = ptr[1];
- int sound = ptr[2];
- int holdtype = ptr[3];
- if ( sound > 0 ) { Game->PlaySound(sound); }
- if ( message > 0 ) { Screen->Message(sound); }
- if ( holdtype ) {
- Link->Action = LA_HOLD1LAND + holdtype - 1;
- Link->HeldItem = item_id;
- }
- ClearCallBack(ptr);
- ClearCurrentCallBack();
- }
- }
- //void SetCallBackStart(int index) {
- //}
- void ClearCallBacks() {
- int sz = SizeOfArray(CallBacks);
- for ( int q = 0; q < zs; q++ ) {
- CallBacks[q] = -1;
- }
- }
- int GetFreeCallback() {
- for ( int q = 0; q < zs; q++ ) {
- if ( CallBacks[q] == -1 ) return q;
- }
- return 0; //Null Callback ID
- }
- bool SetCurrentCallBack(){
- int cb = GetFreeCallback();
- if (cb) { CallBacks[0] = cb; return true; }
- return false;
- }
- int GetCurrentCallBack(){
- return CallBacks[0];
- }
- bool StoreCallBack(float value){
- int cb = GetFreeCallback();
- if (cb) { CallBacks[cb] = value; return true; }
- return false;
- }
- void ClearCallBack(int value){
- CallBacks[value] = -1;
- }
- bool ClearCurrentCallBack(){
- int cb = CallBacks[0];
- CallBacks[cb] = -1;
- }
- //Screen->D[reg] to use for chest open flagss.
- const int CHEST_REGISTER = 5;
- const int CHEST_ONE = 00000001b;
- const int CHEST_TWO = 00000010b;
- const int CHEST_THREE = 00000100b;
- const int CHEST_FOUR = 00001000b;
- const int CHEST_FIVE = 00010000b;
- const int CHEST_SIX = 00100000b;
- const int CHEST_SEVEN = 01000000b;
- const int CHEST_EIGHT = 10000000b;
- //Combos
- const int CMB_CHEST_SMALL = 0;
- const int CMB_CHEST_SMALL_LOCKED = 0;
- const int CMB_CHEST_SMALL_BOSSLOCKED = 0;
- //Big chests, 1x2 left combo of each
- const int CMB_CHEST_BIG = 0;
- const int CMB_CHEST_BIG_LOCKED = 0;
- const int CMB_CHEST_BIG_BOSSLOCKED = 0;
- //Big chests, 4x4 combo saize, bottom-left combo.
- const int CMB_CHEST_LARGE = 0;
- const int CMB_CHEST_LARGE_LOCKED = 0;
- const int CMB_CHEST_LARGE_BOSSLOCKED = 0;
- //const int CHEST_LAYER = 1; //Layer on which chests are placed.
- //Check for chests on these layers. 0 = No, 1= yes.
- const int CHEST_LAYER_ZERO = 1; //Check for chests on layer 0
- const int CHEST_LAYER_ONE = 1; //Check for chests on layer 1
- const int CHEST_LAYER_TWO = 1; //Check for chests on layer 2
- const int CHEST_HOLDUP_TYPE = 1; //0 = none, 1 = one hand, 2 = two hands.
- ffc script Chest{
- //void run(int contents, int enemy, int open_from_side, int e, int f, int g, int h){
- void run(int contents_enemy_1, int contents_enemy_2, int contents_enemy_3, int contents_enemy_4,
- int contents_enemy_5, int contents_enemy_6, int contents_enemy_7, int contents_enemy_8){
- int q[256];
- // [0[ Loop Q
- // [1] Loop W
- // [2] Loop E
- // [3] Temp Chest Contents for Item creation anim and hold-up
- int chest_exists[8];
- int chest_pos[8];
- int chest_type[8];
- int pickup_script_args[8]; //fed to the callback
- // [0] None
- // [1] Small, Unlocked
- // [2] Small, Locked
- // [3] Small, Bosslocked
- // [4] Large, Unlocked
- // [5] Large, Locked
- // [6] Large, Bosslocked
- int chest_contents[8]; //negative values are npcs.
- int contents[16];
- int enemy[16];
- item i; itemdata id;
- //Check which chests EXIST and flag them
- for
- //Sotore the positions --combo locations-- of each chest
- //Check which have been opened by reading the bits, and advance their combos on screen init.
- //Then ...
- //Store the contents into an array.
- for ( q[0] = 0; q[0] < 16; q[0]++ ) {
- if ( q < 8 ) {
- if ( contents[q[0]] > 0 ) { contents[q[0]] = GetHighFloat(this->InitD[q[0]]); }
- if ( contents[q[0]] < 0 ) { enemy[q[0]] = GetHighFloat(this-InitD[q[0]]); }
- }
- else {
- if ( contents[q[0]] > 0 ) { contents[q[0]] = GetHighFloat(this->InitD[q[0]-8]); }
- if ( contents[q[0]] < 0 ) { enemy[q[0]] = GetHighFloat(this-InitD[q[0]-8]); }
- }
- }
- int flags;
- //Can we use tilewidth and tileheight to set the chest sise, without making this tedious
- ///for the user?
- //! We can avoid using chest ID and read from top left to bottom right for combos on the screen.
- //! if a combo is a big chest CMB_ then we open those next to it using adjacent combo, to
- //! determine which others are part of it.
- if ( draw_over ) //Big Chest
- if ( translucent ) ///Can Open from Side
- if ( ethereal ) //
- if ( stationary ) {
- //A.Speed is a specific chest ID on the screen, at this->X and this->Y.
- //If we can;t use tile width and height, we can use x speed to set the chest size.
- while(true){
- //Check Link Proximity to Chest Combos
- //If Link is within range, and presses a button
- //If the chest is larger than 1x1, open all related combos.
- ///If the chest has an enemy, Spawn it
- //If the chest has contents, give them.
- //Make the item
- i = Screen->CreateItem item_id
- //Find a free callback ID
- //If we find one, store it
- //Set the callback value with the pointer for 'pickup_script_args'
- id = Game->LoadItemData item_id
- id->InitD =
- // We could do it this way, as a callback is safer.
- //Set the itemdata for the chest bit int he pickup script
- //This tells the pickup script which bit to set on the screen, as D1
- //Otherwise, we just make the igtem and award it.
- //As long as it does not have IP_PICKUP it should be safe.
- //Freeze Link and move the item down toward him in an animation.
- //If Collision with Link, flag the screen D
- //FLag Screen D that this chest was opened.
- //Do a holdup animation.
- if CHEST_HOLDUP_TYPE
- Link->Action = LA_HOLD1LAND + CHEST_HOLDUP_TYPE - 1;
- Link->HeldItem = q[3];
- Waitframe();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement