Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const int NPCM_HISTORY_PTR = 15;
- npc script foo{
- void run(){
- int history_index = -1;
- int hp_history[600];
- int x_history[600];
- int y_history[600];
- int z_history[600];
- int jump_history[600];
- int dir_history[600];
- int misc_00_history[600];
- int misc_01_history[600];
- int misc_02_history[600];
- int misc_03_history[600];
- int misc_04_history[600];
- int misc_05_history[600];
- int misc_06_history[600];
- int misc_07_history[600];
- int misc_08_history[600];
- int misc_09_history[600];
- int misc_10_history[600];
- int misc_11_history[600];
- int misc_12_history[600];
- int misc_13_history[600];
- int misc_14_history[600];
- int misc_15_history[600];
- int history_ptrs[]={history_index, hp_history, x_history, y_history, z_history,
- jump_history, dir_history, misc_00_history, misc_01_history,
- misc_02_history, misc_03_history, misc_04_history, misc_05_history,
- misc_06_history, misc_07_history, misc_08_history, misc_09_history,
- misc_10_history, misc_11_history, misc_12_history, misc_13_history,
- misc_14_history, misc_15_history };
- int Q[16]; int tempptr;
- npc n = Screen->CreateNPC(foo); //Replace with ghost creation
- n->Misc[NPCM_HISTORY_PTR] = history_ptrs; //Store the pointer for external use.
- while(true){
- //update the history every frame
- if ( history_index < 599 ) history_index++;
- if ( history_index == 599 ) {
- //Shift walues downward.
- //here is where slowdown could occur.
- for ( Q[0] = SizeOfArray(history_ptrs); Q[0] > 0; Q[0]-- ) {
- tempptr = history_ptrs[Q[0]];
- for ( Q[1] = 599; Q[1] > 0; Q[1]-- ) {
- tempptr[Q[1]-1] = tempptr[Q[1]];
- }
- }
- }
- hp_history[history_index] = n->HP;
- x_history[history_index] = n->X;
- y_history[history_index] = n->Y;
- z_history[history_index] = n->Z;
- jump_history[history_index] = n->Jump;
- dir_history[history_index] = n->Dir;
- misc_00_history[history_index] = n->Misc[0];
- misc_01_history[history_index] = n->Misc[1];
- misc_02_history[history_index] = n->Misc[2];
- misc_03_history[history_index] = n->Misc[3];
- misc_04_history[history_index] = n->Misc[4];
- misc_05_history[history_index] = n->Misc[5];
- misc_06_history[history_index] = n->Misc[6];
- misc_07_history[history_index] = n->Misc[7];
- misc_08_history[history_index] = n->Misc[8];
- misc_09_history[history_index] = n->Misc[9];
- misc_10_history[history_index] = n->Misc[10];
- misc_11_history[history_index] = n->Misc[11];
- misc_12_history[history_index] = n->Misc[12];
- misc_13_history[history_index] = n->Misc[13];
- misc_14_history[history_index] = n->Misc[14];
- misc_15_history[history_index] = n->Misc[15];
- //NPC code
- Waitframe();
- }
- }
- void Rewind(int frames, npc n){
- int ptr = n->Misc[NPCM_HISTORY_PTR];
- int q; int end_index = ptr[0];
- int fcount = (end_index - frames);
- fcount = VBound(fcount, 0, 600);
- for ( q = end_index, q > fcount ; q-- ) { //This may be right.
- n->X = ptr[1[q]];
- n->Y = ptr[2[q]];
- n->Z = ptr[3[q]];
- n->Jump = ptr[4[q]];
- n->Dir = ptr[5[q]];
- n->Misc[1] = ptr[6[q]];
- n->Misc[2] = ptr[7[q]];
- n->Misc[3] = ptr[8[q]];
- n->Misc[4] = ptr[9[q]];
- n->Misc[5] = ptr[10[q]];
- n->Misc[6] = ptr[11[q]];
- n->Misc[7] = ptr[12[q]];
- n->Misc[8] = ptr[13[q]];
- n->Misc[9] = ptr[14[q]];
- n->Misc[10] = ptr[15[q]];
- n->Misc[11] = ptr[16[q]];
- n->Misc[12] = ptr[17[q]];
- n->Misc[13] = ptr[18[q]];
- n->Misc[14] = ptr[19[q]];
- n->Misc[15] = ptr[20[q]];
- Waitframe();
- }
- ptr[0] = q;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement