Jump to content

Photo

How to make a sword do no damage


  • Please log in to reply
55 replies to this topic

#31 Mero

Mero

    Touch Fluffy Tail

  • Banned
  • Real Name:Tamamo No Mae
  • Location:Rainbow Factory

Posted 05 July 2011 - 12:45 PM

QUOTE(linktopower @ Jul 5 2011, 10:22 AM) View Post

Sorry blackbishop89 i just don't know how get it to work
i found another way to make my sword
in the item editor i edited the master sword
and change the damage on it to 1 and then made the sword beam 1000 damage!!
and the make it only use magic to shot the beams
but hey thanks for helping me i think i'm starting to understand scripts a little better now
and hey i will go ahead stick your name in my games credits for helping me understand scripts a little better now


No problem, sorry it didn't work. I discovered why though. Using Link->Item[Item_ID] = true; doesn't work you need to create the item, load it into a item pointer and position it to link's position like this:
CODE
item itm= Screen->CreateItem[Item_ID];
itm->X = Link->X;
itm->Y = Link->Y;
itm->Z = Link->Z;

There's a inconsistency though. To remove items you can use Link->Item[Item_ID] = false; We should be able to do the opposite by doing using Link->Item[Item_ID] = false;. Don't you agree.

Also if you want me to write you a script that makes it so sword beams take damage I can. It'll be a item script I believe. icon_wink.gif

Edited by blackbishop89, 05 July 2011 - 04:20 PM.


#32 Ventus

Ventus

    Legend

  • Members

Posted 05 July 2011 - 01:56 PM

QUOTE(blackbishop89 @ Jul 5 2011, 12:45 PM) View Post

No problem, sorry it didn't work. I discovered why though. Using Link->Item[Item_ID] = true; doesn't work you need to create the item, load it into a item pointer and position it to link's position like this:
CODE
Item itm= Screen->CreateItem[Item_ID];
itm->X = Link->X;
itm->Y = Link->Y;
itm->Z = Link->Z;

There's a inconsistency though. To remove items you can use Link->Item[Item_ID] = false; We should be able to do the opposite by doing using Link->Item[Item_ID] = false;. Don't you agree.

so do you think this will be able fix our problem ?

Edited by linktopower, 05 July 2011 - 01:57 PM.


#33 Mero

Mero

    Touch Fluffy Tail

  • Banned
  • Real Name:Tamamo No Mae
  • Location:Rainbow Factory

Posted 05 July 2011 - 03:11 PM

QUOTE(linktopower @ Jul 5 2011, 12:56 PM) View Post

so do you think this will be able fix our problem ?


It should just replace the Link->Item[Item_ID] = true; lines with that and it should work.

#34 Ventus

Ventus

    Legend

  • Members

Posted 05 July 2011 - 03:32 PM

QUOTE(blackbishop89 @ Jul 5 2011, 03:11 PM) View Post

It should just replace the Link->Item[Item_ID] = true; lines with that and it should work.

Could you repost the script with those lines replaced
with that because I don't know where to put it?

#35 Mero

Mero

    Touch Fluffy Tail

  • Banned
  • Real Name:Tamamo No Mae
  • Location:Rainbow Factory

Posted 05 July 2011 - 04:25 PM

QUOTE(linktopower @ Jul 5 2011, 02:32 PM) View Post

Could you repost the script with those lines replaced
with that because I don't know where to put it?


Just a second and I'll post it. Just going to be sure it compiles and works.

CODE
import "std.zh"  

int SaveX;
int SaveY;
const int SWORD3 = ?; //replace the questions marks like always.
const int SWORD3A = ?;
const int SWORD3B = ?;
bool WasOnLadder = false;

bool HookGrab(){
    int HSFor;
    for(HSFor = 1; HSFor <= Screen->NumLWeapons(); HSFor++){
        lweapon HSCheck = Screen->LoadLWeapon(HSFor);
        if(HSCheck->ID == LW_HOOKSHOT && Screen->ComboT[ComboAt (HSCheck->X, HSCheck->Y)] == CT_HSGRAB || Screen->ComboT[ComboAt (HSCheck->X+15, HSCheck->Y)] == CT_HSGRAB || Screen->ComboT[ComboAt (HSCheck->X, HSCheck->Y+15)] == CT_HSGRAB || Screen->ComboT[ComboAt (HSCheck->X+15, HSCheck->Y+15)] == CT_HSGRAB){
            return(true);
        }
    }
    return(false);
}

bool OnLadder()
{
    if(Screen->ComboT[ComboAt (Link->X, Link->Y+8)] == CT_SCRIPT1 || Screen->ComboT[ComboAt (Link->X+15, Link->Y+8)] == CT_SCRIPT1 || Screen->ComboT[ComboAt (Link->X, Link->Y+15)] == CT_SCRIPT1 || Screen->ComboT[ComboAt (Link->X+15, Link->Y+15)] == CT_SCRIPT1){
        return(true);
    }
    return(false);
}

