Jump to content

  •  





Intermediate Healer & Buffer Script

Posted by GmOcean, in 2. Intermediate Scripts 26 November 2014 · 1114 views

Intermediate Healer & Buffer Script ( 2 parts )
An intermediate version of the Basic Healer & Buffer Script.

Part 1

Okay let's start by opening up the final version of our Basic Healer & Buffer Script.
prontera,150,180,4	script	Healer	4_F_ARUNA_POP,{
mes "[^0000FF Healer ^000000]";
mes "Would you like me to heal you?";
mes "^FF0000 *Note - It costs "+ .heal_price +" zeny to get healed.* ^000000";
mes "^FF0000 *Note - AGI-UP + BLESSING Level 10 costs "+ .buff_price +" zeny.* ^000000";
switch( select("Yes, heal me.", "I want buffs", "No thank you") ) {
	case 1:
		if (Zeny < .heal_price) {
			mes "I'm sorry, but you don't have enough zeny.";
			close;
		}
		Zeny -= .heal_price;
		percentheal 100,100;
		break;
	
	case 2:
		if (Zeny < .buff_price) {
			mes "I'm sorry, but you don't have enough zeny.";
			close;
		}
		Zeny -= .buff_price;
		sc_start SC_BLESSING,300000,10;
		sc_start SC_INC_AGI,300000,10;
		break;
}
close;

OnInit:
    .heal_price = 1000;
    .buff_price = 5000;
    end;
}

So what we're going to do here is edit our script quite a bit. but firstly we are going to make the zeny price for healing / buffing optional. To do that is simple. We just need to put our current zeny checks and zeny payment lines, into another if() statement that simply checks to see if we set a variable to anything other than 0. The variable we are going to use is our .heal_price and .buff_price
So let's make those changes:
if (.heal_price) {
    if (Zeny < .heal_price) {
        mes "I'm sorry, but you don't have enough zeny.";
        close;
    }
    Zeny -= .heal_price;
}
and
if (.buff_price) {
    if (Zeny < .buff_price) {
	mes "I'm sorry, but you don't have enough zeny.";
	close;
    }
    Zeny -= .buff_price;
}

That takes care of the first part. Now this is where we get a little technical. We are going to add another variable that gets set every time the server starts / reloads. We are going to call it .include_buffs. And let's just set it to 1 since it's going to be a simple toggle on/off setting.
Also, make sure to place it above the other variables we set beforehand:
.include_buffs = 1;

Now this may not seem obvious, but this setting is going to let us decide whether or not players receive buffs when they pay for heals (free of charge). Assuming we are all kind admins. So let's add a check in case 1:.
It's going to check if the variable is set to 0. And then simply wrap the existing break; command inside that check:
if (!.include_buffs) {
    break;
}

Doing this will let the script rn on through case 1: to case 2:. Next is a bit tricky, we are going to modify the way we set our .buff_price variable. To be more specific, we are going to use a (? :) check. For more information regarding (:?) look here: Conditional Operator.
Otherwise let's make the following changes:
.buff_price = ((.include_buffs)?0:5000);

Okay so this little bit of code is in short, just going to set the variable to 0 if we include buffs when they buy heals. Otherwise set the variable to 5000 which is what we said buffs cost normally.
Alright, so we only have 2 more changes to make, and that is simply 1 more check to determine whether or not we show them the buff price. Obviously, if buffs come with heals, we are going to just not show it so let's simply wrap the mes command dealing with showing buff pricing, into a check to see if .include_buffs is 0, additionally let's make that check also check to see if .buff_price is above 0.
if (!.include_buffs && .buff_price) {
    mes "^FF0000 *Note - AGI-UP + BLESSING Level 10 costs "+ .buff_price +" zeny.* ^000000";
}

And lastly, we are going to edit our menu. Again, this time we are going to use a (:?) check. We will be doing a little trick where we push the menu options down 1 slot. So let's edit our menu:
switch( select("Yes, heal me.", ( .include_buffs?"":"I want buffs" ), "No thank you") ) {

What this effectively allows us to do, is hide our option to choose "I want buffs" while still making sure the option "No thank you", which is now shown as option 2, doesn't get directed to case 2: since it is used for buffs only.
And that's it. Your script should look something like this:
prontera,150,180,4	script	Healer	4_F_ARUNA_POP,{
mes "[^0000FF Healer ^000000]";
mes "Would you like me to heal you?";
if (.heal_price) {
    mes "^FF0000 *Note - It costs "+ .heal_price +" zeny to get healed.* ^000000";
}
if (!.include_buffs && .buff_price){
    mes "^FF0000 *Note - AGI-UP + BLESSING Level 10 costs "+ .buff_price +" zeny.* ^000000";
}
switch( select("Yes, heal me.", ( .include_buffs?"":"I want buffs" ), "No thank you") ) {
	case 1:
		if (.heal_price) {
			if (Zeny < .heal_price) {
				mes "I'm sorry, but you don't have enough zeny.";
				close;
			}
			Zeny -= .heal_price;
		}
		percentheal 100,100;
		if (!.include_buffs) {
                    break;
                }
	
	case 2:
		if( .buff_price ){
			if( Zeny < .buff_price ) {
				mes "I'm sorry, but you don't have enough zeny.";
				close;
			}
			Zeny -= .buff_price;
		}
		sc_start SC_BLESSING,300000,10;
		sc_start SC_INC_AGI,300000,10;
		break;
}
close;

OnInit:
    .include_buffs = 1;
    .heal_price = 1000;
    .buff_price = ( (.include_buffs)?0:5000 );
    end;
}
So there we go, we now just made the Zeny Price for Heals & Buffs optional. As well as made it so buffs can be included with heals. Lastly, this will work for free should you choose to.

Part 2
Okay, here we're going to make it so, players in a guild receive additional buffs, at no extra cost.

So let's open up the script from before:
prontera,150,180,4	script	Healer	4_F_ARUNA_POP,{
mes "[^0000FF Healer ^000000]";
mes "Would you like me to heal you?";
if (.heal_price) {
    mes "^FF0000 *Note - It costs "+ .heal_price +" zeny to get healed.* ^000000";
}
if (!.include_buffs && .buff_price){
    mes "^FF0000 *Note - AGI-UP + BLESSING Level 10 costs "+ .buff_price +" zeny.* ^000000";
}
switch( select("Yes, heal me.", ( .include_buffs?"":"I want buffs" ), "No thank you") ) {
	case 1:
		if (.heal_price) {
			if (Zeny < .heal_price) {
				mes "I'm sorry, but you don't have enough zeny.";
				close;
			}
			Zeny -= .heal_price;
		}
		percentheal 100,100;
		if (!.include_buffs) {
                    break;
                }
	
	case 2:
		if( .buff_price ){
			if( Zeny < .buff_price ) {
				mes "I'm sorry, but you don't have enough zeny.";
				close;
			}
			Zeny -= .buff_price;
		}
		sc_start SC_BLESSING,300000,10;
		sc_start SC_INC_AGI,300000,10;
		break;
}
close;

OnInit:
    .include_buffs = 1;
    .heal_price = 1000;
    .buff_price = ( (.include_buffs)?0:5000 );
    end;
}

Alright, now let's add a mes command near the top that lets players know that they get more buffs if they are in a guild, also let's use ^0000FF as the color so it stands out:
mes "^0000FF *Note - Players in a guild receive additional buffs at no extra charge.* ^000000";

Next, beneath where we give them Increase AGI and Blessing, we are going to add a check to see if they are in a guild. Any guild doesn't matter so long as they are in one.
To do that we will need to use this command: getcharid(<type>{,"<character name>"})
if (getcharid(2)) {

Now we just need to give them more buffs. You can add as many as you like, but for this tutorial we're just going to give them Impositio Manus Level 5 and Assumptio Level 5:
    sc_start SC_IMPOSITIO,300000,5;
    sc_start SC_ASSUMPTIO,300000,5;
}

And that's it. We didn't do much here, but that's because the brunt of the work was done a long time ago. Now we are just expanding it with additional features. So your script should look something like this:
prontera,150,180,4	script	Healer	4_F_ARUNA_POP,{
mes "[^0000FF Healer ^000000]";
mes "Would you like me to heal you?";
if( .heal_price ){ mes "^FF0000 *Note - It costs "+ .heal_price +" zeny to get healed.* ^000000"; }
if( !.include_buffs && .buff_price ){ mes "^FF0000 *Note - AGI-UP + BLESSING Level 10 costs "+ .buff_price +" zeny.* ^000000"; }
mes "^0000FF *Note - Players in a guild receive additional buffs at no extra charge.* ^000000";
switch( select("Yes, heal me.", ( .include_buffs?"":"I want buffs" ), "No thank you") ) {
	case 1:
		if (.heal_price) {
			if (Zeny < .heal_price) {
				mes "I'm sorry, but you don't have enough zeny.";
				close;
			}
			Zeny -= .heal_price;
		}
		percentheal 100,100;
		if (!.include_buffs) {
                    break;
                }
	
	case 2:
		if (.buff_price) {
			if (Zeny < .buff_price) {
				mes "I'm sorry, but you don't have enough zeny.";
				close;
			}
			Zeny -= .buff_price;
		}
		sc_start SC_BLESSING,300000,10;
		sc_start SC_INC_AGI,300000,10;
		if (getcharid(2)) {
			sc_start SC_IMPOSITIO,300000,5;
			sc_start SC_ASSUMPTIO,300000,5;
		}
		break;
}
close;

OnInit:
    .include_buffs = 1;
    .heal_price = 0;
    .buff_price = ( (.include_buffs)?0:5000 );
end;
}
That's it for our healer, we probably won't need to come back to this ever again. But we will, I assure you.