All pastes #914573 Raw Edit

Moriquendu

public cpp v1 · immutable
·published 2008-02-23 00:14 UTC
rendered paste body
/** This program is distributed in the hope that it will be useful,* but WITHOUT ANY WARRANTY; without even the implied warranty of* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.** Yeah!*/#include <stdio.h>#include <conio.h>#include <io.h>int** create_new(int** arr, int &size, FILE* output, int &textid);void show_conditions();void show_actions();void show_targets();int pow(int a, int n);int main(){    // The array of results    int** arr = new int* [20];    for(int i=0; i<20; i++)        arr[i] = new int [20];    for(int i=0; i<20; i++)        for(int j=0; j<20; j++)            arr[i][j] = 0; // 0 by default                // The rest    FILE* output = fopen("output.sql", "wt"); // <- Change this path to save elsewhere.    if(!output)     {        printf("Warning: Unable to create output file. Check priviledges or modify the source code to select another location!\n");        getchar();    }else     {    char c = 0;    int textid = 0; // This takes care of localized_texts ID    int size = 0;        do        {            printf("\n#-#-#- Main Menu [%d] -#-#-#",size);            printf("\n| 1. Create new action");            printf("\n# 2. [NYI] Show already finished actions");            printf("\n# 3. Save & Exit");            switch(c = getch())            {                case '1':                    arr = create_new(arr,size,output, textid);                    break;                case '2':                    //show_finished(arr,size,output);                    break;                case '3':                    c = 27;                    break;                case 27 : // Esc - Quit                     break;                default : // Invalid key                    c = 0;                    printf("\n\nInvalid key.\n");                    getch();                    break;                                    }        }while(c!=27); // Esc to break and exit            printf("\n\n\n\n\n\nThank you. After pressing any key, the program will close,\nand the results will be saved in the specified destination.\n\n");    getch();    // Print on screen...    printf("\nREPLACE INTO `eventai_scripts` (id, creature_id, event_type, event_inverse_phase_mask, event_param1, event_param2, event_param3, action1_type, action1_param1, action1_param2, action1_param3, action2_type, action2_param1, action2_param2, action2_param3, action3_type, action3_param1, action3_param2, action3_param3, comment) VALUES");    for(int i=0; i<20; i++)        if(arr[i][0])        {            printf("\n(%d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d)",arr[i][0],arr[i][1],arr[i][2],arr[i][3],arr[i][4],arr[i][5],arr[i][6],arr[i][7],arr[i][8],arr[i][9],arr[i][10],arr[i][11],arr[i][12],arr[i][13],arr[i][14],arr[i][15],arr[i][16],arr[i][17],arr[i][18],arr[i][19]);            if((i==19) || !arr[i+1][0])                printf(";");            else                printf(",");        }    getch();        // ...and into the file specified in Line 32    if(textid)     {        fseek(output, -1, 2);        fprintf(output,";");    }            fprintf(output,"\n\nREPLACE INTO `eventai_scripts` (`id`, `creature_id`, `event_type`, `event_inverse_phase_mask`, `event_param1`, `event_param2`, `event_param3`, `action1_type`, `action1_param1`, `action1_param2`, `action1_param3`, `action2_type`, `action2_param1`, `action2_param2`, `action2_param3`, `action3_type`, `action3_param1`, `action3_param2`, `action3_param3`, `comment`) VALUES");    for(int i=0; i<20; i++)    if(arr[i][0])        {            fprintf(output,"\n('%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d')",arr[i][0],arr[i][1],arr[i][2],arr[i][3],arr[i][4],arr[i][5],arr[i][6],arr[i][7],arr[i][8],arr[i][9],arr[i][10],arr[i][11],arr[i][12],arr[i][13],arr[i][14],arr[i][15],arr[i][16],arr[i][17],arr[i][18],arr[i][19]);                        if((i==19) || !arr[i+1][0])                fprintf(output,";");            else                fprintf(output,",");        }        }    for(int i=0; i<20; i++) // Free memory        delete [] arr[i];    delete [] arr;    fclose(output);     return 0;}void show_conditions(){    printf("\n   0 = EVENT_T_TIMER_REPEAT       4 = EVENT_T_HP_SINGLE   8 = EVENT_T_DEATH");    printf("\n   1 = EVENT_T_TIMER_SINGLE       5 = EVENT_T_MANA        9 = EVENT_T_EVADE");    printf("\n   2 = EVENT_T_TIMER_OOC_REPEAT   6 = EVENT_T_AGGRO      10 = EVENT_T_SPELLHIT");    printf("\n   3 = EVENT_T_TIMER_OOC_SINGLE   7 = EVENT_T_KILL\n");    printf("\n             For more information on specific condition,");    printf("\n        visit http://wiki.udbforums.org/index.php/Event_AI   :  ");}void show_actions(){    printf("\n                 Choose an action:");    printf("\n   1 = ACTION_T_SAY                15 = ACTION_T_QUEST_COMPLETE");    printf("\n   2 = ACTION_T_YELL               16 = ACTION_T_CASTCREATUREGO");    printf("\n   3 = ACTION_T_TEXTEMOTE          17 = ACTION_T_SET_UNIT_FIELD");    printf("\n   4 = ACTION_T_SOUND              18 = ACTION_T_SET_UNIT_FLAG");    printf("\n   5 = ACTION_T_EMOTE              19 = ACTION_T_REMOVE_UNIT_FLAG");    printf("\n   6 = ACTION_T_RANDOM_SAY         20 = ACTION_T_AUTO_ATTACK");    printf("\n   7 = ACTION_T_RANDOM_YELL        21 = ACTION_T_COMBAT_MOVEMENT");    printf("\n   8 = ACTION_T_RANDOM_TEXTEMOTE   22 = ACTION_T_SET_PHASE");    printf("\n   9 = ACTION_T_RANDOM_SOUND       23 = ACTION_T_INC_PHASE");    printf("\n   10 = ACTION_T_RANDOM_EMOTE      24 = ACTION_T_EVADE");    printf("\n   11 = ACTION_T_CAST              25 = ACTION_T_FLEE");    printf("\n   12 = ACTION_T_SUMMON            26 = ACTION_T_QUEST_COMPLETE_ALL");    printf("\n   13 = ACTION_T_THREAT_SINGLE_PCT 27 = ACTION_T_CASTCREATUREGO_ALL");    printf("\n   14 = ACTION_T_THREAT_ALL_PCT\n");    printf("\n               For more information on specific action,");    printf("\n        visit http://wiki.udbforums.org/index.php/Event_AI   :  ");}void show_targets(){    printf("\n   0 = TARGET_T_SELF                    : self");    printf("\n   1 = TARGET_T_HOSTILE                 : current victim");    printf("\n   2 = TARGET_T_HOSTILE_SECOND_AGGRO    : 2nd on aggro list");    printf("\n   3 = TARGET_T_HOSTILE_LAST_AGGRO      : last on aggro list");    printf("\n   4 = TARGET_T_HOSTILE_RANDOM          : random target");    printf("\n   5 = TARGET_T_HOSTILE_RANDOM_NOT_TOP  : random non-tank");}int pow(int a, int n) // a^n{    int result = 1;    for(int i=0; i<n; i++)        result *= a;    return result;}void init_localized_texts(FILE* output){    fprintf(output,"REPLACE INTO `localized_texts` (id, locale_0, comment) VALUES");}int** create_new(int** arr, int &size, FILE* output, int &textid){    // This function creates a new entry.       // ** Creature Entry **    int x, x2, x3; // Temporary variables    printf("\n\n");    printf("\n 1.1 What is the creature ID?  :  ");    scanf("%d",&x);    arr[size][1] = x; // Save        // ** Conditions **    int condition;    printf("\n\n 1.2 Condition");    printf("\n");    show_conditions(); // Show the list of available conditions    scanf("%d",&condition);    while((condition < 0) || (condition > 10))    {        if(condition == -1)            show_conditions();        else            printf("\nError: Incorrect condition! ( Enter -1 to see condition list again ) : ");        scanf("%d",&condition);    }        int param1 = 0,  param2 = 0, param3 = 0; // Parameters    fflush(stdin);    switch(condition) // The funny part #1 : Conditions    {        case 0:            printf("\nEVENT_T_TIMER_REPEAT : Basic repeatable timed event - in combat");            printf("\n\n\n\nFirst time the event will happen after (miliseconds): \n");            scanf("%d", &param2);            printf("\n\n\n\nThe event will trigger every x to y miliseconds (x and y may be equal): \n");            scanf("%d%d", &param1, &x);            if(x > param1)                param3 = x - param1;            else            {                printf("\n\n\n\nChance (0-100) that event will occure: ");                scanf("%d", &param3);                if     (param3 > 100) param3 = 100;                else if(param3 < 0)   param3 = 0;                else    param3 *= -1; // Chance is stored as negative value            }            break;        case 1:             param3 = 0;            printf("\nEVENT_T_TIMER_SINGLE : Basic single timed event - in combat");            printf("\n\n\n\nThe event will happen after (miliseconds): \n");            scanf("%d", &param1);            if(param1 < 0) param1 = 0;            printf("\n\n\n\nChance (0-100) that event will occure: ");            scanf("%d", &param2);            if     (param2 > 100) param2 = 100;            else if(param2 < 0)   param2 = 0;            break;        case 2:            printf("\nEVENT_T_TIMER_OOC_REPEAT : Basic repeatable timed event - out of combat");            printf("\n\n\n\nFirst time the event will happen after (miliseconds): \n");            scanf("%d", &param2);            printf("\n\n\n\nThe event will trigger every X to Y miliseconds (X and Y may be equal!): \n");            scanf("%d%d", &param1, &x);            if(x > param1)                param3 = x - param1;            else            {                printf("\n\n\n\nChance (0-100) that event will occure: ");                scanf("%d", &param3);                if     (param3 > 100) param3 = 100;                else if(param3 < 0)   param3 = 0;                else    param3 *= -1; // Chance is stored as negative value            }            break;        case 3:            param3 = 0;            printf("\nEVENT_T_TIMER_OOC_SINGLE : Basic single timed event - out of combat");            printf("\n\n\n\nThe event will happen after (miliseconds): \n");            scanf("%d", &param1);            printf("\n\n\n\nChance (0-100) that event will occure: ");            scanf("%d", &param2);            break;        case 4:            printf("\nEVENT_T_HP_SINGLE : Single or repeatable event, triggering only if creature has given health");            printf("\n\n\n\nThe creature must have between X and Y mana (enter 2 values; 0-100) : \n");            scanf("%d%d", &param2, &param1);            if     (param1 > 100) param1 = 100;            else if(param1 < 0)   param1 = 0;            if     (param2 > 100) param2 = 100;            else if(param2 < 0)   param2 = 0;            if(param1 > param2)            {                x = param1;                param1 = param2;                param2 = x;            }            x = 0;            do            {                printf("\n\n\n\nDo you want the event to be repeatable? Y/N : ");                fflush(stdin);                x = getch();                if(x == 'y' || x == 'Y')                {                    printf("\n\n\nEnter interval between 2 of these events: \n");                    scanf("%d", &param3);                    if(param3 < 0) param3 = 0;                }else if(x == 'n' || x == 'N')                    param3 = 0;            }while(x != 'y' && x != 'Y' && x != 'n' && x != 'N');            break;        case 5:            printf("\nEVENT_T_MANA : Single or repeatable event, triggering only if creature has given mana");            printf("\n\n\n\nThe creature must have between X and Y percent mana (enter 2 values; 0-100) : \n");            scanf("%d%d", &param2, &param1);            if     (param1 > 100) param1 = 100;            else if(param1 < 0)   param1 = 0;            if     (param2 > 100) param2 = 100;            else if(param2 < 0)   param2 = 0;            if(param1 > param2)            {                x = param1;                param1 = param2;                param2 = x;            }            x = 0;            do            {                printf("\n\n\n\nDo you want the event to be repeatable? Y/N : ");                fflush(stdin);                x = getch();                if(x == 'y' || x == 'Y')                {                    printf("\n\n\nEnter interval between 2 of these events: \n");                    scanf("%d", &param3);                    if(param3 < 0) param3 = 0;                }else if(x == 'n' || x == 'N')                    param3 = 0;            }while(x != 'y' && x != 'Y' && x != 'n' && x != 'N');            break;        case 6:            printf("\nEVENT_T_AGGRO : Happens the moment creature aggroes");            param2 = 0;            param3 = 0;            printf("\n\n\n\nEnter the chance this even will occur (0-100) : \n");            scanf("%d",&param1);            if     (param1 > 100) param1 = 100;            else if(param1 < 0)   param1 = 0;            break;        case 7:            printf("\nEVENT_T_KILL : Is triggered when the creature kills something (or someone)");            x = 0;            do            {                printf("\n\n\n\nShould the event have 'cooldown'? (Prevents ie. spamming yells) Y/N : ");                fflush(stdin);                x = getch();                if(x == 'y' || x == 'Y')                {                    printf("\n\n\nEnter interval between 2 of these events: \n");                    scanf("%d", &param1);                    if(param1 < 0) param1 = 0;                }else if(x == 'n' || x == 'N')                    param1 = 0;            }while(x != 'y' && x != 'Y' && x != 'n' && x != 'N');            printf("\n\n\n\nEnter the chance this even will occur (0-100) : \n");            scanf("%d",&param2);            if     (param2 > 100) param2 = 100;            else if(param2 < 0)   param2 = 0;            break;        case 8:            printf("\nEVENT_T_DEATH : Is triggered when the creature dies");            param2 = 0;            param3 = 0;            printf("\n\n\n\nEnter the chance this even will occur (0-100) : \n");            scanf("%d",&param1);            if     (param1 > 100) param1 = 100;            else if(param1 < 0)   param1 = 0;            break;        case 9:            printf("\nEVENT_T_EVADE : Is triggered when the creature enters evade mode (or respawns)");            param2 = 0;            param3 = 0;            printf("\n\n\n\nEnter the chance this even will occur (0-100) : \n");            scanf("%d",&param1);            if     (param1 > 100) param1 = 100;            else if(param1 < 0)   param1 = 0;            break;        case 10:            printf("\nEVENT_T_SPELLHIT : Is triggered when the creature is hit by spell. Can be single or repeatable");            printf("\n\n\n\nEnter either a spell ID if you want this to be specific,\nor 0 to trigger at ANY spell hit : \n");            scanf("%d",&param1);             if(param1 < 0) param1 = 0;            x = 0;            do            {                printf("\n\n\n\nDo you want the event to have 'cooldown'?  Y/N\n(It won't trigger again before the given time passes)\n");                fflush(stdin);                x = getch();                if(x == 'y' || x == 'Y')                {                    printf("\n\n\nEnter interval between 2 of these events: \n");                    scanf("%d", &param2);                    if(param2 < 0) param2 = 0;                }else if(x == 'n' || x == 'N')                    param2 = 0;            }while(x != 'y' && x != 'Y' && x != 'n' && x != 'N');            printf("\n\n\n\nEnter the chance this even will occur (0-100) : \n");            scanf("%d",&param3);            if     (param3 > 100) param3 = 100;            else if(param3 < 0)   param3 = 0;            break;    }        // Conditions read; save the results    arr[size][2] = condition;    arr[size][4] = param1;    arr[size][5] = param2;    arr[size][6] = param3;        x = 0;    do    {        printf("\n\n\nDoes your event use different phases? Y/N : ");        fflush(stdin);        x = getch();        if(x == 'y' || x == 'Y')        {            printf("\n\n\nEnter number of phases your script uses (1 - 32) :\n");            scanf("%d", &x2);            if      (x2 < 1)  x2 =  1;            else if (x2 > 32) x2 = 32;                        if (x2 > 1)            {                int phase[32] = {0};                arr[size][3] = 0; // event_inverse_phase_mask                printf("\n");                for(int i=0; i<x2; i++)                {                    do                    {                        printf("Should your event happen in phase %d ? Y/N\n",i+1);                        fflush(stdin);                        x3 = getch();                    }while(x3 != 'y' && x3 != 'Y' && x3 != 'n' && x3 != 'N');                    if(x3 == 'y' || x3 == 'Y')                        phase[31-i] = 0;                    else                         phase[31-i] = 1;                                        arr[size][3] += phase[31-i]*pow(2,i);                }            }        }    }while(x != 'y' && x != 'Y' && x != 'n' && x != 'N');        printf("\n\n\nCondition set successfully! Now specify what actions should be taken.\n        Press any key...\n\n\n");    getch();        // ** Actions **    int action_count = 0;    int action_chosen;    printf("\n\n 1.3 Actions");    printf("\n\n");    while(action_count < 3)    {        show_actions(); // Show the list of available conditions        scanf("%d",&action_chosen);        while((action_chosen < 1) || (action_chosen > 27))        {            if(action_chosen == -1)                show_actions();            else                printf("\nError: Incorrect action! ( Enter -1 to see action list again ) : ");            scanf("%d",&action_chosen);        }            param1 = 0;        param2 = 0;        param3 = 0;        char str[2048];        switch(action_chosen) // The funny part #2 : Actions        {            case 1:                printf("\nACTION_T_SAY : Creature will say something - recommended for talkative creatures");                printf("\n\n\n\nEnter the text to be said : \n");                fflush(stdin);                gets(str);                if(!textid) init_localized_texts(output);                textid++;                param1 = arr[size][1]*100+textid;                fprintf(output,"\n('%d', '",param1);                fputs(str,output);                fprintf(output,"', 'Creature %d - say'),",arr[size][1]);                break;            case 2:                printf("\nACTION_T_YELL : Creature will yell something");                printf("\n\n\n\nEnter the text to be yelled : \n");                fflush(stdin);                gets(str);                if(!textid) init_localized_texts(output);                textid++;                param1 = arr[size][1]*100+textid;                fprintf(output,"\n('%d', '",param1);                fputs(str,output);                fprintf(output,"', 'Creature %d - yell'),",arr[size][1]);                break;            case 3:                printf("\nACTION_T_TEXTEMOTE : Creature will do a text emote");                printf("\n\n\n\nEnter the text to be emoted : \n");                fflush(stdin);                gets(str);                                if(!textid) init_localized_texts(output);                textid++;                param1 = arr[size][1]*100+textid;                fprintf(output,"\n('%d', '",param1);                fputs(str,output);                fprintf(output,"', 'Creature %d - text emote'),",arr[size][1]);                break;            case 4:                printf("\nACTION_T_SOUND : A sound will be played");                printf("\n\n\n\nEnter ID of the sound to be played : \n");                scanf("%d", &param1);                if(param1 < 0) param1 = 0;                break;            case 5:                printf("\nACTION_T_EMOTE : Creature will do an emote (gesture, not text)");                printf("\n\n\n\nEnter ID of the emote : \n");                scanf("%d", &param1);                if(param1 < 0) param1 = 0;                break;            case 6:                printf("\nACTION_T_RANDOM_SAY : Creature will choose one of 3 possible phrases to say");                printf("\n\n\n\nEnter #1 text to be said : \n");                fflush(stdin);                gets(str);                                if(!textid) init_localized_texts(output);                textid++;                param1 = arr[size][1]*100+textid;                fprintf(output,"\n('%d', '",param1);                fputs(str,output);                fprintf(output,"', 'Creature %d - random say (option 1)'),",arr[size][1]);                x = 0;                do                {                    printf("\n\n\n\nDo you to enter a second text? (random one of two) Y/N");                    fflush(stdin);                    x = getch();                    if(x == 'y' || x == 'Y')                    {                        printf("\nEnter it: ");                        fflush(stdin);                        gets(str);                                                textid++;                        param2 = param1+1;                        fprintf(output,"\n('%d', '",param2);                        fputs(str,output);                        fprintf(output,"', 'Creature %d - random say (option 2)'),",arr[size][1]);                    }else if(x == 'n' || x == 'N')                        param2 = -1;                }while(x != 'y' && x != 'Y' && x != 'n' && x != 'N');                x = 0;                if(param2 != -1)                do                {                    printf("\n\n\n\nDo you to enter a third text? (random one of three) Y/N");                    fflush(stdin);                    x = getch();                    if(x == 'y' || x == 'Y')                    {                        printf("\nEnter it: ");                        fflush(stdin);                        gets(str);                                                textid++;                        param3 = param2+1;                        fprintf(output,"\n('%d', '",param3);                        fputs(str,output);                        fprintf(output,"', 'Creature %d - random say (option 3)'),",arr[size][1]);                    }else if(x == 'n' || x == 'N')                        param3 = -1;                }while(x != 'y' && x != 'Y' && x != 'n' && x != 'N');                if(param1 < 0) param1 = -1;                if(param2 < 0) param2 = -1;                if(param3 < 0) param3 = -1;                break;            case 7:                printf("\nACTION_T_RANDOM_YELL : Creature will choose one of 3 possible phrases to yell");                printf("\n\n\n\nEnter #1 text to be yelled : \n");                fflush(stdin);                gets(str);                                if(!textid) init_localized_texts(output);                textid++;                param1 = arr[size][1]*100+textid;                fprintf(output,"\n('%d', '",param1);                fputs(str,output);                fprintf(output,"', 'Creature %d - random yell (option 1)'),",arr[size][1]);                x = 0;                do                {                    printf("\n\n\n\nDo you to enter a second text? (random one of two) Y/N");                    fflush(stdin);                    x = getch();                    if(x == 'y' || x == 'Y')                    {                        printf("\nEnter it: ");                        fflush(stdin);                        gets(str);                                                textid++;                        param2 = param1+1;                        fprintf(output,"\n('%d', '",param2);                        fputs(str,output);                        fprintf(output,"', 'Creature %d - random yell (option 2)'),",arr[size][1]);                    }else if(x == 'n' || x == 'N')                        param2 = -1;                }while(x != 'y' && x != 'Y' && x != 'n' && x != 'N');                x = 0;                if(param2 != -1)                do                {                    printf("\n\n\n\nDo you to enter a third text? (random one of three) Y/N");                    fflush(stdin);                    x = getch();                    if(x == 'y' || x == 'Y')                    {                        printf("\nEnter it: ");                        fflush(stdin);                        gets(str);                                                textid++;                        param3 = param2+1;                        fprintf(output,"\n('%d', '",param3);                        fputs(str,output);                        fprintf(output,"', 'Creature %d - random yell (option 3)'),",arr[size][1]);                    }else if(x == 'n' || x == 'N')                        param3 = -1;                }while(x != 'y' && x != 'Y' && x != 'n' && x != 'N');                if(param1 < 0) param1 = -1;                if(param2 < 0) param2 = -1;                if(param3 < 0) param3 = -1;                break;            case 8:                printf("\nACTION_T_RANDOM_TEXTEMOTE : Creature will choose one of 3 possible phrases to emote");                printf("\n\n\n\nEnter #1 text to be emoted : \n");                fflush(stdin);                gets(str);                                if(!textid) init_localized_texts(output);                textid++;                param1 = arr[size][1]*100+textid;                fprintf(output,"\n('%d', '",param1);                fputs(str,output);                fprintf(output,"', 'Creature %d - random text emote (option 1)'),",arr[size][1]);                x = 0;                do                {                    printf("\n\n\n\nDo you to enter a second text? (random one of two) Y/N");                    fflush(stdin);                    x = getch();                    if(x == 'y' || x == 'Y')                    {                        printf("\nEnter it: ");                        fflush(stdin);                        gets(str);                                                textid++;                        param2 = param1+1;                        fprintf(output,"\n('%d', '",param2);                        fputs(str,output);                        fprintf(output,"', 'Creature %d - random text emote (option 2)'),",arr[size][1]);                    }else if(x == 'n' || x == 'N')                        param2 = -1;                }while(x != 'y' && x != 'Y' && x != 'n' && x != 'N');                x = 0;                if(param2 != -1)                do                {                    printf("\n\n\n\nDo you to enter a third text? (random one of three) Y/N");                    fflush(stdin);                    x = getch();                    if(x == 'y' || x == 'Y')                    {                        printf("\nEnter it: ");                        fflush(stdin);                        gets(str);                                                textid++;                        param3 = param2+1;                        fprintf(output,"\n('%d', '",param3);                        fputs(str,output);                        fprintf(output,"', 'Creature %d - random text emote (option 3)'),",arr[size][1]);                    }else if(x == 'n' || x == 'N')                        param3 = -1;                }while(x != 'y' && x != 'Y' && x != 'n' && x != 'N');                if(param1 < 0) param1 = -1;                if(param2 < 0) param2 = -1;                if(param3 < 0) param3 = -1;                break;            case 9:                printf("\nACTION_T_RANDOM_SAY : Creature will choose one of 3 possible sounds to play");                printf("\n\n\n\nEnter ID #1 of the first sound to be played : \n");                scanf("%d", &param1);                printf("\n\n\n\nEnter ID #2 of the second sound to be played (or -1 to do nothing) : \n");                scanf("%d", &param2);                printf("\n\n\n\nEnter ID #3 of the third sound to be played (or -1 to do nothing) : \n");                scanf("%d", &param3);                if(param1 < 0) param1 = -1;                if(param2 < 0) param2 = -1;                if(param3 < 0) param3 = -1;                break;            case 10:                printf("\nACTION_T_RANDOM_EMOTE : Creature will choose one of 3 possible emotes to perform");                printf("\n\n\n\nEnter ID #1 of the first emote to be performed : \n");                scanf("%d", &param1);                printf("\n\n\n\nEnter ID #2 of the second emote to be performed (or -1 to do nothing) : \n");                scanf("%d", &param2);                printf("\n\n\n\nEnter ID #3 of the third emote to be performed (or -1 to do nothing) : \n");                scanf("%d", &param3);                if(param1 < 0) param1 = -1;                if(param2 < 0) param2 = -1;                if(param3 < 0) param3 = -1;                break;            case 11:                printf("\nACTION_T_CAST : Creature will cast a spell of given ID on a given target");                printf("\n\n\n\nEnter a valid ID of the spell to be cast : \n");                scanf("%d", &param1);                if(param1 < 0) param1 = 0;                printf("\n\n\n\nEnter target type - list of target types:");                show_targets();                printf("\n   ");                scanf("%d", &param2);                if(param2 < 0 || param2 > 5) param2 = 0;                x = 0;                do                {                    printf("\n\n\n\nDo you want the spellcast to be triggered? (Executed no matter what) Y/N \n");                    fflush(stdin);                    x = getch();                    if(x == 'y' || x == 'Y')                        param3 = 1;                    else if(x == 'n' || x == 'N')                        param3 = 0;                }while(x != 'y' && x != 'Y' && x != 'n' && x != 'N');                break;            case 12:                printf("\nACTION_T_SUMMON : Creature will summon another creature");                printf("\n\n\n\nEnter a valid ID of the creature to summon : \n");                scanf("%d", &param1);                if(param1 < 0) param1 = 0;                printf("\n\n\n\nEnter target type - list of target types:");                show_targets();                printf("\n-- Choosing 0 has no effect; creature won't attack self --   ");                scanf("%d", &param2);                if(param2 < 0 || param2 > 5) param2 = 0;                printf("\n\n\n\nEnter the duration of the summoned creature (miliseconds):\n(or 0 to despawn it when out of combat)\n");                scanf("%d", &param3);                if(param3 < 0) param3 = 0;                break;            case 13:                printf("\nACTION_T_THREAT_SINGLE_PCT : Modify threat for single target (add or substract)");                printf("\n\n\n\nPercent value that will be added/substracted to/from target (-100 to 100) :\n");                scanf("%d", &param1);                if      (param1 < -100) param1 = -100;                else if (param1 >  100) param1 =  100;                printf("\n\n\n\nEnter target type - list of target types:");                show_targets();                scanf("%d", &param2);                if(param2 < 0 || param2 > 5) param2 = 0;                break;            case 14:                printf("\nACTION_T_THREAT_ALL_PCT : Modify threat for entire threatlist - add or substract");                printf("\n\n\n\nEnter percent value that will be added/substracted (-100 to 100) :\n");                printf("\nTip: -100 will cause the creature to `reset aggro`, but not enter evade mode.\n     Everyone in the threatlist will have 0 threat after this\n");                scanf("%d", &param1);                if      (param1 < -100) param1 = -100;                else if (param1 >  100) param1 =  100;                break;            case 15:                printf("\nACTION_T_QUEST_COMPLETE : Will set the quest to 'complete' for a PLAYER target\n");                printf("\n\n\n\nEnter quest template ID of the quest to be completed :\n   (Quest should have SpecialFlags set to 2)\n");                scanf("%d", &param1);                if(param1 < 0) param1 = 0;                printf("\n\n\n\nEnter target type - list of target types:");                show_targets();                printf("\n          Make sure you point a PLAYER   :  ");                scanf("%d", &param2);                if(param2 < 0 || param2 > 5) param2 = 1;                break;            case 16:                printf("\nACTION_T_CASTCREATUREGO : Used to update a quest objective for a PLAYER target\n                          As if (s)he casted a spell of given ID on that target\n");                printf("\n\n\n\nEnter quest template ID of the quest to be updated\n");                scanf("%d", &param1);                if(param1 < 0) param1 = 0;                printf("\n\n\n\nEnter a valid spell ID to use to `simulate` the cast\n");                scanf("%d", &param2);                if(param2 < 0) param2 = 0;                printf("\n\n\n\nEnter target type - list of target types:");                show_targets();                printf("\n          Make sure you point a PLAYER   :  ");                scanf("%d", &param3);                if(param3 < 0 || param3 > 5) param3 = 1;                break;            case 17:                printf("\nACTION_T_SET_UNIT_FIELD : Sets a given unit field to a different value\n");                printf("\n\n\n\nEnter the index of the field to be changed : \nNote: List can be found at http://wiki.udbforums.org/index.php/Character_data\nThose beginning with PLAYER_* are used only for players, not for creatures\n");                                scanf("%d", &param1);                if(param1 < 0) param1 = 0;                printf("\n\n\n\nEnter the new value to be put in that field : \n");                scanf("%d", &param2);                  printf("\n\n\n\nEnter target type - list of target types:");                show_targets();                printf("\n   ");                scanf("%d", &param3);                if(param3 < 0 || param3 > 5) param3 = 0;                                break;            case 18:                printf("\nACTION_T_SET_UNIT_FLAG : Add flags to a unit\n");                printf("\n\n\n\nEnter flag(s) to be set. Multiple flags can be set\n by using bitwise-OR on them (adding them together) : \n");                scanf("%d", &param1);                if(param1 < 0) param1 = 0;                printf("\n\n\n\nEnter target type - list of target types:");                show_targets();                printf("\n   ");                scanf("%d", &param2);                if(param2 < 0 || param2 > 5) param2 = 0;                break;            case 19:                printf("\nACTION_T_REMOVE_UNIT_FLAG : Removes flags from a unit\n");                printf("\n\n\n\nEnter flag(s) to be removed. Multiple flags can be removed\n by using bitwise-OR on them (adding them together) : \n");                scanf("%d", &param1);                if(param1 < 0) param1 = 0;                printf("\n\n\n\nEnter target type - list of target types:");                show_targets();                printf("\n   ");                scanf("%d", &param2);                if(param2 < 0 || param2 > 5) param2 = 0;                break;            case 20:                printf("\nACTION_T_AUTO_ATTACK : Makes creature start/stop melee attacking it's current target\n");                printf("\n\n\n\nEnter 0 to cease attacking, or non-zero to resume attacking : \n");                scanf("%d", &param1);                if(!param1) param1 = 1;                break;            case 21:                printf("\nACTION_T_COMBAT_MOVEMENT : Makes creature start/stop following it's current target\n");                printf("\n\n\n\nEnter 0 to root creature in place, or non-zero to resume following : \n");                scanf("%d", &param1);                if(!param1) param1 = 1;                break;            case 22:                printf("\nACTION_T_SET_PHASE : Sets creature's phase to a given value\n");                printf("\n\n\n\nEnter a new phase: (0-31) : \n");                scanf("%d", &param1);                if      (param1 <  0) param1 =  0;                else if (param1 > 31) param1 = 31;                break;            case 23:                printf("\nACTION_T_SET_PHASE : Sets creature's phase to a given value\n");                printf("\n\n\n\nEnter the number of phases to increase or decrease (Remember that phase must stay in 0-31 range) : \n");                scanf("%d", &param1);                break;            case 24:                printf("\nACTION_T_EVADE : Creature enters evade mode and resets itself\n");                break;            case 25:                printf("\nACTION_T_FLEE : Creature stats fleeing (ie. casts `Run Away` on itself)\n");                break;            case 26:                printf("\nACTION_T_QUEST_COMPLETE : Will set the quest to 'complete' for a PLAYER target\n                          ** This affects entire creature's threatlist! **");                printf("\n\n\n\nEnter a valid ID of the quest to complete for entire threatlist : \n");                scanf("%d", &param1);                if(param1 < 0) param1 = 0;                break;            case 27:                printf("\nACTION_T_CASTCREATUREGO : Used to update a quest objective for a PLAYER target\n                          As if (s)he casted a spell of given ID on that target\n                          ** This affects entire creature's threatlist! **");                printf("\n\n\n\nEnter quest template ID of the quest to be updated\n");                scanf("%d", &param1);                if(param1 < 0) param1 = 0;                printf("\n\n\n\nEnter a valid spell ID to use to `simulate` the cast\n");                scanf("%d", &param2);                if(param2 < 0) param2 = 0;                break;            default:                break;        }        if(action_chosen > 0 && action_chosen < 28) arr[size][7+(action_count*4)] = action_chosen; // 7, 11 and 15 are "action1_type" , "action2_type" and "action3_type"        if(param1) arr[size][8+(action_count*4)] = param1;        if(param2) arr[size][9+(action_count*4)] = param2;        if(param3) arr[size][10+(action_count*4)] = param3;                printf("\nAction saved successfully!\n");        getch();                if(action_count<2) // This basically takes care so that it won't go out of range        {            printf("\nAnother action? (Already %d action(s)) Y/N",action_count+1);            fflush(stdin);            if((x=getch())!='y')                action_count = 3;            else action_count++;        }        else action_count = 3; // Quit    }    arr[size][0] = arr[size][1]*100+size+1;    size++;        return arr;}