Jump to content

Photo

Removing MP from Link


  • Please log in to reply
6 replies to this topic

#1 Joe123

Joe123

    Retired

  • Members

Posted 26 September 2007 - 01:33 PM

How do I say, take 8 MP from Link at a given point in a script?

I've messed with the Link->MP function for a while, but to no avail.

EDIT: Ignore this, I've found out already. Sorry.

Edited by Joe123, 26 September 2007 - 01:37 PM.


#2 Gleeok

Gleeok

    It's dangerous to dough alone, bake this.

  • Members
  • Real Name:Pillsbury
  • Location:Magical Land of Dough

Posted 27 September 2007 - 07:54 AM

Wow though, your scripting is getting good fast. Just thought i'd share something neat with you.

If you have //whatever stuff here

in a while or for loop

you can increment every if statement in the loop. For example:
if //yada yada
Link->MP = Link->MP -(mpcounter);
mpcounter + int var;
if (mpcounter >= //whatever{
something cool happens


I'm messing around with this for Items that have EXP points. When the conditions are met, they level up!

If you use this as an item script though, you have to set the vars to be global, and you can't loop really...haven't tried it as an item script actually...

Edited by Gleeok, 27 September 2007 - 07:55 AM.


#3 Joe123

Joe123

    Retired

  • Members

Posted 27 September 2007 - 10:24 AM

My scripting isn't getting that good really... I've managed to change a couple of scripts to do slightly different things, but the only script I've written is that play sound effect one, and even that I had to ask how to use the command.

Although I really don't get your incrementing thing icon_razz.gif

Edited by Joe123, 27 September 2007 - 10:25 AM.


#4 ShadowTiger

ShadowTiger

    The Doctor Is In

  • Members

Posted 27 September 2007 - 01:22 PM

Gleeok, maybe try adding even more comments, and better yet, colorizing your script? Explain every single line in depth, both in and of itself, and in conjunction with the other lines, in a useful, serious context.

Let's take a n00bish crack at this.

if //yada yada <- The beginning of the if statement. Your conditions for the if statement will follow within the { and } without a semicolon after the if. (There shouldn't ever be a semicolon after the if, I believe.)

Link->MP = Link->MP -(mpcounter); <- Link->MP is the indicator of Link's current Magic Points. (Link->MaxMP is his Maximum.) so what saying "Link->MP =" means is that they're setting whatever is to the LEFT of the = sign to the value of whatever is to the RIGHT. I believe that's how it goes, anyway. It's like saying x = 6 + 4. ----> x = 10 ---> 10 = 10. The value to the left is what you're loading the stuff at the right into. So that's why the incrementing is done on the right: To change all the values on the right, and then load it into whatever is on the left. So here, it's changing Link->MP to be the variable or operation (We don't know, because it's pseudoscript. icon_razz.gif ) within the curly brackets.

mpcounter + int var; <- So it's now working with the variable mpcounter. (We know it's a variable of our creation because there is no such value or variable already present within ZScript. We have to create it ourself to keep track of whatever we want.) So here, it's increasing the value of mpcounter by the integer (int icon_razz.gif ) entitled var. I don't know though, honestly, because I would have imagined it being something like "int var = (whatever var will be);
mpcounter = mpcounter + var;


if (mpcounter >= //whatever{ <- Again, an if statement. If ( mpcounter is greater than or equal to ... well, whatever you want.) then do stuff.


#5 Snarwin

Snarwin

    Still Lazy After All These Years

  • Members
  • Real Name:Paul
  • Location:New York

Posted 27 September 2007 - 07:00 PM

QUOTE(Gleeok @ Sep 27 2007, 08:54 AM) View Post
if (//yada yada)
{

Link->MP = Link->MP -(mpcounter);
mpcounter + int var;
}
if (mpcounter >= //whatever)
{
//something cool happens;
}
Suggested changes for easier reading in bold. Also, I think you want "mpcounter += int var;" for your third line; without the = for assignment, it doesn't actually do anything.

That said, it is an interesting script. Not quite sure what you'd use it for...probably a limited use item of some sort. Perhaps a "broken wand" that has a limited number of uses before it runs out of power ("something cool") and needs to be recharged? Or perhaps, if you added some lines to gradually decrease mpcounter over time, it could be some sort of powerful but unstable magical item which, if used too often, "overheats" and damages the player? Hmm...

#6 Gleeok

Gleeok

    It's dangerous to dough alone, bake this.

  • Members
  • Real Name:Pillsbury
  • Location:Magical Land of Dough

Posted 28 September 2007 - 12:30 AM

Huh? I was just mentioning the use of global variables to use as counters that can be used to directly influence the items effect, and indirectly influence it. I saw one of joe123's scripts at AGN and was thinking...actually I was drinking at the time. icon_lol.gif icon_razz.gif

Basically: here's a very simple breakdown,(i just started messing with the idea, but if i finish it i'll post it)

int link_exp =0;
int use = 0;
int exp= 0;
int effect = 3;
int coun = 0;

script levelup{

//conditions for using item and effects go here
//ie

if(Link->MP >= effect){
exp + 5;
Link->MP - effect;}
if (exp >=600){
Link->Item[this_item] = false;
Link->Item[other_item] = true;

// add a message string maybe??
//Wand is now lv2!!!!!


The idea is using variables to keep track of all items usage andexp, in turn increasing link's level and exp, along with the items. Although i'll probably add into the global script i've got running to add extra exp to link for each enemy he kills...though i'm not sure how to do this yet.

Ultimately when I finish these cursed scripts i'm gonna make a side project thats a random old-school dungeon crawler. Every playthrough would be infinately different from the last. Random enemies, random warps, pit traps, random door spawns, and exp points, etc.

#7 Joe123

Joe123

    Retired

  • Members

Posted 28 September 2007 - 02:02 AM

I didn't write those scripts Gleeok! they're just edits of Beefster's roll script!


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users