Jump to content

Photo

Help With Script


  • Please log in to reply
18 replies to this topic

#1 Mibbitable

Mibbitable

    Junior

  • Members

Posted 12 November 2017 - 07:46 PM

Hello, so I have this script file, and somewhere in it, is something that causes the rupee counter to be stupid. First of all, as soon as you start the game, you automatically get 10. And while I was testing my game, when I died, it reset the rupee counter to 10 again. I don't know how to fix this, everything else works wonderfully.

It's really long. But if somebody could make a global script that acts the same as the normal rupee counter, that would be lovely. Or show me the problem and how i can fix it. Thank you! 

 

It's long so I have to give you a download link.

 

https://www.dropbox....ptsNEW.txt?dl=0



#2 Saffith

Saffith

    IPv7 user

  • ZC Developers

Posted 12 November 2017 - 07:54 PM

It's because of these counter indices:
const int CR_HP = 8;
const int CR_MP = 9;
const int CR_HP_MAX = 10;
const int CR_MP_MAX = 11;
const int CR_XP = 12;
const int CR_LEVEL = 13;
const int CR_LVL = 13;
const int CR_XP_10K = 14;
const int CR_STAT_MUSC = 1;
const int CR_STAT_BODY = 3;
const int CR_STAT_MIND = 1;
const int CR_STAT_MYST = 1;
const int CR_STAT_INFL = 1;
const int CR_STAT_LUCK = 1;
These should all be unique, and they need to be in the range 7-31. Counter 1 is the rupee counter, so when it initializes the stats to 10, it's also setting rupees.
  • Mibbitable likes this

#3 Mibbitable

Mibbitable

    Junior

  • Members

Posted 12 November 2017 - 07:58 PM

Thank you so much!



#4 ywkls

ywkls

    Master

  • Members

Posted 12 November 2017 - 08:10 PM

These lines here at the start of your global active script are also part of the problem.
 

Game->MCounter[CR_LEVEL] = 20;
Game->MCounter[CR_XP] = 211500;
Game->Counter[CR_STAT_BODY] = 10;
Game->MCounter[CR_STAT_BODY] = 100;
Game->Counter[CR_STAT_MUSC] = 10;
Game->MCounter[CR_STAT_MUSC] = 100;
Game->Counter[CR_STAT_MIND] = 10;
Game->MCounter[CR_STAT_MIND] = 100;
Game->Counter[CR_STAT_MYST] = 10;
Game->MCounter[CR_STAT_MYST] = 100;
Game->Counter[CR_STAT_INFL] = 10;
Game->MCounter[CR_STAT_INFL] = 100;
Game->Counter[CR_STAT_LUCK] = 10;
Game->MCounter[CR_STAT_LUCK] = 100;

Anything placed there will run each and every time you start the quest.

Great for certain things but I don't think that's what you want here.

What you probably intended was for these things to run once, the first time you loaded the quest and then never again,

In that case, you'd need to do this.

Example Fix

 

The second reason that this is happening is because of what Saffith said. 


Edited by ywkls, 12 November 2017 - 08:11 PM.


#5 Mibbitable

Mibbitable

    Junior

  • Members

Posted 12 November 2017 - 08:19 PM

Now what would I add if I wanted it to display the Current Level of the player?



#6 Mibbitable

Mibbitable

    Junior

  • Members

Posted 13 November 2017 - 04:35 PM

And I want to edit this code to where you gain abilities or items at a certain level. Right now, at level 5, you learn how to slash. I want to figure out how to make it where you get new stuff at certain levels like a HP Ring or Magic Ring, just stuff like that.



#7 ywkls

ywkls

    Master

  • Members

Posted 13 November 2017 - 08:36 PM

Now what would I add if I wanted it to display the Current Level of the player?

To have a number show up on the passive subscreen you'd either have to use Draw Integer or layer 7 at negative Y coordinates (I believe the top is -56) or create a counter object in the subscreen editor which corresponded to the counter in question.

 

Keep in mind that the script drawing option only applies to the passive subscreen. You have to use counter objects on the active subscreen or script a subscreen yourself.

 

And I want to edit this code to where you gain abilities or items at a certain level. Right now, at level 5, you learn how to slash. I want to figure out how to make it where you get new stuff at certain levels like a HP Ring or Magic Ring, just stuff like that.

There are various ways to go about this. One is to have a specific spot in the game where you can go to get said abilities.

This method is the easier one to script.

 ffc script LevelUpReward{
	void run(int counter_type, int amount, int item_to_give, int m){
		while(!Screen->State[ST_SECRET]){
			if ( Game->Counter[countertype] >= amount) {
				Game->PlaySound(SFX_SECRET);
				Screen->TriggerSecrets();
				Screen->State[ST_SECRET] = true;
				item TradeSeqItem;
				//Create the item and place it at Link's location.
				TradeSeqItem = Screen->CreateItem(item_to_give);
				TradeSeqItem->X = Link->X;
				TradeSeqItem->Y = Link->Y;
				TradeSeqItem->Pickup |= IP_HOLDUP;
				Screen->Message(m);
			}
			Waitframe();
		}
	}
 }

