viewing paste menu_create_instance | Text

Posted on the
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
function    script  funMenuCreateInstance   {
    .@instance_name$ = getarg(0);
    .@party_id = getarg(1);
    
    callfunc("funConfig_" + .@instance_name$, .@md_name$, ".md_name$");
    callfunc("funConfig_" + .@instance_name$, .@quest_timeout, ".quest_timeout");
    callfunc("funConfig_" + .@instance_name$, .@max_number_floor, ".number_floors");
    callfunc("funConfig_" + .@instance_name$, .@map_zone$, ".@map_zone$");
    
    .@p_name = getpartyname(.@party_id);
    .@party_leader$ = strcharinfo(PC_NAME, getpartyleader(.@party_id, 2));
    .@instance_map_name$ = funInstanceMapName(.@instance_name$);
    
    .@instance_id = instance_create(.@md_name$, .@party_id);
    
    mesf("funMenuCreateInstance: The instance name is %s and %s.", .@md_name$, .@instance_name$);
    mesf("The party ID is: %d.", .@party_id);
    mesf("funMenuCreateInstance: The instance ID is %d.", .@instance_id);
    next();
    
    if (.@instance_id >= 0) {
        funMapSelector(.@instance_name$, .@maps_this_run$);
 
        mesf("The instance for maps this run is %s.", .@which_instance_for_maps$);
        mesf("The max number of floors is: %d.", .@max_number_floor);
        mesf("The maps are %s %s.", .@maps_this_run$[0], .@maps_this_run$[1]);
        next();
 
        for (.@floor = 0; .@floor <= .@max_number_floor; ++.@floor) {
            .@virtual_name$ = .@floor + .@instance_map_name$;
            .@real_name$ = .@maps_this_run$[.@floor];
            //consolemes(CONSOLEMES_DEBUG, "VirtualName %s ; RealMap %s", .@virtual_name$, .@real_name$);
 
            if (!getstrlen( 
                instance_attachmap(.@real_name$, 
                .@instance_id, true, .@virtual_name$)
                 )
                ) {
                
                mesf("Party id: %s", .@party_id);
                mesf("Party Name: %s", .@p_name$);
                mesf("Party Leader: %s", strcharinfo(PC_NAME));
                mesf("^0000ff%s ^000000 - Reservation Failed.", .@md_name$);
                instance_destroy();
                close();
            }
            
            /* Doesn't work. Had to edit the gvg.txt file and comment out the entries. 
            if("guild_vs2" == .@real_name$)
                setmapflag(.@virtual_name$, MF_ZONE, "All");
            */
            
            // Provide map zone flag here. MF_ZONE = 36
            setmapflag(.@virtual_name$, MF_ZONE, .@map_zone$);
            
           funSetRates(.@instance_name$, .@party_id, .@floor, .@virtual_name$);
        }
        instance_attach(.@instance_id); // how to attach instance to a npc script?
        instance_set_timeout(.@quest_timeout, 60, .@instance_id); // out-of-instance timeout can be tweaked
        instance_init(.@instance_id);
    }
    
    mesf("^0000ff%s^000000- Attempting to book an entrance", .@md_name$);
    mesf("After making a reservation, you have to select 'Enter the Dungeon' from the menu if you wish to enter the %s.", .@md_name$);
    close();
    
    return .@instance_id;
}
Viewed 547 times, submitted by Guest.