summaryrefslogblamecommitdiff
path: root/npc/magic/transmigration.txt
blob: 666f176ef6cda29c9eec25115074ff818fcff993 (plain) (tree)
1
2
3
4
5
6
7
8


                                     
                                    
  


                                                                          


                                       
       






                                                                           
                                                  

            




                                                       
                                     
                                                             


                                                 


                                                                        
                           
















                                                                                                            
         






                                     






                                     
                      
                                                      


                                                  

                            
                                            


                                                  
                  



















                                                    

                                                                                                        

















                                                                                         
                             
                          
            

                               






                                                                        
                                                 


        
                                                        

        
// TMW2 script
// Author: Jesusalva <admin@tmw2.org>
//
// Magic Script: TMW2_TRANSMIGRATION
//
// Attempts to make stuff from other stuff
// This is actually referred as transmutation in human-readable forms, and
// transmigration in scripts.

-	script	sk#mkpot	32767,{
    end;
OnCall:
    // Check cooldown
    if (@mkpot_at > gettimetick(2)) {
        dispbottom l("Skill is in cooldown for @@.", FuzzyTime(@mkpot_at));
        end;
    }

    // Check requisites
    if (!MagicCheck(TMW2_TRANSMIGRATION, 185, -5))
        end;

    do {
        mes ".:: " + l("Transmutation Skill") + " ::.";
        mesc l("What will you transmute today?");
        mes "";
        menuint
            l("Crazy Rum"), CrazyRum,
            rif(false, l("Downgrade Snake Skin")), SnakeSkin,
            l("Mouboo Figurine"), MoubooFigurine;

        mes "";
        mesc l("Transmutating @@ will require:", getitemlink(@menuret));

        // Requeriments listing
        switch (@menuret) {
        case CrazyRum:
            mesc l("* @@/@@ @@", countitem(Plushroom), 10, getitemlink(Plushroom));
            mesc l("* @@/@@ @@", countitem(Milk), 1, getitemlink(Milk));
            break;
        case MoubooFigurine:
            mesc l("* @@/@@ @@", countitem(WoodenLog), 1, getitemlink(WoodenLog));
            break;
        case SnakeSkin:
            //mesc l("* @@/@@ @@", countitem(WoodenLog), 1, getitemlink(WoodenLog));
            menuint
            rif(countitem(BlackMambaSkin), l("Black Mamba Skin -> Mountain Snake Skin")), MountainSnakeSkin,
            rif(countitem(MountainSnakeSkin), l("Mountain Snake Skin -> Snake Skin")), SnakeSkin,
            rif(countitem(SnakeSkin), l("Snake Skin -> Cave Snake Skin")), CaveSnakeSkin,
            l("Cancel");
            break;
        default:
            Exception("ERROR, INVALID TRANSMIGRATION OPTION", RB_DEFAULT|RB_SPEECH); @menuret=0; break;
        }
        // Confirmation
        if (@menuret) {
            next;
            mesc l("Transmute?!");
            if (askyesno() == ASK_NO)
                @menuret=0;
        }
    } while (!@menuret);

    // Close the dialog
    closeclientdialog;

    // Check and Consume the reagents
    switch (@menuret) {
        case CrazyRum:
            if (!transcheck(Plushroom, 10, Milk, 1)) {
                dispbottom l("Not enough items!");
                end;
            }
            break;
        case MoubooFigurine:
            if (!transcheck(WoodenLog, 1)) {
                dispbottom l("Not enough items!");
                end;
            }
            break;
        // Snake Skin Chain
        case MountainSnakeSkin:
            if (!transcheck(BlackMambaSkin, 1)) {
                dispbottom l("Not enough items!");
                end;
            }
            break;
        case SnakeSkin:
            if (!transcheck(MountainSnakeSkin, 1)) {
                dispbottom l("Not enough items!");
                end;
            }
            break;
        case CaveSnakeSkin:
            if (!transcheck(SnakeSkin, 1)) {
                dispbottom l("Not enough items!");
                end;
            }
            break;

        default:
            Exception("ERROR, INVALID TRANSMIGRATION REAGENTS", RB_DEFAULT|RB_SPEECH|RB_ISFATAL); break;
    }

    // Do the roll from 1 to 100
    // Base success chance is 0%
    // Each abizit() point gives you 18% success rate (max 90%)
    // Each skill level gives you 1% success rate (max 10%)
    .@r=rand2(1, 100)-abizit()*18-getskilllv(TMW2_TRANSMIGRATION);

    // Backfire chance: 30%
    if (.@r >= 70) {
        dispbottom l("The spell backfires!");
        percentheal -(rand2(5, 15)), 0;
    // Chance for nothing to happen
    } else if (.@r >= 30) {
        dispbottom l("Your reagents vanish into emptiness!");
    // Chance for you getting a junk item
    } else if (.@r > 0) {
        dispbottom l("Your spell takes a mind of its own and shapes in something else!");
        getitem WarpedLog, 1;
    // You were successful
    } else {
        dispbottom l("*plim*");
        getitem @menuret, 1;
    }

    // set cooldown
    @mkpot_at=gettimetick(2);
    @mkpot_at=@mkpot_at+6;

    // Get a few mana experience points (this is NOT used by Mana Stone)
    GetManaExp(TMW2_TRANSMIGRATION, rand2(4,11));
    end;

OnInit:
    bindatcmd "sk-trans", "sk#mkpot::OnCall", 0, 100, 0;
    end;
}