bool OnLadderDown()
{
    if(Screen->ComboT[ComboAt (Link->X, Link->Y+8)] != CT_SCRIPT1 && Screen->ComboT[ComboAt (Link->X+15, Link->Y+8)] != CT_SCRIPT1 && (Screen->ComboT[ComboAt (Link->X, Link->Y+15)] == CT_SCRIPT1 || Screen->ComboT[ComboAt (Link->X+15, Link->Y+15)] == CT_SCRIPT1)){
        return(true);
    }
    return(false);
}

bool isLSolidHorz(int y)
{
    int x;
    for(x=Link->X; x<=Link->X+16; x+=8)
    {
        if(x==Link->X+16) x--;
        if(Screen->isSolid(x, y)) return(true);
    }
    return(false);
}

bool isFiringHS(){
    int HSFor;
    for(HSFor = 1; HSFor <= Screen->NumLWeapons(); HSFor++){
        lweapon HSCheck = Screen->LoadLWeapon(HSFor);
        if(HSCheck->ID == LW_HOOKSHOT){
            return(true);
        }
    }
    return(false);
}

bool isJumping(){
    if((GetEquipmentA() == I_ROCSFEATHER && Link->InputA == true) || (GetEquipmentB() == I_ROCSFEATHER && Link->InputB == true) || Link->Jump > 1){
        return(true);
    }
    return(false);
}

global script Slot2{
    void run(){
    while(true){
        if(OnLadder() == true && HookGrab() == false && isJumping() == false){
            if(WasOnLadder == false){
                Link->Jump = 1;
                if(OnLadderDown()){
                    Link->Y++;
                    SaveY = Link->Y;
                }
            }
            else{
                Link->Jump = 0;
            }
            if(!isFiringHS()){
                if(Link->InputUp == true && !isLSolidHorz(Link->Y+7)){
                    SaveY--;
                }
                else if(Link->InputDown == true && !isLSolidHorz(Link->Y+16)){
                    SaveY++;
                }
                if(Link->InputLeft == true && !Screen->isSolid(Link->X-1, Link->Y+8) && !Screen->isSolid(Link->X-1, Link->Y+15)){
                    SaveX--;
                }
                else if(Link->InputRight == true && !Screen->isSolid(Link->X+16, Link->Y+8) && !Screen->isSolid(Link->X+16, Link->Y+15)){
                    SaveX++;
                }
            }
            Link->X = SaveX;
            Link->Y = SaveY;
            WasOnLadder = true;
        }
        else{
            if(WasOnLadder == true){
                Link->Jump = 0;
                WasOnLadder = false;
            }
            SaveX = Link->X;
            SaveY = Link->Y;
        }
if(Link->Item[SWORD3] == true){
                if(Link->MP > 0){
                   item itm= Screen->CreateItem(SWORD3A);
                   itm->X = Link->X;
                   iitm->Y = Link->Y;
                   itm->Z = Link->Z;
                    Link->Item[SWORD3B] = false;
                }
                else{
                    Link->Item[SWORD3A] = false;
                    item itm= Screen->CreateItem(SWORD3B);
                    itm->X = Link->X;
                    itm->Y = Link->Y;
                    itm->Z = Link->Z;
                }
            }
        Waitframe();
    }
    }
}

item script Roc{
    void run(){
        if(OnLadder() == true){
            Link->Jump = 3;
        }
    }
}


In order for it to work correctly you need to have sword3A and 3b have keep lower level items checked. Also theres an unfortunate behavior of causing enemies to be stunned by power level 0 items. There's no way around this.

#36 Ventus

Ventus

    Legend

  • Members

Posted 05 July 2011 - 04:53 PM

okay i got it in my game but some reason it's leaving a trail of swords wherever link go's
did i do something wrong?

Edited by linktopower, 05 July 2011 - 04:54 PM.


#37 Mero

Mero

    Touch Fluffy Tail

  • Banned
  • Real Name:Tamamo No Mae
  • Location:Rainbow Factory

Posted 05 July 2011 - 05:58 PM

QUOTE(linktopower @ Jul 5 2011, 03:53 PM) View Post

okay i got it in my game but some reason it's leaving a trail of swords wherever link go's
did i do something wrong?

Hmm... I'm all out of ideas, do you mind if I take a look at your quest file?

#38 Ventus

Ventus

    Legend

  • Members

Posted 05 July 2011 - 10:51 PM

QUOTE(blackbishop89 @ Jul 5 2011, 05:58 PM) View Post

