Jump to content

Photo

Pickup Script Global script


  • Please log in to reply
4 replies to this topic

#1 Christian

Christian

    Summoner

  • Members
  • Real Name:Chris
  • Location:New Jersey

Posted 08 December 2008 - 03:02 PM

CODE
//Constants//
const int F_PICKUP = 0; //flag to set when you pick up a rock or bush
const int CMB_POTS = 0; //Combo of a rock
const int CMB_BUSH = 0; //Combo of a bush
const int T_PICKUP = 0; // First tile of your link pick up graphics in the order of up;down;left,and right
const int SFX_PICKUP = 0; //SFX to use when you pick up a pot
const int SFX_THROW = 0; //SFX to use when you throw an object
const int Pickupframes = 0;//number of frames link uses to use when rock is picked up
const int CMB_UNDERBUSH = 0;//undercombo of the bush
const int CMB_UNDERPOT = 0;//under combo of the pot

//checks for both flags and inherent flags
bool ComboFI(int x,int y,int combotype){
if(Screen->ComboF[ComboAt(x,y)] == combotype
|| Screen->ComboI[COmboAt(x,y)] == combotype) return true;
}

//Global Variables//
bool hit;
bool hold;

global script Slot_2{
      void run(){
         while(true){
    //call the pickup functions
        if(hit && hold) Pickup();
          Waitframe();
        }
    }
}

     //Pickup Functions
     void Pickup(){
         int xx = 0;
         int yy = 0;
         int this_dam = 0;
         int under;
         int dam_1;
         int dam_2;
         int dam_3;
         int x = Link->X;
         int y = Link->Y;
       if(Link->Dir == 0){
            xx = Link->X;
            yy = Link->Y-8;
       }
         if(Link->Dir == 1){
              xx == Link->X;
              yy == Link->Y+16;
       }
         if(Link->Dir == 2){
               xx == Link->X-16;
               yy == Link->Y;
       }
         if(Link->Dir == 3){
               xx == Link->X+16;
               yy == Link->Y;
       }

         if(Link->InputR && ComboFI(Link->X+8,Link->Y+8,F_PICKUP
                    && can_lift(xx,yy) > 0 && hold == false)){
                  Game->PlaySound(SFX_PICKUP);
           Screen->DrawTile(3,x,y,T_PICKUP+(Floor(Pickupframes),1,1,6,1,0,0,0,0,true,128);
                   Link->Action = LA_DROWNING;
                   Link->HP=Link->MaxHP;
                        Waitdraw();
                   if (can_lift(xx,yy) == 1) {this_dam = dam_1;}
            if (can_lift(xx,yy) == 2) {this_dam = dam_2;}
            if (can_lift(xx,yy) == 3) {this_dam = dam_3;}
                     //shape of the pot or bush
               Screen->ComboD[ComboAt(xx,yy)] + 20;
               Screen->ComboC[ComboAt(xx,yy)];
              //Changes pot or bush to undercombo
             Screen->ComboD[ComboAt(xx,yy)] = CMB_UNDERPOT;
                //Changes Rock to undercombo
             Screen->ComboD[ComboAt(xx,yy)] = CMB_UNDERBUSH;
        //Sets flag to tell Link is holding rock
            hold = true;
                
        while(Link->InputR) { Waitframe(); }
    }
                  if (hold == true) {
        //moves pot to above Link's head
            CMB_POTs = Link->X;
            CMB_POTS = Link->Y-12;
        }
                  if(hold == true){
                 //moves bush to above Link's head
                   CMB_BUSH = Link->X;
                   CMB_BUSH = Link->Y-12;
                }
            }
        }
     }
}



this is what i have right now..im having trouble adding the throwing though icon_frown.gif
can someone help out to do the math when you throw the object at the enemies???
i failed all 4 years of math in high school icon_lol.gif it'll be awesome if someone can help

#2 Joe123

Joe123

    Retired

  • Members

Posted 09 December 2008 - 07:07 AM

Hrm...

I'm not trying to put you off scripting or anything here, but I think you might've tried to go a bit in over your head with this one.

This is one of the most complicated things that I can think of to script - I've certainly never even dreamed of trying it.
There are a lot of errors in what you're written, and alongside the fact that you've just missed a lot of what you need out, I think it's fair to assume you still haven't really grasped the basics of ZScript quite yet.

I'll go back to your other thread with all those scripts in when I get the time, and show you how you've gone wrong in those ones and hopefully that'll help.
Practise and patience.

#3 Gleeok

Gleeok

    It's dangerous to dough alone, bake this.

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

Posted 09 December 2008 - 10:22 AM

Well Joe, that's because Chris here is not afraid of terms like "complicated" and the like. He just wants to script new features and obviously doesn't care if people think he can or not, and good for him I say. Did anyone tell me that I should try and script easier stuff? (well probably icon_razz.gif) Peoples minds work differently from person to person. It took me a little while to be able think in code, so to speak.

Chris; What I've learned is this: Scripting is 90% planning and 10% coding. (then 99% bugfixing... icon_mad.gif ) It just happens that the coding part takes up 90% of the time. Does that make any sense?! ..Well think about it. If your design is poor then think about the mangled mess you'll have when you put all the parts together.
From the looks of it though, it doesn't look too bad. It's nowhere done yet but it's a good start. If I can suggest using an FFC instead of integers and drawtiles for the pot once link picks it up. That way it will be easier to move around and damage enemies when you throw it at them without keeping track of raw numbers.


But stuff like this:
CODE

               Screen->ComboD[ComboAt(xx,yy)] + 20;
               Screen->ComboC[ComboAt(xx,yy)];


or this:
CODE
                   Link->HP=Link->MaxHP;
                        Waitdraw();

Picking up a pot refills Links hearts?

Need to be cleaned up a bit.

#4 Joe123

Joe123

    Retired

  • Members

Posted 09 December 2008 - 11:20 AM

I'm pretty sure I remember you telling me I should script easier stuff ¬_¬

#5 Christian

Christian

    Summoner

  • Members
  • Real Name:Chris
  • Location:New Jersey

Posted 09 December 2008 - 01:12 PM

Hehe icon_smile.gif joe's right i went pretty big over myself trying to think it was possible. Thinking about it more, i don't think it's worth scripters even trying to do it now. Its done when the developers wants to. And gleeok , you're trying to say i should start scripting easier stuff >_>? icon_razz.gif


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users