summaryrefslogblamecommitdiff
path: root/npc/functions/main.txt
blob: d510f05bac50bd79361f3ec34ad3ac37a7f56d62 (plain) (tree)
1
2
3
4


                  
              

























                                         
                                            

 





                                              

                                                 
                         
           
 



                                 




                                                                                        























                                                                 
 

                                                       




                                                            
                                         
                



                                        

                    
                            

     
                      

               
                        
                                            

                                

                             
     





                           


           

                                                    




                                                            
                                 
                



                                        

                    
                            

     
                      

               
         
                                            

                         


                             
     





                           

           







                                                           
// Evol functions.
// Authors:
//    4144
//    Travolta
// Description:
//    Build in functions.

function	script	menuimage	{
    return getarg(0) + "|" + getarg(1);
}

function	script	mesn	{
    if (getargcount() > 0)
    {
        .@s$ = "[" + getarg(0) + "]";
    }
    else
    {
        .@s$ = "[" + strnpcinfo(1) + "]";
    }
    mes .@s$;
    return;
}

function	script	mesq	{
    mes "\"" + getarg(0)+  "\"";
    return;
}

function	script	g	{
    return Sex == 0 ? getarg(0) : getarg(1);
}

function	script	col	{
    .@color = getarg(1);
    if (.@color < 0) .@color = 0;
    if (.@color > 9) .@color = 9;
    return "##" + .@color + getarg(0) + "##0";
}

function	script	adddefaultskills	{
    skill NV_BASIC, 9, 0;
    return;
}

function	script	str	{
    return "" + getarg(0);
}

function	script	addremovemapmask	{
    setmapmask getarg(0), (getmapmask(getarg(0)) | (getarg(1) + getarg(2))) ^ getarg(2);
    return;
}

// remove spaces at the start and end of string and return result
function	script	strip	{
    .@s$ = getarg(0);
    if (.@s$ == "")
        return "";
    .@start = 0;
    .@end = getstrlen(.@s$) - 1;
    for (.@i = .@start; .@i < .@end; .@i++)
    {
        if (charat(.@s$, .@i) != " ")
            break;
        else
            .@start++;
    }
    for (.@i = .@end; .@i >= .@start; .@i--)
    {
        if (charat(.@s$, .@i) != " ")
            break;
        else
            .@end--;
    }
    return substr(.@s$, .@start, .@end);
}


// Function to show narrator text. Accepts string args.
// If first arg is a number N, then it represents bit flags.
// Bit flags :
//   0x1 -- blank line at beginning
//   0x2 -- blank line at the end
//   0x4 -- use last "next;"
function	script	narrator	{
    .@start = 0;
    .@argc = getargcount();
    .@flags = 0;

    if (.@argc > 1 && !isstr(getarg(0)))
    {
        .@start = 1;
        .@flags = getarg(0);
    }

    if (.@flags & 0x1)
        mes "";

    mes l("[Narrator]");
    for (.@i = .@start; .@i < .@argc; .@i++)
    {
        mes col(getarg(.@i), 9);
        if (.@i < .@argc - 1)
            next;
    }

    if (.@flags & 0x4)
        next;
    else if (.@flags & 0x2)
        mes "";

    return;
}


// Function to show NPC speech. Accepts string args.
// If first arg is a number N, then it represents bit flags.
// Bit flags :
//   0x1 -- blank line at beginning
//   0x2 -- blank line at the end
//   0x4 -- use last "next;"
function	script	speech	{
    .@start = 0;
    .@argc = getargcount();
    .@flags = 0;

    if (.@argc > 1 && !isstr(getarg(0)))
    {
        .@start = 1;
        .@flags = getarg(0);
    }

    if (.@flags & 0x1)
        mes "";

    mesn;
    for (.@i = .@start; .@i < .@argc; .@i++)
    {
        mesq getarg(.@i);

        if (.@i < .@argc - 1)
            next;
    }

    if (.@flags & 0x4)
        next;
    else if (.@flags & 0x2)
        mes "";

    return;
}


// Show debug message if .debug variable of NPC is set to 1
function	script	npcdebug	{
    if (getvariableofnpc(.debug, strnpcinfo(3)))
        debugmes strnpcinfo(3) + ": " + getarg(0);
    return;
}