Jump to content

Photo

ALTTP Torches Lighting Room.


  • Please log in to reply
42 replies to this topic

#31 AdmiralJaden

AdmiralJaden

    Experienced Forumer

  • Members

Posted 07 March 2016 - 07:52 PM

New save slot - check
Assign proper global active script - check

Reverse the order of check, then recompile, then new save slot - check

 

Result: Same (bummer)

 

I'm not sure why it's doing that either lol it's very odd.



#32 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 07 March 2016 - 10:11 PM

New save slot - check
Assign proper global active script - check

Reverse the order of check, then recompile, then new save slot - check

 

Result: Same (bummer)

 

I'm not sure why it's doing that either lol it's very odd.

 

Does it work on screens that do not have the ghosted enemy on them?

 

I rolled the script back to the older version,a nd added in the ghost things:

 

Spoiler

 

I'd need the quest file to do any debugging if that doesn't work.



#33 AdmiralJaden

AdmiralJaden

    Experienced Forumer

  • Members

Posted 07 March 2016 - 10:22 PM

Same result and nope. The only place where I have the torches is in a cave, so far. Incidentally the same cave the player gets the lantern. The ghosted enemy is the boss for the first dungeon, so it doesn't appear anywhere but there.

 

Where should I upload the quest for you? I'll defer to your specifications for that part.



#34 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 07 March 2016 - 10:43 PM

Same result and nope. The only place where I have the torches is in a cave, so far. Incidentally the same cave the player gets the lantern. The ghosted enemy is the boss for the first dungeon, so it doesn't appear anywhere but there.

 

Where should I upload the quest for you? I'll defer to your specifications for that part.

 

If you use Skype, you may send it to me directly. My username there is identical to here.

 

Otherwise, you could open a quest project here, and upload the quest file as a 'demo'. You should be able to make it a private project, and add me to the project as an advisor or something, so that I can grab the file.

 

P.S. It would be useful to have your allegro.log file as well, so you can upload that to one of the text file sharing sites, or something like that; or send it across to me over Skype, if you are a Skype user.


Edited by ZoriaRPG, 07 March 2016 - 10:58 PM.


#35 Saffith

Saffith

    IPv7 user

  • ZC Developers

Posted 07 March 2016 - 10:59 PM

float GRAM[214727]; //Global Array to hold values.

//Array indices:
const int GR_MAIN       = 214747;
You're using an index of 214747 in an array of size 214727.

#36 Jared

Jared

    Deified

  • Members
  • Real Name:Jared
  • Pronouns:He / Him
  • Location:New Hampshire

Posted 07 March 2016 - 11:13 PM

Kind of random, but when this is finished, it should be put into the database with a demo quest. I bet it'll be a big use to a lot of people. :)


  • AdmiralJaden likes this

#37 AdmiralJaden

AdmiralJaden

    Experienced Forumer

  • Members

Posted 08 March 2016 - 01:03 AM

http://www.purezc.ne...projects&id=346

That's the hidden project, The demo file is a zip that contains the allegro log as well as the qst file.



#38 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 08 March 2016 - 02:57 AM

float GRAM[214727]; //Global Array to hold values.

//Array indices:
const int GR_MAIN       = 214747;
You're using an index of 214747 in an array of size 214727.

 

 

Oops. I didn't even notice that. Interestingly, it probably works because the function returns -1, and evaluates true in the while statement. It will however, flood the log with array index errors.

 

I don't think this is the culprit though, as if it was, it wouldn't work at all. It did work before, even with that erroneous value, so something else is clearly happening that falls outside the scope of minor errors. Obviously, I'll change that for him, but I'm not seeing why the global loop is running, and without ghost.zh the torches function works, but with ghost.zh running, it does not.

 

Is there anything in the version of ghost.zh that he's using (current, I presume) that could interfere with screen states?

 

This is the script, with that correction. Feel free to try it, and see if it does in fact hinge on this.

 

//import "std.zh"
    //Remove the comment before the import directive
    //instruction if you do not elsewhere call this.

/////////////////////////////////////////
// Basic : Lit Torches Dispel Darkness //
//      v0.5 - 7th March, 2016         //
//          By: ZoriaRPG               //
///////////////////////////////////////////////////////////////////////////////////
// This script set creates a fading darkness effect when a lit torch set by the  //
// constant 'CMB_LIT_TORCH'.                                                     //
// ----------------------------------------------------------------------------- //
// [ 1 ] Set-Up: Make a 'lit torch' combo, and assign its ID to the constant     //
//       CMB_LIT_TORCH.                                                          //
// [ 2 ] Set up a combo on the screen with a secret flag (burn).                 //
//       Set the 'burn' combo in Screen->Secret Combos to match the combo that   //
//       you selected as 'CMB_LIT_TORCH'.                                        //
// [ 3 ] If you wish to use more than one combo as a lit torch, populate the     //
//       array 'torchCombos[]', in the function SimpleLightRoom() at line '48'   //
//       with the combo numbers or with self-defined constants that you assign   //
//       to those values, separated by commas.                                   //
///////////////////////////////////////////////////////////////////////////////////

//////////////
// SETTINGS //
//////////////

//Combo and Colour Constants

const int CMB_LIT_TORCH             = 0;    //Set to the combo number of the torch in its lit state.
const int TORCH_HIGHEST_LAYER       = 6;    //The highest layer on which a lit torch can appear.

/////////////////////
// ARRAYS AND VARS //
/////////////////////

float GRAM[214727]; //Global Array to hold values.

//Array indices:
const int GR_MAIN       = 214746;

/////////////////////////////////////
// DARKNESS AND LIGHTING FUNCTIONS //
/////////////////////////////////////

//The primarycomponent function, called by Torches()
void SimpleLightRoom(){
    float torchCombos[]={CMB_LIT_TORCH}; //Populate with combos that you want to use as lit torches, separated by commas.
    if ( !Screen->Lit ) {
        for ( int q = 0; q <= TORCH_HIGHEST_LAYER; q++ ) { //layers
            if (Screen->LayerMap(q) != -1) {
                for ( int w = 0; w < 176; w++ ){
                    if ( __MatchComboD(torchCombos, w) ) {
                        Screen->Lit = true;
                    }
                }
            }
        }
    }
}

//Compares combo 'cmb' and compares it to the values in array 'list'.
//Returns true of any of the entries on the list match its Data.
bool __MatchComboD(int list, int cmb){
    bool match = false;
    for ( int q = 0; q < SizeOfArray(list); q++ ) {
        if ( Screen->ComboD[cmb] == list[q] ) match = true;
    }
    return match;
}

///////////////////
// GLOBAL SCRIPT //
///////////////////

global script active_example_timed_fading_torch_darkness{
    void run() {
        main(true); //Enable the main loop.
        StartGhostZH();
        while( main() ) {       //! I do this, instead of while(true) to allow suspending it,
                                //! and changing to an alternate global loop, as an option.
            
            SimpleLightRoom(); //The main function for custom darkness (no special effects version)
            UpdateGhostZH1();
            Waitdraw();
            
            UpdateGhostZH2();
            Waitframe();
        }
    }
    int main() { return GRAM(GR_MAIN); }

    void main(bool enabled) {
        if ( enabled ) GRAM(GR_MAIN,1);
        else GRAM(GR_MAIN,0);
    }
}

void GRAM(int index, int val){GRAM[index]=val;} //Sets Global RAM array index to a specific value.
int GRAM(int index){ return GRAM[index];} //Returns the value of specified index of Global RAM array.

Edited by ZoriaRPG, 08 March 2016 - 03:04 AM.

  • AdmiralJaden likes this

#39 Saffith

Saffith

    IPv7 user

  • ZC Developers

Posted 08 March 2016 - 10:36 AM

I don't see ghost.zh making any difference, and I don't know of any reason why it would. I do see two other issues that would make it work only on certain screens. Screen->LayerMap() is checked for all layers, but it returns -1 for layer 0. __MatchComboD() is used for each layer, but it uses Screen->ComboD[].

#40 AdmiralJaden

AdmiralJaden

    Experienced Forumer

  • Members

Posted 08 March 2016 - 05:11 PM

 

Oops. I didn't even notice that. Interestingly, it probably works because the function returns -1, and evaluates true in the while statement. It will however, flood the log with array index errors.

 

I don't think this is the culprit though, as if it was, it wouldn't work at all. It did work before, even with that erroneous value, so something else is clearly happening that falls outside the scope of minor errors. Obviously, I'll change that for him, but I'm not seeing why the global loop is running, and without ghost.zh the torches function works, but with ghost.zh running, it does not.

 

Is there anything in the version of ghost.zh that he's using (current, I presume) that could interfere with screen states?

 

This is the script, with that correction. Feel free to try it, and see if it does in fact hinge on this.

//import "std.zh"
    //Remove the comment before the import directive
    //instruction if you do not elsewhere call this.

/////////////////////////////////////////
// Basic : Lit Torches Dispel Darkness //
//      v0.5 - 7th March, 2016         //
//          By: ZoriaRPG               //
///////////////////////////////////////////////////////////////////////////////////
// This script set creates a fading darkness effect when a lit torch set by the  //
// constant 'CMB_LIT_TORCH'.                                                     //
// ----------------------------------------------------------------------------- //
// [ 1 ] Set-Up: Make a 'lit torch' combo, and assign its ID to the constant     //
//       CMB_LIT_TORCH.                                                          //
// [ 2 ] Set up a combo on the screen with a secret flag (burn).                 //
//       Set the 'burn' combo in Screen->Secret Combos to match the combo that   //
//       you selected as 'CMB_LIT_TORCH'.                                        //
// [ 3 ] If you wish to use more than one combo as a lit torch, populate the     //
//       array 'torchCombos[]', in the function SimpleLightRoom() at line '48'   //
//       with the combo numbers or with self-defined constants that you assign   //
//       to those values, separated by commas.                                   //
///////////////////////////////////////////////////////////////////////////////////

//////////////
// SETTINGS //
//////////////

//Combo and Colour Constants

const int CMB_LIT_TORCH             = 0;    //Set to the combo number of the torch in its lit state.
const int TORCH_HIGHEST_LAYER       = 6;    //The highest layer on which a lit torch can appear.

/////////////////////
// ARRAYS AND VARS //
/////////////////////

float GRAM[214727]; //Global Array to hold values.

//Array indices:
const int GR_MAIN       = 214746;

/////////////////////////////////////
// DARKNESS AND LIGHTING FUNCTIONS //
/////////////////////////////////////

//The primarycomponent function, called by Torches()
void SimpleLightRoom(){
    float torchCombos[]={CMB_LIT_TORCH}; //Populate with combos that you want to use as lit torches, separated by commas.
    if ( !Screen->Lit ) {
        for ( int q = 0; q <= TORCH_HIGHEST_LAYER; q++ ) { //layers
            if (Screen->LayerMap(q) != -1) {
                for ( int w = 0; w < 176; w++ ){
                    if ( __MatchComboD(torchCombos, w) ) {
                        Screen->Lit = true;
                    }
                }
            }
        }
    }
}

//Compares combo 'cmb' and compares it to the values in array 'list'.
//Returns true of any of the entries on the list match its Data.
bool __MatchComboD(int list, int cmb){
    bool match = false;
    for ( int q = 0; q < SizeOfArray(list); q++ ) {
        if ( Screen->ComboD[cmb] == list[q] ) match = true;
    }
    return match;
}

///////////////////
// GLOBAL SCRIPT //
///////////////////

global script active_example_timed_fading_torch_darkness{
    void run() {
        main(true); //Enable the main loop.
        StartGhostZH();
        while( main() ) {       //! I do this, instead of while(true) to allow suspending it,
                                //! and changing to an alternate global loop, as an option.
            
            SimpleLightRoom(); //The main function for custom darkness (no special effects version)
            UpdateGhostZH1();
            Waitdraw();
            
            UpdateGhostZH2();
            Waitframe();
        }
    }
    int main() { return GRAM(GR_MAIN); }

    void main(bool enabled) {
        if ( enabled ) GRAM(GR_MAIN,1);
        else GRAM(GR_MAIN,0);
    }
}

void GRAM(int index, int val){GRAM[index]=val;} //Sets Global RAM array index to a specific value.
int GRAM(int index){ return GRAM[index];} //Returns the value of specified index of Global RAM array.

That fixed it. :) Thank you guys.

I should mention though that Allegro is still stating that the 214746 index is still invalid for local array 214727


Edited by AdmiralJaden, 08 March 2016 - 05:14 PM.


#41 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 09 March 2016 - 12:01 AM

That fixed it. :) Thank you guys.

I should mention though that Allegro is still stating that the 214746 index is still invalid for local array 214727


Change 214727 to 214747. That's a typo, pure and simple. Interesting though, that this is the same type of error, and yet, it is now working...

The following is a crucial update, that you should use. No new save file should be required:
 

//import "std.zh"
    //Remove the comment before the import directive
    //instruction if you do not elsewhere call this.

/////////////////////////////////////////
// Basic : Lit Torches Dispel Darkness //
//      v0.6 - 9th March, 2016         //
//          By: ZoriaRPG               //
///////////////////////////////////////////////////////////////////////////////////
// This script set creates a fading darkness effect when a lit torch set by the  //
// constant 'CMB_LIT_TORCH'.                                                     //
// ----------------------------------------------------------------------------- //
// [ 1 ] Set-Up: Make a 'lit torch' combo, and assign its ID to the constant     //
//       CMB_LIT_TORCH.                                                          //
// [ 2 ] Set up a combo on the screen with a secret flag (burn).                 //
//       Set the 'burn' combo in Screen->Secret Combos to match the combo that   //
//       you selected as 'CMB_LIT_TORCH'.                                        //
// [ 3 ] If you wish to use more than one combo as a lit torch, populate the     //
//       array 'torchCombos[]', in the function SimpleLightRoom() at line '48'   //
//       with the combo numbers or with self-defined constants that you assign   //
//       to those values, separated by commas.                                   //
///////////////////////////////////////////////////////////////////////////////////

