Jump to content

Photo

Combining Global Scripts


  • Please log in to reply
6 replies to this topic

#1 OmegaX

OmegaX

    Leader of Omega GamingHunters101

  • Members
  • Real Name:Matthew
  • Location:Rochester, NY

Posted 08 February 2017 - 09:20 PM

I need helparrow-10x10.png Combining Global Scripts for a quest i'm making. Here'sarrow-10x10.png the scripts.

 

Difficulty Settings

 

Link's Awakening

 

Ghost.zh

 

My attempt at combining them



#2 Russ

Russ

    Caelan, the Encouraging

  • Administrators
  • Location:Washington

Posted 08 February 2017 - 09:30 PM

Your big issue is that everything that you want running every frame has to be between these two lines
while(true){
Waitframe();
Your difficulty code isn't inside there, so it will run once when you load your save file, then never again. The easiest way to combine the scripts would be to take everything inside those two lines from the the difficulty script, and put them anywhere between the lines in your main global script. You could do that with all global scripts you want to combine.

For the Link's Awakenings one, you need to copy those "Main Functions" anywhere in your script file, then just put the individual function lines in your global script like this:

while(true){
	ReduceBuffTimers();
	LinksAwakeningItems();
	//You get the idea
	Waitframe();
}
By the way, when asking for help with scripts, please put the scripts in code tags. It's nearly impossible to read them without indents when you put them in quotes like that.

#3 OmegaX

OmegaX

    Leader of Omega GamingHunters101

  • Members
  • Real Name:Matthew
  • Location:Rochester, NY

Posted 09 February 2017 - 04:03 PM

I almost got it. Here's my second attempt

import "std.zh"
import "string.zh"
import "ghost.zh"
import "Difficuly Settings.zh"
import "LinksAwakening.z"

global script activeslot
{
	void run()
	{		
		StartGhostZH();
		
		while (true)
		{
			UpdateGhostZH1();

                        ReduceBuffTimers();
	                LinksAwakeningItems();
	                //You get the idea
			Waitdraw();
                        npc enem = Screen->LoadNPC();
			UpdateGhostZH2();
			Waitframe();
		}
	}
}

it's saying it can't match the npc enem = Screen->LoadNPC(); type signature.



#4 OmegaX

OmegaX

    Leader of Omega GamingHunters101

  • Members
  • Real Name:Matthew
  • Location:Rochester, NY

Posted 11 February 2017 - 09:15 PM

I think i got it.

import "std.zh"
import "string.zh"
import "ghost.zh"
import "Difficulty Settings.zh"
import "LinksAwakening.z"

global script activeslot
{
	void run()
	{		
		StartGhostZH();
		
		while (true)
		{
			UpdateGhostZH1();

                        ReduceBuffTimers();
	                LinksAwakeningItems();
                        if ( difficulty == DIFF_EASY )    //Easy);
                        if ( difficulty == DIFF_HARD) //Normal);
                        if ( difficulty == DIFF_HARD) //Hard);
			Waitdraw();
			UpdateGhostZH2();
			Waitframe();
		}
	}
}

I still don't know if it works or if i did it correctly.



#5 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 12 February 2017 - 12:52 AM

I think i got it.

[...]

I still don't know if it works or if i did it correctly.


  if ( difficulty == DIFF_EASY )    //Easy);
  if ( difficulty == DIFF_HARD) //Normal);
  if ( difficulty == DIFF_HARD) //Hard);

These lines do nothing. They are pseudo-code that is intended to call functions, and issue instructions for each difficulty setting. Other than that, you have it reasonably correct.

Any instructions in the scripts that you are merging that are issued before Waitdraw() should be before Waitdraw() in your final product. Take care about doing that, to avoid bugs.

Here, anyway, is what you want:
 

import "std.zh"
import "string.zh"
import "ghost.zh"
import "Difficulty Settings.zh"
import "LinksAwakening.z"

//Global RAM Array to save global registers. 
int ____GlobRAM[256];
//Indices of the array. 
const int DIFFICULTY_SETTING = 0;

//Settings
const int DRAW_DIFFICULTY = 1; //Set to 1 to display the present difficulty rating dfor testing purposes.


global script activeslot
{
	void run()
	{		
		StartGhostZH();
		
		while (true)
		{
			UpdateGhostZH1();
			TestDifficulty(); //Press Ex1/Ex2 to modify the present setting, to test them.
                        ReduceBuffTimers();
	                LinksAwakeningItems();
                        DifficultyAdjust(); //Handles adjusting npc values for difficulty settings. 
			Waitdraw();
			UpdateGhostZH2();
			Waitframe();
		}
	}
}

//A test function to determine if npc values are changing.
void TestDifficulty(){
	if ( Link->PressEx1 && GetDifficulty() > DIFF_EASY ) {
		SetDifficulty( GetDifficulty() -= 1 );
	}
	if ( Link->PressEx2 && GetDifficulty() < DIFF_HARD+1 ){
		SetDifficulty( GetDifficulty() += 1 );
	}
	if ( DRAW_DIFFICULTY ) Screen->DrawInteger(7,0,0,2,0x01, 0, -1, -1, GetDifficulty(), 0,128);
}

//Adjusts the npc difficulty based on the global setting.
void DifficultyAdjust(){
	//Difficulty adjustment
	if ( GetDifficulty() != DIFF_MED ){ //If not medium (default)
                //Check each enemy
                for ( int i = Screen->NumNPCs(); i > 0; i-- ){
			npc enem = Screen->LoadNPC(i);
			//If difficulty not adjusted
			if ( enem->Misc[NPC_MISC_DIFF] == 0 ){
				if ( GetDifficulty() == DIFF_EASY ){    //Easy
					//Can't set health or damage lower than 1
					enem->HP = Max(enem->HP * .5, 1); //HP = 50%
					enem->Damage = Max(enem->Damage * .5, 1); //Damage = 50%
					enem->WeaponDamage = Max(enem->WeaponDamage * .5, 1); //WeaponDamage = 50%
					enem->Step *= .85; //Step speed = 85%
				}
				else if ( GetDifficulty() == DIFF_HARD){ //Hard
					enem->HP *= 1.5; //HP = 150%
					enem->Damage *= 2; //Damage = 200%
					enem->WeaponDamage *= 2;
					enem->Step *= 1.2; //Step speed = 120%
				}
				else{ //Insane (!!!!!)
					enem->HP *= 1.5; //HP = 150%
					enem->Damage *= 3; //Damage = 400%
					enem->WeaponDamage *= 4; //WeaponDamage = 400%
					enem->Step *= 1.5; //Step speed = 150%
					enem->Haltrate += 2; //Halt/fire rate increased by 2
				}
				enem->Misc[NPC_MISC_DIFF] = 1; //Mark as adjusted
			}
		}
	}
}

//Accessors
void SetDifficulty(int diff){ 
	____GlobRAM[DIFFICULTY_SETTING] = diff;
}

int GetDifficulty(){ return ____GlobRAM[DIFFICULTY_SETTING]; }

I set this up to display the present game difficulty, and to allow pressing Ex1/Ex2 to change it down, or up, respectively, to verify that it is working. Adding menus and such, is in fact, a bit more complicated than implementing this system

 

I also performed some other code clean-up.


Edited by ZoriaRPG, 12 February 2017 - 01:12 AM.


#6 OmegaX

OmegaX

    Leader of Omega GamingHunters101

  • Members
  • Real Name:Matthew
  • Location:Rochester, NY

Posted 12 February 2017 - 03:57 AM

Now it says there's a syntax error, unexpected minus assign, expecting rparen on token -= (at least that's what the compiler says)

#7 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 14 February 2017 - 09:29 AM

Replace:

 

//A test function to determine if npc values are changing.
void TestDifficulty(){
    if ( Link->PressEx1 && GetDifficulty() > DIFF_EASY ) {
        SetDifficulty( GetDifficulty() -= 1 );
    }
    if ( Link->PressEx2 && GetDifficulty() < DIFF_HARD+1 ){
        SetDifficulty( GetDifficulty() += 1 );
    }
    if ( DRAW_DIFFICULTY ) Screen->DrawInteger(7,0,0,2,0x01, 0, -1, -1, GetDifficulty(), 0,128);
}

 

with

 


//A test function to determine if npc values are changing.
void TestDifficulty(){
    if ( Link->PressEx1 && GetDifficulty() > DIFF_EASY ) {
        SetDifficulty( GetDifficulty() - 1 );
    }
    if ( Link->PressEx2 && GetDifficulty() < DIFF_HARD+1 ){
        SetDifficulty( GetDifficulty() + 1 );
    }
    if ( DRAW_DIFFICULTY ) Screen->DrawInteger(7,0,0,2,0x01, 0, -1, -1, GetDifficulty(), 0,128);
}



0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users