Jump to content

Photo

Revive on death


  • Please log in to reply
17 replies to this topic

#1 Eragon615

Eragon615

    Junior

  • Members
  • Real Name:Clayton
  • Location:Texas

Posted 30 May 2010 - 07:55 PM

Is it even possible to code an item that upon links death is used and revives hime? If someone can, I'd like it to include Links spinning on the red screen of death before the fairy spins out and heals him. Please and thank you?


#2 Gleeok

Gleeok

    It's dangerous to dough alone, bake this.

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

Posted 30 May 2010 - 09:14 PM

Yes. As of build 1150 (ish..) you have exactly one frame to check if Link->HP <= 0 before he dies, and then do something. It's really easy; Here is a function for that: If it returns true then code something to give him back life if he has an item or whatever then subtract the temporary 100 life.)

CODE

bool LinkHasDied(){
  if( Link->HP <= 0 ){
    Link->HP += 100;
    return true;
  }
  return false;
}


#3 Eragon615

Eragon615

    Junior

  • Members
  • Real Name:Clayton
  • Location:Texas

Posted 30 May 2010 - 09:36 PM

Sounds to good to be true. I'm actually trying to modify Joe123s bottle script (He gave me permission on the terms I didn't pester him for help) and thought it'd be cool to have a fairy. So here's what I have so far:

It's gotta be part global so it constantly checks HP, right? so I add

bool LinkHasDied(){
if ( link->HP <= 0 )
return true;
}
else return false;
}

then I have a fairy bottle with the global

bool LinkHasDied(){
if true [long check each bottle for fairy section]
if true Link->HP += however much 8 hearts is
else die
else do nothing

and finally a simple item script that uses the fairy if set to B. Whew, sounds fun. BTW this is my first actual script mod, so please help with the terms and syntax!

Edited by Eragon615, 30 May 2010 - 09:51 PM.


#4 Gleeok

Gleeok

    It's dangerous to dough alone, bake this.

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

Posted 30 May 2010 - 11:31 PM

A fairy bottle item? Try this:

CODE

bool LinkHasDied(){
  if( Link->HP <= 0 )
    return true;
  return false;
}


int resurrection_counter = 0;
const int BOTTLE_EMPTY; //set these
const int BOTTLE_FAIRY;

int Resurrect( int life, bool temp_invulnerability )
{
if( resurrection_counter > 0 )
{
  resurrection_counter--;
  if( life > 0)
   Link->HP++;
  if( temp_invulnerability &&  Link->HP <= 0 )
   Link->HP = 1;
}
else
{
  if( LinkHasDied() )
  {
   if( Link->Item[BOTTLE_FAIRY] )
   {
     Link->Item[BOTTLE_FAIRY] = false;
     Link->Item[ BOTTLE_EMPTY] = true;
     resurrection_counter = life;
   }
  }
}
return resurrection_counter;
}



//global script
int resurrect = Resurrect( 8 * 16, true ); // 8 hearts
if( resurrect > 0 )
Game->PlaySound( SFX_REFILL );
//whatever else


I think that should work fine.

#5 Eragon615

Eragon615

    Junior

  • Members
  • Real Name:Clayton
  • Location:Texas

Posted 31 May 2010 - 12:49 AM

Gonna have to hack that up just a bit to get it to work, but thanks a million. In case you're wondering why I'm gonna mince it, I have six bottles, so I have to perform multiple checks and make sure the proper items are moved/removed. But I think I can handle that part. I'll have results in an hour or two unless I fall asleep first.

Aw crap. Something's goofed up. I'm having problems with this part

int resurrect = Resurrect( 8 * 16, true ); // 8 hearts
if( resurrect > 0 )
Game->PlaySound( SFX_REFILL );

I must've entered it wrong because it keeps giving me compiling errors. The rest is working fine though. I'll fight with it in the morning...

Okay, it's a decent hour now, here I go again. I've entered everything so far, and it's worked, except the global slot 2 part. Here are my mods to check each bottle:

CODE
const int I_FARY1                       = 182;          // bottled fairies 1-6
const int I_FARY2                       = 183;
const int I_FARY3                       = 123;
const int I_FARY4                       = 124;
const int I_FARY5                       = 125;
const int I_FARY6                       = 126;

int resurrection_counter = 0;

bool LinkHasDied(){
  if( Link->HP <= 0 )
    return true;
  return false;
}

//Here is the part you made, set up to check each and every bottle. Tell me if I messed up this part.
int Resurrect( int life, bool temp_invulnerability )
    {
    if( resurrection_counter > 0 )
        {
        resurrection_counter--;
        if( life > 0)
        Link->HP++;
        if( temp_invulnerability &&  Link->HP <= 0 )
        Link->HP = 1;
        }
    else
        {
        if( LinkHasDied() )
            {
            if( Link->Item[I_FARY1] ){
            Link->Item[I_FARY1] = false;
            Link->Item[I_BTTL1] = true;
            resurrection_counter = life;
            }else if( Link->Item[I_FARY2] ){
            Link->Item[I_FARY2] = false;
            Link->Item[I_BTTL2] = true;
            resurrection_counter = life;
            }else if( Link->Item[I_FARY3] ){
            Link->Item[I_FARY3] = false;
            Link->Item[I_BTTL3] = true;
            resurrection_counter = life;
            }else if( Link->Item[I_FARY4] ){
            Link->Item[I_FARY4] = false;
            Link->Item[I_BTTL4] = true;
            resurrection_counter = life;
            }else if( Link->Item[I_FARY5] ){
            Link->Item[I_FARY5] = false;
            Link->Item[I_BTTL5] = true;
            resurrection_counter = life;
            }else if( Link->Item[I_FARY6] ){
            Link->Item[I_FARY6] = false;
            Link->Item[I_BTTL6] = true;
            resurrection_counter = life;
            }
        }
    }
return resurrection_counter;
}

//and then the slot 2 part
global script Slot2{
int resurrect = Resurrect( 8 * 16, true ); // 8 hearts
if( resurrect > 0 )
Game->PlaySound( SFX_REFILL );
//plus the rest of my scripts


Do I have this right?

Edited by Eragon615, 31 May 2010 - 12:20 PM.


#6 Sephiroth

Sephiroth

    The Legendary Sephiroth

  • Members
  • Location:Somewhere... Lemme know if you find me :)

Posted 31 May 2010 - 12:18 PM

QUOTE(Eragon615 @ May 31 2010, 12:49 AM) View Post

Gonna have to hack that up just a bit to get it to work, but thanks a million. In case you're wondering why I'm gonna mince it, I have six bottles, so I have to perform multiple checks and make sure the proper items are moved/removed. But I think I can handle that part. I'll have results in an hour or two unless I fall asleep first.

Aw crap. Something's goofed up. I'm having problems with this part

int resurrect = Resurrect( 8 * 16, true ); // 8 hearts
if( resurrect > 0 )
Game->PlaySound( SFX_REFILL );

I must've entered it wrong because it keeps giving me compiling errors. The rest is working fine though. I'll fight with it in the morning...


looks like you're missing { and } for that if statement.

#7 Eragon615

Eragon615

    Junior

  • Members
  • Real Name:Clayton
  • Location:Texas

Posted 31 May 2010 - 12:22 PM

Okay, but I'm still very new at code. Where do I put them? Like this?

int resurrect = Resurrect( 8 * 16, true ); // 8 hearts
{if( resurrect > 0 )
Game->PlaySound( SFX_REFILL );}

#8 Joe123

Joe123

    Retired

  • Members

Posted 31 May 2010 - 12:27 PM

No, they come after the brackets of the if like this:
CODE
if ( expression ) {
    //code goes here
}

If there's only one statement to go inside the if you don't need braces though, so your code was right.

If you put '[ code ]' before and '[ /code ]' after your code it'll put the code formatting box thing in.


#9 Eragon615

Eragon615

    Junior

  • Members
  • Real Name:Clayton
  • Location:Texas

Posted 31 May 2010 - 12:37 PM

Okay, really sorry guys but it's still giving me fits. I've tried both with and without brackets and no matter how I set it up I get the error

unexpected if expecting rbrace blah blah can't open or parse file on line 248.

Line 248 is the if( resurrect > 0 ) line. Sorry to bother but I can't seem to get it on my own. Should I just post my entire buffer?

#10 Joe123

Joe123

    Retired

  • Members

Posted 31 May 2010 - 12:57 PM

QUOTE(Eragon615 @ May 31 2010, 06:37 PM) View Post
Should I just post my entire buffer?
Yes.


#11 Eragon615

Eragon615

    Junior

  • Members
  • Real Name:Clayton
  • Location:Texas

Posted 31 May 2010 - 01:11 PM

Alright, I'm posting the buffer as it is now, with no compiling errors. If I compile this, it works.

CODE
import "std.zh"

const int WSP_BALL        = 91;   //weapon/misc sprite for you ball head
const int T_CHAIN         = 90;   //chain-link sprite
const int SFX_BALL        = 3;    //sound effect for when the ball is thrown
const int CF_BALLCHAIN    = 98;   //'ball->next' flag
const int cntr           = 2;       //The counter number the bomb cores use.
const int bombsfx       = 21;   //The SFX number for setting a bomb.

const int SFX_ITEMGET            = 76;        
const int SFX_POTION                = 65;        // Potion is used
const int SFX_DOOR                      = 0;

const int I_BTTL1            = 166;        // empty bottles 1-6
const int I_BTTL2            = 168;
const int I_BTTL3            = 169;
const int I_BTTL4            = 170;        
const int I_BTTL5            = 171;
const int I_BTTL6            = 172;
const int I_BTTLP            = 161;        // empty bottle pickup
const int I_LPTN1            = 175;        // life potions 1-6
const int I_LPTN2            = 176;
const int I_LPTN3            = 177;
const int I_LPTN4            = 178;        
const int I_LPTN5            = 179;
const int I_LPTN6            = 180;
const int I_LPTNP            = 162;        // life potion pickup
const int I_MPTN1            = 134;        // magic potions 1-6
const int I_MPTN2            = 135;
const int I_MPTN3            = 136;
const int I_MPTN4            = 134;        
const int I_MPTN5            = 135;
const int I_MPTN6            = 136;
const int I_MPTNP            = 137;        // magic potion pickup
const int I_BPTN1            = 181;        // blue potions 1-6
const int I_BPTN2            = 197;
const int I_BPTN3            = 128;
const int I_BPTN4            = 129;
const int I_BPTN5            = 130;
const int I_BPTN6            = 131;
const int I_BPTNP            = 163;        // blue potion pickup
const int I_FARY1                       = 182;          // bottled fairies 1-6
const int I_FARY2                       = 183;
const int I_FARY3                       = 123;
const int I_FARY4                       = 124;
const int I_FARY5                       = 125;
const int I_FARY6                       = 126;
const int I_FARYP                       = 127;          // bottled fairy pickup
const int I_HMLK1                       = 190;          // milk half 1-6
const int I_HMLK2                       = 191;
const int I_HMLK3                       = 192;
const int I_HMLK4                       = 193;
const int I_HMLK5                       = 194;
const int I_HMLK6                       = 195;
const int I_MILK1                       = 184;          // milk 1-6
const int I_MILK2                       = 185;
const int I_MILK3                       = 186;
const int I_MILK4                       = 187;
const int I_MILK5                       = 188;
const int I_MILK6                       = 189;
const int I_MILKP                       = 196;          // milk pickup


const int T_POTION            = 129;        // tile used for potion animation


const int M_NOBOTTLE                    = 118;

int BallDamage            = 4;    //damage dealt by ball
int BallSpeed             = 6;    //speed of spinning


bool BallCanMove        = false;    //true if Link can move whilst spinning the ball

int UseBall;
int BallCounter;
int BallRadius;
int LastHP;
int StoreInput;
int UsePotion;

int resurrection_counter = 0;


int Resurrect( int life, bool temp_invulnerability )
    {
    if( resurrection_counter > 0 )
        {
        resurrection_counter--;
        if( life > 0)
        Link->HP++;
        if( temp_invulnerability &&  Link->HP <= 0 )
        Link->HP = 1;
        }
    else
        {
        if( LinkHasDied() )
            {
            if( Link->Item[I_FARY1] ){
            Link->Item[I_FARY1] = false;
            Link->Item[I_BTTL1] = true;
            resurrection_counter = life;
            }else if( Link->Item[I_FARY2] ){
            Link->Item[I_FARY2] = false;
            Link->Item[I_BTTL2] = true;
            resurrection_counter = life;
            }else if( Link->Item[I_FARY3] ){
            Link->Item[I_FARY3] = false;
            Link->Item[I_BTTL3] = true;
            resurrection_counter = life;
            }else if( Link->Item[I_FARY4] ){
            Link->Item[I_FARY4] = false;
            Link->Item[I_BTTL4] = true;
            resurrection_counter = life;
            }else if( Link->Item[I_FARY5] ){
            Link->Item[I_FARY5] = false;
            Link->Item[I_BTTL5] = true;
            resurrection_counter = life;
            }else if( Link->Item[I_FARY6] ){
            Link->Item[I_FARY6] = false;
            Link->Item[I_BTTL6] = true;
            resurrection_counter = life;
            }
        }
    }
return resurrection_counter;
}

//These functions should only be included in your script file once
bool SelectPressInput(int input){
    if(input == 0) return Link->PressA;
    else if(input == 1) return Link->PressB;
    else if(input == 2) return Link->PressL;
    else if(input == 3) return Link->PressR;
}
void SetInput(int input, bool state){
    if(input == 0) Link->InputA = state;
    else if(input == 1) Link->InputB = state;
    else if(input == 2) Link->InputL = state;
    else if(input == 3) Link->InputR = state;
}


void StoreInputs(){
    if(Link->InputA && !Link->InputB) StoreInput = 1;
    else if(Link->InputB && !Link->InputA) StoreInput = 2;
    else if(Link->InputB && Link->InputA) StoreInput = 3;
    else StoreInput = 0;
}
bool CheckInputs(){
    return (((StoreInput&1) != 0 && Link->InputA) || ((StoreInput&2) != 0 && Link->InputB));
}

bool LinkHasDied(){
  if( Link->HP <= 0 )
    return true;
  return false;
}

void NoAction(){
    Link->InputUp = false; Link->InputDown = false;
    Link->InputLeft = false; Link->InputRight = false;
    Link->InputR = false; Link->InputL = false;
    Link->InputA = false; Link->InputB = false;
}

bool ComboFI(int loc,int combotype){
if(Screen->ComboF[loc] == combotype
|| Screen->ComboI[loc] == combotype) return true;
}


void RunPotion(int set1, int set2, int set3, int set4, int set5, int set6, int m){
    if(Link->Item[I_BTTL1]){
        Link->Item[set1] = true;
        Link->Item[I_BTTL1] = false;
    }else if(Link->Item[I_BTTL2]){
        Link->Item[set2] = true;
        Link->Item[I_BTTL2] = false;
    }else if(Link->Item[I_BTTL3]){
        Link->Item[set3] = true;
        Link->Item[I_BTTL3] = false;
    }else if(Link->Item[I_BTTL4]){
        Link->Item[set4] = true;
        Link->Item[I_BTTL4] = false;
    }else if(Link->Item[I_BTTL5]){
        Link->Item[set5] = true;
        Link->Item[I_BTTL5] = false;
    }else if(Link->Item[I_BTTL6]){
        Link->Item[set6] = true;
        Link->Item[I_BTTL6] = false;
    }else Screen->Message(M_NOBOTTLE);
}

////////////////////////////////////////////////////////////////////////
//
//Global Scripts
//
////////////////////////////////////////////////////////////////////////


global script Slot2{
    void run(){
        UseBall = 0;
        while(true){
            BallAndChain();
        Waitframe();
        }
    }
    void BallAndChain(){
        if(UseBall == 0) return;
        else if(UseBall < 25) ThrowBall();
        else SpinBall();
        LastHP = Link->HP;
    }
    void ThrowBall(){
        lweapon Ball = FindBall();
        if(LastHP < Link->HP){
            Ball->DeadState = WDS_DEAD;
            UseBall = 0;
            return;
        }
        if(UseBall < 10){
            int x = Link->X; int y = Link->Y;
            if(Link->Dir == DIR_UP || Link->Dir == DIR_DOWN){ x += Link->Dir*16-8; y -= Link->Dir*32-16; }
            else{ y += 8; x -= (Link->Dir-2)*32-16; }
            Ball->X = x; Ball->Y = y;
        }else if(UseBall < 15){
            PlaceBall(Ball);
            BallRadius += 8;
        }else if(UseBall == 15) Game->PlaySound(SFX_BALL);
        else PlaceBall(Ball);
        
        UseBall++;
        NoAction();
    }
    void SpinBall(){
        lweapon Ball = FindBall();
        if(LastHP < Link->HP || !CheckInputs()){
            Ball->DeadState = WDS_DEAD;
            UseBall = 0;
            return;
        }
        PlaceBall(Ball);
        BallCombo(Ball);
        
        BallCounter = (BallCounter+BallSpeed)%360;
        if(!BallCanMove) NoAction();
    }
    lweapon FindBall(){
        lweapon l;
        for(int i=1;i<=Screen->NumLWeapons();i++){
            l = Screen->LoadLWeapon(i);
            if(l->ID == LW_SCRIPT1) return l;
        }
        l = Screen->CreateLWeapon(LW_SCRIPT1);
        l->Damage = BallDamage;
        l->UseSprite(WSP_BALL);
        return l;
    }
    void PlaceBall(lweapon Ball){
        Ball->X = Link->X+BallRadius*Cos(BallCounter);
        Ball->Y = Link->Y+BallRadius*Sin(BallCounter);
        for(int i=4;i>0;i--)
            Screen->FastTile(2,Link->X+(40*(i/5))*Cos(BallCounter),Link->Y+(40*(i/5))*Sin

(BallCounter),T_CHAIN,8,128);

    }
    void BallCombo(lweapon Ball){
        int loc = ComboAt(Ball->X,Ball->Y);
        if(ComboFI(loc,CF_BALLCHAIN)){
            Screen->ComboD[loc]++;
            if(Screen->ComboF[loc] == CF_BALLCHAIN) Screen->ComboF[loc] = 0;
            Game->PlaySound(SFX_BALL);
        }
    }
    void PotionEffect(){
        Link->Action = LA_FROZEN;
        if(UsePotion == 50) Game->PlaySound(SFX_POTION);
        else if(UsePotion <= 25) Screen->DrawTile(3,Link->X,Link->Y,T_POTION+5-Floor

(UsePotion/5),1,1,11,1,1,0,0,0,0,true,128);
        if(UsePotion == 0) Link->Action = 0;
        UsePotion--;
    }
}



////////////////////////////////////////////////////////////////////////
//
//Item Pickup Scripts
//
////////////////////////////////////////////////////////////////////////

item script EmptyBottlePickup{
    void run(int m, int n){
        if(Link->Item[I_BTTL5]){Link->Item[I_BTTL6] = true; Screen->Message(m);}
        else if(Link->Item[I_BTTL4]){Link->Item[I_BTTL5] = true; Screen->Message(m);}
        else if(Link->Item[I_BTTL3]){Link->Item[I_BTTL4] = true; Screen->Message(m);}
        else if(Link->Item[I_BTTL2]){Link->Item[I_BTTL3] = true; Screen->Message(m);}
        else if(Link->Item[I_BTTL1]){Link->Item[I_BTTL2] = true; Screen->Message(m);}
        else{Link->Item[I_BTTL1] = true; Screen->Message(n);}
    }
}

item script LifePotionPickup{
    void run(int m){
        Game->PlaySound(SFX_ITEMGET);
        Screen->Message(m);
        RunPotion(I_LPTN1,I_LPTN2,I_LPTN3,I_LPTN4,I_LPTN5,I_LPTN6,1);
    }
}

item script MagicPotionPickup{
    void run(int m){
        Game->PlaySound(SFX_ITEMGET);
        Screen->Message(m);
        RunPotion(I_MPTN1,I_MPTN2,I_MPTN3,I_MPTN4,I_MPTN5,I_MPTN6,1);
    }
}

item script BluePotionPickup{
    void run(int m){
        Game->PlaySound(SFX_ITEMGET);
        Screen->Message(m);
        RunPotion(I_BPTN1,I_BPTN2,I_BPTN3,I_BPTN4,I_BPTN5,I_BPTN6,1);
    }
}

item script BottledFairyPickup{
    void run(int m){
        Game->PlaySound(SFX_ITEMGET);
        Screen->Message(m);
        RunPotion(I_FARY1,I_FARY2,I_FARY3,I_FARY4,I_FARY5,I_FARY6,1);
    }
}

item script MilkPickup{
    void run(int m){
        Game->PlaySound(SFX_ITEMGET);
        Screen->Message(m);
        RunPotion(I_MILK1,I_MILK2,I_MILK3,I_MILK4,I_MILK5,I_MILK6,1);
    }
}

////////////////////////////////////////////////////////////////////////
//
//Item Action Scripts
//
////////////////////////////////////////////////////////////////////////

item script BallAndChain{
    void run(){
        if(UseBall > 0) return;
        int d = Link->Dir;
        if(d==3) d=0; else if(d==0) d=3;
        BallCounter = d*90;
        BallRadius = 0;
        StoreInputs();
        UseBall++;
    }
}

item script LifePotionAction{
    void run(int foo, int place){
        Link->HP += 320;
        if(Link->HP > Link->MaxHP) Link->HP = Link->MaxHP;
        if(place < 2){Link->Item[I_BTTL1] = true; Link->Item[I_LPTN1] = false;}
        else if(place < 3){Link->Item[I_BTTL2] = true; Link->Item[I_LPTN2] = false;}
        else if(place < 4){Link->Item[I_BTTL3] = true; Link->Item[I_LPTN3] = false;}
        else if(place < 5){Link->Item[I_BTTL4] = true; Link->Item[I_LPTN4] = false;}
        else if(place < 6){Link->Item[I_BTTL5] = true; Link->Item[I_LPTN5] = false;}
        else if(place < 7){Link->Item[I_BTTL6] = true; Link->Item[I_LPTN6] = false;}
        UsePotion = 50;
    }
}

item script MagicPotionAction{
    void run(int foo, int place){
        Link->MP = 256;
        if(place < 2){Link->Item[I_BTTL1] = true; Link->Item[I_MPTN1] = false;}
        else if(place < 3){Link->Item[I_BTTL2] = true; Link->Item[I_MPTN2] = false;}
        else if(place < 4){Link->Item[I_BTTL3] = true; Link->Item[I_MPTN3] = false;}
        else if(place < 5){Link->Item[I_BTTL4] = true; Link->Item[I_MPTN4] = false;}
        else if(place < 6){Link->Item[I_BTTL5] = true; Link->Item[I_MPTN5] = false;}
        else if(place < 7){Link->Item[I_BTTL6] = true; Link->Item[I_MPTN6] = false;}
        UsePotion = 50;
    }
}

item script BluePotionAction{
    void run(int foo, int place){
        Link->HP += 320;
        if(Link->HP > Link->MaxHP) Link->HP = Link->MaxHP;
        Link->MP = 256;
        if(place < 2){Link->Item[I_BTTL1] = true; Link->Item[I_BPTN1] = false;}
        else if(place < 3){Link->Item[I_BTTL2] = true; Link->Item[I_BPTN2] = false;}
        else if(place < 4){Link->Item[I_BTTL3] = true; Link->Item[I_BPTN3] = false;}
        else if(place < 5){Link->Item[I_BTTL4] = true; Link->Item[I_BPTN4] = false;}
        else if(place < 6){Link->Item[I_BTTL5] = true; Link->Item[I_BPTN5] = false;}
        else if(place < 7){Link->Item[I_BTTL6] = true; Link->Item[I_BPTN6] = false;}
        UsePotion = 50;
    }
}

item script BottledFairyAction{
    void run(int foo, int place){
        Link->HP += 128;
        if(Link->HP > Link->MaxHP) Link->HP = Link->MaxHP;
        if(place < 2){Link->Item[I_BTTL1] = true; Link->Item[I_FARY1] = false;}
        else if(place < 3){Link->Item[I_BTTL2] = true; Link->Item[I_FARY2] = false;}
        else if(place < 4){Link->Item[I_BTTL3] = true; Link->Item[I_FARY3] = false;}
        else if(place < 5){Link->Item[I_BTTL4] = true; Link->Item[I_FARY4] = false;}
        else if(place < 6){Link->Item[I_BTTL5] = true; Link->Item[I_FARY5] = false;}
        else if(place < 7){Link->Item[I_BTTL6] = true; Link->Item[I_FARY6] = false;}
        UsePotion = 50;
    }
}

item script HalfMilkAction{
    void run(int foo, int place){
        Link->HP += 80;
        if(Link->HP > Link->MaxHP) Link->HP = Link->MaxHP;
        if(place < 2){Link->Item[I_BTTL1] = true; Link->Item[I_HMLK1] = false;}
        else if(place < 3){Link->Item[I_BTTL2] = true; Link->Item[I_HMLK2] = false;}
        else if(place < 4){Link->Item[I_BTTL3] = true; Link->Item[I_HMLK3] = false;}
        else if(place < 5){Link->Item[I_BTTL4] = true; Link->Item[I_HMLK4] = false;}
        else if(place < 6){Link->Item[I_BTTL5] = true; Link->Item[I_HMLK5] = false;}
        else if(place < 7){Link->Item[I_BTTL6] = true; Link->Item[I_HMLK6] = false;}
        UsePotion = 50;
    }
}

item script MilkAction{
    void run(int foo, int place){
        Link->HP += 80;
        if(Link->HP > Link->MaxHP) Link->HP = Link->MaxHP;
        if(place < 2){Link->Item[I_HMLK1] = true; Link->Item[I_MILK1] = false;}
        else if(place < 3){Link->Item[I_HMLK2] = true; Link->Item[I_MILK2] = false;}
        else if(place < 4){Link->Item[I_HMLK3] = true; Link->Item[I_MILK3] = false;}
        else if(place < 5){Link->Item[I_HMLK4] = true; Link->Item[I_MILK4] = false;}
        else if(place < 6){Link->Item[I_HMLK5] = true; Link->Item[I_MILK5] = false;}
        else if(place < 7){Link->Item[I_HMLK6] = true; Link->Item[I_MILK6] = false;}
        UsePotion = 50;
    }
}

////////////////////////////////////////////////////////////////////////
//
//FCC Scripts
//
////////////////////////////////////////////////////////////////////////

ffc script Signpost{
    void run(int m,int input){
        int loc = ComboAt(this->X,this->Y);
        while(true){
            while(!AgainstComboBase(loc) || !SelectPressInput(input)) Waitframe();
            SetInput(input,false);
            Screen->Message(m);
            Waitframe();
        }
    }
    bool AgainstComboBase(int loc){
        return Link->Z == 0 && (Link->Dir == DIR_UP && Link->Y == ComboY(loc)+8 && Abs(Link->X-ComboX(loc)) <

8);
    }
}

ffc script DoorOpen{
     void run(int opencombo, bool closeafter, int distance, bool stayopen, int d){
        bool DoorOpen = false;
        int default = this->Data;
        int disable = 0;
        if(distance == 0) distance = 20;

        while(true){
            if(Screen->D[d] == 0 && DoorOpen == false){
                if(infront(this)){
                    Link->Action = 3;
                    DoorOpen = true;
                    Screen->D[d] = 1;
                }
            }if(Screen->D[d] >= 1 && DoorOpen == true && closeafter == false && this->Data == default){
                Game->PlaySound(SFX_DOOR);
                Waitframes(20);
                this->Data = opencombo;
                Link->Action = 0;
                Quit();
            }else if(Screen->D[d] >= 1 && DoorOpen == true && closeafter == true && disable == 0 && this-

>Data == default){
                Game->PlaySound(SFX_DOOR);
                Waitframes(20);
                this->Data = opencombo;
                Link->Action = 0;
                disable = 1;
            }else if(Screen->D[d] >= 1 && closeafter == true){
                if(Link->X <= this->X - distance || Link->X >= this->X + (this->TileWidth*16) - 16 + distance

|| Link->Y <= this->Y - distance || Link->Y >= this->Y + (this->TileHeight*16) - 16 + distance){
                    this->Data = default;
                    Screen->D[d] = 0;
                    DoorOpen = false;
                    Game->PlaySound(SFX_DOOR);
                    disable = 0;
                }
            }
            
            if(Screen->D[d] >= 1 && DoorOpen == false && this->Data == default && stayopen == false){
                if(ontop(this) == false){
                    Screen->D[d] = 0;
                }
                else{
                    this->Data = opencombo;
                    DoorOpen = true;
                }
            }else if(Screen->D[d] >= 1 && DoorOpen == false){
                if(stayopen == true || ontop(this)){
                    this->Data = opencombo;
                    DoorOpen = true;
                }
            }
            
            if(Link->Action != LA_WALKING && DoorOpen == false){
                if(infront(this)) Link->InputUp = false;
            }
            
            Waitframe();
        }
     }
     bool infront(ffc this){
          if(Link->X >= this->X
          && Link->X <= this->X + (this->TileWidth*16) - 16
          && Link->Y >= this->Y + 8 + (this->TileHeight*16) - 16
          && Link->Y <= this->Y + 10 + (this->TileHeight*16) - 16
          && Link->Dir == 0
          &&  Link->Action == 1) return true;
          else return false;
     }
     bool ontop(ffc this){
          if(Link->X >= this->X - 4
          && Link->X <= this->X + 4 + (this->TileWidth*16) - 16
          && Link->Y >= this->Y - 4
          && Link->Y <= this->Y + 4 + (this->TileHeight*16) - 16) return true;
          else return false;
     }
}


Edit: I'm constantly updating my sript file, so I'll try to keep it current until someone comes up with an answer.

Edited by Eragon615, 01 June 2010 - 04:54 PM.


#12 Joe123

Joe123

    Retired

  • Members

Posted 02 June 2010 - 05:48 AM

I'm not quite sure exactly what you're asking to be done...

#13 Eragon615

Eragon615

    Junior

  • Members
  • Real Name:Clayton
  • Location:Texas

Posted 02 June 2010 - 04:49 PM

Oh, my bad, should've put that in there. I've created an instance in your (Joe's) bottle script to add fairies. I_FARY 1-6. Now Gleeok has written a fair bit of script (posted up top) to cause a fairy to revive you if you die, and in my buffer I (think) moddified it to check each of the 6 bottles. The rest of Gleeok's script (the part that actually revives you) won't compile for me, no matter how I set it up. Was wondering if it had to do with the mods I made. This script would be a great addition to my game if someone can get it functional. Please and Thanks.

#14 Gleeok

Gleeok

    It's dangerous to dough alone, bake this.

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

Posted 02 June 2010 - 07:10 PM

Merge this with your global2 script.

CODE

global script Slot2{
    void run(){
        UseBall = 0;
        while(true){
            doBottleFairy();
        Waitframe();
        }
    }
    void doBottleFairy(){
    // put other bottle fairy effect code here.
      int temp = 128; // 8 hearts
      if( temp > Link->MaxHP )
        temp = Link->MaxHP;
      if( Resurrect( temp, true ) > 0 )
        Game->PlaySound( SFX_REFILL );
    }





#15 Eragon615

Eragon615

    Junior

  • Members
  • Real Name:Clayton
  • Location:Texas

Posted 03 June 2010 - 12:25 AM

Yay! It compiled properly this time! There is bad news though. When tested, upon death the bottled fairy item is "used" as the item became an empty bottle. However, I still got a GAME OVER. I'm going to look over all the code and make sure it wasn't my mistake. If anyone wants, I can just gve a link to download my entire quest, or just camp out in a chat room. But yeah for now I'm just going to make absolute sure this isn't my mistake.

Edit: Okay, fairly confident this one isn't my fault now. A little more testing shows that not only is the fairy used, it heals me too! Only problem is I'm healed after I hit CONTINUE. Did I flub something up or is it just a mistake somewhere?

Edited by Eragon615, 03 June 2010 - 12:48 AM.



0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users