//////////////
// SETTINGS //
//////////////

//Combo and Colour Constants

const int CMB_LIT_TORCH             = 0;    //Set to the combo number of the torch in its lit state.
const int TORCH_HIGHEST_LAYER       = 6;    //The highest layer on which a lit torch can appear.

/////////////////////
// ARRAYS AND VARS //
/////////////////////

float GRAM[214747]; //Global Array to hold values.

//Array indices:
const int GR_MAIN       = 214746;

/////////////////////////////////////
// DARKNESS AND LIGHTING FUNCTIONS //
/////////////////////////////////////

//The primarycomponent function, called by Torches()
void SimpleLightRoom(){
    float torchCombos[]={CMB_LIT_TORCH}; //Populate with combos that you want to use as lit torches, separated by commas.
    if ( !Screen->Lit ) {
        for ( int q = 0; q <= TORCH_HIGHEST_LAYER; q++ ) { //layers
            if (q == 0 || (Screen->LayerMap(q) != -1) ) {
                for ( int w = 0; w < 176; w++ ){
                    if ( __MatchLayerComboD(torchCombos, q, w) ) {
                        Screen->Lit = true;
                    }
                }
            }
        }
    }
}

//Compares combo 'cmb' and compares it to the values in array 'list'. 
//Returns true of any of the entries on the list match its Data. 
bool __MatchLayerComboD(int list, int layer, int cmb){
	bool match = false;
	for ( int q = 0; q < SizeOfArray(list); q++ ) {
		if ( GetLayerComboD(layer,cmb) == list[q] ) match = true;
	}
	return match;
}

///////////////////
// GLOBAL SCRIPT //
///////////////////

global script active_example_timed_fading_torch_darkness{
    void run() {
        main(true); //Enable the main loop.
        StartGhostZH();
        while( main() ) {       //! I do this, instead of while(true) to allow suspending it,
                                //! and changing to an alternate global loop, as an option.
            
            SimpleLightRoom(); //The main function for custom darkness (no special effects version)
            UpdateGhostZH1();
            Waitdraw();
            
            UpdateGhostZH2();
            Waitframe();
        }
    }
    int main() { return GRAM(GR_MAIN); }

    void main(bool enabled) {
        if ( enabled ) GRAM(GR_MAIN,1);
        else GRAM(GR_MAIN,0);
    }
}

void GRAM(int index, int val){GRAM[index]=val;} //Sets Global RAM array index to a specific value.
int GRAM(int index){ return GRAM[index];} //Returns the value of specified index of Global RAM array.

That should be the last change to this.
 

I don't see ghost.zh making any difference, and I don't know of any reason why it would. I do see two other issues that would make it work only on certain screens. Screen->LayerMap() is checked for all layers, but it returns -1 for layer 0. __MatchComboD() is used for each layer, but it uses Screen->ComboD[].


Given that I made MatchLayerComboD() and put it into the proposed standard header, I should know this, but apparently my brain turns to pudding after 92 hours of metalcrafting, and tooling in one week, compiled on a three week period of exactly the same.

LayerMap, values of n < 1. Forgot that one. I'm a bit curious at to the reason for doing that, but at present I can't even recall if Map 0 is valid. If not, I'd think that LayerMap should return 0, as it could be used for simple boolean checks that way. If it is, then everything passes the insomnia mark of approval for the day.


Edited by ZoriaRPG, 09 March 2016 - 01:25 AM.

  • AdmiralJaden likes this

#42 SparksTheUnicorn

SparksTheUnicorn

    Lonk, Hero of Lime

  • Members

Posted 12 May 2020 - 08:28 PM

I know this thread is old but does anyone know if this script for the torches would work with 2.55, and if so which version of the script should be used?



#43 Russ

Russ

    Caelan, the Encouraging

  • Administrators
  • Location:Washington

Posted 13 May 2020 - 01:06 PM

Any script that's made for 2.50/2.53 should work fine in 2.55. 2.55 may have more efficient ways of doing the same thing, but the old method would still work. Zoria's script in the post above yours oughta do the trick.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users