From 76cb652d08822dcf84e61f9711e9bef36f6f43b1 Mon Sep 17 00:00:00 2001 From: Malik <31506138+msmalik681@users.noreply.github.com> Date: Wed, 6 Jun 2018 15:07:56 +0100 Subject: [PATCH] Fixed the issue with PSP display modes. --- engine/openbor.c | 3920 ++++++++++++++++++++--------------------- engine/psp/graphics.c | 9 +- 2 files changed, 1965 insertions(+), 1964 deletions(-) diff --git a/engine/openbor.c b/engine/openbor.c index ca2389b6a..3eba788b5 100644 --- a/engine/openbor.c +++ b/engine/openbor.c @@ -64,9 +64,9 @@ List *modelstxtcmdlist = NULL; List *levelcmdlist = NULL; List *levelordercmdlist = NULL; -int atkchoices[MAX_ANIS]; //tempory values for ai functions, should be well enough LOL - -#ifdef ANDROID +int atkchoices[MAX_ANIS]; //tempory values for ai functions, should be well enough LOL + +#ifdef ANDROID int touch_default_keys[MAX_BTN_NUM]; #endif @@ -147,7 +147,7 @@ const s_collision_attack emptyattack = .blocksound = -1, .coords = NULL, .counterattack = 0, - .damage_on_landing.attack_force = 0, + .damage_on_landing.attack_force = 0, .damage_on_landing.attack_type = ATK_NONE, .dropv = { .x = 0, .y = 0, @@ -707,9 +707,9 @@ s_playercontrols playercontrols1; s_playercontrols playercontrols2; s_playercontrols playercontrols3; s_playercontrols playercontrols4; -s_playercontrols *playercontrolpointers[] = {&playercontrols1, &playercontrols2, &playercontrols3, &playercontrols4}; -#if ANDROID -s_playercontrols touch_control; +s_playercontrols *playercontrolpointers[] = {&playercontrols1, &playercontrols2, &playercontrols3, &playercontrols4}; +#if ANDROID +s_playercontrols touch_control; #endif //global script @@ -1996,19 +1996,19 @@ void load_scripts() { Script_Compile(&pdie_script[i]); } -} - -void unfrozen(entity *e) -{ - ent_set_colourmap(e, e->map); - e->frozen = 0; - e->freezetime = 0; -} - -int is_frozen(entity *e) -{ +} + +void unfrozen(entity *e) +{ + ent_set_colourmap(e, e->map); + e->frozen = 0; + e->freezetime = 0; +} + +int is_frozen(entity *e) +{ return ((textbox && e->modeldata.type != TYPE_TEXTBOX) || - (smartbomber && e != smartbomber && e->modeldata.type != TYPE_TEXTBOX) ||(self->frozen&&self->freezetime>time)); + (smartbomber && e != smartbomber && e->modeldata.type != TYPE_TEXTBOX) ||(self->frozen&&self->freezetime>time)); } // This method is called once when the engine is shutting down, do not use it multiple times @@ -2164,41 +2164,41 @@ void execute_takedamage_script(entity *ent, entity *other, s_collision_attack *a { ScriptVariant_Init(&tempvar); ScriptVariant_ChangeType(&tempvar, VT_PTR); - + tempvar.ptrVal = (VOID *)ent; Script_Set_Local_Variant(cs, "self", &tempvar); - + tempvar.ptrVal = (VOID *)other; Script_Set_Local_Variant(cs, "attacker", &tempvar); - + ScriptVariant_ChangeType(&tempvar, VT_INTEGER); - + tempvar.lVal = (LONG)attack->attack_force; Script_Set_Local_Variant(cs, "damage", &tempvar); - + tempvar.lVal = (LONG)attack->attack_drop; Script_Set_Local_Variant(cs, "drop", &tempvar); - + tempvar.lVal = (LONG)attack->attack_type; Script_Set_Local_Variant(cs, "attacktype", &tempvar); - + tempvar.lVal = (LONG)attack->no_block; - Script_Set_Local_Variant(cs, "noblock", &tempvar); + Script_Set_Local_Variant(cs, "noblock", &tempvar); tempvar.lVal = (LONG)attack->guardcost; Script_Set_Local_Variant(cs, "guardcost", &tempvar); - + tempvar.lVal = (LONG)attack->jugglecost; Script_Set_Local_Variant(cs, "jugglecost", &tempvar); - + tempvar.lVal = (LONG)attack->pause_add; Script_Set_Local_Variant(cs, "pauseadd", &tempvar); - + tempvar.lVal = (LONG)attack->tag; - Script_Set_Local_Variant(cs, "tag", &tempvar); - - - Script_Execute(cs); + Script_Set_Local_Variant(cs, "tag", &tempvar); + + + Script_Execute(cs); //clear to save variant space ScriptVariant_Clear(&tempvar); @@ -2248,35 +2248,35 @@ void execute_onfall_script(entity *ent, entity *other, s_collision_attack *attac ScriptVariant_ChangeType(&tempvar, VT_PTR); tempvar.ptrVal = (VOID *)ent; Script_Set_Local_Variant(cs, "self", &tempvar); - + tempvar.ptrVal = (VOID *)other; Script_Set_Local_Variant(cs, "attacker", &tempvar); - + ScriptVariant_ChangeType(&tempvar, VT_INTEGER); - + tempvar.lVal = (LONG)attack->attack_force; Script_Set_Local_Variant(cs, "damage", &tempvar); - + tempvar.lVal = (LONG)attack->attack_drop; Script_Set_Local_Variant(cs, "drop", &tempvar); - + tempvar.lVal = (LONG)attack->attack_type; Script_Set_Local_Variant(cs, "attacktype", &tempvar); - + tempvar.lVal = (LONG)attack->no_block; - Script_Set_Local_Variant(cs, "noblock", &tempvar); + Script_Set_Local_Variant(cs, "noblock", &tempvar); tempvar.lVal = (LONG)attack->guardcost; Script_Set_Local_Variant(cs, "guardcost", &tempvar); - + tempvar.lVal = (LONG)attack->jugglecost; Script_Set_Local_Variant(cs, "jugglecost", &tempvar); - + tempvar.lVal = (LONG)attack->pause_add; Script_Set_Local_Variant(cs, "pauseadd", &tempvar); - + tempvar.lVal = (LONG)attack->tag; - Script_Set_Local_Variant(cs, "tag", &tempvar); + Script_Set_Local_Variant(cs, "tag", &tempvar); Script_Execute(cs); //clear to save variant space @@ -2322,25 +2322,25 @@ void execute_onblockw_script(entity *ent, s_terrain *wall, int index, e_plane pl ScriptVariant_ChangeType(&tempvar, VT_PTR); tempvar.ptrVal = (VOID *)ent; Script_Set_Local_Variant(cs, "self", &tempvar); - + ScriptVariant_ChangeType(&tempvar, VT_DECIMAL); tempvar.dblVal = (DOUBLE)wall->height; - Script_Set_Local_Variant(cs, "height", &tempvar); - + Script_Set_Local_Variant(cs, "height", &tempvar); + tempvar.dblVal = (DOUBLE)wall->depth; - Script_Set_Local_Variant(cs, "depth", &tempvar); + Script_Set_Local_Variant(cs, "depth", &tempvar); + + ScriptVariant_ChangeType(&tempvar, VT_INTEGER); - ScriptVariant_ChangeType(&tempvar, VT_INTEGER); - tempvar.lVal = (LONG)wall->type; - Script_Set_Local_Variant(cs, "type", &tempvar); + Script_Set_Local_Variant(cs, "type", &tempvar); tempvar.lVal = (LONG)index; - Script_Set_Local_Variant(cs, "index", &tempvar); - + Script_Set_Local_Variant(cs, "index", &tempvar); + tempvar.lVal = (LONG)plane; Script_Set_Local_Variant(cs, "plane", &tempvar); - + Script_Execute(cs); //clear to save variant space @@ -2364,30 +2364,30 @@ void execute_inhole_script(entity *ent, s_terrain *hole, int index) ScriptVariant_ChangeType(&tempvar, VT_PTR); tempvar.ptrVal = (VOID *)ent; Script_Set_Local_Variant(cs, "self", &tempvar); - + ScriptVariant_ChangeType(&tempvar, VT_DECIMAL); tempvar.dblVal = (DOUBLE)hole->height; - Script_Set_Local_Variant(cs, "height", &tempvar); - + Script_Set_Local_Variant(cs, "height", &tempvar); + tempvar.dblVal = (DOUBLE)hole->depth; - Script_Set_Local_Variant(cs, "depth", &tempvar); + Script_Set_Local_Variant(cs, "depth", &tempvar); + + ScriptVariant_ChangeType(&tempvar, VT_INTEGER); - ScriptVariant_ChangeType(&tempvar, VT_INTEGER); - tempvar.lVal = (LONG)hole->type; - Script_Set_Local_Variant(cs, "type", &tempvar); + Script_Set_Local_Variant(cs, "type", &tempvar); tempvar.lVal = (LONG)index; Script_Set_Local_Variant(cs, "index", &tempvar); - + Script_Execute(cs); //clear to save variant space ScriptVariant_Clear(&tempvar); Script_Set_Local_Variant(cs, "self", &tempvar); Script_Set_Local_Variant(cs, "height", &tempvar); - Script_Set_Local_Variant(cs, "index", &tempvar); - Script_Set_Local_Variant(cs, "depth", &tempvar); + Script_Set_Local_Variant(cs, "index", &tempvar); + Script_Set_Local_Variant(cs, "depth", &tempvar); Script_Set_Local_Variant(cs, "type", &tempvar); } } @@ -2539,43 +2539,43 @@ void execute_ondeath_script(entity *ent, entity *other, s_collision_attack *atta { ScriptVariant_Init(&tempvar); ScriptVariant_ChangeType(&tempvar, VT_PTR); - + tempvar.ptrVal = (VOID *)ent; Script_Set_Local_Variant(cs, "self", &tempvar); - + tempvar.ptrVal = (VOID *)other; Script_Set_Local_Variant(cs, "attacker", &tempvar); - + ScriptVariant_ChangeType(&tempvar, VT_INTEGER); - + tempvar.lVal = (LONG)attack->attack_force; Script_Set_Local_Variant(cs, "damage", &tempvar); - + tempvar.lVal = (LONG)attack->attack_drop; Script_Set_Local_Variant(cs, "drop", &tempvar); - + tempvar.lVal = (LONG)attack->attack_type; Script_Set_Local_Variant(cs, "attacktype", &tempvar); - + tempvar.lVal = (LONG)attack->no_block; - Script_Set_Local_Variant(cs, "noblock", &tempvar); + Script_Set_Local_Variant(cs, "noblock", &tempvar); tempvar.lVal = (LONG)attack->guardcost; Script_Set_Local_Variant(cs, "guardcost", &tempvar); - + tempvar.lVal = (LONG)attack->jugglecost; Script_Set_Local_Variant(cs, "jugglecost", &tempvar); - + tempvar.lVal = (LONG)attack->pause_add; Script_Set_Local_Variant(cs, "pauseadd", &tempvar); - + tempvar.lVal = (LONG)attack->tag; Script_Set_Local_Variant(cs, "tag", &tempvar); - + Script_Execute(cs); - //clear to save variant space + //clear to save variant space - ScriptVariant_Clear(&tempvar); + ScriptVariant_Clear(&tempvar); Script_Set_Local_Variant(cs, "self", &tempvar); Script_Set_Local_Variant(cs, "attacker", &tempvar); Script_Set_Local_Variant(cs, "damage", &tempvar); @@ -2613,40 +2613,40 @@ void execute_didblock_script(entity *ent, entity *other, s_collision_attack *att if(Script_IsInitialized(cs)) { ScriptVariant_Init(&tempvar); - ScriptVariant_ChangeType(&tempvar, VT_PTR); + ScriptVariant_ChangeType(&tempvar, VT_PTR); tempvar.ptrVal = (VOID *)ent; Script_Set_Local_Variant(cs, "self", &tempvar); - + tempvar.ptrVal = (VOID *)other; Script_Set_Local_Variant(cs, "attacker", &tempvar); - + ScriptVariant_ChangeType(&tempvar, VT_INTEGER); - + tempvar.lVal = (LONG)attack->attack_force; Script_Set_Local_Variant(cs, "damage", &tempvar); - + tempvar.lVal = (LONG)attack->attack_drop; Script_Set_Local_Variant(cs, "drop", &tempvar); - + tempvar.lVal = (LONG)attack->attack_type; Script_Set_Local_Variant(cs, "attacktype", &tempvar); - + tempvar.lVal = (LONG)attack->no_block; - Script_Set_Local_Variant(cs, "noblock", &tempvar); + Script_Set_Local_Variant(cs, "noblock", &tempvar); tempvar.lVal = (LONG)attack->guardcost; Script_Set_Local_Variant(cs, "guardcost", &tempvar); - + tempvar.lVal = (LONG)attack->jugglecost; Script_Set_Local_Variant(cs, "jugglecost", &tempvar); - + tempvar.lVal = (LONG)attack->pause_add; Script_Set_Local_Variant(cs, "pauseadd", &tempvar); - + tempvar.lVal = (LONG)attack->tag; - Script_Set_Local_Variant(cs, "tag", &tempvar); - + Script_Set_Local_Variant(cs, "tag", &tempvar); + Script_Execute(cs); //clear to save variant space ScriptVariant_Clear(&tempvar); @@ -2673,41 +2673,41 @@ void execute_ondoattack_script(entity *ent, entity *other, s_collision_attack *a ScriptVariant_ChangeType(&tempvar, VT_PTR); tempvar.ptrVal = (VOID *)ent; Script_Set_Local_Variant(cs, "self", &tempvar); - + tempvar.ptrVal = (VOID *)other; Script_Set_Local_Variant(cs, "attacker", &tempvar); - + ScriptVariant_ChangeType(&tempvar, VT_INTEGER); - + tempvar.lVal = (LONG)attack->attack_force; Script_Set_Local_Variant(cs, "damage", &tempvar); - + tempvar.lVal = (LONG)attack->attack_drop; Script_Set_Local_Variant(cs, "drop", &tempvar); - + tempvar.lVal = (LONG)attack->attack_type; Script_Set_Local_Variant(cs, "attacktype", &tempvar); - + tempvar.lVal = (LONG)attack->no_block; - Script_Set_Local_Variant(cs, "noblock", &tempvar); + Script_Set_Local_Variant(cs, "noblock", &tempvar); tempvar.lVal = (LONG)attack->guardcost; Script_Set_Local_Variant(cs, "guardcost", &tempvar); - + tempvar.lVal = (LONG)attack->jugglecost; Script_Set_Local_Variant(cs, "jugglecost", &tempvar); - + tempvar.lVal = (LONG)attack->pause_add; Script_Set_Local_Variant(cs, "pauseadd", &tempvar); - + tempvar.lVal = (LONG)attack->tag; Script_Set_Local_Variant(cs, "tag", &tempvar); tempvar.lVal = (LONG)which; - Script_Set_Local_Variant(cs, "which", &tempvar); + Script_Set_Local_Variant(cs, "which", &tempvar); tempvar.lVal = (LONG)attack_id; - Script_Set_Local_Variant(cs, "attack_id", &tempvar); + Script_Set_Local_Variant(cs, "attack_id", &tempvar); Script_Execute(cs); //clear to save variant space @@ -2765,45 +2765,45 @@ static void _execute_didhit_script(Script *cs, entity *ent, entity *other, s_col { ScriptVariant tempvar; ScriptVariant_Init(&tempvar); - + ScriptVariant_ChangeType(&tempvar, VT_PTR); - + tempvar.ptrVal = (VOID *)ent; Script_Set_Local_Variant(cs, "self", &tempvar); - + tempvar.ptrVal = (VOID *)other; Script_Set_Local_Variant(cs, "damagetaker", &tempvar); - + ScriptVariant_ChangeType(&tempvar, VT_INTEGER); - + tempvar.lVal = (LONG)attack->attack_force; Script_Set_Local_Variant(cs, "damage", &tempvar); - + tempvar.lVal = (LONG)attack->attack_drop; Script_Set_Local_Variant(cs, "drop", &tempvar); - + tempvar.lVal = (LONG)attack->attack_type; Script_Set_Local_Variant(cs, "attacktype", &tempvar); - + tempvar.lVal = (LONG)attack->no_block; - Script_Set_Local_Variant(cs, "noblock", &tempvar); + Script_Set_Local_Variant(cs, "noblock", &tempvar); tempvar.lVal = (LONG)attack->guardcost; Script_Set_Local_Variant(cs, "guardcost", &tempvar); - + tempvar.lVal = (LONG)attack->jugglecost; Script_Set_Local_Variant(cs, "jugglecost", &tempvar); - + tempvar.lVal = (LONG)attack->pause_add; Script_Set_Local_Variant(cs, "pauseadd", &tempvar); - + tempvar.lVal = (LONG)attack->tag; - Script_Set_Local_Variant(cs, "tag", &tempvar); - + Script_Set_Local_Variant(cs, "tag", &tempvar); + tempvar.lVal = (LONG)blocked; Script_Set_Local_Variant(cs, "blocked", &tempvar); - + Script_Execute(cs); //clear to save variant space ScriptVariant_Clear(&tempvar); @@ -3068,11 +3068,11 @@ void execute_pdie_script(int index) } // ------------------------ Save/load ----------------------------- - -void clearbuttons(int player) -{ - if (player == 0) - { + +void clearbuttons(int player) +{ + if (player == 0) + { savedata.keys[0][SDID_MOVEUP] = CONTROL_DEFAULT1_UP; savedata.keys[0][SDID_MOVEDOWN] = CONTROL_DEFAULT1_DOWN; savedata.keys[0][SDID_MOVELEFT] = CONTROL_DEFAULT1_LEFT; @@ -3087,9 +3087,9 @@ void clearbuttons(int player) savedata.keys[0][SDID_SCREENSHOT] = CONTROL_DEFAULT1_SCREENSHOT; #ifdef SDL //savedata.keys[0][SDID_ESC] = CONTROL_DEFAULT1_ESC; - #endif - - #ifdef ANDROID + #endif + + #ifdef ANDROID touch_default_keys[SDID_MOVEUP] = CONTROL_DEFAULT1_UP; touch_default_keys[SDID_MOVEDOWN] = CONTROL_DEFAULT1_DOWN; touch_default_keys[SDID_MOVELEFT] = CONTROL_DEFAULT1_LEFT; @@ -3101,8 +3101,8 @@ void clearbuttons(int player) touch_default_keys[SDID_JUMP] = CONTROL_DEFAULT1_FIRE5; touch_default_keys[SDID_SPECIAL] = CONTROL_DEFAULT1_FIRE6; touch_default_keys[SDID_START] = CONTROL_DEFAULT1_START; - touch_default_keys[SDID_SCREENSHOT] = CONTROL_DEFAULT1_SCREENSHOT; - + touch_default_keys[SDID_SCREENSHOT] = CONTROL_DEFAULT1_SCREENSHOT; + control_setkey(&touch_control, FLAG_ESC, CONTROL_ESC); control_setkey(&touch_control, FLAG_MOVEUP, touch_default_keys[SDID_MOVEUP]); control_setkey(&touch_control, FLAG_MOVEDOWN, touch_default_keys[SDID_MOVEDOWN]); @@ -3115,11 +3115,11 @@ void clearbuttons(int player) control_setkey(&touch_control, FLAG_JUMP, touch_default_keys[SDID_JUMP]); control_setkey(&touch_control, FLAG_SPECIAL, touch_default_keys[SDID_SPECIAL]); control_setkey(&touch_control, FLAG_START, touch_default_keys[SDID_START]); - control_setkey(&touch_control, FLAG_SCREENSHOT, touch_default_keys[SDID_SCREENSHOT]); - #endif - } - else if (player == 1) - { + control_setkey(&touch_control, FLAG_SCREENSHOT, touch_default_keys[SDID_SCREENSHOT]); + #endif + } + else if (player == 1) + { savedata.keys[1][SDID_MOVEUP] = CONTROL_DEFAULT2_UP; savedata.keys[1][SDID_MOVEDOWN] = CONTROL_DEFAULT2_DOWN; savedata.keys[1][SDID_MOVELEFT] = CONTROL_DEFAULT2_LEFT; @@ -3134,10 +3134,10 @@ void clearbuttons(int player) savedata.keys[1][SDID_SCREENSHOT] = CONTROL_DEFAULT2_SCREENSHOT; #ifdef SDL //savedata.keys[1][SDID_ESC] = CONTROL_DEFAULT2_ESC; - #endif - } - else if (player == 2) - { + #endif + } + else if (player == 2) + { savedata.keys[2][SDID_MOVEUP] = CONTROL_DEFAULT3_UP; savedata.keys[2][SDID_MOVEDOWN] = CONTROL_DEFAULT3_DOWN; savedata.keys[2][SDID_MOVELEFT] = CONTROL_DEFAULT3_LEFT; @@ -3152,10 +3152,10 @@ void clearbuttons(int player) savedata.keys[2][SDID_SCREENSHOT] = CONTROL_DEFAULT3_SCREENSHOT; #ifdef SDL //savedata.keys[2][SDID_ESC] = CONTROL_DEFAULT3_ESC; - #endif - } - else if (player == 3) - { + #endif + } + else if (player == 3) + { savedata.keys[3][SDID_MOVEUP] = CONTROL_DEFAULT4_UP; savedata.keys[3][SDID_MOVEDOWN] = CONTROL_DEFAULT4_DOWN; savedata.keys[3][SDID_MOVELEFT] = CONTROL_DEFAULT4_LEFT; @@ -3170,13 +3170,13 @@ void clearbuttons(int player) savedata.keys[3][SDID_SCREENSHOT] = CONTROL_DEFAULT4_SCREENSHOT; #ifdef SDL //savedata.keys[3][SDID_ESC] = CONTROL_DEFAULT4_ESC; - #endif - } -} + #endif + } +} void clearsettings() -{ - int i = 0; +{ + int i = 0; savedata.compatibleversion = COMPATIBLEVERSION; savedata.gamma = 0; @@ -3218,9 +3218,9 @@ void clearsettings() savedata.overscan[3] = 0; #endif - for (i = 0; i < MAX_PLAYERS; i++) - { - clearbuttons(i); + for (i = 0; i < MAX_PLAYERS; i++) + { + clearbuttons(i); } } @@ -3800,120 +3800,120 @@ size_t ParseArgs(ArgList *list, char *input, char *output) { assert(list); assert(input); - assert(output); - + assert(output); + memset(output,0,MAX_ARG_LEN); size_t pos = 0; size_t wordstart = 0; - size_t item = 0; + size_t item = 0; // flags int done_flag = 0; - int space_flag = 0; // can find more spaces - int double_apex_flag = 0; + int space_flag = 0; // can find more spaces + int double_apex_flag = 0; int single_apex_flag = 0; while(pos < MAX_ARG_LEN - 1 && item < MAX_ARG_COUNT) { switch(input[pos]) - { - // read strings - case '"': - if ( (pos > 0 && input[pos-1] != '\\') || pos <= 0 ) - { - if (space_flag && !double_apex_flag) - { - double_apex_flag = 1; - space_flag = 0; - wordstart = pos; - output[pos] = input[pos]; - break; - } - else if (double_apex_flag) - { - double_apex_flag = 0; - output[pos] = input[pos]; - // continue to get inputs - break; - } - else - { + { + // read strings + case '"': + if ( (pos > 0 && input[pos-1] != '\\') || pos <= 0 ) + { + if (space_flag && !double_apex_flag) + { + double_apex_flag = 1; + space_flag = 0; + wordstart = pos; + output[pos] = input[pos]; + break; + } + else if (double_apex_flag) + { + double_apex_flag = 0; + output[pos] = input[pos]; + // continue to get inputs + break; + } + else + { if(space_flag) { wordstart = pos; } output[pos] = input[pos]; - space_flag = 0; - break; - } - } - else - { + space_flag = 0; + break; + } + } + else + { if(space_flag) { wordstart = pos; } output[pos] = input[pos]; - space_flag = 0; - break; - } - case '\'': - if ( (pos > 0 && input[pos-1] != '\\') || pos <= 0 ) - { - if (space_flag && !single_apex_flag) - { - single_apex_flag = 1; - space_flag = 0; - wordstart = pos; - output[pos] = input[pos]; - break; - } - else if (single_apex_flag) - { - single_apex_flag = 0; - output[pos] = input[pos]; - // continue to get inputs - break; - } - else - { + space_flag = 0; + break; + } + case '\'': + if ( (pos > 0 && input[pos-1] != '\\') || pos <= 0 ) + { + if (space_flag && !single_apex_flag) + { + single_apex_flag = 1; + space_flag = 0; + wordstart = pos; + output[pos] = input[pos]; + break; + } + else if (single_apex_flag) + { + single_apex_flag = 0; + output[pos] = input[pos]; + // continue to get inputs + break; + } + else + { if(space_flag) { wordstart = pos; } output[pos] = input[pos]; - space_flag = 0; - break; - } - } - else - { + space_flag = 0; + break; + } + } + else + { if(space_flag) { wordstart = pos; } output[pos] = input[pos]; - space_flag = 0; - break; - } - + space_flag = 0; + break; + } + // complete item case '\r': case '\n': - case '#': - if (double_apex_flag || single_apex_flag) - { - output[pos] = input[pos]; - break; + case '#': + if (double_apex_flag || single_apex_flag) + { + output[pos] = input[pos]; + break; } case '\0': - done_flag = 1; - + done_flag = 1; + // skip spaces case ' ': - case '\t': - if (!double_apex_flag && !single_apex_flag) - { + case '\t': + if (!double_apex_flag && !single_apex_flag) + { output[pos] = '\0'; if(!space_flag && wordstart != pos) { @@ -3922,9 +3922,9 @@ size_t ParseArgs(ArgList *list, char *input, char *output) item++; } space_flag = 1; - break; + break; } - + // read character default: if(space_flag && !double_apex_flag && !single_apex_flag) @@ -3933,7 +3933,7 @@ size_t ParseArgs(ArgList *list, char *input, char *output) } output[pos] = input[pos]; space_flag = 0; - } + } if(done_flag) { @@ -3941,16 +3941,16 @@ size_t ParseArgs(ArgList *list, char *input, char *output) } pos++; } - list->count = item; - - // TEST - /*printf("found: "); - int i; - for (i = 0; i < list->count; i++) { - printf("|%s|:%d",list->args[i],list->arglen[i]); - if (i < list->count - 1) printf(" "); - } - printf("\n");*/ + list->count = item; + + // TEST + /*printf("found: "); + int i; + for (i = 0; i < list->count; i++) { + printf("|%s|:%d",list->args[i],list->arglen[i]); + if (i < list->count - 1) printf(" "); + } + printf("\n");*/ return item; } @@ -4782,64 +4782,64 @@ s_sprite *loadsprite2(char *filename, int *width, int *height) size_t size; s_bitmap *bitmap = NULL; s_sprite *sprite = NULL; - int clip_left; - int clip_right; - int clip_top; + int clip_left; + int clip_right; + int clip_top; int clip_bottom; - - // Load raw bitmap (image) file from pack. If this + + // Load raw bitmap (image) file from pack. If this // fails, then we return NULL. bitmap = loadbitmap(filename, packfile, pixelformat); - + if(!bitmap) { return NULL; - } - + } + // Apply width and height adjustments, if any. if(width) { *width = bitmap->width; } - + if(height) { *height = bitmap->height; - } - - // Trim empty pixels from the bitmap to save memory. - // We will pass the arguments by reference - they will - // be modified by the clipping function to tell us + } + + // Trim empty pixels from the bitmap to save memory. + // We will pass the arguments by reference - they will + // be modified by the clipping function to tell us // exactly how much trim work on each axis was done. clipbitmap(bitmap, &clip_left, &clip_right, &clip_top, &clip_bottom); - - // Get size of trimmed bitmap and allocate memory for - // use as a sprite. If this fails, then free the memory - // bitmap occupies, and return NULL. - size = fakey_encodesprite(bitmap); + + // Get size of trimmed bitmap and allocate memory for + // use as a sprite. If this fails, then free the memory + // bitmap occupies, and return NULL. + size = fakey_encodesprite(bitmap); sprite = (s_sprite *)malloc(size); - + if(!sprite) { freebitmap(bitmap); return NULL; } - - // Transpose bitmap to a sprite, using the memory - // we allocated for it above. The trim arguments - // from our trimming function will be used as an - // offset. We'll also store/ the bitmap's trimmed - // dimensions for later use. + + // Transpose bitmap to a sprite, using the memory + // we allocated for it above. The trim arguments + // from our trimming function will be used as an + // offset. We'll also store/ the bitmap's trimmed + // dimensions for later use. encodesprite(-clip_left, -clip_top, bitmap, sprite); sprite->offsetx = clip_left; sprite->offsety = clip_top; sprite->srcwidth = bitmap->width; sprite->srcheight = bitmap->height; - - // Delete the raw bitmap, we don't need it - // any more. + + // Delete the raw bitmap, we don't need it + // any more. freebitmap(bitmap); - + // Return encoded sprite. return sprite; } @@ -4915,72 +4915,72 @@ void cachesound(int index, int load) sound_unload_sample(index); } } - -// Cachesprite -// Unknown original date & author -// Rewrite by Caskey, Damon V. -// 2018-03-19 -// -// Add or remove a sprite to the the sprite list -// by index. -// -// index: Target index in the sprite list. + +// Cachesprite +// Unknown original date & author +// Rewrite by Caskey, Damon V. +// 2018-03-19 +// +// Add or remove a sprite to the the sprite list +// by index. +// +// index: Target index in the sprite list. // load: Load 1, or unload 0 the target sprite index. void cachesprite(int index, int load) -{ - s_sprite *sprite; // Sprite placeholder. - s_sprite_list *map_node; // Sprite map node placeholder. - - // Valid sprite list? - if(sprite_map) - { - // Index argument valid? - if(index >= 0) - { - // Index argument should be more than - // the number of sprites loaded. - if(index < sprites_loaded) - { - // Get the sprite list node from sprite maps - // using our target index. - map_node = sprite_map[index].node; - - // If load is true, then we want to load - // a sprite and assign it the target index. - // Otherwise, we want to free a sprite with - // target index. +{ + s_sprite *sprite; // Sprite placeholder. + s_sprite_list *map_node; // Sprite map node placeholder. + + // Valid sprite list? + if(sprite_map) + { + // Index argument valid? + if(index >= 0) + { + // Index argument should be more than + // the number of sprites loaded. + if(index < sprites_loaded) + { + // Get the sprite list node from sprite maps + // using our target index. + map_node = sprite_map[index].node; + + // If load is true, then we want to load + // a sprite and assign it the target index. + // Otherwise, we want to free a sprite with + // target index. if(load) - { - // Make sure there is not already - // a sprite with our target index. - sprite = map_node->sprite; - - if(!sprite) - { - // Load the sprite file, then assign its - // new pointer to the sprite map using our - // index for the sprite map position. - sprite = loadsprite2(map_node->filename, NULL, NULL); - map_node->sprite = sprite; + { + // Make sure there is not already + // a sprite with our target index. + sprite = map_node->sprite; + + if(!sprite) + { + // Load the sprite file, then assign its + // new pointer to the sprite map using our + // index for the sprite map position. + sprite = loadsprite2(map_node->filename, NULL, NULL); + map_node->sprite = sprite; } } else if(!load) { - // Does the target sprite exist? - sprite = map_node->sprite; - - if(sprite) - { - // Free the target sprite's resources, then remove - // its pointer from sprite map. + // Does the target sprite exist? + sprite = map_node->sprite; + + if(sprite) + { + // Free the target sprite's resources, then remove + // its pointer from sprite map. free(sprite); - map_node->sprite = NULL; + map_node->sprite = NULL; - //printf("uncached sprite: %s\n", map_node->filename); + //printf("uncached sprite: %s\n", map_node->filename); } - } - } - } + } + } + } } } @@ -5331,49 +5331,49 @@ int nextcolourmap(s_model *model, int c) ); return c; -} - +} + int nextcolourmapln(s_model *model, int c, int p) { - int color_index = nextcolourmap(model, c); - s_set_entry *set = levelsets + current_set; - - if ( colourselect && (set->nosame & 2) ) - { - int i = 0, j = 0; - int maps_count = model->maps_loaded; - int used_colors_map[maps_count]; - int used_color_count = 0; - - // reset color map - for(i = 0; i < maps_count; i++) used_colors_map[i] = 0; - // check max color map count - if (model->maps.frozen > 0) --maps_count; - if (model->maps.hide_start > 0) maps_count -= model->maps.hide_end - model->maps.hide_start + 1; - - // map all used colors - for(i = 0; i < MAX_PLAYERS; i++) - { - if ( p != i && stricmp(player[p].name, player[i].name) == 0 ) - { - used_colors_map[player[i].colourmap] = 1; - ++used_color_count; - // all busy colors? return the next natural - if (used_color_count >= maps_count) return color_index; - } - } - - // search the first free color - for(i = color_index, j = 0; j < maps_count; j++) - { - if ( !used_colors_map[i] ) - { - return i; - } - i = nextcolourmap(model, i); - } - } - + int color_index = nextcolourmap(model, c); + s_set_entry *set = levelsets + current_set; + + if ( colourselect && (set->nosame & 2) ) + { + int i = 0, j = 0; + int maps_count = model->maps_loaded; + int used_colors_map[maps_count]; + int used_color_count = 0; + + // reset color map + for(i = 0; i < maps_count; i++) used_colors_map[i] = 0; + // check max color map count + if (model->maps.frozen > 0) --maps_count; + if (model->maps.hide_start > 0) maps_count -= model->maps.hide_end - model->maps.hide_start + 1; + + // map all used colors + for(i = 0; i < MAX_PLAYERS; i++) + { + if ( p != i && stricmp(player[p].name, player[i].name) == 0 ) + { + used_colors_map[player[i].colourmap] = 1; + ++used_color_count; + // all busy colors? return the next natural + if (used_color_count >= maps_count) return color_index; + } + } + + // search the first free color + for(i = color_index, j = 0; j < maps_count; j++) + { + if ( !used_colors_map[i] ) + { + return i; + } + i = nextcolourmap(model, i); + } + } + return color_index; } @@ -5393,49 +5393,49 @@ int prevcolourmap(s_model *model, int c) ); return c; -} - +} + int prevcolourmapln(s_model *model, int c, int p) { - int color_index = prevcolourmap(model, c); - s_set_entry *set = levelsets + current_set; - - if ( colourselect && (set->nosame & 2) ) - { - int i = 0, j = 0; - int maps_count = model->maps_loaded; - int used_colors_map[maps_count]; - int used_color_count = 0; - - // reset color map - for(i = 0; i < maps_count; i++) used_colors_map[i] = 0; - // check max color map count - if (model->maps.frozen > 0) --maps_count; - if (model->maps.hide_start > 0) maps_count -= model->maps.hide_end - model->maps.hide_start + 1; - - // map all used colors - for(i = 0; i < MAX_PLAYERS; i++) - { - if ( p != i && stricmp(player[p].name, player[i].name) == 0 ) - { - used_colors_map[player[i].colourmap] = 1; - ++used_color_count; - // all busy colors? return the next natural - if (used_color_count >= maps_count) return color_index; - } - } - - // search the first free color - for(i = color_index, j = 0; j < maps_count; j++) - { - if ( !used_colors_map[i] ) - { - return i; - } - i = prevcolourmap(model, i); - } - } - + int color_index = prevcolourmap(model, c); + s_set_entry *set = levelsets + current_set; + + if ( colourselect && (set->nosame & 2) ) + { + int i = 0, j = 0; + int maps_count = model->maps_loaded; + int used_colors_map[maps_count]; + int used_color_count = 0; + + // reset color map + for(i = 0; i < maps_count; i++) used_colors_map[i] = 0; + // check max color map count + if (model->maps.frozen > 0) --maps_count; + if (model->maps.hide_start > 0) maps_count -= model->maps.hide_end - model->maps.hide_start + 1; + + // map all used colors + for(i = 0; i < MAX_PLAYERS; i++) + { + if ( p != i && stricmp(player[p].name, player[i].name) == 0 ) + { + used_colors_map[player[i].colourmap] = 1; + ++used_color_count; + // all busy colors? return the next natural + if (used_color_count >= maps_count) return color_index; + } + } + + // search the first free color + for(i = color_index, j = 0; j < maps_count; j++) + { + if ( !used_colors_map[i] ) + { + return i; + } + i = prevcolourmap(model, i); + } + } + return color_index; } @@ -5474,19 +5474,19 @@ s_model *nextplayermodel(s_model *current) } shutdown(1, "Fatal: can't find any player models!"); return NULL; -} - +} + s_model *nextplayermodeln(s_model *current, int p) { int i; s_set_entry *set = levelsets + current_set; - s_model *model = nextplayermodel(current); + s_model *model = nextplayermodel(current); if(set->nosame & 1) - { - int used_player_count = 0, player_count = 0; - - // check count of selectable players + { + int used_player_count = 0, player_count = 0; + + // check count of selectable players for(i = 0; i < models_cached; i++) { if(model_cache[i].model && model_cache[i].model->type == TYPE_PLAYER && @@ -5495,29 +5495,29 @@ s_model *nextplayermodeln(s_model *current, int p) { ++player_count; } - } - + } + // count all used player for(i = 0; model && i < MAX_PLAYERS; i++) { if(i != p && stricmp(player[p].name, player[i].name) == 0) - { - ++used_player_count; - // all busy players? return the next natural + { + ++used_player_count; + // all busy players? return the next natural if (used_player_count >= player_count) return nextplayermodel(current); } - } - - // search the first free player - for(i = 0; model && i < MAX_PLAYERS; i++) - { - if(i != p && stricmp(model->name, player[i].name) == 0) - { - i = -1; - model = nextplayermodel(model); - } } - } + + // search the first free player + for(i = 0; model && i < MAX_PLAYERS; i++) + { + if(i != p && stricmp(model->name, player[i].name) == 0) + { + i = -1; + model = nextplayermodel(model); + } + } + } return model; } @@ -5563,13 +5563,13 @@ s_model *prevplayermodeln(s_model *current, int p) { int i; s_set_entry *set = levelsets + current_set; - s_model *model = prevplayermodel(current); + s_model *model = prevplayermodel(current); if(set->nosame & 1) - { - int used_player_count = 0, player_count = 0; - - // check count of selectable players + { + int used_player_count = 0, player_count = 0; + + // check count of selectable players for(i = 0; i < models_cached; i++) { if(model_cache[i].model && model_cache[i].model->type == TYPE_PLAYER && @@ -5578,29 +5578,29 @@ s_model *prevplayermodeln(s_model *current, int p) { ++player_count; } - } - + } + // count all used player for(i = 0; model && i < MAX_PLAYERS; i++) { if(i != p && stricmp(player[p].name, player[i].name) == 0) - { - ++used_player_count; - // all busy players? return the prev natural + { + ++used_player_count; + // all busy players? return the prev natural if (used_player_count >= player_count) return prevplayermodel(current); } - } - - // search the first free player - for(i = 0; model && i < MAX_PLAYERS; i++) - { - if(i != p && stricmp(model->name, player[i].name) == 0) - { - i = -1; - model = prevplayermodel(model); - } } - } + + // search the first free player + for(i = 0; model && i < MAX_PLAYERS; i++) + { + if(i != p && stricmp(model->name, player[i].name) == 0) + { + i = -1; + model = prevplayermodel(model); + } + } + } return model; } @@ -5914,25 +5914,25 @@ void free_anim(s_anim *anim) { free(anim->counterrange); anim->counterrange = NULL; - } + } if(anim->dropframe) { free(anim->dropframe); anim->dropframe = NULL; - } - + } + if(anim->jumpframe) { free(anim->jumpframe); anim->jumpframe = NULL; - } - + } + if(anim->landframe) { free(anim->landframe); anim->landframe = NULL; - } + } if(anim->energycost) { @@ -6715,12 +6715,12 @@ char *get_cached_model_path(char *name) } static void _readbarstatus(char *, s_barstatus *); - -static int translate_attack_type(char *command) -{ - int atk_id = -1, tempInt; - - modelCommands cmd = getModelCommand(modelcmdlist, command); + +static int translate_attack_type(char *command) +{ + int atk_id = -1, tempInt; + + modelCommands cmd = getModelCommand(modelcmdlist, command); switch(cmd) { @@ -6776,14 +6776,14 @@ static int translate_attack_type(char *command) { tempInt = MAX_ATKS - STA_ATKS + 1; } - atk_id = tempInt + STA_ATKS - 1; - break; - default: + atk_id = tempInt + STA_ATKS - 1; break; - } - - return atk_id; -} + default: + break; + } + + return atk_id; +} //move here to ease animation name to id logic static int translate_ani_id(const char *value, s_model *newchar, s_anim *newanim, s_collision_attack *attack) @@ -9003,8 +9003,8 @@ s_model *load_cached_model(char *name, char *owner, char unload) s_move move = { { .x = 0, .y = 0, - .z = 0}, - .base = -1 //-1 = Disabled, 0+ base set + .z = 0}, + .base = -1 //-1 = Disabled, 0+ base set }; s_damage_recursive recursive; @@ -10430,8 +10430,8 @@ s_model *load_cached_model(char *name, char *owner, char unload) newanim->followup.animation = 0; // Default disabled newanim->followup.condition = FOLLOW_CONDITION_DISABLED; newanim->unsummonframe = -1; - newanim->landframe = NULL; - newanim->jumpframe = NULL; + newanim->landframe = NULL; + newanim->jumpframe = NULL; newanim->dropframe = NULL; newanim->cancel = 0; // OX. For cancelling anims into a freespecial. 0 by default , 3 when enabled. IMPORTANT!! Must stay as it is! newanim->animhits = 0; //OX counts hits on a per anim basis for cancels. @@ -10559,47 +10559,47 @@ s_model *load_cached_model(char *name, char *owner, char unload) // UT: merge dive and jumpframe, because they can't be used at the same time case CMD_MODEL_DIVE: //antigrav kicks newanim->antigrav = 1; - - // Allocate jumpframe and use it to set movement. + + // Allocate jumpframe and use it to set movement. newanim->jumpframe = malloc(sizeof(*newanim->jumpframe)); memset(newanim->jumpframe, 0, sizeof(*newanim->jumpframe)); - - newanim->jumpframe->frame = 0; - newanim->jumpframe->velocity.x = GET_FLOAT_ARG(1); - newanim->jumpframe->velocity.y = -GET_FLOAT_ARG(2); + + newanim->jumpframe->frame = 0; + newanim->jumpframe->velocity.x = GET_FLOAT_ARG(1); + newanim->jumpframe->velocity.y = -GET_FLOAT_ARG(2); newanim->jumpframe->ent = -1; break; case CMD_MODEL_DIVE1: - newanim->antigrav = 1; - - // Allocate jumpframe and use it to set movement. + newanim->antigrav = 1; + + // Allocate jumpframe and use it to set movement. newanim->jumpframe = malloc(sizeof(*newanim->jumpframe)); - memset(newanim->jumpframe, 0, sizeof(*newanim->jumpframe)); + memset(newanim->jumpframe, 0, sizeof(*newanim->jumpframe)); newanim->jumpframe->frame = 0; newanim->jumpframe->velocity.x = GET_FLOAT_ARG(1); newanim->jumpframe->ent = -1; break; case CMD_MODEL_DIVE2: - newanim->antigrav = 1; - - // Allocate jumpframe and use it to set movement. + newanim->antigrav = 1; + + // Allocate jumpframe and use it to set movement. newanim->jumpframe = malloc(sizeof(*newanim->jumpframe)); - memset(newanim->jumpframe, 0, sizeof(*newanim->jumpframe)); + memset(newanim->jumpframe, 0, sizeof(*newanim->jumpframe)); newanim->jumpframe->frame = 0; newanim->jumpframe->velocity.y = -GET_FLOAT_ARG(1); newanim->jumpframe->ent = -1; break; case CMD_MODEL_JUMPFRAME: - { - // Allocate jumpframe. + { + // Allocate jumpframe. newanim->jumpframe = malloc(sizeof(*newanim->jumpframe)); - memset(newanim->jumpframe, 0, sizeof(*newanim->jumpframe)); + memset(newanim->jumpframe, 0, sizeof(*newanim->jumpframe)); newanim->jumpframe->frame = GET_FRAME_ARG(1); newanim->jumpframe->velocity.y = GET_FLOAT_ARG(2); - + value = GET_ARG(3); if(value[0]) { @@ -10650,14 +10650,14 @@ s_model *load_cached_model(char *name, char *owner, char unload) case CMD_MODEL_BOUNCEFACTOR: newanim->bounce = GET_FLOAT_ARG(1); break; - case CMD_MODEL_LANDFRAME: + case CMD_MODEL_LANDFRAME: newanim->landframe = malloc(sizeof(*newanim->landframe)); memset(newanim->landframe, 0, sizeof(*newanim->landframe)); - // Landing frame. - newanim->landframe->frame = GET_FRAME_ARG(1); - - // Entity to spawn when land frame triggers. + // Landing frame. + newanim->landframe->frame = GET_FRAME_ARG(1); + + // Entity to spawn when land frame triggers. value = GET_ARG(2); if(value[0]) { @@ -10666,7 +10666,7 @@ s_model *load_cached_model(char *name, char *owner, char unload) else { newanim->landframe->ent = -1; - } + } break; case CMD_MODEL_DROPFRAME: @@ -11370,7 +11370,7 @@ s_model *load_cached_model(char *name, char *owner, char unload) // fake throw damage on landing pattack = (!newanim && newchar->smartbomb) ? newchar->smartbomb : &attack; pattack->damage_on_landing.attack_force = GET_INT_ARG(1); - pattack->blast = GET_INT_ARG(2); + pattack->blast = GET_INT_ARG(2); pattack->damage_on_landing.attack_type = translate_attack_type(GET_ARG(3)); break; case CMD_MODEL_SEAL: @@ -11822,7 +11822,7 @@ s_model *load_cached_model(char *name, char *owner, char unload) scriptlen = strlen(scriptbuf); } sprintf(namebuf, call_text, value); - buffer_append(&scriptbuf, namebuf, 0xffffff, &sbsize, &scriptlen); + buffer_append(&scriptbuf, namebuf, 0xffffff, &sbsize, &scriptlen); do //argument and comma { @@ -11838,7 +11838,7 @@ s_model *load_cached_model(char *name, char *owner, char unload) } } while(value && value[0]); - } + } buffer_append(&scriptbuf, endcall_text, 0xffffff, &sbsize, &scriptlen); if(no_cmd_compatible) @@ -13992,8 +13992,8 @@ void load_levelorder() break; default: if (command && command[0]) - { - if (err <= 0) printf("\n"); + { + if (err <= 0) printf("\n"); ++err; printf("Command '%s' not understood in level order!\n", command); } @@ -14682,9 +14682,9 @@ void load_level(char *filename) strcpy(level->name, filename); // Allocate memory for player spawn - only as much as we need. - player_max = levelsets[current_set].maxplayers; - level->spawn = calloc(player_max, sizeof(*level->spawn)); - + player_max = levelsets[current_set].maxplayers; + level->spawn = calloc(player_max, sizeof(*level->spawn)); + // Default player spawn Y position just above the screen top. for(i = 0; i < player_max && level->spawn; i++) { @@ -14718,11 +14718,11 @@ void load_level(char *filename) texttime = 0; nopause = 0; nofadeout = 0; - noscreenshot = 0; + noscreenshot = 0; panel_width = panel_height = frontpanels_loaded = 0; - //reset_playable_list(1); + //reset_playable_list(1); // Now interpret the contents of buf line by line pos = 0; @@ -15136,8 +15136,8 @@ void load_level(char *filename) { level->spawn[i].x = GET_INT_ARG(1); level->spawn[i].z = GET_INT_ARG(2); - level->spawn[i].y = GET_INT_ARG(3); - + level->spawn[i].y = GET_INT_ARG(3); + if(level->spawn[i].y < 0) level->spawn[i].y = videomodes.vRes + 60; } @@ -16207,7 +16207,7 @@ void updatestatus() // don't like a characters color try a new one! else if(player[i].playkeys & (FLAG_MOVEUP | FLAG_MOVEDOWN) && colourselect) { - player[i].colourmap = ((player[i].playkeys & FLAG_MOVEUP) ? nextcolourmapln : prevcolourmapln)(model, player[i].colourmap, i); + player[i].colourmap = ((player[i].playkeys & FLAG_MOVEUP) ? nextcolourmapln : prevcolourmapln)(model, player[i].colourmap, i); player[i].playkeys = 0; } @@ -17196,13 +17196,13 @@ void free_ent(entity *e) } clear_all_scripts(e->scripts, 2); free_all_scripts(&e->scripts); - - // Item properties. + + // Item properties. if(e->item_properties) { free(e->item_properties); e->item_properties = NULL; - } + } if(e->waypoints) { @@ -17478,8 +17478,8 @@ void ent_default_init(entity *e) e->takeaction = common_spawn; } else if(!e->animation) - { - int player_index = (int)e->playerindex; + { + int player_index = (int)e->playerindex; if(player_index < levelsets[current_set].maxplayers && level->spawn && time && level->spawn[player_index].y > e->position.y) { @@ -17756,7 +17756,7 @@ void ent_spawn_ent(entity *ent) if(s_ent->modeldata.subtype == SUBTYPE_ARROW || s_ent->modeldata.subtype == SUBTYPE_BOOMERANG) { s_ent->owner = ent; - } + } s_ent->spawntype = SPAWN_TYPE_CMD_SPAWN; s_ent->parent = ent; //maybe used by A.I. execute_onspawn_script(s_ent); @@ -17806,7 +17806,7 @@ void ent_summon_ent(entity *ent) { s_ent->owner = ent; } - //maybe used by A.I. + //maybe used by A.I. s_ent->spawntype = SPAWN_TYPE_CMD_SUMMON; s_ent->parent = ent; ent->subentity = s_ent; @@ -17851,63 +17851,63 @@ int calculate_edelay(entity *ent, int f) } } return iDelay; -} - -// Caskey, Damon V. -// 2018-04-20 -// -// Set up jumping velocity for an animation -// that has jump frame defined and is at the -// designated jump frame. Also spawns effect -// entity if one is defined. -bool check_jumpframe(entity *ent, unsigned int frame) -{ - entity *effect; - - // Must have jump frame allocated. - if(!ent->animation->jumpframe) - { - return 0; - } - - // Must be on assigned jump frame. +} + +// Caskey, Damon V. +// 2018-04-20 +// +// Set up jumping velocity for an animation +// that has jump frame defined and is at the +// designated jump frame. Also spawns effect +// entity if one is defined. +bool check_jumpframe(entity *ent, unsigned int frame) +{ + entity *effect; + + // Must have jump frame allocated. + if(!ent->animation->jumpframe) + { + return 0; + } + + // Must be on assigned jump frame. if(ent->animation->jumpframe->frame != frame) - { - return 0; - } + { + return 0; + } // Chuck entity into the air. toss(ent, ent->animation->jumpframe->velocity.y); - - // Set left or right horizontal velocity depending on - // current direction. - if(ent->direction == DIRECTION_RIGHT) - { - ent->velocity.x = ent->animation->jumpframe->velocity.x; - } - else - { - ent->velocity.x = -ent->animation->jumpframe->velocity.x; - } - + + // Set left or right horizontal velocity depending on + // current direction. + if(ent->direction == DIRECTION_RIGHT) + { + ent->velocity.x = ent->animation->jumpframe->velocity.x; + } + else + { + ent->velocity.x = -ent->animation->jumpframe->velocity.x; + } + // Lateral velocity. ent->velocity.z = ent->animation->jumpframe->velocity.z; - + // Spawn an effect entity if defined. if(ent->animation->jumpframe->ent >= 0) { effect = spawn(ent->position.x, ent->position.z, ent->position.y, ent->direction, NULL, ent->animation->jumpframe->ent, NULL); if(effect) - { + { effect->spawntype = SPAWN_TYPE_DUST_JUMP; effect->base = ent->position.y; effect->autokill = 2; execute_onspawn_script(effect); } - } - + } + return 1; - + } // move here to prevent some duplicated code in ent_sent_anim and update_ents @@ -18053,8 +18053,8 @@ void update_frame(entity *ent, unsigned int f) { sound_play_sample(anim->soundtoplay[f], 0, savedata.effectvol, savedata.effectvol, 100); } - - // Perform jumping if on a jumpframe. + + // Perform jumping if on a jumpframe. check_jumpframe(self, f); @@ -18645,9 +18645,9 @@ void kill(entity *victim) textbox = self; } } - } - - //free_ent(victim); + } + + //free_ent(victim); //victim = alloc_ent(); self = tempent; @@ -19705,8 +19705,8 @@ void do_attack(entity *e) temp = self; self = target; - - // Execute the doattack scripts so author can set take action + + // Execute the doattack scripts so author can set take action // before the hit code below does. execute_ondoattack_script(self, e, attack, EXCHANGE_RECIPIANT, current_attack_id); execute_ondoattack_script(e, self, attack, EXCHANGE_CONFERRER, current_attack_id); @@ -19756,8 +19756,8 @@ void do_attack(entity *e) if(didhit) { if(attack->attack_type == ATK_ITEM) - { - do_item_script(self, e); + { + do_item_script(self, e); didfind_item(e); return; @@ -19798,10 +19798,10 @@ void do_attack(entity *e) self->takeaction = common_block; set_blocking(self); self->velocity.x = self->velocity.z = 0; - ent_set_anim(self, ANI_BLOCK, 0); + ent_set_anim(self, ANI_BLOCK, 0); execute_didblock_script(self, e, attack); - + if(self->modeldata.guardpoints.max > 0) { self->modeldata.guardpoints.current = self->modeldata.guardpoints.current - attack->guardcost; @@ -19830,7 +19830,7 @@ void do_attack(entity *e) //ent_default_init(flash); // initiliaze this because there're no default values now if(flash) - { + { flash->spawntype = SPAWN_TYPE_FLASH; execute_onspawn_script(flash); } @@ -19884,7 +19884,7 @@ void do_attack(entity *e) } //ent_default_init(flash); // initiliaze this because there're no default values now if(flash) - { + { flash->spawntype = SPAWN_TYPE_FLASH; execute_onspawn_script(flash); } @@ -19962,7 +19962,7 @@ void do_attack(entity *e) } //ent_default_init(flash); // initiliaze this because there're no default values now if(flash) - { + { flash->spawntype = SPAWN_TYPE_FLASH; execute_onspawn_script(flash); } @@ -19995,7 +19995,7 @@ void do_attack(entity *e) flash = spawn(lasthit.position.x, lasthit.position.z, lasthit.position.y, 0, NULL, self->modeldata.flash, NULL); } if(flash) - { + { flash->spawntype = SPAWN_TYPE_FLASH; execute_onspawn_script(flash); } @@ -20272,51 +20272,51 @@ void do_attack(entity *e) return 0; }*/ - -// Caskey, Damon V. -// 2018-04-20 -// -// Go to landing frame if available. Also spawns an effect ("dust") entity if set. -bool check_landframe(entity *ent) -{ - entity *effect; - + +// Caskey, Damon V. +// 2018-04-20 +// +// Go to landing frame if available. Also spawns an effect ("dust") entity if set. +bool check_landframe(entity *ent) +{ + entity *effect; + // Must have a landframe. - if(!ent->animation->landframe) - { - return 0; - } - // Can't be passed over current animation's frame count. - if(ent->animation->landframe->frame > ent->animation->numframes) - { - return 0; - } - - // Can't be already at or passed land frame. - if(ent->animpos >= ent->animation->landframe->frame) - { - return 0; - } - - // If a land frame dust effect entity is set, let's spawn it here. + if(!ent->animation->landframe) + { + return 0; + } + // Can't be passed over current animation's frame count. + if(ent->animation->landframe->frame > ent->animation->numframes) + { + return 0; + } + + // Can't be already at or passed land frame. + if(ent->animpos >= ent->animation->landframe->frame) + { + return 0; + } + + // If a land frame dust effect entity is set, let's spawn it here. if(ent->animation->landframe->ent >= 0) { effect = spawn(ent->position.x, ent->position.z, ent->position.y, ent->direction, NULL, ent->animation->landframe->ent, NULL); - + if(effect) - { + { effect->spawntype = SPAWN_TYPE_DUST_LAND; effect->base = ent->position.y; effect->autokill = 2; execute_onspawn_script(effect); } - } + } + + update_frame(ent, ent->animation->landframe->frame); + + return 1; +} - update_frame(ent, ent->animation->landframe->frame); - - return 1; -} - void check_gravity(entity *e) { @@ -20409,10 +20409,10 @@ void check_gravity(entity *e) // If falling and frame has not // passed dropframe, set frame to dropframe. if(self->velocity.y <= 0) - { - if(self->animpos < self->animation->dropframe->frame) - { - update_frame(self, self->animation->dropframe->frame); + { + if(self->animpos < self->animation->dropframe->frame) + { + update_frame(self, self->animation->dropframe->frame); } } } @@ -20451,13 +20451,13 @@ void check_gravity(entity *e) { dust = spawn(self->position.x, self->position.z, self->position.y, self->direction, NULL, self->modeldata.dust.fall_land, NULL); if(dust) - { + { dust->spawntype = SPAWN_TYPE_DUST_FALL; dust->base = self->position.y; dust->autokill = 2; execute_onspawn_script(dust); } - } + } // bounce/quake if(tobounce(self) && self->modeldata.bounce) @@ -20496,13 +20496,13 @@ void check_gravity(entity *e) if(plat && !self->landed_on_platform && self->position.y <= plat->position.y + plat->animation->platform[plat->animpos][7]) { self->landed_on_platform = plat; - } - - // Set landing frame if we have one. - check_landframe(self); - - // Taking damage on a landing? - checkdamageonlanding(); + } + + // Set landing frame if we have one. + check_landframe(self); + + // Taking damage on a landing? + checkdamageonlanding(); // in case landing, set hithead to NULL self->hithead = NULL; @@ -20583,8 +20583,8 @@ int check_lost() if(!is_frozen(self) && self->lifespancountdown != 0x7fffffff) { self->lifespancountdown--; - } - + } + return 0; } @@ -20778,8 +20778,8 @@ void adjust_base(entity *e, entity **pla) //printf("stb:%d\n",self->modeldata.subject_to_basemap); if(self->modeldata.subject_to_basemap > 0) maxbase = check_basemap(self->position.x, self->position.z); - if(self->modeldata.subject_to_hole > 0 && - ( (self->modeldata.subject_to_basemap > 0 && maxbase == T_MIN_BASEMAP) || (self->modeldata.subject_to_basemap <= 0) ) + if(self->modeldata.subject_to_hole > 0 && + ( (self->modeldata.subject_to_basemap > 0 && maxbase == T_MIN_BASEMAP) || (self->modeldata.subject_to_basemap <= 0) ) ) { hole = (wall < 0 && !other) ? checkhole_in(self->position.x, self->position.z, self->position.y) : 0; @@ -20843,38 +20843,38 @@ void adjust_base(entity *e, entity **pla) self = tempself; } - -// Caskey Damon V. -// 2018-04-08 -// -// If entity has a timed color set, check -// to see if colorset has expired. If so, -// revert to default colorset and clear -// the timer. -int colorset_timed_expire(entity *ent) -{ - // No color set time? Nothing to do. - if(!ent->maptime) - { - return 0; - } - - // If elapsed time has surpassed color - // set time, then color set time is expired. - // Revert entity back to default color set - // and reset the color set timer. - if(time >= ent->maptime) - { - ent_set_colourmap(ent, ent->map); - ent->maptime = 0; - + +// Caskey Damon V. +// 2018-04-08 +// +// If entity has a timed color set, check +// to see if colorset has expired. If so, +// revert to default colorset and clear +// the timer. +int colorset_timed_expire(entity *ent) +{ + // No color set time? Nothing to do. + if(!ent->maptime) + { + return 0; + } + + // If elapsed time has surpassed color + // set time, then color set time is expired. + // Revert entity back to default color set + // and reset the color set timer. + if(time >= ent->maptime) + { + ent_set_colourmap(ent, ent->map); + ent->maptime = 0; + return 1; - } - - // Color set time was not expired. - return 0; -} - + } + + // Color set time was not expired. + return 0; +} + void update_animation() { @@ -20936,7 +20936,7 @@ void update_animation() { unfrozen(self); } - + // Check for forced color set expiring. colorset_timed_expire(self); @@ -21053,34 +21053,34 @@ void check_attack() } self->attack_id_outgoing = 0; } - -// Caskey, Damon V. -// 2018-04-08 -// -// If actively charging, add energy to -// entity based on chargerate property -// and elapsed time. Returns 1 if -// energy was added, 0 otherwise. -int do_energy_charge(entity *ent) -{ - // Have we surpassed the next allowed charge time? - // If so, we add the amount of energy from chargerate - // and reset the next available time. - if(ent->charging && time >= ent->mpchargetime) - { - // How much GAME_SPEED will be added onto elapsed time to know when we can next add energy. - float speed_rate = 0.25; - int factor = GAME_SPEED * speed_rate; - + +// Caskey, Damon V. +// 2018-04-08 +// +// If actively charging, add energy to +// entity based on chargerate property +// and elapsed time. Returns 1 if +// energy was added, 0 otherwise. +int do_energy_charge(entity *ent) +{ + // Have we surpassed the next allowed charge time? + // If so, we add the amount of energy from chargerate + // and reset the next available time. + if(ent->charging && time >= ent->mpchargetime) + { + // How much GAME_SPEED will be added onto elapsed time to know when we can next add energy. + float speed_rate = 0.25; + int factor = GAME_SPEED * speed_rate; + ent->energy_status.mp_current += ent->modeldata.chargerate; - ent->mpchargetime = time + factor; - - return 1; - } - - // Didn't charge. - return 0; -} + ent->mpchargetime = time + factor; + + return 1; + } + + // Didn't charge. + return 0; +} void update_health() @@ -21106,7 +21106,7 @@ void update_health() } self->guardtime = time + GAME_SPEED; //Reset guardtime. } - + //Damage over time. damage_recursive(self); @@ -21180,9 +21180,9 @@ void update_health() self->magictime = time + GAME_SPEED; //Reset magictime. } } - - // Active MP charging? - do_energy_charge(self); + + // Active MP charging? + do_energy_charge(self); if(self->energy_status.mp_current > self->modeldata.mp) { @@ -21207,22 +21207,22 @@ void update_health() self->energy_status.mp_old--; } } - + // damage_recursive // Caskey, Damon V. -// 2009-06-17 -// --2018-01-02 retooled from former common_dot. +// 2009-06-17 +// --2018-01-02 retooled from former common_dot. +// +// Apply recursive damage (damage over time (dot)). // -// Apply recursive damage (damage over time (dot)). -// -// When an entity is hit with a recursive damage -// enabled attack, an array keyed from 0 to -// MAX_DOTS on the target will be populated -// with recursive damage values. Which key -// will be populated is module author's choice, -// determined an argument in the recursive attack. -// This function operates by reviewing all keys -// of the target's recursive damage array, and +// When an entity is hit with a recursive damage +// enabled attack, an array keyed from 0 to +// MAX_DOTS on the target will be populated +// with recursive damage values. Which key +// will be populated is module author's choice, +// determined an argument in the recursive attack. +// This function operates by reviewing all keys +// of the target's recursive damage array, and // applying any values found accordingly. void damage_recursive(entity *target) { @@ -21237,21 +21237,21 @@ void damage_recursive(entity *target) float offense; // Owner's offense. float defense; // target defense. entity *owner; // Owner of dot effect. - s_collision_attack attack; // Attack structure. - + s_collision_attack attack; // Attack structure. + // Loop through all DOT indexes. for(index = 0; index < MAX_DOTS; index++) - { + { // Populate local time vars. time_expire = target->dot_time[index]; time_tick = target->dot_cnt[index]; time_rate = target->dot_rate[index]; - - // Is there a recursive damage expire time? If so we + + // Is there a recursive damage expire time? If so we // know there is a recursive damage active on this index. if(time_expire) - { - // If time has expired, clear out other values + { + // If time has expired, clear out other values // and exit this iteration of the loop. if(time > time_expire) { @@ -21260,152 +21260,152 @@ void damage_recursive(entity *target) target->dot_cnt[index] = 0; target->dot_rate[index] = 0; target->dot_time[index] = 0; - target->dot_force[index] = 0; - + target->dot_force[index] = 0; + + continue; + } + + // If it is not yet time for a tick, exit + // this iteration of loop. + if(!(time >= time_tick)) + { continue; - } - - // If it is not yet time for a tick, exit - // this iteration of loop. - if(!(time >= time_tick)) - { - continue; - } - + } + // If target is not alive, exit this iteration of loop. if(target->energy_status.health_current <= 0) - { - continue; - } - + { + continue; + } + // Reset next tick time. target->dot_cnt[index] = time + (time_rate * GAME_SPEED / 100); - + // Populate local recursive type and force vars. mode = target->dot[index]; - force = target->dot_force[index]; - - // Does this recursive damage affect HP? + force = target->dot_force[index]; + + // Does this recursive damage affect HP? if(mode == DOT_MODE_HP || mode == DOT_MODE_HP_MP || mode == DOT_MODE_NON_LETHAL_HP || mode == DOT_MODE_NON_LETHAL_HP_MP) - { - // Recursive HP Damage Logic: - // - // Normally it is preferable to apply takedamage(), - // any time we want to damage a target, but because - // it breaks grabs and would spam the HUD, - // takedamage() is not tenable for every tick - // of a recursive damage effect. However, we DO want - // the owner to get credit, grabs to be broken, HUD - // to react, etc., if the target is KO'd. - - // To handle both needs, we will first factor offense - // and defense manually to get a calculated force. If - // the calculated force is sufficient to KO target, and - // this recursive tick is allowed to KO, we will go ahead - // and apply takedamage() using the original recursive - // force (takedamage() automatically calculates offense - // and defense). This way the engine will treat KO tick as - // if it were a direct hit with all appropriate reactions - // and credit. Otherwise, we'll just subject the calculated - // force directly from target's HP for a 'silent' damage effect. - - // Populate remaining local vars we'll need - // to apply recursive HP damage. + { + // Recursive HP Damage Logic: + // + // Normally it is preferable to apply takedamage(), + // any time we want to damage a target, but because + // it breaks grabs and would spam the HUD, + // takedamage() is not tenable for every tick + // of a recursive damage effect. However, we DO want + // the owner to get credit, grabs to be broken, HUD + // to react, etc., if the target is KO'd. + + // To handle both needs, we will first factor offense + // and defense manually to get a calculated force. If + // the calculated force is sufficient to KO target, and + // this recursive tick is allowed to KO, we will go ahead + // and apply takedamage() using the original recursive + // force (takedamage() automatically calculates offense + // and defense). This way the engine will treat KO tick as + // if it were a direct hit with all appropriate reactions + // and credit. Otherwise, we'll just subject the calculated + // force directly from target's HP for a 'silent' damage effect. + + // Populate remaining local vars we'll need + // to apply recursive HP damage. owner = target->dot_owner[index]; attack_type = target->dot_atk[index]; - force_final = force; - - // Get owner's offense and target's defense + force_final = force; + + // Get owner's offense and target's defense // factors for the recursive damage type. offense = owner->offense_factors[attack_type]; - defense = target->defense[attack_type].factor; - - // Calculate resulting force from any existing owner - // offense and target defense factors. + defense = target->defense[attack_type].factor; + + // Calculate resulting force from any existing owner + // offense and target defense factors. if (offense) { force_final = (int)(force * offense); - } - + } + if (defense) { force_final = (int)(force_final * defense); - } - - // Is calculated force enough to KO target? - // Is this recursive damage allowed to KO? + } + + // Is calculated force enough to KO target? + // Is this recursive damage allowed to KO? if(force_final >= target->energy_status.health_current) - { - // Is this recursive damage allowed to KO? - if(mode == DOT_MODE_HP || mode == DOT_MODE_HP_MP) - { - // Does target have a takedamage structure? If so - // we can use takedamage() for the finishing damage. - // Otherwise it must be a none type or some other - // exceptional entity like a projectile. In that case + { + // Is this recursive damage allowed to KO? + if(mode == DOT_MODE_HP || mode == DOT_MODE_HP_MP) + { + // Does target have a takedamage structure? If so + // we can use takedamage() for the finishing damage. + // Otherwise it must be a none type or some other + // exceptional entity like a projectile. In that case // we will simply kill it. if(target->takedamage) - { - // Populate attack structure with + { + // Populate attack structure with // our recursive damage values. attack = emptyattack; attack.attack_type = attack_type; attack.attack_force = force; attack.dropv.y = default_model_dropv.y; attack.dropv.x = default_model_dropv.x; - attack.dropv.z = default_model_dropv.z; - - // Apply takedamage(). The engine will - // take care of everything else damage + attack.dropv.z = default_model_dropv.z; + + // Apply takedamage(). The engine will + // take care of everything else damage // related. target->takedamage(owner, &attack, 0); } else - { + { // Kill target instantly. kill(target); - } - } - else - { - // Recursive damage is not allowed to KO - // just set target's HP to minimum value. - target->energy_status.health_current = 1; - - // Execute the target's takedamage script. - execute_takedamage_script(target, owner, &attack); + } + } + else + { + // Recursive damage is not allowed to KO + // just set target's HP to minimum value. + target->energy_status.health_current = 1; + + // Execute the target's takedamage script. + execute_takedamage_script(target, owner, &attack); } } else - { - // Calculated damage is insufficient to KO. - // Subtract directly from target's HP. + { + // Calculated damage is insufficient to KO. + // Subtract directly from target's HP. target->energy_status.health_current -= force_final; - // Execute the target's takedamage script. + // Execute the target's takedamage script. execute_takedamage_script(target, owner, &attack); - } - - } + } + + } // Does this recursive damage affect MP? if(mode == DOT_MODE_MP || mode == DOT_MODE_HP_MP || mode == DOT_MODE_NON_LETHAL_HP_MP) - { - // Recursive HP Damage Logic: - - // Could not be more simple. Subtract - // recursive force from MP. If MP would - // end with negative value, set 0. - + { + // Recursive HP Damage Logic: + + // Could not be more simple. Subtract + // recursive force from MP. If MP would + // end with negative value, set 0. + // Subtract force from MP. target->energy_status.mp_current -= force; - - // Stabilize MP at 0. + + // Stabilize MP at 0. if(target->energy_status.mp_current < 0) { target->energy_status.mp_current = 0; @@ -22645,7 +22645,7 @@ int set_pain(entity *iPain, int type, int reset) } /* - * Copy animations from newmodel to model. If newmodel has anim that is not in model, + * Copy animations from newmodel to model. If newmodel has anim that is not in model, * then copy that anim (but no frames with alloc_anim()) from newmodel to model */ void normalize_anim_models(s_model *model, s_model *newmodel) @@ -22896,7 +22896,7 @@ entity *block_find_target(int anim, int detect_adj) if( attacker && attacker->exists && attacker != self //cant target self && (attacker->modeldata.candamage & self->modeldata.type) && (anim < 0 || (anim >= 0 && check_range_target_all(self, attacker, anim))) - && !attacker->dead //must be alive + && !attacker->dead //must be alive && attacker->attacking != ATTACKING_INACTIVE && attacker->animation->collision_attack && attacker->animation->collision_attack[attacker->animpos] && attacker->animation->collision_attack[attacker->animpos]->instance && ( !attacker->animation->collision_attack[attacker->animpos]->instance[instance] || (attacker->animation->collision_attack[attacker->animpos]->instance[instance] && attacker->animation->collision_attack[attacker->animpos]->instance[instance]->no_block == 0) ) @@ -22935,89 +22935,89 @@ entity *normal_find_target(int anim, int detect_adj) int detect_adj: Local detection adjustment. Allows lesser or greater penetration of target's stealth for location. */ - int i; - int min; - int max; + int i; + int min; + int max; int detect; int index = -1; - float diffx = 0; - float diffz = 0; - float diffd = 0; - float diffo = 0; - + float diffx = 0; + float diffz = 0; + float diffd = 0; + float diffo = 0; + min = 0; - max = 9999; + max = 9999; detect = detect_adj + self->modeldata.stealth.detect; //find the 'nearest' one for(i = 0; i < ent_max; i++) - { - // Must exist. - if(!ent_list[i]->exists) - { - continue; - } - - // Can't be self. - if(ent_list[i] == self) - { - continue; - } - - // Must be hostile. - if(!(ent_list[i]->modeldata.type & self->modeldata.hostile)) - { - continue; - } - - // If anim is defined, then then target must be - // in range of animation. - if(anim >= 0) - { - if(!check_range_target_all(self, ent_list[i], anim)) - { - continue; - } - } - - // Can't be dead. - if(ent_list[i]->dead) - { - continue; - } - - // Get X and Z differences between us and target. We then - // add them up to get a total distance. - diffx = diff(ent_list[i]->position.x, self->position.x); - diffz = diff(ent_list[i]->position.z, self->position.z); - diffd = diffx + diffz; - - // Distance must be within min and max. - if(diffd <= min || diffd >= max) - { - continue; - } - + { + // Must exist. + if(!ent_list[i]->exists) + { + continue; + } + + // Can't be self. + if(ent_list[i] == self) + { + continue; + } + + // Must be hostile. + if(!(ent_list[i]->modeldata.type & self->modeldata.hostile)) + { + continue; + } + + // If anim is defined, then then target must be + // in range of animation. + if(anim >= 0) + { + if(!check_range_target_all(self, ent_list[i], anim)) + { + continue; + } + } + + // Can't be dead. + if(ent_list[i]->dead) + { + continue; + } + + // Get X and Z differences between us and target. We then + // add them up to get a total distance. + diffx = diff(ent_list[i]->position.x, self->position.x); + diffz = diff(ent_list[i]->position.z, self->position.z); + diffd = diffx + diffz; + + // Distance must be within min and max. + if(diffd <= min || diffd >= max) + { + continue; + } + // Stealth must not be greater than perception. if(ent_list[i]->modeldata.stealth.hide > detect) - { + { continue; - } + } + - - if(index < 0 - || (index >= 0 && (!ent_list[index]->animation->vulnerable[ent_list[index]->animpos] || ent_list[index]->invincible == 1)) - // don't turn to the one on the back + if(index < 0 + || (index >= 0 && (!ent_list[index]->animation->vulnerable[ent_list[index]->animpos] || ent_list[index]->invincible == 1)) + // don't turn to the one on the back || ((self->position.x < ent_list[i]->position.x) == (self->direction == DIRECTION_RIGHT) && diffd < diffo) ) { index = i; diffo = diffd; - } - - - } + } + + + } if(index >= 0) { @@ -23282,7 +23282,7 @@ void common_jump() } self->velocity.z = self->velocity.x = 0; - + // check if jumpland animation exists and not using landframe if(validanim(self, ANI_JUMPLAND) && !self->animation->landframe) { @@ -23292,7 +23292,7 @@ void common_jump() { dust = spawn(self->position.x, self->position.z, self->position.y, self->direction, NULL, self->modeldata.dust.jump_land, NULL); if(dust) - { + { dust->spawntype = SPAWN_TYPE_DUST_LAND; dust->base = self->position.y; dust->autokill = 2; @@ -23306,7 +23306,7 @@ void common_jump() { dust = spawn(self->position.x, self->position.z, self->position.y, self->direction, NULL, self->modeldata.dust.jump_land, NULL); if(dust) - { + { dust->spawntype = SPAWN_TYPE_DUST_LAND; dust->base = self->position.y; dust->autokill = 2; @@ -23380,7 +23380,7 @@ void doland() self->velocity.x = self->velocity.z = 0; self->drop = 0; self->projectile = 0; - self->damage_on_landing.attack_force = 0; + self->damage_on_landing.attack_force = 0; self->damage_on_landing.attack_type = ATK_NONE; if(validanim(self, ANI_LAND)) { @@ -23600,48 +23600,48 @@ void dograbattack(int which) } } else - { + { do_grab_attack_finish(self, 0); } -} - -// Caskey, Damon V. -// 2018-04-11 -// -// Choose appropriate grab finish animation -// or do nothing if we can't find one. Returns -// selected animation. -e_animations do_grab_attack_finish(entity *ent, int which) -{ - e_animations animation; - - // Clear out the combostep array since this is - // the finishing attack. +} + +// Caskey, Damon V. +// 2018-04-11 +// +// Choose appropriate grab finish animation +// or do nothing if we can't find one. Returns +// selected animation. +e_animations do_grab_attack_finish(entity *ent, int which) +{ + e_animations animation; + + // Clear out the combostep array since this is + // the finishing attack. memset(ent->combostep, 0, sizeof(*ent->combostep) * 5); - - // Get the finisher animation. - animation = grab_attacks[which][1]; - - // If selected attack animation exists then - // that's what we use. Otherwise default to - // attack3. If THAT fails, we don't do anything. - // The target entity is already unlinked from - // grab before this function was called, so in - // game they are let go with no finishing attack. + + // Get the finisher animation. + animation = grab_attacks[which][1]; + + // If selected attack animation exists then + // that's what we use. Otherwise default to + // attack3. If THAT fails, we don't do anything. + // The target entity is already unlinked from + // grab before this function was called, so in + // game they are let go with no finishing attack. if(validanim(ent, animation)) { - ent_set_anim(ent, animation, 0); + ent_set_anim(ent, animation, 0); return animation; - } + } else if(validanim(ent, ANI_ATTACK3)) - { + { // Get the finisher animation. - ent_set_anim(ent, ANI_ATTACK3, 0); + ent_set_anim(ent, ANI_ATTACK3, 0); return ANI_ATTACK3; - } - - // Could not find a valid finisher. Return none. - return ATK_NONE; + } + + // Could not find a valid finisher. Return none. + return ATK_NONE; } void common_grab_check() @@ -23800,13 +23800,13 @@ entity *drop_item(entity *e) s_spawn_entry p; entity *item; memset(&p, 0, sizeof(p)); - - // Just to make sure there is an item so - // we don't look for data on a NULL pointer. - if(!e->item_properties) - { - return NULL; - } + + // Just to make sure there is an item so + // we don't look for data on a NULL pointer. + if(!e->item_properties) + { + return NULL; + } p.index = e->item_properties->index; p.item_properties.index = p.weaponindex = -1; @@ -23815,13 +23815,13 @@ entity *drop_item(entity *e) p.health[0] = e->item_properties->health; p.alpha = e->item_properties->alpha; p.colourmap = e->item_properties->colorset; - p.flip = e->direction; - - item = smartspawn(&p); + p.flip = e->direction; + + item = smartspawn(&p); if(item) - { - item->spawntype = SPAWN_TYPE_ITEM; + { + item->spawntype = SPAWN_TYPE_ITEM; item->position.x = e->position.x; item->position.z = e->position.z; @@ -23850,7 +23850,7 @@ entity *drop_item(entity *e) } } return item; -} +} //drop the driver, just spawn, dont takedamage // damage will adjust by the biker @@ -23871,21 +23871,21 @@ entity *drop_driver(entity *e) } p.position.y = e->position.y + 10; p.weaponindex = -1; - strcpy(p.alias, e->name); - - // Carrying an item, so let's transfer that to spawn - // entry for the driver. - if(e->item_properties) - { - strcpy(p.item_properties.alias, e->item_properties->alias); - - p.item_properties.index = e->item_properties->index; + strcpy(p.alias, e->name); + + // Carrying an item, so let's transfer that to spawn + // entry for the driver. + if(e->item_properties) + { + strcpy(p.item_properties.alias, e->item_properties->alias); + + p.item_properties.index = e->item_properties->index; p.item_properties.colorset = e->item_properties->colorset; p.item_properties.alpha = e->item_properties->alpha; p.item_properties.health = e->item_properties->health; - p.item_properties.player_count = e->item_properties->player_count; - } - + p.item_properties.player_count = e->item_properties->player_count; + } + //p.colourmap = e->map; for(i = 0; i < MAX_PLAYERS; i++) @@ -23896,7 +23896,7 @@ entity *drop_driver(entity *e) driver = smartspawn(&p); if(driver) - { + { driver->spawntype = SPAWN_TYPE_BIKER; driver->position.x = e->position.x; driver->position.z = e->position.z; @@ -23923,15 +23923,15 @@ void checkdeath() if(self->modeldata.diesound >= 0) { sound_play_sample(self->modeldata.diesound, 0, savedata.effectvol, savedata.effectvol, 100); - } + } - // Drop an item if we have one. - if(self->item_properties) - { - if(count_ents(TYPE_PLAYER) > self->item_properties->player_count) - { - drop_item(self); - } + // Drop an item if we have one. + if(self->item_properties) + { + if(count_ents(TYPE_PLAYER) > self->item_properties->player_count) + { + drop_item(self); + } } @@ -24200,10 +24200,10 @@ void checkhitscore(entity *other, s_collision_attack *attack) { addscore(opp->playerindex, attack->attack_force); } -} - -int calculate_force_damage(entity *other, s_collision_attack *attack) -{ +} + +int calculate_force_damage(entity *other, s_collision_attack *attack) +{ int force = attack->attack_force; int type = attack->attack_type; @@ -24215,47 +24215,47 @@ int calculate_force_damage(entity *other, s_collision_attack *attack) { force = (int)(force * other->offense_factors[type]); force = (int)(force * self->defense[type].factor); - } - - return force; -} - -void checkdamageonlanding() -{ - if (self->energy_status.health_current <= 0) return; - - if( (self->damage_on_landing.attack_force > 0 && !self->dead) ) - { - int didhit = 0; - - //################## - s_collision_attack attack; - entity *other; - + } + + return force; +} + +void checkdamageonlanding() +{ + if (self->energy_status.health_current <= 0) return; + + if( (self->damage_on_landing.attack_force > 0 && !self->dead) ) + { + int didhit = 0; + + //################## + s_collision_attack attack; + entity *other; + attack = emptyattack; attack.attack_force = self->damage_on_landing.attack_force; - if (attack.damage_on_landing.attack_type >= 0) attack.attack_type = self->damage_on_landing.attack_type; - else attack.attack_type = ATK_LAND; - - if (self->opponent && self->opponent->exists && !self->opponent->dead && self->opponent->energy_status.health_current > 0) other = self->opponent; - else other = self; - - lasthit.confirm = 1; - lasthit.attack = &attack; - lasthit.position.x = self->position.x; - lasthit.position.y = self->position.y; - lasthit.position.z = self->position.z; - - // Execute the doattack functions before damage is - // processed. - execute_ondoattack_script(self, other, &attack, EXCHANGE_RECIPIANT, other->attack_id_outgoing); - execute_ondoattack_script(other, self, &attack, EXCHANGE_CONFERRER, other->attack_id_outgoing); - - if(lasthit.confirm) - { - didhit = 1; - } - + if (attack.damage_on_landing.attack_type >= 0) attack.attack_type = self->damage_on_landing.attack_type; + else attack.attack_type = ATK_LAND; + + if (self->opponent && self->opponent->exists && !self->opponent->dead && self->opponent->energy_status.health_current > 0) other = self->opponent; + else other = self; + + lasthit.confirm = 1; + lasthit.attack = &attack; + lasthit.position.x = self->position.x; + lasthit.position.y = self->position.y; + lasthit.position.z = self->position.z; + + // Execute the doattack functions before damage is + // processed. + execute_ondoattack_script(self, other, &attack, EXCHANGE_RECIPIANT, other->attack_id_outgoing); + execute_ondoattack_script(other, self, &attack, EXCHANGE_CONFERRER, other->attack_id_outgoing); + + if(lasthit.confirm) + { + didhit = 1; + } + if(self->dead) { return; @@ -24268,87 +24268,87 @@ void checkdamageonlanding() if(!checkgrab(other, &attack)) { return; // try to grab but failed, so return 0 means attack missed - } - + } + if(self != other) { set_opponent(self, other); - } - //################## - - if (didhit) - { - // pre-check drop - checkdamagedrop(&attack); - // Drop Weapon due to being hit. - if(self->modeldata.weaploss[0] == WEAPLOSS_TYPE_ANY) - { - dropweapon(1); - } - // check effects, e.g., frozen, blast, steal - if(!(self->modeldata.guardpoints.max > 0 && self->modeldata.guardpoints.current <= 0)) - { - checkdamageeffects(&attack); - } - - // mprate can also control the MP recovered per hit. - checkmpadd(); - //damage score - checkhitscore(other, &attack); - - checkdamage(other, &attack); - + } + //################## + + if (didhit) + { + // pre-check drop + checkdamagedrop(&attack); + // Drop Weapon due to being hit. + if(self->modeldata.weaploss[0] == WEAPLOSS_TYPE_ANY) + { + dropweapon(1); + } + // check effects, e.g., frozen, blast, steal + if(!(self->modeldata.guardpoints.max > 0 && self->modeldata.guardpoints.current <= 0)) + { + checkdamageeffects(&attack); + } + + // mprate can also control the MP recovered per hit. + checkmpadd(); + //damage score + checkhitscore(other, &attack); + + checkdamage(other, &attack); + // is it dead now? - checkdeath(); - - execute_didhit_script(other, self, &attack, 0); - } - - if (self->energy_status.health_current <= 0) - { - self->die_on_landing = 1; - } - - self->damage_on_landing.attack_force = 0; + checkdeath(); + + execute_didhit_script(other, self, &attack, 0); + } + + if (self->energy_status.health_current <= 0) + { + self->die_on_landing = 1; + } + + self->damage_on_landing.attack_force = 0; } // takedamage if thrown or basted - //if( (self->damage_on_landing.attack_force > 0 && !self->dead) && - if( (self->die_on_landing && !self->dead) && - ((!tobounce(self) && self->modeldata.bounce) || !self->modeldata.bounce) && - (self->velocity.x == 0 && self->velocity.z == 0 && self->velocity.y == 0) + //if( (self->damage_on_landing.attack_force > 0 && !self->dead) && + if( (self->die_on_landing && !self->dead) && + ((!tobounce(self) && self->modeldata.bounce) || !self->modeldata.bounce) && + (self->velocity.x == 0 && self->velocity.z == 0 && self->velocity.y == 0) ) { if(self->takedamage) - { - //################## - s_collision_attack attack; - entity *other; - + { + //################## + s_collision_attack attack; + entity *other; + attack = emptyattack; attack.attack_force = self->damage_on_landing.attack_force; - if (attack.damage_on_landing.attack_type >= 0) attack.attack_type = self->damage_on_landing.attack_type; - else attack.attack_type = ATK_LAND; - - if (self->opponent && self->opponent->exists && !self->opponent->dead && self->opponent->energy_status.health_current > 0) other = self->opponent; - else other = self; - //################## - + if (attack.damage_on_landing.attack_type >= 0) attack.attack_type = self->damage_on_landing.attack_type; + else attack.attack_type = ATK_LAND; + + if (self->opponent && self->opponent->exists && !self->opponent->dead && self->opponent->energy_status.health_current > 0) other = self->opponent; + else other = self; + //################## + self->takedamage(other, &attack, 1); } else - { + { kill(self); - } - if (self) - { - self->damage_on_landing.attack_force = 0; - self->damage_on_landing.attack_type = ATK_NONE; - self->die_on_landing = 0; } - } - - return; + if (self) + { + self->damage_on_landing.attack_force = 0; + self->damage_on_landing.attack_type = ATK_NONE; + self->die_on_landing = 0; + } + } + + return; } void checkdamage(entity *other, s_collision_attack *attack) @@ -24368,7 +24368,7 @@ void checkdamage(entity *other, s_collision_attack *attack) { self->energy_status.health_current = 1; } - + // Execute the take damage script. execute_takedamage_script(self, other, attack); @@ -24384,12 +24384,12 @@ void checkdamage(entity *other, s_collision_attack *attack) { self->energy_status.health_current = self->modeldata.health; //Reset to max health. } - } - + } + // Execute ondeath script. execute_ondeath_script(self, other, attack); - } - + } + return; } @@ -24446,7 +24446,7 @@ int common_takedamage(entity *other, s_collision_attack *attack, int fall_flag) { set_opponent(self, other); } - + // adjust type if(attack->attack_type >= 0 && attack->attack_type < max_attack_types) { @@ -24455,10 +24455,10 @@ int common_takedamage(entity *other, s_collision_attack *attack, int fall_flag) else { self->last_damage_type = ATK_NORMAL; - } - - if (!self->die_on_landing) - { + } + + if (!self->die_on_landing) + { // pre-check drop checkdamagedrop(attack); // Drop Weapon due to being hit. @@ -24470,24 +24470,24 @@ int common_takedamage(entity *other, s_collision_attack *attack, int fall_flag) if(!(self->modeldata.guardpoints.max > 0 && self->modeldata.guardpoints.current <= 0)) { checkdamageeffects(attack); - } + } } // check backpain check_backpain(other,self); // check flip direction - checkdamageflip(other, attack); - - if (!self->die_on_landing) - { + checkdamageflip(other, attack); + + if (!self->die_on_landing) + { // mprate can also control the MP recovered per hit. checkmpadd(); //damage score - checkhitscore(other, attack); + checkhitscore(other, attack); // check damage, cost hp. - checkdamage(other, attack); + checkdamage(other, attack); // is it dead now? - checkdeath(); + checkdeath(); } if(self->modeldata.type & TYPE_PLAYER) @@ -24512,10 +24512,10 @@ int common_takedamage(entity *other, s_collision_attack *attack, int fall_flag) { self->damage_on_landing.attack_force = 0; return 1; - }*/ - // reset damageonlanding - self->damage_on_landing.attack_force = 0; - self->damage_on_landing.attack_type = ATK_NONE; + }*/ + // reset damageonlanding + self->damage_on_landing.attack_force = 0; + self->damage_on_landing.attack_type = ATK_NONE; // White Dragon: fix damage_on_landing bug if(self->die_on_landing && self->energy_status.health_current <= 0) @@ -24540,7 +24540,7 @@ int common_takedamage(entity *other, s_collision_attack *attack, int fall_flag) { self->escapecount++; } - } + } // New pain, fall, and death animations. Also, the nopain flag. if(self->drop || self->energy_status.health_current <= 0) @@ -24562,7 +24562,7 @@ int common_takedamage(entity *other, s_collision_attack *attack, int fall_flag) set_death(self, attack->attack_type, 0); } else - { + { if (fall_flag >= 1) return 1; self->velocity.x = attack->dropv.x; self->velocity.z = attack->dropv.z; @@ -24572,7 +24572,7 @@ int common_takedamage(entity *other, s_collision_attack *attack, int fall_flag) } if(self->inbackpain) self->velocity.x *= -1; toss(self, attack->dropv.y); - self->damage_on_landing.attack_force = attack->damage_on_landing.attack_force; + self->damage_on_landing.attack_force = attack->damage_on_landing.attack_force; self->damage_on_landing.attack_type = attack->damage_on_landing.attack_type; self->knockdowncount = self->modeldata.knockdowncount; // reset the knockdowncount self->knockdowntime = 0; @@ -24609,7 +24609,7 @@ int common_takedamage(entity *other, s_collision_attack *attack, int fall_flag) { self->takeaction = common_pain; set_pain(self, self->last_damage_type, 1); - } + } return 1; } @@ -24970,7 +24970,7 @@ int common_try_jumpattack(entity *target) { dust = spawn(self->position.x, self->position.z, self->position.y, self->direction, NULL, self->modeldata.dust.jump_start, NULL); if(dust) - { + { dust->spawntype = SPAWN_TYPE_DUST_JUMP; dust->base = self->position.y; dust->autokill = 2; @@ -25041,7 +25041,7 @@ void common_throw() // toss the grabbed one void dothrow() -{ +{ s_collision_attack attack; entity *other; self->velocity.x = self->velocity.z = 0; @@ -25078,9 +25078,9 @@ void dothrow() ent_unlink(other); other->takeaction = common_fall; - self->takeaction = common_throw; - - // Use default attack values. + self->takeaction = common_throw; + + // Use default attack values. attack = emptyattack; set_fall(other, self, &attack, 0); ent_set_anim(self, ANI_THROW, 0); @@ -27061,20 +27061,20 @@ int common_try_wander(entity *target, int dox, int doz) return walk; } - -// Caskey, Damon V. -// 208-04-09 -// -// Set up attack by item and execute didhit script as if item "hit" collector -// to allow easy item scripting. -void do_item_script(entity *ent, entity *item) -{ - s_collision_attack attack; - attack = emptyattack; - attack.attack_type = ATK_ITEM; - - execute_didhit_script(item, ent, &attack, 0); -} + +// Caskey, Damon V. +// 208-04-09 +// +// Set up attack by item and execute didhit script as if item "hit" collector +// to allow easy item scripting. +void do_item_script(entity *ent, entity *item) +{ + s_collision_attack attack; + attack = emptyattack; + attack.attack_type = ATK_ITEM; + + execute_didhit_script(item, ent, &attack, 0); +} //A.I chracter pickup an item void common_pickupitem(entity *other) @@ -27139,8 +27139,8 @@ void common_pickupitem(entity *other) } // hide it if(pickup) - { - do_item_script(self, other); + { + do_item_script(self, other); other->position.z = 100000; } @@ -27265,67 +27265,67 @@ int arrow_move() { // Bounce off walls or platforms. projectile_wall_deflect(self); - } - - if(self->projectile_prime & PROJECTILE_PRIME_BASE_FLOOR) - { - self->autokill = 2; + } + + if(self->projectile_prime & PROJECTILE_PRIME_BASE_FLOOR) + { + self->autokill = 2; } return 1; } - -// Caskey, Damon V. -// 2018-04-07 -// -// Find out if there is a wall blocking target entity, and -// if so return its array key. Returns 0 if no blocking -// wall is found. -int check_block_wall(entity *entity) -{ - int wall; - - // Target entity affected by walls? - if(entity->modeldata.subject_to_wall) - { - // Get wall number at our X and Z axis (if any). - wall = checkwall(entity->position.x, entity->position.z); - - // Did we find a wall? - if (wall > 0) - { - // Compare wall height to our current - // Y axis position. If the wall is - // higher, then it's blocking our way. - // We can return the wall number. - if(entity->position.y < level->walls[wall].height) - { - return wall; - } - } - } - - // Got this far? Then there's no wall blocking our way. - return 0; -} - -// Caskey, Damon V. -// 2018-04-07 -// -// Return obstacle entity that is blocking target -// entity (if any). Returns NULL if not blocking -// obstacle found. -entity *check_block_obstacle(entity *ent) -{ - entity *obstacle = NULL; - int height; - - // Target entity affected by obstacles? - if(ent->modeldata.subject_to_platform) - { - // Get the height. if entity does not have an - // animation height defined, then use its - // the entity height instead. + +// Caskey, Damon V. +// 2018-04-07 +// +// Find out if there is a wall blocking target entity, and +// if so return its array key. Returns 0 if no blocking +// wall is found. +int check_block_wall(entity *entity) +{ + int wall; + + // Target entity affected by walls? + if(entity->modeldata.subject_to_wall) + { + // Get wall number at our X and Z axis (if any). + wall = checkwall(entity->position.x, entity->position.z); + + // Did we find a wall? + if (wall > 0) + { + // Compare wall height to our current + // Y axis position. If the wall is + // higher, then it's blocking our way. + // We can return the wall number. + if(entity->position.y < level->walls[wall].height) + { + return wall; + } + } + } + + // Got this far? Then there's no wall blocking our way. + return 0; +} + +// Caskey, Damon V. +// 2018-04-07 +// +// Return obstacle entity that is blocking target +// entity (if any). Returns NULL if not blocking +// obstacle found. +entity *check_block_obstacle(entity *ent) +{ + entity *obstacle = NULL; + int height; + + // Target entity affected by obstacles? + if(ent->modeldata.subject_to_platform) + { + // Get the height. if entity does not have an + // animation height defined, then use its + // the entity height instead. if(ent->animation->size.y) { height = ent->animation->size.y; @@ -27333,256 +27333,256 @@ entity *check_block_obstacle(entity *ent) else { height = ent->modeldata.size.y; - } - - // Add Y position to get the exact Y axis - // height of the entity's top edge. - height += ent->position.y; - - // Find obstacle at entitiy's position (if any). - obstacle = check_platform_between(ent->position.x, ent->position.z, ent->position.y, height, ent); - } - - return obstacle; -} - -// Caskey, Damon V -// 2018-04-06 -// -// Ricochet a projectile off of walls and platforms. -// Returns 1 on successful ricochet. 0 otherwise. -int projectile_wall_deflect(entity *ent) -{ - #define FALL_FORCE 1000 // Knockdown force that will be applied to projectile entity. - #define RICHOCHET_VELOCITY_X_FACTOR 0.25 // This value is multiplied by current velocity to get an X velocity value to bounce off wall.. - #define RICHOCHET_VELOCITY_Y 2.5 // Base Y velocity applied when projectile bounces off wall. - #define RICHOCHET_VELOCITY_Y_RAND 1 // Random seed for Y variance added to base Y velocity when bouncing off wall. - - float richochet_velocity_x; - s_collision_attack attack; - + } + + // Add Y position to get the exact Y axis + // height of the entity's top edge. + height += ent->position.y; + + // Find obstacle at entitiy's position (if any). + obstacle = check_platform_between(ent->position.x, ent->position.z, ent->position.y, height, ent); + } + + return obstacle; +} + +// Caskey, Damon V +// 2018-04-06 +// +// Ricochet a projectile off of walls and platforms. +// Returns 1 on successful ricochet. 0 otherwise. +int projectile_wall_deflect(entity *ent) +{ + #define FALL_FORCE 1000 // Knockdown force that will be applied to projectile entity. + #define RICHOCHET_VELOCITY_X_FACTOR 0.25 // This value is multiplied by current velocity to get an X velocity value to bounce off wall.. + #define RICHOCHET_VELOCITY_Y 2.5 // Base Y velocity applied when projectile bounces off wall. + #define RICHOCHET_VELOCITY_Y_RAND 1 // Random seed for Y variance added to base Y velocity when bouncing off wall. + + float richochet_velocity_x; + s_collision_attack attack; + if(validanim(ent, ANI_FALL)) { - int blocking_wall; - entity *blocking_obstacle = NULL; - - blocking_wall = check_block_wall(self); - blocking_obstacle = check_block_obstacle(self); + int blocking_wall; + entity *blocking_obstacle = NULL; + + blocking_wall = check_block_wall(self); + blocking_obstacle = check_block_obstacle(self); + + if(blocking_wall || blocking_obstacle) { - if(blocking_wall || blocking_obstacle) { - - // Use the projectiles speed and our factor to see how - // hard it will bounce off wall. - richochet_velocity_x = ent->velocity.x * RICHOCHET_VELOCITY_X_FACTOR; + // Use the projectiles speed and our factor to see how + // hard it will bounce off wall. + richochet_velocity_x = ent->velocity.x * RICHOCHET_VELOCITY_X_FACTOR; ent->takeaction = common_fall; ent->attacking = ATTACKING_INACTIVE; ent->energy_status.health_current = 0; ent->projectile = 0; ent->velocity.x = (ent->direction == DIRECTION_RIGHT) ? (-richochet_velocity_x) : richochet_velocity_x; - ent->damage_on_landing.attack_force = 0; + ent->damage_on_landing.attack_force = 0; ent->damage_on_landing.attack_type = ATK_NONE; - toss(ent, RICHOCHET_VELOCITY_Y + randf(RICHOCHET_VELOCITY_Y_RAND)); - + toss(ent, RICHOCHET_VELOCITY_Y + randf(RICHOCHET_VELOCITY_Y_RAND)); + // Use default attack values. - attack = emptyattack; - set_fall(ent, ent, &attack, 0); - + attack = emptyattack; + set_fall(ent, ent, &attack, 0); + return 1; } - } - - // Did not ricochet, so return false. - return 0; - - #undef FALL_FORCE - #undef RICHOCHET_VELOCITY_X_FACTOR - #undef RICHOCHET_VELOCITY_Y - #undef RICHOCHET_VELOCITY_Y_RAND -} - -// Caskey, Damon V. -// 2018-04-08 -// -// Destroy target and while ent plays catch animation -// if ent has the catch animation and target is in range. -// Mainly for boomerang projectiles but useful for any -// time one entity should "catch" another out of the air. -// -// Returns true on successful catch, false otherwise. -int do_catch(entity *ent, entity *target, int animation_catch) -{ - // Valid catch animation? - if(validanim(ent, animation_catch)) - { - // If target is in range, then destroy it - // while we play the catch animation, - // and return true. - if(check_range_target_all(ent, target, animation_catch)) - { + } + + // Did not ricochet, so return false. + return 0; + + #undef FALL_FORCE + #undef RICHOCHET_VELOCITY_X_FACTOR + #undef RICHOCHET_VELOCITY_Y + #undef RICHOCHET_VELOCITY_Y_RAND +} + +// Caskey, Damon V. +// 2018-04-08 +// +// Destroy target and while ent plays catch animation +// if ent has the catch animation and target is in range. +// Mainly for boomerang projectiles but useful for any +// time one entity should "catch" another out of the air. +// +// Returns true on successful catch, false otherwise. +int do_catch(entity *ent, entity *target, int animation_catch) +{ + // Valid catch animation? + if(validanim(ent, animation_catch)) + { + // If target is in range, then destroy it + // while we play the catch animation, + // and return true. + if(check_range_target_all(ent, target, animation_catch)) + { ent->takeaction = common_animation_normal; ent->attacking = ATTACKING_INACTIVE; ent->idling = 0; ent_set_anim(ent, animation_catch, 0); kill(target); - - return 1; - } - } - - // Did not catch anything. - return 0; -} - - -// Caskey, Damon V. -// 2-18-04-06 -// -// Invert current sorting position vs. parent. -void sort_invert(entity *entity) -{ - if(entity->sortid <= entity->parent->sortid) - { - entity->sortid = entity->parent->sortid + 1; - } - else - { - entity->sortid = entity->parent->sortid - 1; - } -} - -// Caskey, Damon V. -// 2018-04-06 -// -// Broken off from White Dragon's boomerang_move() function. -// Verify boomerang is in catchable state and attempt -// catch action. -int boomerang_catch(entity *ent, float distance_x_current) -{ - int animation_catch; // Animation for parent catching boomerang. - - // Only catch if in front of parent and traveling - // back toward them. Otherwise exit function since - // any further checks are pointless. - if(ent->parent->direction == DIRECTION_RIGHT) - { - // Traveling right? - if(ent->velocity.x >= 0) - { - return 0; - } - - // At or to left of parent? - if(ent->position.x <= ent->parent->position.x) - { - return 0; - } - } - else if(ent->parent->direction == DIRECTION_LEFT) - { - // Traveling left? - if(ent->velocity.x <= 0) - { - return 0; - } - - // At or to right of parent? - if(ent->position.x >= ent->parent->position.x) - { - return 0; - } - } - - // Can't catch if parent is under any sort of duress. - - // Pain? - if(ent->parent->inpain) - { - return 0; - } - - // Knocked down? - if(ent->parent->falling) - { - return 0; - } - - // Dead? - if(ent->parent->dead) - { - return 0; - } - - // Have to be beyond first cycle of + + return 1; + } + } + + // Did not catch anything. + return 0; +} + + +// Caskey, Damon V. +// 2-18-04-06 +// +// Invert current sorting position vs. parent. +void sort_invert(entity *entity) +{ + if(entity->sortid <= entity->parent->sortid) + { + entity->sortid = entity->parent->sortid + 1; + } + else + { + entity->sortid = entity->parent->sortid - 1; + } +} + +// Caskey, Damon V. +// 2018-04-06 +// +// Broken off from White Dragon's boomerang_move() function. +// Verify boomerang is in catchable state and attempt +// catch action. +int boomerang_catch(entity *ent, float distance_x_current) +{ + int animation_catch; // Animation for parent catching boomerang. + + // Only catch if in front of parent and traveling + // back toward them. Otherwise exit function since + // any further checks are pointless. + if(ent->parent->direction == DIRECTION_RIGHT) + { + // Traveling right? + if(ent->velocity.x >= 0) + { + return 0; + } + + // At or to left of parent? + if(ent->position.x <= ent->parent->position.x) + { + return 0; + } + } + else if(ent->parent->direction == DIRECTION_LEFT) + { + // Traveling left? + if(ent->velocity.x <= 0) + { + return 0; + } + + // At or to right of parent? + if(ent->position.x >= ent->parent->position.x) + { + return 0; + } + } + + // Can't catch if parent is under any sort of duress. + + // Pain? + if(ent->parent->inpain) + { + return 0; + } + + // Knocked down? + if(ent->parent->falling) + { + return 0; + } + + // Dead? + if(ent->parent->dead) + { + return 0; + } + + // Have to be beyond first cycle of // boomerang logic. if(ent->boomerang_loop <= 1) - { - return 0; - } - - // In air? Then use air catch. Otherwise use ground catch. - if(inair(ent->parent)) - { - animation_catch = ANI_GETBOOMERANGINAIR; - } - else - { - animation_catch = ANI_GETBOOMERANG; - } - - // Verify parent has catch animation and that we - // are in catch animation range, attempt to - // perform catch, and return result. - return do_catch(ent->parent, ent, animation_catch); -} - -// Caskey, Damon V. -// 2018-04-06 -// -// Offloaded from boomerang_move(). -// Gets a boomerang type projectile set up when -// first thrown. -void boomerang_initialize(entity *ent) -{ - #define GRABFORCE -99999 - #define OFF_SCREEN_LIMIT 80 - - // We don't want our directional facing + { + return 0; + } + + // In air? Then use air catch. Otherwise use ground catch. + if(inair(ent->parent)) + { + animation_catch = ANI_GETBOOMERANGINAIR; + } + else + { + animation_catch = ANI_GETBOOMERANG; + } + + // Verify parent has catch animation and that we + // are in catch animation range, attempt to + // perform catch, and return result. + return do_catch(ent->parent, ent, animation_catch); +} + +// Caskey, Damon V. +// 2018-04-06 +// +// Offloaded from boomerang_move(). +// Gets a boomerang type projectile set up when +// first thrown. +void boomerang_initialize(entity *ent) +{ + #define GRABFORCE -99999 + #define OFF_SCREEN_LIMIT 80 + + // We don't want our directional facing // changing automatically. - ent->modeldata.noflip = 1; - - // Populate offscreenkill in case our - // boomerang gets out of bounds. + ent->modeldata.noflip = 1; + + // Populate offscreenkill in case our + // boomerang gets out of bounds. ent->modeldata.offscreenkill = OFF_SCREEN_LIMIT; - - // If we have a parent entity, then we need + + // If we have a parent entity, then we need // should set up to match the parent's attributes. if(ent->parent) - { - // Make sure we're not hostile to our parent + { + // Make sure we're not hostile to our parent // model type. - ent->modeldata.hostile &= ~(ent->parent->modeldata.type); - - // If we were thrown by an enemy or player faction - // then make sure we're hostile to the opposite + ent->modeldata.hostile &= ~(ent->parent->modeldata.type); + + // If we were thrown by an enemy or player faction + // then make sure we're hostile to the opposite // faction. - if (ent->parent->modeldata.type == TYPE_PLAYER - || ent->parent->modeldata.type == TYPE_NPC) - { + if (ent->parent->modeldata.type == TYPE_PLAYER + || ent->parent->modeldata.type == TYPE_NPC) + { ent->modeldata.hostile |= TYPE_ENEMY; - } - else if(ent->parent->modeldata.type == TYPE_ENEMY) - { + } + else if(ent->parent->modeldata.type == TYPE_ENEMY) + { ent->modeldata.hostile |= (TYPE_PLAYER | TYPE_NPC); - } - - // Match the parent's direction and drawing order + } + + // Match the parent's direction and drawing order // layer position in the sprite que. ent->direction = ent->parent->direction; ent->sortid = ent->parent->sortid + 1; } - - // Move along X axis according to the direction + + // Move along X axis according to the direction // we're facing. if(ent->direction == DIRECTION_LEFT) { @@ -27591,83 +27591,83 @@ void boomerang_initialize(entity *ent) else if(ent->direction == DIRECTION_RIGHT) { ent->velocity.x = ent->modeldata.speed; - } - - // Synchronize with parent's vertical + } + + // Synchronize with parent's vertical // and lateral position. ent->position.z = ent->parent->position.z; ent->position.y = ent->parent->position.y; - + // Make sure that we can't grab or be grabbed. ent->modeldata.antigrab = 1; ent->modeldata.grabforce = GRABFORCE; - ++ent->boomerang_loop; - - #undef GRABFORCE - #undef OFF_SCREEN_LIMIT -} + ++ent->boomerang_loop; + + #undef GRABFORCE + #undef OFF_SCREEN_LIMIT +} // for common boomerang types int boomerang_move() -{ - float acceleration; // Rate of velocity difference per update. - float distance_x_current; // Current X axis distance from parent. - float distance_x_max; // Maximum X axis distance allowed from parent. - float velocity_x_accelerated; // X velocity after acceleration applied as an addition vs. current velocity. - float velocity_x_decelerated; // X velocity after acceleration applied as a reduction vs. current velocity. +{ + float acceleration; // Rate of velocity difference per update. + float distance_x_current; // Current X axis distance from parent. + float distance_x_max; // Maximum X axis distance allowed from parent. + float velocity_x_accelerated; // X velocity after acceleration applied as an addition vs. current velocity. + float velocity_x_decelerated; // X velocity after acceleration applied as a reduction vs. current velocity. if(!self->modeldata.nomove) - { - // Populate local vars with acceleration and - // maximum horizontal distance from modeldata. - // If there is no model data defined then we'll + { + // Populate local vars with acceleration and + // maximum horizontal distance from modeldata. + // If there is no model data defined then we'll // need to use some default values instead. - - // Acceleration. - if(self->modeldata.boomerang_acc != 0) - { - acceleration = self->modeldata.boomerang_acc; - } - else - { - acceleration = self->modeldata.speed/(GAME_SPEED/20); - } - + + // Acceleration. + if(self->modeldata.boomerang_acc != 0) + { + acceleration = self->modeldata.boomerang_acc; + } + else + { + acceleration = self->modeldata.speed/(GAME_SPEED/20); + } + // Maximum X distance from parent. - if(self->modeldata.boomerang_distx > 0) - { - distance_x_max = self->modeldata.boomerang_distx; + if(self->modeldata.boomerang_distx > 0) + { + distance_x_max = self->modeldata.boomerang_distx; } - else - { - distance_x_max = videomodes.hRes/(3); + else + { + distance_x_max = videomodes.hRes/(3); } - // If not moving on X axis and loop count - // is 0, then this must be a new boomerang. - // Run the initialize function to set up + // If not moving on X axis and loop count + // is 0, then this must be a new boomerang. + // Run the initialize function to set up // all of the attributes we'll need. if(self->velocity.x == 0) - { - if(!self->boomerang_loop) - { - boomerang_initialize(self); + { + if(!self->boomerang_loop) + { + boomerang_initialize(self); } - } - + } + // No lateral movement. if(self->velocity.z != 0) self->velocity.z = 0; - - // If our boomerang has no parent and gets - // too far off the screen, then we will + + // If our boomerang has no parent and gets + // too far off the screen, then we will // destroy it and exit the function. if(!self->parent) - { - // Did check_lost() kill us? - if (check_lost()) - { - return 0; + { + // Did check_lost() kill us? + if (check_lost()) + { + return 0; } } @@ -27677,101 +27677,101 @@ int boomerang_move() self->position.z = self->parent->position.z; self->position.y = self->parent->position.y; - // Movement. - + // Movement. + // Right of parent on X axis? if (self->position.x >= self->parent->position.x) - { - // Get a possible X velocity to apply that - // will slightly decelerate us. - velocity_x_decelerated = self->velocity.x - acceleration; - + { + // Get a possible X velocity to apply that + // will slightly decelerate us. + velocity_x_decelerated = self->velocity.x - acceleration; + // Exceeded maximum distance from parent? if (distance_x_current >= distance_x_max) - { + { // Have we stopped accelerating? if(velocity_x_decelerated <= 0) - { - // Moving right along X axis? - if(self->velocity.x > 0) - { - // Increment tracking loop - ++self->boomerang_loop; - - // Reverse sorting in relation to parent. - sort_invert(self); + { + // Moving right along X axis? + if(self->velocity.x > 0) + { + // Increment tracking loop + ++self->boomerang_loop; + + // Reverse sorting in relation to parent. + sort_invert(self); } - } - - // This is where we reverse our X velocity and - // return to thrower. - // - // If we're already reversed, then we just make sure - // our X axis velocity is equal to our model - // speed (inverted). - // - // If we're still moving forward (away from parent) - // then apply the next velocity. This will - // have the effect of reducing the X velocity - // until it falls below inverted model speed, at - // which point our reversed condition will be true. - if(velocity_x_decelerated < -self->modeldata.speed) - { - self->velocity.x = -self->modeldata.speed; - } - else - { - self->velocity.x = velocity_x_decelerated; + } + + // This is where we reverse our X velocity and + // return to thrower. + // + // If we're already reversed, then we just make sure + // our X axis velocity is equal to our model + // speed (inverted). + // + // If we're still moving forward (away from parent) + // then apply the next velocity. This will + // have the effect of reducing the X velocity + // until it falls below inverted model speed, at + // which point our reversed condition will be true. + if(velocity_x_decelerated < -self->modeldata.speed) + { + self->velocity.x = -self->modeldata.speed; + } + else + { + self->velocity.x = velocity_x_decelerated; } } - else if (self->velocity.x <= 0) - { - if(velocity_x_decelerated < -self->modeldata.speed) - { - self->velocity.x = -self->modeldata.speed; - } - else - { - self->velocity.x = velocity_x_decelerated; - } + else if (self->velocity.x <= 0) + { + if(velocity_x_decelerated < -self->modeldata.speed) + { + self->velocity.x = -self->modeldata.speed; + } + else + { + self->velocity.x = velocity_x_decelerated; + } } } else if (self->position.x <= self->parent->position.x) - { - // Calculate an X velocity with acceleration added. - velocity_x_accelerated = self->velocity.x + acceleration; + { + // Calculate an X velocity with acceleration added. + velocity_x_accelerated = self->velocity.x + acceleration; if(distance_x_current >= distance_x_max) { if(velocity_x_accelerated >= 0 && self->velocity.x < 0) { ++self->boomerang_loop; - - // Reverse sorting in relation to parent. + + // Reverse sorting in relation to parent. sort_invert(self); - } - - // Make sure X velocity is no greater than - // the model speed setting. - if(velocity_x_accelerated > self->modeldata.speed) - { - self->velocity.x = self->modeldata.speed; - } - else - { - self->velocity.x = velocity_x_accelerated; + } + + // Make sure X velocity is no greater than + // the model speed setting. + if(velocity_x_accelerated > self->modeldata.speed) + { + self->velocity.x = self->modeldata.speed; + } + else + { + self->velocity.x = velocity_x_accelerated; } } - else if (self->velocity.x >= 0) - { - if(velocity_x_accelerated > self->modeldata.speed) - { - self->velocity.x = self->modeldata.speed; - } - else - { - self->velocity.x = velocity_x_accelerated; - } + else if (self->velocity.x >= 0) + { + if(velocity_x_accelerated > self->modeldata.speed) + { + self->velocity.x = self->modeldata.speed; + } + else + { + self->velocity.x = velocity_x_accelerated; + } } } @@ -27807,19 +27807,19 @@ int bomb_move() } else if(self->takeaction != bomb_explode) { - self->takeaction = bomb_explode; - + self->takeaction = bomb_explode; + // hit something, just make it an explosion animation. self->modeldata.subject_to_wall = 1; self->modeldata.subject_to_platform = 1; self->modeldata.subject_to_hole = 1; //self->modeldata.no_adjust_base = 1; // Stop moving up/down - self->modeldata.subject_to_basemap = 1; - - if ( !checkhole(self->position.x, self->position.z) ) { - self->velocity.y = 0; // Stop moving up/down + self->modeldata.subject_to_basemap = 1; + + if ( !checkhole(self->position.x, self->position.z) ) { + self->velocity.y = 0; // Stop moving up/down self->base = self->position.y; - self->velocity.x = self->velocity.z = 0; + self->velocity.x = self->velocity.z = 0; } if(self->modeldata.diesound >= 0) @@ -27848,8 +27848,8 @@ int star_move() } //self->base -= 4; - //self->position.y = self->base; - + //self->position.y = self->base; + // Bounce off walls or platforms. projectile_wall_deflect(self); @@ -28549,8 +28549,8 @@ void suicide() // Used by player_fall and player_takedamage void player_die() { - int playerindex = self->playerindex; - int i = 0; + int playerindex = self->playerindex; + int i = 0; if(!livescheat) { @@ -28585,31 +28585,31 @@ void player_die() } if(player[playerindex].lives <= 0) - { - int all_p_alive = 0; - - for(i = 0; i < MAX_PLAYERS; i++) - { - if (!player[i].ent) ++all_p_alive; - } - all_p_alive = (all_p_alive >= MAX_PLAYERS) ? 1 : 0; - - //if(!player[0].ent && !player[1].ent && !player[2].ent && !player[3].ent) + { + int all_p_alive = 0; + + for(i = 0; i < MAX_PLAYERS; i++) + { + if (!player[i].ent) ++all_p_alive; + } + all_p_alive = (all_p_alive >= MAX_PLAYERS) ? 1 : 0; + + //if(!player[0].ent && !player[1].ent && !player[2].ent && !player[3].ent) if(all_p_alive) - { - int all_p_nojoin = 0, all_p_nocredits = 0; - - for(i = 0; i < MAX_PLAYERS; i++) - { - if (!player[i].joining) ++all_p_nojoin; - } - all_p_nojoin = (all_p_nojoin >= MAX_PLAYERS) ? 1 : 0; - - for(i = 0; i < MAX_PLAYERS; i++) - { - if (player[i].credits < 1) ++all_p_nocredits; - } - all_p_nocredits = (all_p_nocredits >= MAX_PLAYERS) ? 1 : 0; + { + int all_p_nojoin = 0, all_p_nocredits = 0; + + for(i = 0; i < MAX_PLAYERS; i++) + { + if (!player[i].joining) ++all_p_nojoin; + } + all_p_nojoin = (all_p_nojoin >= MAX_PLAYERS) ? 1 : 0; + + for(i = 0; i < MAX_PLAYERS; i++) + { + if (player[i].credits < 1) ++all_p_nocredits; + } + all_p_nocredits = (all_p_nocredits >= MAX_PLAYERS) ? 1 : 0; timeleft = 10 * COUNTER_SPEED; if(all_p_nojoin && ((!noshare && credits < 1) || all_p_nocredits) ) @@ -28717,167 +28717,167 @@ int check_energy(e_cost_check which, int ani) return result; } - -// Caskey Damon V. -// 2018-05-10 -// -// Replaces unreadable check_range() macro. Runs individual -// check range functions for each axis and returns true -// if target is within range of ALL. -int check_range_target_all(entity *ent, entity *target, e_animations animation_id) -{ - s_anim *animation; // Current animation - - // Must have a valid target entity. - if(!target) - { - return 0; - } - - // Get pointer to animation. - animation = ent->modeldata.animation[animation_id]; - - // Return result of individual axis range checks. - return(check_range_target_base(ent, target, animation) - && check_range_target_x(ent, target, animation) - && check_range_target_y(ent, target, animation) - && check_range_target_z(ent, target, animation)); -} - -// Caskey, Damon V. -// 2018-05-12 -// -// Return true if target is within Base range -// of entity's animation. -int check_range_target_base(entity *ent, entity *target, s_anim *animation) -{ - int ent_base; - int target_base; - - // Must have a target. - if(!target) - { - return 0; - } - - // Get positions cast as integers. - ent_base = (int)ent->base; - target_base = (int)target->base; - - // Subtract entity Base position from target position. - target_base -= ent_base; - - // Return true if final target location is - // within range min and max. - return (target_base >= animation->range.base.min - && target_base <= animation->range.base.max); -} - -// Caskey, Damon V. -// 2018-05-10 -// -// Return true if target is within X range -// of entity's animation. -int check_range_target_x(entity *ent, entity *target, s_anim *animation) -{ - int ent_x; - int target_x; - s_metric_range range; - - // Must have a target. - if(!target) - { - return 0; - } - - // Get positions cast as integers. - ent_x = (int)ent->position.x; - target_x = (int)target->position.x; - - // Return true if final target location is - // within range X min and max. Range comparison - // is reversed when entity faces left. - if(ent->direction == DIRECTION_RIGHT) - { - // Add animation range to entity X position - // for final X range coordinates. - range.min = ent_x + animation->range.x.min; - range.max = ent_x + animation->range.x.max; - - return (target_x >= range.min - && target_x <= range.max); - } - else - { - // Subtract animation range from entity X - // position for final X range coordinates. - range.min = ent_x - animation->range.x.min; - range.max = ent_x - animation->range.x.max; - - return (target_x <= range.min - && target_x >= range.max); - } -} - -// Caskey, Damon V. -// 2018-05-10 -// -// Return true if target is within Y range -// of entity's animation. -int check_range_target_y(entity *ent, entity *target, s_anim *animation) -{ - int ent_y; - int target_y; - - // Must have a target. - if(!target) - { - return 0; - } - - // Get positions cast as integers. - ent_y = (int)ent->position.y; - target_y = (int)target->position.y; - - // Subtract entity Y position from target position. - target_y -= ent_y; - - // Return true if final target location is - // within range min and max. - return (target_y >= animation->range.y.min - && target_y <= animation->range.y.max); -} - -// Caskey, Damon V. -// 2018-05-12 -// -// Return true if target is within Z range -// of entity's animation. -int check_range_target_z(entity *ent, entity *target, s_anim *animation) -{ - int ent_z; - int target_z; - - // Must have a target. - if(!target) - { - return 0; - } - - // Get positions cast as integers. - ent_z = (int)ent->position.z; - target_z = (int)target->position.z; - - // Subtract entity Z position from target position. - target_z -= ent_z; - - // Return true if final target location is - // within range min and max. + +// Caskey Damon V. +// 2018-05-10 +// +// Replaces unreadable check_range() macro. Runs individual +// check range functions for each axis and returns true +// if target is within range of ALL. +int check_range_target_all(entity *ent, entity *target, e_animations animation_id) +{ + s_anim *animation; // Current animation + + // Must have a valid target entity. + if(!target) + { + return 0; + } + + // Get pointer to animation. + animation = ent->modeldata.animation[animation_id]; + + // Return result of individual axis range checks. + return(check_range_target_base(ent, target, animation) + && check_range_target_x(ent, target, animation) + && check_range_target_y(ent, target, animation) + && check_range_target_z(ent, target, animation)); +} + +// Caskey, Damon V. +// 2018-05-12 +// +// Return true if target is within Base range +// of entity's animation. +int check_range_target_base(entity *ent, entity *target, s_anim *animation) +{ + int ent_base; + int target_base; + + // Must have a target. + if(!target) + { + return 0; + } + + // Get positions cast as integers. + ent_base = (int)ent->base; + target_base = (int)target->base; + + // Subtract entity Base position from target position. + target_base -= ent_base; + + // Return true if final target location is + // within range min and max. + return (target_base >= animation->range.base.min + && target_base <= animation->range.base.max); +} + +// Caskey, Damon V. +// 2018-05-10 +// +// Return true if target is within X range +// of entity's animation. +int check_range_target_x(entity *ent, entity *target, s_anim *animation) +{ + int ent_x; + int target_x; + s_metric_range range; + + // Must have a target. + if(!target) + { + return 0; + } + + // Get positions cast as integers. + ent_x = (int)ent->position.x; + target_x = (int)target->position.x; + + // Return true if final target location is + // within range X min and max. Range comparison + // is reversed when entity faces left. + if(ent->direction == DIRECTION_RIGHT) + { + // Add animation range to entity X position + // for final X range coordinates. + range.min = ent_x + animation->range.x.min; + range.max = ent_x + animation->range.x.max; + + return (target_x >= range.min + && target_x <= range.max); + } + else + { + // Subtract animation range from entity X + // position for final X range coordinates. + range.min = ent_x - animation->range.x.min; + range.max = ent_x - animation->range.x.max; + + return (target_x <= range.min + && target_x >= range.max); + } +} + +// Caskey, Damon V. +// 2018-05-10 +// +// Return true if target is within Y range +// of entity's animation. +int check_range_target_y(entity *ent, entity *target, s_anim *animation) +{ + int ent_y; + int target_y; + + // Must have a target. + if(!target) + { + return 0; + } + + // Get positions cast as integers. + ent_y = (int)ent->position.y; + target_y = (int)target->position.y; + + // Subtract entity Y position from target position. + target_y -= ent_y; + + // Return true if final target location is + // within range min and max. + return (target_y >= animation->range.y.min + && target_y <= animation->range.y.max); +} + +// Caskey, Damon V. +// 2018-05-12 +// +// Return true if target is within Z range +// of entity's animation. +int check_range_target_z(entity *ent, entity *target, s_anim *animation) +{ + int ent_z; + int target_z; + + // Must have a target. + if(!target) + { + return 0; + } + + // Get positions cast as integers. + ent_z = (int)ent->position.z; + target_z = (int)target->position.z; + + // Subtract entity Z position from target position. + target_z -= ent_z; + + // Return true if final target location is + // within range min and max. return (target_z >= animation->range.z.min - && target_z <= animation->range.z.max); -} - - + && target_z <= animation->range.z.max); +} + + int check_special() { @@ -29109,7 +29109,7 @@ void dojump(float jumpv, float jumpx, float jumpz, int animation_id) { dust = spawn(self->position.x, self->position.z, self->position.y, self->direction, NULL, self->modeldata.dust.jump_start, NULL); if(dust) - { + { dust->spawntype = SPAWN_TYPE_DUST_JUMP; dust->base = self->position.y; dust->autokill = 2; @@ -30410,11 +30410,11 @@ void player_think() set_getting(self); self->takeaction = common_get; ent_set_anim(self, ANI_GET, 0); - - // Item "attacks" collector to make it - // easy to script actions on item pick up. - do_item_script(self, other); - + + // Item "attacks" collector to make it + // easy to script actions on item pick up. + do_item_script(self, other); + didfind_item(other); goto endthinkcheck; } @@ -30766,7 +30766,7 @@ void player_think() if((other = find_ent_here(self, self->position.x, self->position.z, TYPE_ITEM, player_test_touch)) ) { - do_item_script(self, other); + do_item_script(self, other); didfind_item(other); // Added function to clean code up a bit } @@ -30976,8 +30976,8 @@ int player_takedamage(entity *other, s_collision_attack *attack, int fall_flag) void drop_all_enemies() { int i; - entity *weapself = self; - s_collision_attack attack; + entity *weapself = self; + s_collision_attack attack; for(i = 0; i < ent_max; i++) { @@ -30993,21 +30993,21 @@ void drop_all_enemies() ent_list[i]->attacking = ATTACKING_INACTIVE; ent_list[i]->projectile = 0; ent_list[i]->takeaction = common_fall;//enemy_fall; - ent_list[i]->damage_on_landing.attack_force = 0; + ent_list[i]->damage_on_landing.attack_force = 0; ent_list[i]->damage_on_landing.attack_type = ATK_NONE; self = ent_list[i]; ent_unlink(self); ent_list[i]->velocity.x = (self->direction == DIRECTION_RIGHT) ? (-1.2) : 1.2; - if(ent_list[i]->modeldata.weaploss[0] != WEAPLOSS_TYPE_CHANGE) - { - dropweapon(1); + if(ent_list[i]->modeldata.weaploss[0] != WEAPLOSS_TYPE_CHANGE) + { + dropweapon(1); } toss(ent_list[i], 2.5 + randf(1)); ent_list[i]->knockdowncount = ent_list[i]->modeldata.knockdowncount; - ent_list[i]->knockdowntime = 0; - - // Use default attack values. + ent_list[i]->knockdowntime = 0; + + // Use default attack values. attack = emptyattack; set_fall(ent_list[i], self, &attack, 1); } @@ -31130,21 +31130,21 @@ entity *knife_spawn(char *name, int index, float x, float z, float a, int direct { return NULL; } - - // Index takes priority in spawning, so if it's here - // then we'll type this as an index spawn source. - if(index < 0) - { - e->projectile_prime = PROJECTILE_PRIME_SOURCE_INDEX; - } - else - { - e->projectile_prime = PROJECTILE_PRIME_SOURCE_NAME; - } - - e->projectile_prime += PROJECTILE_PRIME_BASE_Y; - e->projectile_prime += PROJECTILE_PRIME_LAUNCH_MOVING; - e->projectile_prime += PROJECTILE_PRIME_REQUEST_UNDEFINED; + + // Index takes priority in spawning, so if it's here + // then we'll type this as an index spawn source. + if(index < 0) + { + e->projectile_prime = PROJECTILE_PRIME_SOURCE_INDEX; + } + else + { + e->projectile_prime = PROJECTILE_PRIME_SOURCE_NAME; + } + + e->projectile_prime += PROJECTILE_PRIME_BASE_Y; + e->projectile_prime += PROJECTILE_PRIME_LAUNCH_MOVING; + e->projectile_prime += PROJECTILE_PRIME_REQUEST_UNDEFINED; e->position.y = a; } @@ -31154,13 +31154,13 @@ entity *knife_spawn(char *name, int index, float x, float z, float a, int direct if(!e) { return NULL; - } - - e->projectile_prime = PROJECTILE_PRIME_BASE_Y; - e->projectile_prime += PROJECTILE_PRIME_LAUNCH_MOVING; - e->projectile_prime += PROJECTILE_PRIME_SOURCE_WEAPON; + } + + e->projectile_prime = PROJECTILE_PRIME_BASE_Y; + e->projectile_prime += PROJECTILE_PRIME_LAUNCH_MOVING; + e->projectile_prime += PROJECTILE_PRIME_SOURCE_WEAPON; e->projectile_prime += PROJECTILE_PRIME_REQUEST_PROJECTILE; - + e->position.y = a; } else if(self->animation->projectile.knife >= 0) @@ -31170,12 +31170,12 @@ entity *knife_spawn(char *name, int index, float x, float z, float a, int direct { return NULL; } - - e->projectile_prime = PROJECTILE_PRIME_BASE_Y; - e->projectile_prime += PROJECTILE_PRIME_LAUNCH_MOVING; - e->projectile_prime += PROJECTILE_PRIME_SOURCE_ANIMATION; + + e->projectile_prime = PROJECTILE_PRIME_BASE_Y; + e->projectile_prime += PROJECTILE_PRIME_LAUNCH_MOVING; + e->projectile_prime += PROJECTILE_PRIME_SOURCE_ANIMATION; e->projectile_prime += PROJECTILE_PRIME_REQUEST_KNIFE; - + e->position.y = a; } else if(self->animation->projectile.flash >= 0) @@ -31185,11 +31185,11 @@ entity *knife_spawn(char *name, int index, float x, float z, float a, int direct { return NULL; } - - e->projectile_prime = PROJECTILE_PRIME_BASE_FLOOR; - e->projectile_prime += PROJECTILE_PRIME_LAUNCH_STATIONARY; - e->projectile_prime += PROJECTILE_PRIME_SOURCE_ANIMATION; - e->projectile_prime += PROJECTILE_PRIME_REQUEST_FLASH; + + e->projectile_prime = PROJECTILE_PRIME_BASE_FLOOR; + e->projectile_prime += PROJECTILE_PRIME_LAUNCH_STATIONARY; + e->projectile_prime += PROJECTILE_PRIME_SOURCE_ANIMATION; + e->projectile_prime += PROJECTILE_PRIME_REQUEST_FLASH; e->position.y = 0; } @@ -31200,11 +31200,11 @@ entity *knife_spawn(char *name, int index, float x, float z, float a, int direct { return NULL; } - - e->projectile_prime = PROJECTILE_PRIME_BASE_Y; - e->projectile_prime += PROJECTILE_PRIME_LAUNCH_MOVING; - e->projectile_prime += PROJECTILE_PRIME_SOURCE_HEADER; - e->projectile_prime += PROJECTILE_PRIME_REQUEST_KNIFE; + + e->projectile_prime = PROJECTILE_PRIME_BASE_Y; + e->projectile_prime += PROJECTILE_PRIME_LAUNCH_MOVING; + e->projectile_prime += PROJECTILE_PRIME_SOURCE_HEADER; + e->projectile_prime += PROJECTILE_PRIME_REQUEST_KNIFE; e->position.y = a; } @@ -31214,12 +31214,12 @@ entity *knife_spawn(char *name, int index, float x, float z, float a, int direct if(!e) { return NULL; - } - - e->projectile_prime = PROJECTILE_PRIME_BASE_FLOOR; - e->projectile_prime += PROJECTILE_PRIME_LAUNCH_STATIONARY; - e->projectile_prime += PROJECTILE_PRIME_SOURCE_HEADER; - e->projectile_prime += PROJECTILE_PRIME_REQUEST_PSHOTNO; + } + + e->projectile_prime = PROJECTILE_PRIME_BASE_FLOOR; + e->projectile_prime += PROJECTILE_PRIME_LAUNCH_STATIONARY; + e->projectile_prime += PROJECTILE_PRIME_SOURCE_HEADER; + e->projectile_prime += PROJECTILE_PRIME_REQUEST_PSHOTNO; e->position.y = 0; } @@ -31230,12 +31230,12 @@ entity *knife_spawn(char *name, int index, float x, float z, float a, int direct { return NULL; } - - e->projectile_prime = PROJECTILE_PRIME_BASE_Y; - e->projectile_prime += PROJECTILE_PRIME_LAUNCH_MOVING; - e->projectile_prime += PROJECTILE_PRIME_SOURCE_GLOBAL; + + e->projectile_prime = PROJECTILE_PRIME_BASE_Y; + e->projectile_prime += PROJECTILE_PRIME_LAUNCH_MOVING; + e->projectile_prime += PROJECTILE_PRIME_SOURCE_GLOBAL; e->projectile_prime += PROJECTILE_PRIME_REQUEST_SHOT; - + e->position.y = a; } else @@ -31245,12 +31245,12 @@ entity *knife_spawn(char *name, int index, float x, float z, float a, int direct { return NULL; } - - e->projectile_prime = PROJECTILE_PRIME_BASE_Y; - e->projectile_prime += PROJECTILE_PRIME_LAUNCH_MOVING; - e->projectile_prime += PROJECTILE_PRIME_SOURCE_GLOBAL; + + e->projectile_prime = PROJECTILE_PRIME_BASE_Y; + e->projectile_prime += PROJECTILE_PRIME_LAUNCH_MOVING; + e->projectile_prime += PROJECTILE_PRIME_SOURCE_GLOBAL; e->projectile_prime += PROJECTILE_PRIME_REQUEST_KNIFE; - + e->position.y = a; } @@ -31275,7 +31275,7 @@ entity *knife_spawn(char *name, int index, float x, float z, float a, int direct { e->modeldata.speed = 0; } - + e->spawntype = SPAWN_TYPE_PROJECTILE_NORMAL; e->owner = self; // Added so projectiles don't hit the owner e->nograb = 1; // Prevents trying to grab a projectile @@ -31374,7 +31374,7 @@ entity *bomb_spawn(char *name, int index, float x, float z, float a, int directi { e->modeldata.speed = 0; } - + e->spawntype = SPAWN_TYPE_PROJECTILE_BOMB; e->attacking = ATTACKING_ACTIVE; e->owner = self; // Added so projectiles don't hit the owner @@ -31477,12 +31477,12 @@ int star_spawn(float x, float z, float a, int direction) // added entity to kno if(e->modeldata.candamage < 0) { e->modeldata.candamage = self->modeldata.candamage; - } + } e->modeldata.subject_to_basemap = e->modeldata.subject_to_wall = e->modeldata.subject_to_platform = e->modeldata.subject_to_hole = e->modeldata.subject_to_gravity = 1; - e->modeldata.no_adjust_base = 0; - + e->modeldata.no_adjust_base = 0; + e->spawntype = SPAWN_TYPE_PROJECTILE_STAR; } return 1; @@ -31524,7 +31524,7 @@ void steam_spawn(float x, float z, float a) { return; } - + e->spawntype = SPAWN_TYPE_STEAM; e->base = a; e->modeldata.no_adjust_base = 1; @@ -31764,50 +31764,50 @@ int obstacle_takedamage(entity *other, s_collision_attack *attack, int fall_flag self->nextthink = time + 1; return 1; -} - -// Caskey, Damon V. -// 2018-04-27 -// -// Allocate memory and set entity properties that will be transfered +} + +// Caskey, Damon V. +// 2018-04-27 +// +// Allocate memory and set entity properties that will be transfered // to a dropped item. -void initialize_item_carry(entity *ent, s_spawn_entry *spawn_entry) -{ - // It's possible to call this from script, so if - // if there is already memory for an item allocated - // here, clear it out to make sure we don't end up - // with any memory leaks. - if(ent->item_properties) - { - free(ent->item_properties); - ent->item_properties = NULL; - } - - // Allocate memory for the item. +void initialize_item_carry(entity *ent, s_spawn_entry *spawn_entry) +{ + // It's possible to call this from script, so if + // if there is already memory for an item allocated + // here, clear it out to make sure we don't end up + // with any memory leaks. + if(ent->item_properties) + { + free(ent->item_properties); + ent->item_properties = NULL; + } + + // Allocate memory for the item. ent->item_properties = malloc(sizeof(*ent->item_properties)); - memset(ent->item_properties, 0, sizeof(*ent->item_properties)); - + memset(ent->item_properties, 0, sizeof(*ent->item_properties)); + if(spawn_entry) { - ent->item_properties->index = spawn_entry->item_properties.index; - + ent->item_properties->index = spawn_entry->item_properties.index; + if(spawn_entry->item_properties.alias[0]) { safe_strncpy(ent->item_properties->alias, spawn_entry->item_properties.alias, MAX_NAME_LEN); - } + } if(spawn_entry->item_properties.colorset) { ent->item_properties->colorset = spawn_entry->item_properties.colorset; - } + } if(spawn_entry->item_properties.health) { ent->item_properties->health = spawn_entry->item_properties.health; } ent->item_properties->player_count = spawn_entry->item_properties.player_count; - } -} + } +} entity *smartspawn(s_spawn_entry *props) // 7-1-2005 Entire section replaced with lord balls code { @@ -31849,20 +31849,20 @@ entity *smartspawn(s_spawn_entry *props) // 7-1-2005 Entire section replace return NULL; } - //printf("%s, (%f, %f, %f) - (%f, %f, %f)", props->name, props->position.x, props->position.z, props->position.y, e->position.x, e->position.z, e->position.y); + //printf("%s, (%f, %f, %f) - (%f, %f, %f)", props->name, props->position.x, props->position.z, props->position.y, e->position.x, e->position.z, e->position.y); // Alias? if(props->alias[0]) { safe_strncpy(e->name, props->alias, MAX_NAME_LEN); } - - // If we have item properties in spawn entry, then prepare a set of - // properties to pass on to the item when it is dropped. + + // If we have item properties in spawn entry, then prepare a set of + // properties to pass on to the item when it is dropped. if(props->item) - { + { initialize_item_carry(e, props); - } + } if(props->spawntype) { @@ -31933,9 +31933,9 @@ entity *smartspawn(s_spawn_entry *props) // 7-1-2005 Entire section replace if(wp) { //ent_default_init(wp); - set_weapon(e, wp->modeldata.weapnum, 0); - e->weapent = wp; - + set_weapon(e, wp->modeldata.weapnum, 0); + e->weapent = wp; + e->weapent->spawntype = SPAWN_TYPE_WEAPON; } } @@ -32013,7 +32013,7 @@ void spawnplayer(int index) p.position.x = (float)(20 + 30 * index); } p.flip = 1; - } + } if(level->spawn && level->spawn[index].z) { @@ -32033,7 +32033,7 @@ void spawnplayer(int index) else { p.position.z = (float)PLAYER_MIN_Z; - } + } if(p.position.z < PLAYER_MIN_Z) { @@ -32042,7 +32042,7 @@ void spawnplayer(int index) else if(p.position.z > PLAYER_MAX_Z) { p.position.z = PLAYER_MAX_Z; - } + } //////////////////checking holes/ walls/////////////////////////////////// for(xc = 0; xc < videomodes.hRes / 4; xc++) @@ -32113,7 +32113,7 @@ void spawnplayer(int index) shutdown(1, "Fatal: unable to spawn player from '%s'\n", p.name); } - player[index].ent->playerindex = index; + player[index].ent->playerindex = index; player[index].ent->spawntype = SPAWN_TYPE_PLAYER_MAIN; if(nomaxrushreset[4] >= 1) { @@ -32209,7 +32209,7 @@ void update_scroller() float tx = advancex, ty = advancey; float rm = -9999, lm = 999999, bm = -9999, tm = 999999; //player boundary box static int scrolladd = 0; - scrolldx = scrolldy = 0; + scrolldx = scrolldy = 0; int p_alive = 0; if(time < level->advancetime || freezeall) @@ -32230,17 +32230,17 @@ void update_scroller() if(level_completed) { return; - } - - for(i = 0; i < MAX_PLAYERS; i++) - { - if (player[i].ent && !player[i].ent->dead) - { - p_alive = 1; - break; - } - } - + } + + for(i = 0; i < MAX_PLAYERS; i++) + { + if (player[i].ent && !player[i].ent->dead) + { + p_alive = 1; + break; + } + } + if(current_spawn >= level->numspawns && !findent(TYPE_ENEMY) && p_alive) /*if(current_spawn >= level->numspawns && !findent(TYPE_ENEMY) && ((player[0].ent && !player[0].ent->dead) || (player[1].ent && !player[1].ent->dead) || (player[2].ent && !player[2].ent->dead) || (player[3].ent && !player[3].ent->dead)) @@ -32913,7 +32913,7 @@ void draw_scrolled_bg() //if(level) printf("%d %d %d %d\n", vpx, vpy, vpw, vph); s_drawmethod screenmethod = plainmethod; - + /*s_drawmethod *pscreenmethod = &screenmethod; for(i = 0; i < level->numholes; i++) { @@ -33495,9 +33495,9 @@ void free_input_recorder() } void update(int ingame, int usevwait) -{ - int i = 0; - int p_keys = 0; +{ + int i = 0; + int p_keys = 0; getinterval(); if(playrecstatus->status == A_REC_PLAY && !pause && level) if ( !playRecordedInputs() ) stopRecordInputs(); @@ -33549,31 +33549,31 @@ void update(int ingame, int usevwait) { update_scroller(); if(!freezeall) - { - int all_p_alive = 0; - - for(i = 0; i < MAX_PLAYERS; i++) - { - if (!player[i].ent) ++all_p_alive; - } - all_p_alive = (all_p_alive >= MAX_PLAYERS) ? 1 : 0; - + { + int all_p_alive = 0; + + for(i = 0; i < MAX_PLAYERS; i++) + { + if (!player[i].ent) ++all_p_alive; + } + all_p_alive = (all_p_alive >= MAX_PLAYERS) ? 1 : 0; + if(level->settime > 0 || (level->type != 2 && all_p_alive)) //if(level->settime > 0 || (level->type != 2 && !player[0].ent && !player[1].ent && !player[2].ent && !player[3].ent)) - { - int all_p_nojoin = 0, all_p_nocredits = 0; - - for(i = 0; i < MAX_PLAYERS; i++) - { - if (!player[i].joining) ++all_p_nojoin; - } - all_p_nojoin = (all_p_nojoin >= MAX_PLAYERS) ? 1 : 0; - - for(i = 0; i < MAX_PLAYERS; i++) - { - if (player[i].credits < 1) ++all_p_nocredits; - } - all_p_nocredits = (all_p_nocredits >= MAX_PLAYERS) ? 1 : 0; + { + int all_p_nojoin = 0, all_p_nocredits = 0; + + for(i = 0; i < MAX_PLAYERS; i++) + { + if (!player[i].joining) ++all_p_nojoin; + } + all_p_nojoin = (all_p_nojoin >= MAX_PLAYERS) ? 1 : 0; + + for(i = 0; i < MAX_PLAYERS; i++) + { + if (player[i].credits < 1) ++all_p_nocredits; + } + all_p_nocredits = (all_p_nocredits >= MAX_PLAYERS) ? 1 : 0; if(timeleft > 0) { @@ -33640,15 +33640,15 @@ void update(int ingame, int usevwait) if(ingame == 1 || alwaysupdate) { execute_updatedscripts(); - } - - for(i = 0; i < MAX_PLAYERS; i++) - { - if (player[i].ent && (player[i].newkeys & FLAG_START)) - { - p_keys = 1; - break; - } + } + + for(i = 0; i < MAX_PLAYERS; i++) + { + if (player[i].ent && (player[i].newkeys & FLAG_START)) + { + p_keys = 1; + break; + } } // 2011/10/22 UT: move pause menu logic here @@ -33657,7 +33657,7 @@ void update(int ingame, int usevwait) (player[1].ent && (player[1].newkeys & FLAG_START)) || (player[2].ent && (player[2].newkeys & FLAG_START)) || (player[3].ent && (player[3].newkeys & FLAG_START))) - )*/ + )*/ if(ingame == 1 && !pause && !nopause && p_keys) { if ( !(goto_mainmenu_flag&1) ) @@ -33878,46 +33878,46 @@ void display_credits() font_printf(_strmidx(2, "Credits"), s, 2, 0, "Credits"); font_printf(_strmidx(1, "OpenBOR"), s + v * m, 1, 0, "OpenBOR"); ++m; - + font_printf(col1, s + v * m, 0, 0, "Caskey, Damon V."); - font_printf(col2, s + v * m, 0, 0, "Project Lead"); ++m; - + font_printf(col2, s + v * m, 0, 0, "Project Lead"); ++m; + font_printf(col1, s + v * m, 0, 0, "White Dragon"); - font_printf(col2, s + v * m, 0, 0, "Developer"); ++m; - + font_printf(col2, s + v * m, 0, 0, "Developer"); ++m; + font_printf(col1, s + v * m, 0, 0, "Plombo"); - font_printf(col2, s + v * m, 0, 0, "Developer"); ++m; - - font_printf(_strmidx(1, "Former Staff"), s + v * m, 1, 0, "Former Staff"); ++m; - - font_printf(col1, s + v * m, 0, 0, "Fightn Words"); + font_printf(col2, s + v * m, 0, 0, "Developer"); ++m; + + font_printf(_strmidx(1, "Former Staff"), s + v * m, 1, 0, "Former Staff"); ++m; + + font_printf(col1, s + v * m, 0, 0, "Fightn Words"); font_printf(col2, s + v * m, 0, 0, "Fugue"); ++m; font_printf(col1, s + v * m, 0, 0, "KBAndressen"); font_printf(col2, s + v * m, 0, 0, "Kirby"); ++m; - font_printf(col1, s + v * m, 0, 0, "LordBall"); - font_printf(col2, s + v * m, 0, 0, "Orochi_X"); ++m; + font_printf(col1, s + v * m, 0, 0, "LordBall"); + font_printf(col2, s + v * m, 0, 0, "Orochi_X"); ++m; font_printf(col1, s + v * m, 0, 0, "SX"); font_printf(col2, s + v * m, 0, 0, "Tails"); ++m; font_printf(col1, s + v * m, 0, 0, "uTunnels"); ++m; font_printf(_strmidx(1, "Ports"), s + v * m, 1, 0, "Ports"); ++m; font_printf(col1, s + v * m, 0, 0, "PSP/Linux/OSX"); - font_printf(col2, s + v * m, 0, 0, "SX"); ++m; + font_printf(col2, s + v * m, 0, 0, "SX"); ++m; font_printf(col1, s + v * m, 0, 0, "OpenDingux"); font_printf(col2, s + v * m, 0, 0, "Shin-NiL"); ++m; - + font_printf(col1, s + v * m, 0, 0, "DreamCast"); - font_printf(col2, s + v * m, 0, 0, "Neill Corlett, SX"); ++m; + font_printf(col2, s + v * m, 0, 0, "Neill Corlett, SX"); ++m; font_printf(col1, s + v * m, 0, 0, "Wii"); font_printf(col2, s + v * m, 0, 0, "Plombo, SX"); ++m; - + font_printf(col1, s + v * m, 0, 0, "Android"); - font_printf(col2, s + v * m, 0, 0, "CRxTRDude, Plombo,"); ++m; - font_printf(col2, s + v * m, 0, 0, "uTunnels,"); ++m; + font_printf(col2, s + v * m, 0, 0, "CRxTRDude, Plombo,"); ++m; + font_printf(col2, s + v * m, 0, 0, "uTunnels,"); ++m; font_printf(col2, s + v * m, 0, 0, "White Dragon"); ++m; - + font_printf(col1, s + v * m, 0, 0, "PS Vita"); font_printf(col2, s + v * m, 0, 0, "Plombo"); ++m; @@ -35004,13 +35004,13 @@ int playlevel(char *filename) level_completed = 1; endgame |= 1; level->force_finishlevel = 0; - } - if (level->force_gameover) - { - //entity* temp = self; + } + if (level->force_gameover) + { + //entity* temp = self; for(i = 0; i < MAX_PLAYERS; i++) //levelsets[current_set].maxplayers { - player[i].lives = 0; + player[i].lives = 0; if(noshare) { player[i].credits = 0; @@ -35018,19 +35018,19 @@ int playlevel(char *filename) else { credits = 0; - } + } if (player[i].ent) { kill(player[i].ent); player[i].ent = NULL; - } - //self = player[i].ent; + } + //self = player[i].ent; //player_die(); - } - //self = temp; - //kill_all(); - endgame |= 1; - level->force_gameover = 0; + } + //self = temp; + //kill_all(); + endgame |= 1; + level->force_gameover = 0; } if(level_completed) { @@ -35058,8 +35058,8 @@ int playlevel(char *filename) nomaxrushreset[i] = player[i].ent->rush.count.max; player[i].spawnhealth = player[i].ent->energy_status.health_current; player[i].spawnmp = player[i].ent->energy_status.mp_current; - } - // reset + } + // reset player[i].weapnum = 0; } @@ -35069,16 +35069,16 @@ int playlevel(char *filename) } sound_stopall_sample(); - unload_level(); - - //|| (player[0].lives > 0 || player[1].lives > 0 || player[2].lives > 0 || player[3].lives > 0) - for(i = 0; i < MAX_PLAYERS; i++) - { - if (player[i].lives > 0) - { - p_alive = 1; - break; - } + unload_level(); + + //|| (player[0].lives > 0 || player[1].lives > 0 || player[2].lives > 0 || player[3].lives > 0) + for(i = 0; i < MAX_PLAYERS; i++) + { + if (player[i].lives > 0) + { + p_alive = 1; + break; + } } return ( (type == 2 && endgame != 2) || p_alive ); @@ -35094,7 +35094,7 @@ static entity *spawnexample(int i) player[i].colourmap = (colourselect && (set->nosame & 2)) ? nextcolourmapln(example->model, player[i].colourmap, i) : 0; - ent_set_colourmap(example, player[i].colourmap); + ent_set_colourmap(example, player[i].colourmap); example->spawntype = SPAWN_TYPE_PLAYER_SELECT; return example; } @@ -35155,14 +35155,14 @@ int selectplayer(int *players, char *filename, int useSavedGame) char argbuf[MAX_ARG_LEN + 1] = ""; s_set_entry *set = levelsets + current_set; s_savelevel *save = savelevel + current_set; - int load_count = 0, saved_select_screen = 0; + int load_count = 0, saved_select_screen = 0; int is_first_select = 1; savelevelinfo(); selectScreen = 1; kill_all(); - if( allowselect_args[0] != 'a' && allowselect_args[0] != 'A' ) reset_playable_list(1); // 'a' is the first char of allowselect, if there's 'a' then there is allowselect + if( allowselect_args[0] != 'a' && allowselect_args[0] != 'A' ) reset_playable_list(1); // 'a' is the first char of allowselect, if there's 'a' then there is allowselect memset(player, 0, sizeof(*player) * 4); if(useSavedGame && save) @@ -35180,15 +35180,15 @@ int selectplayer(int *players, char *filename, int useSavedGame) for(i = 0; i < set->maxplayers; i++) { player[i].hasplayed = players[i]; - } - + } + for(i = 0; i < set->maxplayers; i++) - { - if (savelevel[current_set].pLives[i] > 0) - { - is_first_select = 0; - break; - } + { + if (savelevel[current_set].pLives[i] > 0) + { + is_first_select = 0; + break; + } } if(filename && filename[0]) @@ -35256,12 +35256,12 @@ int selectplayer(int *players, char *filename, int useSavedGame) } } else // without select.txt - { + { if(is_first_select || (!skipselect[0][0] && !set->noselect)) // no select is skipselect without names - { - defaultselect = 1; // normal select or skipselect/noselect? 1 == normal select - } - + { + defaultselect = 1; // normal select or skipselect/noselect? 1 == normal select + } + if(!noshare) { credits = CONTINUES; @@ -35275,17 +35275,17 @@ int selectplayer(int *players, char *filename, int useSavedGame) } if(skipselect[0][0] || set->noselect) - { + { for(i = 0; i < set->maxplayers; i++) { if(!players[i]) { continue; } - strncpy(player[i].name, skipselect[i], MAX_NAME_LEN); - + strncpy(player[i].name, skipselect[i], MAX_NAME_LEN); + if(defaultselect) - { + { player[i].lives = PLAYER_LIVES; if(!creditscheat) { @@ -35297,17 +35297,17 @@ int selectplayer(int *players, char *filename, int useSavedGame) { --credits; } - } - } - else - { + } + } + else + { player[i].lives = savelevel[current_set].pLives[i]; - player[i].score = savelevel[current_set].pScores[i]; - if(noshare) player[i].credits = savelevel[current_set].pCredits[i]; - else credits = savelevel[current_set].credits; + player[i].score = savelevel[current_set].pScores[i]; + if(noshare) player[i].credits = savelevel[current_set].pCredits[i]; + else credits = savelevel[current_set].credits; } } - selectScreen = 0; + selectScreen = 0; return 1; } @@ -35373,8 +35373,8 @@ int selectplayer(int *players, char *filename, int useSavedGame) else { player[i].lives = savelevel[current_set].pLives[i]; - player[i].score = savelevel[current_set].pScores[i]; - if(noshare) player[i].credits = savelevel[current_set].pCredits[i]; + player[i].score = savelevel[current_set].pScores[i]; + if(noshare) player[i].credits = savelevel[current_set].pCredits[i]; else credits = savelevel[current_set].credits; } } @@ -35426,7 +35426,7 @@ int selectplayer(int *players, char *filename, int useSavedGame) sound_play_sample(SAMPLE_BEEP, 0, savedata.effectvol, savedata.effectvol, 100); } ent_set_model(example[i], ((player[i].newkeys & FLAG_MOVELEFT) ? prevplayermodeln : nextplayermodeln)(example[i]->model, i)->name, 0); - strcpy(player[i].name, example[i]->model->name); + strcpy(player[i].name, example[i]->model->name); player[i].colourmap = (colourselect && (set->nosame & 2)) ? nextcolourmapln(example[i]->model, player[i].colourmap, i) : 0; ent_set_colourmap(example[i], player[i].colourmap); } @@ -35649,20 +35649,20 @@ void playgame(int *players, unsigned which_set, int useSavedGame) selectplayer(players, NULL, useSavedGame); // re-select a player } else if(!playlevel(le->filename)) - { - int all_p_lives_zero = 0; - for(i = 0; i < MAX_PLAYERS; i++) - { - if (player[i].lives <= 0) ++all_p_lives_zero; - } - all_p_lives_zero = (all_p_lives_zero >= MAX_PLAYERS) ? 1 : 0; - - //if( (player[0].lives <= 0 && player[1].lives <= 0 && player[2].lives <= 0 && player[3].lives <= 0) ) + { + int all_p_lives_zero = 0; + for(i = 0; i < MAX_PLAYERS; i++) + { + if (player[i].lives <= 0) ++all_p_lives_zero; + } + all_p_lives_zero = (all_p_lives_zero >= MAX_PLAYERS) ? 1 : 0; + + //if( (player[0].lives <= 0 && player[1].lives <= 0 && player[2].lives <= 0 && player[3].lives <= 0) ) if(all_p_lives_zero) { - if( (!set->noshowgameover && !(goto_mainmenu_flag&2)) ) - { - gameover(); + if( (!set->noshowgameover && !(goto_mainmenu_flag&2)) ) + { + gameover(); } if(!set->noshowhof && !(goto_mainmenu_flag&4)) { @@ -36128,7 +36128,7 @@ void term_videomodes() // Load Video Mode from file void init_videomodes(int log) -{ +{ char *filename = "data/video.txt"; int tmp; ptrdiff_t pos, len; @@ -36442,16 +36442,16 @@ void keyboard_setup(int player) disabledkey[MAX_BTN_NUM] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1}, col1 = -8, col2 = 6; ptrdiff_t voffset, pos; - char *buf, - *command, + char *buf, + *command, *filename = "data/menu.txt", buttonnames[btnnum][16]; size_t size; ArgList arglist; - char argbuf[MAX_ARG_LEN + 1] = ""; + char argbuf[MAX_ARG_LEN + 1] = ""; + + printf("Loading control settings.......\t"); - printf("Loading control settings.......\t"); - strncpy(buttonnames[SDID_MOVEUP], "Move Up", 16); strncpy(buttonnames[SDID_MOVEDOWN], "Move Down", 16); strncpy(buttonnames[SDID_MOVELEFT], "Move Left", 16); @@ -36506,12 +36506,12 @@ void keyboard_setup(int player) free(buf); buf = NULL; } - } - + } + while(disabledkey[selector]) if(++selector > btnnum-1) { break; - } + } while(!quit) { @@ -36527,7 +36527,7 @@ void keyboard_setup(int player) } } _menutextm((selector == btnnum), ++voffset, 0, Tr("OK")); - _menutextm((selector == btnnum+1), ++voffset, 0, Tr("Cancel")); + _menutextm((selector == btnnum+1), ++voffset, 0, Tr("Cancel")); _menutextm((selector == btnnum+2), ++voffset, 0, Tr("Default")); update((level != NULL), 0); @@ -36604,7 +36604,7 @@ void keyboard_setup(int player) else if(selector == btnnum+1) { quit = 1; - } + } else if(selector == btnnum+2) { clearbuttons(player); @@ -37660,9 +37660,9 @@ void menu_options_video() #endif #if PSP - if(videoMode == 0) + if(videoMode == 0 || videoMode == 1) { - // 320x240 + // 320x240 or 480x272 videomodes.mode += dir; if(videomodes.mode > PSP_DISPLAY_FORMATS - 1) { @@ -37677,9 +37677,9 @@ void menu_options_video() break; case 4: - if(videoMode == 0) + if(videoMode == 0 || videoMode == 1) { - // 320x240 + // 320x240 or 480x272 videomodes.filter += dir; if(videomodes.filter > PSP_DISPLAY_FILTERS - 1) { @@ -38260,7 +38260,7 @@ void openborMain(int argc, char **argv) case 2: { int previousLoop = musicloop; - char previousMusic[sizeof(currentmusic)]; + char previousMusic[sizeof(currentmusic)]; safe_strncpy(previousMusic, currentmusic, sizeof(previousMusic) - 1); diff --git a/engine/psp/graphics.c b/engine/psp/graphics.c index 960fbe39d..e48131574 100644 --- a/engine/psp/graphics.c +++ b/engine/psp/graphics.c @@ -71,9 +71,10 @@ int displayMode; char* filterName[PSP_DISPLAY_FILTERS] = {"Linear", "Bilinear"}; DisplayFormat displayFormat[PSP_DISPLAY_FORMATS] = {{"320x240 (4x3)", 80, 16, 320, 240}, - {"360x270 (4x3)", 60, 01, 360, 270}, - {"384x272 (24x17)", 48, 00, 384, 272}, - {"480x272 (16x9)", 00, 00, 480, 272}}; + {"480x272 (16x9)", 00, 00, 480, 272}, + {"384x272 (24x17)", 48, 00, 384, 272}, + {"360x270 (4x3)", 60, 01, 360, 270}}; + int checkCable(int mode) { if(getHardwareModel()==1) @@ -168,7 +169,7 @@ void initGraphics(int mode, int pixel) dispBuffer = (void*)PSP_VRAM_ADDRESS(displayMode%2) + PSP_FRAMEBUFFER_SIZE; initialized = 1; guSetup(); - setGraphicsScreen(displayFormat[3], pixel, 0); + setGraphicsScreen(displayFormat[1], pixel, 0); } void disableGraphics()