Hmm... I'm all out of ideas, do you mind if I take a look at your quest file?

sure i'll pm it to you icon_smile.gif

#39 Mero

Mero

    Touch Fluffy Tail

  • Banned
  • Real Name:Tamamo No Mae
  • Location:Rainbow Factory

Posted 06 July 2011 - 10:06 AM

QUOTE(linktopower @ Jul 5 2011, 09:51 PM) View Post

sure i'll pm it to you icon_smile.gif

Several problems here:

1. For the mana sword a & b they should be equipment items.
2. There should be no magic cost for the item. If you want it to take magic we'll need to redo this a little. icon_wink.gif
3. You MUST use custom item slots. Not the zz# slots. Those are for expansion.
4. The problem seems to be that link isn't picking up the item automatically we can fix that by having us change the tile being used by the item to a blank one.
5. Change the pickup sound for swords a & b to 0. That will get rid of the annoying pickup sound playing over and over again.
6. For some reason the item is not being added to links inventory. Not sure why though. I'll look into it later. icon_smile.gif

CODE
const int blank = ?; //define this at the start of the script and set the number to the number of a blank tile.
itm->Tile = blank; //add this line before setting the items position and after creating it.


EDIT: Tested something out and it seems using Link->Item[Item_ID] = true; does worked. I'm going to recombine the two global scripts a different way this time and see if that fixes it.

EDIT: Okay the script works find by itself but when you try to combine them it doesn't work.
CODE
import "std.zh"

const int SWORD3 = 143;
const int SWORD3A = 144;
const int SWORD3B = 145;
int SaveX;
int SaveY;
bool WasOnLadder = false;

bool HookGrab(){
    int HSFor;
    for(HSFor = 1; HSFor <= Screen->NumLWeapons(); HSFor++){
        lweapon HSCheck = Screen->LoadLWeapon(HSFor);
        if(HSCheck->ID == LW_HOOKSHOT && Screen->ComboT[ComboAt (HSCheck->X, HSCheck->Y)] == CT_HSGRAB || Screen->ComboT[ComboAt (HSCheck->X+15, HSCheck->Y)] == CT_HSGRAB || Screen->ComboT[ComboAt (HSCheck->X, HSCheck->Y+15)] == CT_HSGRAB || Screen->ComboT[ComboAt (HSCheck->X+15, HSCheck->Y+15)] == CT_HSGRAB){
            return(true);
        }
    }
    return(false);
}

bool OnLadder()
{
    if(Screen->ComboT[ComboAt (Link->X, Link->Y+8)] == CT_SCRIPT1 || Screen->ComboT[ComboAt (Link->X+15, Link->Y+8)] == CT_SCRIPT1 || Screen->ComboT[ComboAt (Link->X, Link->Y+15)] == CT_SCRIPT1 || Screen->ComboT[ComboAt (Link->X+15, Link->Y+15)] == CT_SCRIPT1){
        return(true);
    }
    return(false);
}

bool OnLadderDown()
{
    if(Screen->ComboT[ComboAt (Link->X, Link->Y+8)] != CT_SCRIPT1 && Screen->ComboT[ComboAt (Link->X+15, Link->Y+8)] != CT_SCRIPT1 && (Screen->ComboT[ComboAt (Link->X, Link->Y+15)] == CT_SCRIPT1 || Screen->ComboT[ComboAt (Link->X+15, Link->Y+15)] == CT_SCRIPT1)){
        return(true);
    }
    return(false);
}

bool isLSolidHorz(int y)
{
    int x;
    for(x=Link->X; x<=Link->X+16; x+=8)
    {
        if(x==Link->X+16) x--;
        if(Screen->isSolid(x, y)) return(true);
    }
    return(false);
}

bool isFiringHS(){
    int HSFor;
    for(HSFor = 1; HSFor <= Screen->NumLWeapons(); HSFor++){
        lweapon HSCheck = Screen->LoadLWeapon(HSFor);
        if(HSCheck->ID == LW_HOOKSHOT){
            return(true);
        }
    }
    return(false);
}

bool isJumping(){
    if((GetEquipmentA() == I_ROCSFEATHER && Link->InputA == true) || (GetEquipmentB() == I_ROCSFEATHER && Link->InputB == true) || Link->Jump > 1){
        return(true);
    }
    return(false);
}

