/* * 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 #include #include void mmenu(int** arr); int** create_new(int** arr, int &size); void show_conditions(); int main() { // Initialization of the array. I KNOW IT SHOULDN'T LOOK LIKE THAT BUT OH NEVER MIND. 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; // The rest char c; FILE* output = fopen("C://output.txt", "wt"); if(!output) { printf("Warning: Unable to create output file. Check priviledges or modify the source code to select another location!\n"); getchar(); }else { mmenu(arr); } fclose(output); return 0; } void mmenu(int** arr) // Main Menu { char c = 0; int size = 0; do // Esc to break { printf("\n#-#-#- Main Menu [%d] -#-#-#",size); printf("\n| 1. Create new action"); printf("\n# 2. Show already finished actions"); printf("\n| 3. Show statistics"); printf("\n# 4. Save & Exit"); switch(c = getch()) { case '1': arr = create_new(arr,size); break; case '2': //show_finished(); break; case '3': //show_stats(); break; case '4': //savenexit(); break; case 27 : // Esc - Quit break; default : // Invalid key c = 0; printf("\n\nInvalid key.\n"); getch(); break; } }while(c!=27); } 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 : "); } int** create_new(int** arr, int &size) { // This function creates a new entry. // ** Creature Entry ** int x; 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 switch(condition) // The funny part #1 : Conditions { case 0: printf("\nEVENT_T_TIMER_REPEAT : Basic repeatable timed event"); printf("\nFirst time the event will happen after (miliseconds): "); scanf("%d", ¶m2); printf("The event will trigger every x to y miliseconds (x and y may be equal): "); scanf("%d%d", ¶m1, &x); if(x > param1) param3 = x - param1; else { printf("Chance (0-100) that event will occure: "); scanf("%d", ¶m3); if (param3 > 100) param3 = 100; else if(param3 < 0) param3 = 0; else param3 *= -1; // Chance is stored as negative value } break; case 1: // TODO: all the rest break; case 2: break; case 3: break; case 4: break; case 5: break; case 6: break; case 7: break; case 8: break; case 9: break; case 10: break; } // Conditions read; save the results arr[size][2] = condition; arr[size][4] = param1; arr[size][5] = param2; arr[size][6] = param3; printf("\n\nCondition set, now specify what actions should happen.\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) || (condition > 27)) { if(condition == -1) show_actions(); else printf("\nError: Incorrect action! ( Enter -1 to see action list again ) : "); scanf("%d",&action_chosen); } // Gather information about actions param1 = 0; param2 = 0; param3 = 0; switch(action_chosen) // The funny part #2 : Actions { /* case 1: // TODO: ... break; case 2: break; case 3: break; case 4: break; case 5: break; case 6: break; case 7: break; case 8: break; case 9: break; case 10: break; case 11: break; case 12: break; case 13: break; case 14: break; case 15: break; case 16: break; case 17: break; case 18: break; case 19: break; case 20: break; case 21: break; case 22: break; case 23: break; case 24: break; case 25: break; case 26: break; case 27: break; */ default: printf("Enter param1, 2 and 3: "); scanf("%d%d%d", ¶m1, ¶m2, ¶m3); 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); if((x=getch())!='y') action_count = 3; else action_count++; } else action_count = 3; // Quit } arr[size][0] = size+1; size++; printf("\nINSERT 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]); getch(); return arr; }