Simply place the ffc with this script in the spot where the award is to be received and you'd automatically get the item when you enter the room.

You could also conceivably install that script within an npc script; though I don't know which one your using so I can't really advise you on how to do that.

 

Another way to use this method would be to have it give you a useless item but unlock a secret which then triggered either the appearance of a chest or access to another room where something like 1/2 magic or Slash could be learned. (Learning slash or 1/2 magic via script is an entirely different subject.)

 

There are more complex ways of doing this, but that'd probably required scripting the entire level up system for you; which most people (including me) would not be inclined to do.


  • Mibbitable likes this

#8 Mibbitable

Mibbitable

    Junior

  • Members

Posted 13 November 2017 - 10:15 PM

I think this is the part of the script that adds slashing when you reach level 5.

void Level5() {
	Game->PlaySound(levelSound);
	Screen->Message(L5String); //This should show on-screen one time, when gaining the level, and not remain forever.
	increaseHP();
	increaseMP();
	increaseStat(); //This should happen one time, when gaining this level, and be permanent.
	Game->Generic[GEN_CANSLASH] = 1; //This should occur when gaining this level, and be permanent.
}

I was just thinking if there could be a way where it automatically generates an item in your inventory when you reach a certain level using the item ID. Is that a possibility?



#9 ywkls

ywkls

    Master

  • Members

Posted 13 November 2017 - 10:37 PM

I think this is the part of the script that adds slashing when you reach level 5.

void Level5() {
	Game->PlaySound(levelSound);
	Screen->Message(L5String); //This should show on-screen one time, when gaining the level, and not remain forever.
	increaseHP();
	increaseMP();
	increaseStat(); //This should happen one time, when gaining this level, and be permanent.
	Game->Generic[GEN_CANSLASH] = 1; //This should occur when gaining this level, and be permanent.
}

I was just thinking if there could be a way where it automatically generates an item in your inventory when you reach a certain level using the item ID. Is that a possibility?

You'd basically have to do something like that for every time you wanted something of this sort to happen.

Keep in mind that unless a message is set up to play in such a script, you'd just get the item without even noticing it.

It'd look very similar to what you posted above.

Something like this, maybe...

void Level10() {
	Game->PlaySound(levelSound);
	increaseHP();
	increaseMP();
	increaseStat(); //This should happen one time, when gaining this level, and be permanent.
	item TradeSeqItem;
	//Create the item and place it at Link's location.
	TradeSeqItem = Screen->CreateItem(L_10_ITEM);//The item to give at level 10.
	TradeSeqItem->X = Link->X;
	TradeSeqItem->Y = Link->Y;
	TradeSeqItem->Pickup |= IP_HOLDUP;
	Screen->Message(L10String); //This should show on-screen one time, when gaining the level, and not remain forever.
}

You should also know that this wouldn't occur just one time.

As long as you the conditions which caused the script to run were true, they'd occur over and over again.

The best way to prevent this is to add a line like this to the script that calls the level 10 function...

if(!Link->Item[L_10_ITEM])

Placing this directly before the level 10 function will mean that will run once and only once; as long as you have the item it gives you. Don't worry too much about items that upgrade (like swords). If you have the flag in the item editor set where you "keep lower level items" then it will stay true.


  • Mibbitable likes this

#10 Saffith

Saffith

    IPv7 user

  • ZC Developers

Posted 13 November 2017 - 10:43 PM

It's already showing a message with each level; you could just add the items with string control codes.
  • Mibbitable likes this

#11 Mibbitable

Mibbitable

    Junior

  • Members

Posted 14 November 2017 - 12:31 AM

And how would I do that?



#12 Saffith

Saffith

    IPv7 user

  • ZC Developers

Posted 14 November 2017 - 12:34 AM

Just write \16\X in the message, replacing X with the item number.
  • Mibbitable likes this

#13 Mibbitable

Mibbitable

    Junior

  • Members

Posted 14 November 2017 - 12:36 AM

Beautiful. Thank you so much! I really appreciate it! I knew about those string codes, just a few though. I never even heard of that one. Is there a list that shows them all? 



#14 Saffith

Saffith

    IPv7 user

  • ZC Developers

Posted 14 November 2017 - 12:43 AM

There's a list on the wiki: http://www.zeldaclas...g_Control_Codes
  • Mibbitable likes this

#15 ywkls

ywkls

    Master

  • Members

Posted 14 November 2017 - 12:57 AM

There's a list on the wiki: http://www.zeldaclas...g_Control_Codes

In the string editor, there's also a help button which pulls up an explanation of the string control codes.

You have to actually be looking at a string to see it, though.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users