global script Slot2{
    void run(){
    while(true){
        onladder();
        checksword3();
        Waitframe();
    }
    }
    void onladder(){
        if(OnLadder() == true && HookGrab() == false && isJumping() == false){
            if(WasOnLadder == false){
                Link->Jump = 1;
                if(OnLadderDown()){
                    Link->Y++;
                    SaveY = Link->Y;
                }
            }
            else{
                Link->Jump = 0;
            }
            if(!isFiringHS()){
                if(Link->InputUp == true && !isLSolidHorz(Link->Y+7)){
                    SaveY--;
                }
                else if(Link->InputDown == true && !isLSolidHorz(Link->Y+16)){
                    SaveY++;
                }
                if(Link->InputLeft == true && !Screen->isSolid(Link->X-1, Link->Y+8) && !Screen->isSolid(Link->X-1, Link->Y+15)){
                    SaveX--;
                }
                else if(Link->InputRight == true && !Screen->isSolid(Link->X+16, Link->Y+8) && !Screen->isSolid(Link->X+16, Link->Y+15)){
                    SaveX++;
                }
            }
            Link->X = SaveX;
            Link->Y = SaveY;
            WasOnLadder = true;
        }
        else{
            if(WasOnLadder == true){
                Link->Jump = 0;
                WasOnLadder = false;
            }
            SaveX = Link->X;
            SaveY = Link->Y;
        }
    }
    void checksword3(){
        if(Link->Item[SWORD3] == true){
                if(Link->MP > 0){
                    Link->Item[SWORD3A] = true;
                    Link->Item[SWORD3B] = false;
                }
                else{
                    Link->Item[SWORD3A] = false;
                    Link->Item[SWORD3B] = true;
                }
        
            }
        
    }
}

item script Roc{
    void run(){
        if(OnLadder() == true){
            Link->Jump = 3;
        }
    }
}


I'm going to recruit saffith and see if he will be willing to help us get this working. Because honestly have no idea what is going on or why it doesn't work. If you

Edited by blackbishop89, 06 July 2011 - 10:07 AM.


#40 Ventus

Ventus

    Legend

  • Members

Posted 06 July 2011 - 11:10 AM

QUOTE
2. There should be no magic cost for the item. If you want it to take magic we'll need to redo this a little

yeah thats what i want it do
the sword will only do damage when you have magic but when the sword drains all of your magic it'll go back to not doing no damage sword

#41 Mero

Mero

    Touch Fluffy Tail

  • Banned
  • Real Name:Tamamo No Mae
  • Location:Rainbow Factory

Posted 06 July 2011 - 11:31 AM

QUOTE(linktopower @ Jul 6 2011, 10:10 AM) View Post

yeah thats what i want it do
the sword will only do damage when you have magic but when the sword drains all of your magic it'll go back to not doing no damage sword


Let's wait and see what saffith says. I sent him a pm. He should stick his head in here eventually. I hope at least.

#42 Saffith

Saffith

    IPv7 user

  • Members

Posted 06 July 2011 - 11:52 AM

Here's the easiest way I see to do it:

CODE
item script MagicSword
{
    void run(int mpCost)
    {
        if(Link->MP>=mpCost)
            Link->MP-=mpCost;
        else
            this->Power=0;
    }
}


Set that as the sword's action script. Set D0 to the magic cost; leave the actual magic cost at 0.

#43 Mero

Mero

    Touch Fluffy Tail

  • Banned
  • Real Name:Tamamo No Mae
  • Location:Rainbow Factory

Posted 06 July 2011 - 12:48 PM

QUOTE(Saffith @ Jul 6 2011, 10:52 AM) View Post

Here's the easiest way I see to do it:

CODE
item script MagicSword
{
    void run(int mpCost)
    {
        if(Link->MP>=mpCost)
            Link->MP-=mpCost;
        else
            this->Power=0;
    }
}


Set that as the sword's action script. Set D0 to the magic cost; leave the actual magic cost at 0.


How would we go about changing the power back. And I thought this was a ffc pointer? I need to go bac through your tutorials I think.

#44 Saffith

Saffith

    IPv7 user

  • Members

Posted 06 July 2011 - 01:29 PM

Oops, you're right. I was thinking it did that automatically, but it doesn't. Easy enough:

CODE
item script MagicSword
{
    void run(int mpCost, int power)
    {
        if(Link->MP>=mpCost)
        {
            Link->MP-=mpCost;
            this->Power=power;
        }
        else
            this->Power=0;
    }
}

Same thing, but put magic cost as D0 and power as D1.

QUOTE(blackbishop89 @ Jul 6 2011, 01:48 PM) View Post

And I thought this was a ffc pointer? I need to go bac through your tutorials I think.

this is an ffc pointer in ffc scripts and an itemdata pointer in item scripts. I think I forgot to mention that in the tutorials. They need updated pretty badly...

#45 Mero

Mero

    Touch Fluffy Tail

  • Banned
  • Real Name:Tamamo No Mae
  • Location:Rainbow Factory

Posted 06 July 2011 - 01:32 PM

Okay then, where can I find more information on the functions for the itemdata pointer type.


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users