Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const int NPCM_HISTORY_PTR = 15;
- const int NPC_HISTORY_ROLLS = 23;
- 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 rolls;
- 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, 0 };
- 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 ) {
- history_ptrs[NPC_HISTORY_ROLLS] = 1; //we only need to know if it has ever rolled.
- history_index = 0;
- }
- //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 rolls = ptr[NPC_HISTORY_ROLLS];
- int q; int end_index = ptr[0];
- int fcount;
- int subptr;
- if (!rolls ) {
- for ( q = end_index, q >= 0 ; q-- ) {
- if ( fcount >= frames ) break;
- subptr = ptr[1];
- n->X = subptr[q];
- subptr = ptr[2];
- n->Y = subptr[q];
- subptr = ptr[3];
- n->Z = subptr[q];
- subptr = ptr[4];
- n->Jump = subptr[q];
- subptr = ptr[5];
- n->Dir = subptr[q];
- subptr = ptr[6];
- n->Misc[1] = subptr[q];
- subptr = ptr[7];
- n->Misc[2] = subptr[q];
- subptr = ptr[8];
- n->Misc[3] = subptr[q];
- subptr = ptr[9];
- n->Misc[4] =subptr[q];
- subptr = ptr[10];
- n->Misc[5] = subptr[q];
- subptr = ptr[11];
- n->Misc[6] = subptr[q];
- subptr = ptr[12];
- n->Misc[7] = subptr[q];
- subptr = ptr[13];
- n->Misc[8] = subptr[q];
- subptr = ptr[14];
- n->Misc[9] = subptr[q];
- subptr = ptr[15];
- n->Misc[10] = subptr[q];
- subptr = ptr[16];
- n->Misc[11] = subptr[q];
- subptr = ptr[17];
- n->Misc[12] = subptr[q];;
- subptr = ptr[18];
- n->Misc[13] = subptr[q];
- subptr = ptr[19];
- n->Misc[14] = subptr[q];
- subptr = ptr[20];
- n->Misc[15] = subptr[q];
- fcount++;
- Waitframe();
- }
- }
- if ( rolls ) {
- for ( q = end_index, q >= 0 ; q-- ) {
- if ( fcount >= frames ) break;
- subptr = ptr[1];
- n->X = subptr[q];
- subptr = ptr[2];
- n->Y = subptr[q];
- subptr = ptr[3];
- n->Z = subptr[q];
- subptr = ptr[4];
- n->Jump = subptr[q];
- subptr = ptr[5];
- n->Dir = subptr[q];
- subptr = ptr[6];
- n->Misc[1] = subptr[q];
- subptr = ptr[7];
- n->Misc[2] = subptr[q];
- subptr = ptr[8];
- n->Misc[3] = subptr[q];
- subptr = ptr[9];
- n->Misc[4] =subptr[q];
- subptr = ptr[10];
- n->Misc[5] = subptr[q];
- subptr = ptr[11];
- n->Misc[6] = subptr[q];
- subptr = ptr[12];
- n->Misc[7] = subptr[q];
- subptr = ptr[13];
- n->Misc[8] = subptr[q];
- subptr = ptr[14];
- n->Misc[9] = subptr[q];
- subptr = ptr[15];
- n->Misc[10] = subptr[q];
- subptr = ptr[16];
- n->Misc[11] = subptr[q];
- subptr = ptr[17];
- n->Misc[12] = subptr[q];;
- subptr = ptr[18];
- n->Misc[13] = subptr[q];
- subptr = ptr[19];
- n->Misc[14] = subptr[q];
- subptr = ptr[20];
- n->Misc[15] = subptr[q];
- fcount++;
- Waitframe();
- }
- for ( q = 599; q < end_index; q-- ) {
- if ( fcount >= frames ) break;
- subptr = ptr[1];
- n->X = subptr[q];
- subptr = ptr[2];
- n->Y = subptr[q];
- subptr = ptr[3];
- n->Z = subptr[q];
- subptr = ptr[4];
- n->Jump = subptr[q];
- subptr = ptr[5];
- n->Dir = subptr[q];
- subptr = ptr[6];
- n->Misc[1] = subptr[q];
- subptr = ptr[7];
- n->Misc[2] = subptr[q];
- subptr = ptr[8];
- n->Misc[3] = subptr[q];
- subptr = ptr[9];
- n->Misc[4] =subptr[q];
- subptr = ptr[10];
- n->Misc[5] = subptr[q];
- subptr = ptr[11];
- n->Misc[6] = subptr[q];
- subptr = ptr[12];
- n->Misc[7] = subptr[q];
- subptr = ptr[13];
- n->Misc[8] = subptr[q];
- subptr = ptr[14];
- n->Misc[9] = subptr[q];
- subptr = ptr[15];
- n->Misc[10] = subptr[q];
- subptr = ptr[16];
- n->Misc[11] = subptr[q];
- subptr = ptr[17];
- n->Misc[12] = subptr[q];;
- subptr = ptr[18];
- n->Misc[13] = subptr[q];
- subptr = ptr[19];
- n->Misc[14] = subptr[q];
- subptr = ptr[20];
- n->Misc[15] = subptr[q];
- fcount++;
- Waitframe();
- }
- }
- ptr[0] = q;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement