From 3fa676fde841b64a50ad61b2e736b1b8a618675b Mon Sep 17 00:00:00 2001 From: terminx Date: Wed, 14 Jan 2009 00:49:26 +0000 Subject: [PATCH] git-svn-id: https://svn.eduke32.com/eduke32@1209 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/source/actors.c | 20 +- polymer/eduke32/source/player.c | 5144 ++++++++++++++++--------------- 2 files changed, 2583 insertions(+), 2581 deletions(-) diff --git a/polymer/eduke32/source/actors.c b/polymer/eduke32/source/actors.c index 94b20fcaf..9a103c37e 100644 --- a/polymer/eduke32/source/actors.c +++ b/polymer/eduke32/source/actors.c @@ -2450,7 +2450,7 @@ static void G_MoveWeapons(void) ll = s->zvel>>1; } - Bmemcpy(&davect,s,sizeof(int32_t) * 3); + Bmemcpy(&davect,s,sizeof(vec3_t)); /* dax = s->x; day = s->y; @@ -2482,7 +2482,7 @@ static void G_MoveWeapons(void) day = s->y; daz = s->z; */ - Bmemcpy(&davect,s,sizeof(int32_t) * 3); + Bmemcpy(&davect,s,sizeof(vec3_t)); tmpvect.x = (k*(sintable[(s->ang+512)&2047]))>>14; tmpvect.y = (k*(sintable[s->ang&2047]))>>14; @@ -2520,7 +2520,7 @@ static void G_MoveWeapons(void) { k = A_Spawn(i,ActorExtra[i].projectile.spawns); - Bmemcpy(&sprite[k],&davect,sizeof(int32_t) * 3); + Bmemcpy(&sprite[k],&davect,sizeof(vec3_t)); /* sprite[k].x = dax; sprite[k].y = day; @@ -2558,7 +2558,7 @@ static void G_MoveWeapons(void) { k = A_Spawn(i,ActorExtra[i].projectile.spawns); - Bmemcpy(&sprite[k],&davect,sizeof(int32_t) * 3); + Bmemcpy(&sprite[k],&davect,sizeof(vec3_t)); /* sprite[k].x = dax; sprite[k].y = day; @@ -2677,7 +2677,7 @@ static void G_MoveWeapons(void) if (ActorExtra[i].projectile.spawns >= 0) { k = A_Spawn(i,ActorExtra[i].projectile.spawns); - Bmemcpy(&sprite[k],&davect,sizeof(int32_t) * 3); + Bmemcpy(&sprite[k],&davect,sizeof(vec3_t)); /* sprite[k].x = dax; sprite[k].y = day; @@ -2778,7 +2778,7 @@ static void G_MoveWeapons(void) if (ActorExtra[i].projectile.workslike & PROJECTILE_RPG && ActorExtra[i].projectile.spawns > 0) { k = A_Spawn(i,ActorExtra[i].projectile.spawns); - Bmemcpy(&sprite[k],&davect,sizeof(int32_t) * 3); + Bmemcpy(&sprite[k],&davect,sizeof(vec3_t)); /* sprite[k].x = dax; sprite[k].y = day; @@ -2892,7 +2892,7 @@ static void G_MoveWeapons(void) ll = s->zvel>>1; } - Bmemcpy(&davect,s,sizeof(int32_t) * 3); + Bmemcpy(&davect,s,sizeof(vec3_t)); /* dax = s->x; day = s->y; @@ -3039,7 +3039,7 @@ static void G_MoveWeapons(void) { vec3_t tmpvect; setsprite(i,&davect); - Bmemcpy(&tmpvect, s, sizeof(int32_t) * 3); + Bmemcpy(&tmpvect, s, sizeof(vec3_t)); A_DamageWall(i,j,&tmpvect,s->picnum); if (s->picnum == FREEZEBLAST) @@ -3090,7 +3090,7 @@ static void G_MoveWeapons(void) if (s->picnum == RPG) { k = A_Spawn(i,EXPLOSION2); - Bmemcpy(&sprite[k],&davect,sizeof(int32_t) * 3); + Bmemcpy(&sprite[k],&davect,sizeof(vec3_t)); /* sprite[k].x = dax; sprite[k].y = day; @@ -4502,7 +4502,7 @@ static void G_MoveActors(void) j &= (MAXWALLS-1); - Bmemcpy(&davect, s, sizeof(int32_t) * 3); + Bmemcpy(&davect, s, sizeof(vec3_t)); A_DamageWall(i,j,&davect,s->picnum); k = getangle( diff --git a/polymer/eduke32/source/player.c b/polymer/eduke32/source/player.c index 5a1fc6883..7dc81b79a 100644 --- a/polymer/eduke32/source/player.c +++ b/polymer/eduke32/source/player.c @@ -317,9 +317,8 @@ int32_t A_Shoot(int32_t i,int32_t atwith) { p = s->yvel; - srcvect.x = g_player[p].ps->posx; - srcvect.y = g_player[p].ps->posy; - srcvect.z = g_player[p].ps->posz+g_player[p].ps->pyoff+(4<<8); + Bmemcpy(&srcvect,g_player[p].ps,sizeof(vec3_t)); + srcvect.z += g_player[p].ps->pyoff+(4<<8); sa = g_player[p].ps->ang; g_player[p].ps->crack_time = 777; @@ -328,7 +327,7 @@ int32_t A_Shoot(int32_t i,int32_t atwith) { p = -1; sa = s->ang; - Bmemcpy(&srcvect,s,sizeof(int32_t) * 3); + Bmemcpy(&srcvect,s,sizeof(vec3_t)); srcvect.z -= ((s->yrepeat*tilesizy[s->picnum])<<1)+(4<<8); if (s->picnum != ROTATEGUN) @@ -440,9 +439,12 @@ int32_t A_Shoot(int32_t i,int32_t atwith) sprite[k].xvel = -1; sprite[k].ang = getangle(wall[hitinfo.hitwall].x-wall[wall[hitinfo.hitwall].point2].x, wall[hitinfo.hitwall].y-wall[wall[hitinfo.hitwall].point2].y)+512; + Bmemcpy(&sprite[k],hitinfo.pos,sizeof(vec3_t)); +/* sprite[k].x = hitinfo.pos.x; sprite[k].y = hitinfo.pos.y; sprite[k].z = hitinfo.pos.z; +*/ if (ProjectileData[atwith].workslike & PROJECTILE_RANDDECALSIZE) { wh = (krand()&ProjectileData[atwith].xrepeat); @@ -606,2573 +608,2573 @@ int32_t A_Shoot(int32_t i,int32_t atwith) if (j == -1) { sa += (angRange/2)-(krand()&(angRange-1)); - zvel = (100-g_player[p].ps->horiz-g_player[p].ps->horizoff)<<5; - zvel += (zRange/2)-(krand()&(zRange-1)); - } - } - else - { - sa += (angRange/2)-(krand()&(angRange-1)); - if (j == -1) - { - // no target - zvel = (100-g_player[p].ps->horiz-g_player[p].ps->horizoff)<<5; - } - zvel += (zRange/2)-(krand()&(zRange-1)); - } - srcvect.z -= (2<<8); - } - else - { - j = A_FindPlayer(s,&x); - srcvect.z -= (4<<8); - hitinfo.pos.x = ldist(&sprite[g_player[j].ps->i], s); - if (hitinfo.pos.x == 0) - hitinfo.pos.x++; - zvel = ((g_player[j].ps->posz-srcvect.z) <<8) / hitinfo.pos.x; - if (s->picnum != BOSS1) - { - zvel += 128-(krand()&255); - sa += 32-(krand()&63); - } - else - { - zvel += 128-(krand()&255); - sa = getangle(g_player[j].ps->posx-srcvect.x,g_player[j].ps->posy-srcvect.y)+64-(krand()&127); - } - } - - if (ProjectileData[atwith].cstat >= 0) s->cstat &= ~ProjectileData[atwith].cstat; - else s->cstat &= ~257; - - if (ActorExtra[i].temp_data[9]) zvel = ActorExtra[i].temp_data[9]; - hitscan((const vec3_t *)&srcvect,sect, - sintable[(sa+512)&2047], - sintable[sa&2047], - zvel<<6,&hitinfo,CLIPMASK1); - - - if (ProjectileData[atwith].cstat >= 0) s->cstat |= ProjectileData[atwith].cstat; - else s->cstat |= 257; - - if (hitinfo.hitsect < 0) return -1; - - if ((ProjectileData[atwith].range > 0) && - ((klabs(srcvect.x-hitinfo.pos.x)+klabs(srcvect.y-hitinfo.pos.y)) > ProjectileData[atwith].range)) - return -1; - - if (ProjectileData[atwith].trail >= 0) - { - A_HitscanProjTrail(&srcvect,&hitinfo.pos,sa,atwith); - } - - if (ProjectileData[atwith].workslike & PROJECTILE_WATERBUBBLES) - { - if ((krand()&15) == 0 && sector[hitinfo.hitsect].lotag == 2) - A_DoWaterTracers(hitinfo.pos.x,hitinfo.pos.y,hitinfo.pos.z,srcvect.x,srcvect.y,srcvect.z,8-(ud.multimode>>1)); - } - - if (p >= 0) - { - k = A_InsertSprite(hitinfo.hitsect,hitinfo.pos.x,hitinfo.pos.y,hitinfo.pos.z,SHOTSPARK1,-15,10,10,sa,0,0,i,4); - sprite[k].extra = ProjectileData[atwith].extra; - if (ProjectileData[atwith].extra_rand > 0) - sprite[k].extra += (krand()%ProjectileData[atwith].extra_rand); - sprite[k].yvel = atwith; // this is a hack to allow you to detect which weapon spawned a SHOTSPARK1 - ActorExtra[k].temp_data[6] = hitinfo.hitwall; - ActorExtra[k].temp_data[7] = hitinfo.hitsect; - ActorExtra[k].temp_data[8] = hitinfo.hitsprite; - - if (hitinfo.hitwall == -1 && hitinfo.hitsprite == -1) - { - if (zvel < 0) - { - if (sector[hitinfo.hitsect].ceilingstat&1) - { - sprite[k].xrepeat = 0; - sprite[k].yrepeat = 0; - return -1; - } - else - Sect_DamageCeiling(hitinfo.hitsect); - } - if (ProjectileData[atwith].spawns >= 0) - { - wh=A_Spawn(k,ProjectileData[atwith].spawns); - if (ProjectileData[atwith].sxrepeat > 4) sprite[wh].xrepeat=ProjectileData[atwith].sxrepeat; - if (ProjectileData[atwith].syrepeat > 4) sprite[wh].yrepeat=ProjectileData[atwith].syrepeat; - ActorExtra[wh].temp_data[6] = hitinfo.hitwall; - ActorExtra[wh].temp_data[7] = hitinfo.hitsect; - ActorExtra[wh].temp_data[8] = hitinfo.hitsprite; - } - } - - if (hitinfo.hitsprite >= 0) - { - A_DamageObject(hitinfo.hitsprite,k); - if (sprite[hitinfo.hitsprite].picnum == APLAYER && (ud.ffire == 1 || (!GTFLAGS(GAMETYPE_PLAYERSFRIENDLY) && GTFLAGS(GAMETYPE_TDM) && g_player[sprite[hitinfo.hitsprite].yvel].ps->team != g_player[sprite[i].yvel].ps->team))) - { - l = A_Spawn(k,JIBS6); - sprite[k].xrepeat = sprite[k].yrepeat = 0; - sprite[l].z += (4<<8); - sprite[l].xvel = 16; - sprite[l].xrepeat = sprite[l].yrepeat = 24; - sprite[l].ang += 64-(krand()&127); - } - else - { - if (ProjectileData[atwith].spawns >= 0) - { - wh=A_Spawn(k,ProjectileData[atwith].spawns); - if (ProjectileData[atwith].sxrepeat > 4) sprite[wh].xrepeat=ProjectileData[atwith].sxrepeat; - if (ProjectileData[atwith].syrepeat > 4) sprite[wh].yrepeat=ProjectileData[atwith].syrepeat; - ActorExtra[wh].temp_data[6] = hitinfo.hitwall; - ActorExtra[wh].temp_data[7] = hitinfo.hitsect; - ActorExtra[wh].temp_data[8] = hitinfo.hitsprite; - } - } - if (p >= 0 && ( - sprite[hitinfo.hitsprite].picnum == DIPSWITCH || - sprite[hitinfo.hitsprite].picnum == DIPSWITCH+1 || - sprite[hitinfo.hitsprite].picnum == DIPSWITCH2 || - sprite[hitinfo.hitsprite].picnum == DIPSWITCH2+1 || - sprite[hitinfo.hitsprite].picnum == DIPSWITCH3 || - sprite[hitinfo.hitsprite].picnum == DIPSWITCH3+1 || - sprite[hitinfo.hitsprite].picnum == HANDSWITCH || - sprite[hitinfo.hitsprite].picnum == HANDSWITCH+1)) - { - P_ActivateSwitch(p,hitinfo.hitsprite,1); - return -1; - } - } - else if (hitinfo.hitwall >= 0) - { - if (ProjectileData[atwith].spawns >= 0) - { - wh=A_Spawn(k,ProjectileData[atwith].spawns); - if (ProjectileData[atwith].sxrepeat > 4) sprite[wh].xrepeat=ProjectileData[atwith].sxrepeat; - if (ProjectileData[atwith].syrepeat > 4) sprite[wh].yrepeat=ProjectileData[atwith].syrepeat; - ActorExtra[wh].temp_data[6] = hitinfo.hitwall; - ActorExtra[wh].temp_data[7] = hitinfo.hitsect; - ActorExtra[wh].temp_data[8] = hitinfo.hitsprite; - } - if (CheckDoorTile(wall[hitinfo.hitwall].picnum) == 1) - goto DOSKIPBULLETHOLE; - if (p >= 0 && ( - wall[hitinfo.hitwall].picnum == DIPSWITCH || - wall[hitinfo.hitwall].picnum == DIPSWITCH+1 || - wall[hitinfo.hitwall].picnum == DIPSWITCH2 || - wall[hitinfo.hitwall].picnum == DIPSWITCH2+1 || - wall[hitinfo.hitwall].picnum == DIPSWITCH3 || - wall[hitinfo.hitwall].picnum == DIPSWITCH3+1 || - wall[hitinfo.hitwall].picnum == HANDSWITCH || - wall[hitinfo.hitwall].picnum == HANDSWITCH+1)) - { - P_ActivateSwitch(p,hitinfo.hitwall,0); - return -1; - } - - if (wall[hitinfo.hitwall].hitag != 0 || (wall[hitinfo.hitwall].nextwall >= 0 && wall[wall[hitinfo.hitwall].nextwall].hitag != 0)) - goto DOSKIPBULLETHOLE; - - if (hitinfo.hitsect >= 0 && sector[hitinfo.hitsect].lotag == 0) - if (wall[hitinfo.hitwall].overpicnum != BIGFORCE) - if ((wall[hitinfo.hitwall].nextsector >= 0 && sector[wall[hitinfo.hitwall].nextsector].lotag == 0) || - (wall[hitinfo.hitwall].nextsector == -1 && sector[hitinfo.hitsect].lotag == 0)) - if ((wall[hitinfo.hitwall].cstat&16) == 0) - { - if (wall[hitinfo.hitwall].nextsector >= 0) - { - l = headspritesect[wall[hitinfo.hitwall].nextsector]; - while (l >= 0) - { - if (sprite[l].statnum == 3 && sprite[l].lotag == 13) - goto DOSKIPBULLETHOLE; - l = nextspritesect[l]; - } - } - - l = headspritestat[STAT_MISC]; - while (l >= 0) - { - if (sprite[l].picnum == ProjectileData[atwith].decal) - if (dist(&sprite[l],&sprite[k]) < (12+(krand()&7))) - goto DOSKIPBULLETHOLE; - l = nextspritestat[l]; - } - if (ProjectileData[atwith].decal >= 0) - { - l = A_Spawn(k,ProjectileData[atwith].decal); - sprite[l].xvel = -1; - sprite[l].ang = getangle(wall[hitinfo.hitwall].x-wall[wall[hitinfo.hitwall].point2].x, - wall[hitinfo.hitwall].y-wall[wall[hitinfo.hitwall].point2].y)+512; - if (ProjectileData[atwith].workslike & PROJECTILE_RANDDECALSIZE) - { - wh = (krand()&ProjectileData[atwith].xrepeat); - if (wh < ProjectileData[atwith].yrepeat) - wh = ProjectileData[atwith].yrepeat; - sprite[l].xrepeat = wh; - sprite[l].yrepeat = wh; - } - else - { - sprite[l].xrepeat = ProjectileData[atwith].xrepeat; - sprite[l].yrepeat = ProjectileData[atwith].yrepeat; - } - sprite[l].cstat = 16+(krand()&12); - sprite[l].x -= mulscale13(1,sintable[(sprite[l].ang+2560)&2047]); - sprite[l].y -= mulscale13(1,sintable[(sprite[l].ang+2048)&2047]); - - A_SetSprite(l,CLIPMASK0); - A_AddToDeleteQueue(l); - } - } - -DOSKIPBULLETHOLE: - - if (wall[hitinfo.hitwall].cstat&2) - if (wall[hitinfo.hitwall].nextsector >= 0) - if (hitinfo.pos.z >= (sector[wall[hitinfo.hitwall].nextsector].floorz)) - hitinfo.hitwall = wall[hitinfo.hitwall].nextwall; - - A_DamageWall(k,hitinfo.hitwall,&hitinfo.pos,atwith); - } - } - else - { - k = A_InsertSprite(hitinfo.hitsect,hitinfo.pos.x,hitinfo.pos.y,hitinfo.pos.z,SHOTSPARK1,-15,24,24,sa,0,0,i,4); - sprite[k].extra = ProjectileData[atwith].extra; - if (ProjectileData[atwith].extra_rand > 0) - sprite[k].extra += (krand()%ProjectileData[atwith].extra_rand); - sprite[k].yvel = atwith; // this is a hack to allow you to detect which weapon spawned a SHOTSPARK1 - ActorExtra[k].temp_data[6] = hitinfo.hitwall; - ActorExtra[k].temp_data[7] = hitinfo.hitsect; - ActorExtra[k].temp_data[8] = hitinfo.hitsprite; - - if (hitinfo.hitsprite >= 0) - { - A_DamageObject(hitinfo.hitsprite,k); - if (sprite[hitinfo.hitsprite].picnum != APLAYER) - { - if (ProjectileData[atwith].spawns >= 0) - { - wh=A_Spawn(k,ProjectileData[atwith].spawns); - if (ProjectileData[atwith].sxrepeat > 4) sprite[wh].xrepeat=ProjectileData[atwith].sxrepeat; - if (ProjectileData[atwith].syrepeat > 4) sprite[wh].yrepeat=ProjectileData[atwith].syrepeat; - ActorExtra[wh].temp_data[6] = hitinfo.hitwall; - ActorExtra[wh].temp_data[7] = hitinfo.hitsect; - ActorExtra[wh].temp_data[8] = hitinfo.hitsprite; - } - } - else sprite[k].xrepeat = sprite[k].yrepeat = 0; - } - else if (hitinfo.hitwall >= 0) - A_DamageWall(k,hitinfo.hitwall,&hitinfo.pos,atwith); - } - - if ((krand()&255) < 4) - if (ProjectileData[atwith].isound >= 0) - { - S_PlaySoundXYZ(ProjectileData[atwith].isound,k,&hitinfo.pos); - } - - return -1; - } - - if (ProjectileData[atwith].workslike & PROJECTILE_RPG) - { - - /* if(ProjectileData[atwith].workslike & PROJECTILE_FREEZEBLAST) - sz += (3<<8);*/ - - if (s->extra >= 0) s->shade = ProjectileData[atwith].shade; - - scount = 1; - vel = ProjectileData[atwith].vel; - - j = -1; - - if (p >= 0) - { - // j = A_FindTargetSprite( s, AUTO_AIM_ANGLE ); // 48 - Gv_SetVar(g_iAimAngleVarID,AUTO_AIM_ANGLE,i,p); - X_OnEvent(EVENT_GETAUTOAIMANGLE, i, p, -1); - j=-1; - if (Gv_GetVar(g_iAimAngleVarID,i,p) > 0) - { - j = A_FindTargetSprite(s, Gv_GetVar(g_iAimAngleVarID,i,p),atwith); - } - if (j >= 0) - { - dal = ((sprite[j].yrepeat*tilesizy[sprite[j].picnum])<<1)+(8<<8); - hitinfo.pos.x = ldist(&sprite[g_player[p].ps->i], &sprite[j]); - - if (hitinfo.pos.x == 0) - hitinfo.pos.x++; - - zvel = ((sprite[j].z-srcvect.z-dal)*vel) / hitinfo.pos.x; - - if (sprite[j].picnum != RECON) - sa = getangle(sprite[j].x-srcvect.x,sprite[j].y-srcvect.y); - } - // else zvel = (100-g_player[p].ps->horiz-g_player[p].ps->horizoff)*81; - else zvel = (100-g_player[p].ps->horiz-g_player[p].ps->horizoff)*(ProjectileData[atwith].vel/8); - - if (ProjectileData[atwith].sound >= 0) - A_PlaySound(ProjectileData[atwith].sound,i); - } - else - { - if (!(ProjectileData[atwith].workslike & PROJECTILE_NOAIM)) - { - j = A_FindPlayer(s,&x); - sa = getangle(g_player[j].ps->oposx-srcvect.x,g_player[j].ps->oposy-srcvect.y); - - l = ldist(&sprite[g_player[j].ps->i],s); - if (l == 0) - l++; - zvel = ((g_player[j].ps->oposz-srcvect.z)*vel) / l; - - if (A_CheckEnemySprite(s) && (s->hitag&face_player_smart)) - sa = s->ang+(krand()&31)-16; - } - } - - - - if (p >= 0 && j >= 0) - l = j; - else l = -1; - - /* j = A_InsertSprite(sect, - sx+(sintable[(348+sa+512)&2047]/448), - sy+(sintable[(sa+348)&2047]/448), - sz-(1<<8),atwith,0,14,14,sa,vel,zvel,i,4);*/ - if (ActorExtra[i].temp_data[9]) zvel = ActorExtra[i].temp_data[9]; - j = A_InsertSprite(sect, - srcvect.x+(sintable[(348+sa+512)&2047]/ProjectileData[atwith].offset), - srcvect.y+(sintable[(sa+348)&2047]/ProjectileData[atwith].offset), - srcvect.z-(1<<8),atwith,0,14,14,sa,vel,zvel,i,4); - - sprite[j].xrepeat=ProjectileData[atwith].xrepeat; - sprite[j].yrepeat=ProjectileData[atwith].yrepeat; - - - if (ProjectileData[atwith].extra_rand > 0) - sprite[j].extra += (krand()&ProjectileData[atwith].extra_rand); - if (!(ProjectileData[atwith].workslike & PROJECTILE_BOUNCESOFFWALLS)) - sprite[j].yvel = l; - else - { - if (ProjectileData[atwith].bounces >= 1) sprite[j].yvel = ProjectileData[atwith].bounces; - else sprite[j].yvel = g_numFreezeBounces; - // sprite[j].xrepeat >>= 1; - // sprite[j].yrepeat >>= 1; - sprite[j].zvel -= (2<<4); - } - /* - if(p == -1) - { - if(!(ProjectileData[atwith].workslike & PROJECTILE_BOUNCESOFFWALLS)) - { - sprite[j].xrepeat = ProjectileData[atwith].xrepeat; // 30 - sprite[j].yrepeat = ProjectileData[atwith].yrepeat; - sprite[j].extra >>= 2; - } - } - */ - if (ProjectileData[atwith].cstat >= 0) sprite[j].cstat = ProjectileData[atwith].cstat; - else sprite[j].cstat = 128; - if (ProjectileData[atwith].clipdist >= 0) sprite[j].clipdist = ProjectileData[atwith].clipdist; - else sprite[j].clipdist = 40; - - Bmemcpy(&ActorExtra[j].projectile, &ProjectileData[sprite[j].picnum], sizeof(ProjectileData[sprite[j].picnum])); - - // sa = s->ang+32-(krand()&63); - // zvel = oldzvel+512-(krand()&1023); - - return j; - } - - } - else - { - switch (DynamicTileMap[atwith]) - { - case BLOODSPLAT1__STATIC: - case BLOODSPLAT2__STATIC: - case BLOODSPLAT3__STATIC: - case BLOODSPLAT4__STATIC: - - if (p >= 0) - sa += 64 - (krand()&127); - else sa += 1024 + 64 - (krand()&127); - zvel = 1024-(krand()&2047); - case KNEE__STATIC: - if (atwith == KNEE) - { - if (p >= 0) - { - zvel = (100-g_player[p].ps->horiz-g_player[p].ps->horizoff)<<5; - srcvect.z += (6<<8); - sa += 15; - } - else - { - j = g_player[A_FindPlayer(s,&x)].ps->i; - zvel = ((sprite[j].z-srcvect.z)<<8) / (x+1); - sa = getangle(sprite[j].x-srcvect.x,sprite[j].y-srcvect.y); - } - } - - if (ActorExtra[i].temp_data[9]) zvel = ActorExtra[i].temp_data[9]; - hitscan((const vec3_t *)&srcvect,sect, - sintable[(sa+512)&2047], - sintable[sa&2047],zvel<<6, - &hitinfo,CLIPMASK1); - - if (atwith == BLOODSPLAT1 || atwith == BLOODSPLAT2 || atwith == BLOODSPLAT3 || atwith == BLOODSPLAT4) - { - if (FindDistance2D(srcvect.x-hitinfo.pos.x,srcvect.y-hitinfo.pos.y) < 1024) - if (hitinfo.hitwall >= 0 && wall[hitinfo.hitwall].overpicnum != BIGFORCE) - if ((wall[hitinfo.hitwall].nextsector >= 0 && hitinfo.hitsect >= 0 && - sector[wall[hitinfo.hitwall].nextsector].lotag == 0 && - sector[hitinfo.hitsect].lotag == 0 && - sector[wall[hitinfo.hitwall].nextsector].lotag == 0 && - (sector[hitinfo.hitsect].floorz-sector[wall[hitinfo.hitwall].nextsector].floorz) > (16<<8)) || - (wall[hitinfo.hitwall].nextsector == -1 && sector[hitinfo.hitsect].lotag == 0)) - if ((wall[hitinfo.hitwall].cstat&16) == 0) - { - if (wall[hitinfo.hitwall].nextsector >= 0) - { - k = headspritesect[wall[hitinfo.hitwall].nextsector]; - while (k >= 0) - { - if (sprite[k].statnum == 3 && sprite[k].lotag == 13) - return -1; - k = nextspritesect[k]; - } - } - - if (wall[hitinfo.hitwall].nextwall >= 0 && - wall[wall[hitinfo.hitwall].nextwall].hitag != 0) - return -1; - - if (wall[hitinfo.hitwall].hitag == 0) - { - k = A_Spawn(i,atwith); - sprite[k].xvel = -12; - sprite[k].ang = getangle(wall[hitinfo.hitwall].x-wall[wall[hitinfo.hitwall].point2].x, - wall[hitinfo.hitwall].y-wall[wall[hitinfo.hitwall].point2].y)+512; - sprite[k].x = hitinfo.pos.x; - sprite[k].y = hitinfo.pos.y; - sprite[k].z = hitinfo.pos.z; - sprite[k].cstat |= (krand()&4); - A_SetSprite(k,CLIPMASK0); - setsprite(k,(vec3_t *)&sprite[k]); - if (PN == OOZFILTER || PN == NEWBEAST) - sprite[k].pal = 6; - } - } - return -1; - } - - if (hitinfo.hitsect < 0) break; - - if ((klabs(srcvect.x-hitinfo.pos.x)+klabs(srcvect.y-hitinfo.pos.y)) < 1024) - { - if (hitinfo.hitwall >= 0 || hitinfo.hitsprite >= 0) - { - j = A_InsertSprite(hitinfo.hitsect,hitinfo.pos.x,hitinfo.pos.y,hitinfo.pos.z,KNEE,-15,0,0,sa,32,0,i,4); - sprite[j].extra += (krand()&7); - if (p >= 0) - { - k = A_Spawn(j,SMALLSMOKE); - sprite[k].z -= (8<<8); - A_PlaySound(KICK_HIT,j); - ActorExtra[k].temp_data[6] = hitinfo.hitwall; - ActorExtra[k].temp_data[7] = hitinfo.hitsect; - ActorExtra[k].temp_data[8] = hitinfo.hitsprite; - } - - if (p >= 0 && g_player[p].ps->steroids_amount > 0 && g_player[p].ps->steroids_amount < 400) - sprite[j].extra += (g_player[p].ps->max_player_health>>2); - - if (hitinfo.hitsprite >= 0 && sprite[hitinfo.hitsprite].picnum != ACCESSSWITCH && sprite[hitinfo.hitsprite].picnum != ACCESSSWITCH2) - { - A_DamageObject(hitinfo.hitsprite,j); - if (p >= 0) P_ActivateSwitch(p,hitinfo.hitsprite,1); - } - - else if (hitinfo.hitwall >= 0) - { - if (wall[hitinfo.hitwall].cstat&2) - if (wall[hitinfo.hitwall].nextsector >= 0) - if (hitinfo.pos.z >= (sector[wall[hitinfo.hitwall].nextsector].floorz)) - hitinfo.hitwall = wall[hitinfo.hitwall].nextwall; - - if (hitinfo.hitwall >= 0 && wall[hitinfo.hitwall].picnum != ACCESSSWITCH && wall[hitinfo.hitwall].picnum != ACCESSSWITCH2) - { - A_DamageWall(j,hitinfo.hitwall,&hitinfo.pos,atwith); - if (p >= 0) P_ActivateSwitch(p,hitinfo.hitwall,0); - } - } - } - else if (p >= 0 && zvel > 0 && sector[hitinfo.hitsect].lotag == 1) - { - j = A_Spawn(g_player[p].ps->i,WATERSPLASH2); - sprite[j].x = hitinfo.pos.x; - sprite[j].y = hitinfo.pos.y; - sprite[j].ang = g_player[p].ps->ang; // Total tweek - sprite[j].xvel = 32; - A_SetSprite(i,CLIPMASK0); - sprite[j].xvel = 0; - - } - } - - break; - - case SHOTSPARK1__STATIC: - case SHOTGUN__STATIC: - case CHAINGUN__STATIC: - - if (s->extra >= 0) s->shade = -96; - - if (p >= 0) - { - int32_t angRange=32; - int32_t zRange=256; - - Gv_SetVar(g_iAimAngleVarID,AUTO_AIM_ANGLE,i,p); - X_OnEvent(EVENT_GETAUTOAIMANGLE, i, p, -1); - j=-1; - if (Gv_GetVar(g_iAimAngleVarID,i,p) > 0) - { - j = A_FindTargetSprite(s, Gv_GetVar(g_iAimAngleVarID,i,p),atwith); - } - if (j >= 0) - { - dal = ((sprite[j].yrepeat*tilesizy[sprite[j].picnum])<<1)+(5<<8); - if (((sprite[j].picnum>=GREENSLIME)&&(sprite[j].picnum<=GREENSLIME+7))||(sprite[j].picnum==ROTATEGUN)) - { - - dal -= (8<<8); - - } - hitinfo.pos.x = ldist(&sprite[g_player[p].ps->i], &sprite[j]); - if (hitinfo.pos.x == 0) hitinfo.pos.x++; - zvel = ((sprite[j].z-srcvect.z-dal)<<8) / hitinfo.pos.x; - sa = getangle(sprite[j].x-srcvect.x,sprite[j].y-srcvect.y); - } - - Gv_SetVar(g_iAngRangeVarID,angRange, i,p); - Gv_SetVar(g_iZRangeVarID,zRange,i,p); - - X_OnEvent(EVENT_GETSHOTRANGE, i,p, -1); - - angRange=Gv_GetVar(g_iAngRangeVarID,i,p); - zRange=Gv_GetVar(g_iZRangeVarID,i,p); - - if (atwith == SHOTSPARK1__STATIC && !WW2GI && !NAM) - { - if (!g_player[p].ps->auto_aim) - { - zvel = (100-g_player[p].ps->horiz-g_player[p].ps->horizoff)<<5; - if (ActorExtra[i].temp_data[9]) zvel = ActorExtra[i].temp_data[9]; - hitscan((const vec3_t *)&srcvect,sect,sintable[(sa+512)&2047],sintable[sa&2047], - zvel<<6,&hitinfo,CLIPMASK1); - if (hitinfo.hitsprite != -1) - { - if (sprite[hitinfo.hitsprite].statnum == 1 || sprite[hitinfo.hitsprite].statnum == 2 || sprite[hitinfo.hitsprite].statnum == 10 || sprite[hitinfo.hitsprite].statnum == 13) - j = hitinfo.hitsprite; - } - } - - if (j == -1) - { - sa += (angRange/2)-(krand()&(angRange-1)); - zvel = (100-g_player[p].ps->horiz-g_player[p].ps->horizoff)<<5; - zvel += (zRange/2)-(krand()&(zRange-1)); - } - } - else - { - sa += (angRange/2)-(krand()&(angRange-1)); - if (j == -1) - { - // no target - zvel = (100-g_player[p].ps->horiz-g_player[p].ps->horizoff)<<5; - } - zvel += (zRange/2)-(krand()&(zRange-1)); - } - - srcvect.z -= (2<<8); - } - else - { - j = A_FindPlayer(s,&x); - srcvect.z -= (4<<8); - hitinfo.pos.x = ldist(&sprite[g_player[j].ps->i], s); - if (hitinfo.pos.x == 0) - hitinfo.pos.x++; - zvel = ((g_player[j].ps->posz-srcvect.z) <<8) / hitinfo.pos.x; - if (s->picnum != BOSS1) - { - zvel += 128-(krand()&255); - sa += 32-(krand()&63); - } - else - { - zvel += 128-(krand()&255); - sa = getangle(g_player[j].ps->posx-srcvect.x,g_player[j].ps->posy-srcvect.y)+64-(krand()&127); - } - } - - s->cstat &= ~257; - if (ActorExtra[i].temp_data[9]) zvel = ActorExtra[i].temp_data[9]; - hitscan((const vec3_t *)&srcvect,sect, - sintable[(sa+512)&2047], - sintable[sa&2047], - zvel<<6,&hitinfo,CLIPMASK1); - s->cstat |= 257; - - if (hitinfo.hitsect < 0) return -1; - - if ((krand()&15) == 0 && sector[hitinfo.hitsect].lotag == 2) - A_DoWaterTracers(hitinfo.pos.x,hitinfo.pos.y,hitinfo.pos.z, - srcvect.x,srcvect.y,srcvect.z,8-(ud.multimode>>1)); - - if (p >= 0) - { - k = A_InsertSprite(hitinfo.hitsect,hitinfo.pos.x,hitinfo.pos.y,hitinfo.pos.z,SHOTSPARK1,-15,10,10,sa,0,0,i,4); - sprite[k].extra = *actorscrptr[atwith]; - sprite[k].extra += (krand()%6); - sprite[k].yvel = atwith; // this is a hack to allow you to detect which weapon spawned a SHOTSPARK1 - ActorExtra[k].temp_data[6] = hitinfo.hitwall; - ActorExtra[k].temp_data[7] = hitinfo.hitsect; - ActorExtra[k].temp_data[8] = hitinfo.hitsprite; - - - if (hitinfo.hitwall == -1 && hitinfo.hitsprite == -1) - { - if (zvel < 0) - { - if (sector[hitinfo.hitsect].ceilingstat&1) - { - sprite[k].xrepeat = 0; - sprite[k].yrepeat = 0; - return -1; - } - else - Sect_DamageCeiling(hitinfo.hitsect); - } - l = A_Spawn(k,SMALLSMOKE); - ActorExtra[l].temp_data[6] = hitinfo.hitwall; - ActorExtra[l].temp_data[7] = hitinfo.hitsect; - ActorExtra[l].temp_data[8] = hitinfo.hitsprite; - } - - if (hitinfo.hitsprite >= 0) - { - A_DamageObject(hitinfo.hitsprite,k); - if (sprite[hitinfo.hitsprite].picnum == APLAYER && (ud.ffire == 1 || (!GTFLAGS(GAMETYPE_PLAYERSFRIENDLY) && GTFLAGS(GAMETYPE_TDM) && g_player[sprite[hitinfo.hitsprite].yvel].ps->team != g_player[sprite[i].yvel].ps->team))) - { - l = A_Spawn(k,JIBS6); - sprite[k].xrepeat = sprite[k].yrepeat = 0; - sprite[l].z += (4<<8); - sprite[l].xvel = 16; - sprite[l].xrepeat = sprite[l].yrepeat = 24; - sprite[l].ang += 64-(krand()&127); - } - else - { - l = A_Spawn(k,SMALLSMOKE); - ActorExtra[l].temp_data[6] = hitinfo.hitwall; - ActorExtra[l].temp_data[7] = hitinfo.hitsect; - ActorExtra[l].temp_data[8] = hitinfo.hitsprite; - } - - if (p >= 0 && ( - sprite[hitinfo.hitsprite].picnum == DIPSWITCH || - sprite[hitinfo.hitsprite].picnum == DIPSWITCH+1 || - sprite[hitinfo.hitsprite].picnum == DIPSWITCH2 || - sprite[hitinfo.hitsprite].picnum == DIPSWITCH2+1 || - sprite[hitinfo.hitsprite].picnum == DIPSWITCH3 || - sprite[hitinfo.hitsprite].picnum == DIPSWITCH3+1 || - sprite[hitinfo.hitsprite].picnum == HANDSWITCH || - sprite[hitinfo.hitsprite].picnum == HANDSWITCH+1)) - { - P_ActivateSwitch(p,hitinfo.hitsprite,1); - return -1; - } - } - else if (hitinfo.hitwall >= 0) - { - l = A_Spawn(k,SMALLSMOKE); - ActorExtra[l].temp_data[6] = hitinfo.hitwall; - ActorExtra[l].temp_data[7] = hitinfo.hitsect; - ActorExtra[l].temp_data[8] = hitinfo.hitsprite; - - if (CheckDoorTile(wall[hitinfo.hitwall].picnum) == 1) - goto SKIPBULLETHOLE; - if (p >= 0 && ( - wall[hitinfo.hitwall].picnum == DIPSWITCH || - wall[hitinfo.hitwall].picnum == DIPSWITCH+1 || - wall[hitinfo.hitwall].picnum == DIPSWITCH2 || - wall[hitinfo.hitwall].picnum == DIPSWITCH2+1 || - wall[hitinfo.hitwall].picnum == DIPSWITCH3 || - wall[hitinfo.hitwall].picnum == DIPSWITCH3+1 || - wall[hitinfo.hitwall].picnum == HANDSWITCH || - wall[hitinfo.hitwall].picnum == HANDSWITCH+1)) - { - P_ActivateSwitch(p,hitinfo.hitwall,0); - return -1; - } - - if (wall[hitinfo.hitwall].hitag != 0 || (wall[hitinfo.hitwall].nextwall >= 0 && wall[wall[hitinfo.hitwall].nextwall].hitag != 0)) - goto SKIPBULLETHOLE; - - if (hitinfo.hitsect >= 0 && sector[hitinfo.hitsect].lotag == 0) - if (wall[hitinfo.hitwall].overpicnum != BIGFORCE) - if ((wall[hitinfo.hitwall].nextsector >= 0 && sector[wall[hitinfo.hitwall].nextsector].lotag == 0) || - (wall[hitinfo.hitwall].nextsector == -1 && sector[hitinfo.hitsect].lotag == 0)) - if ((wall[hitinfo.hitwall].cstat&16) == 0) - { - if (wall[hitinfo.hitwall].nextsector >= 0) - { - l = headspritesect[wall[hitinfo.hitwall].nextsector]; - while (l >= 0) - { - if (sprite[l].statnum == 3 && sprite[l].lotag == 13) - goto SKIPBULLETHOLE; - l = nextspritesect[l]; - } - } - - l = headspritestat[STAT_MISC]; - while (l >= 0) - { - if (sprite[l].picnum == BULLETHOLE) - if (dist(&sprite[l],&sprite[k]) < (12+(krand()&7))) - goto SKIPBULLETHOLE; - l = nextspritestat[l]; - } - l = A_Spawn(k,BULLETHOLE); - sprite[l].xvel = -1; - sprite[l].x = hitinfo.pos.x; - sprite[l].y = hitinfo.pos.y; - sprite[l].z = hitinfo.pos.z; - - sprite[l].ang = getangle(wall[hitinfo.hitwall].x-wall[wall[hitinfo.hitwall].point2].x, - wall[hitinfo.hitwall].y-wall[wall[hitinfo.hitwall].point2].y)+512; - - sprite[l].x -= mulscale13(1,sintable[(sprite[l].ang+2560)&2047]); - sprite[l].y -= mulscale13(1,sintable[(sprite[l].ang+2048)&2047]); - A_SetSprite(l,CLIPMASK0); - } - -SKIPBULLETHOLE: - - if (wall[hitinfo.hitwall].cstat&2) - if (wall[hitinfo.hitwall].nextsector >= 0) - if (hitinfo.pos.z >= (sector[wall[hitinfo.hitwall].nextsector].floorz)) - hitinfo.hitwall = wall[hitinfo.hitwall].nextwall; - - A_DamageWall(k,hitinfo.hitwall,&hitinfo.pos,SHOTSPARK1); - } - } - else - { - k = A_InsertSprite(hitinfo.hitsect,hitinfo.pos.x,hitinfo.pos.y,hitinfo.pos.z,SHOTSPARK1,-15,24,24,sa,0,0,i,4); - sprite[k].extra = *actorscrptr[atwith]; - sprite[k].yvel = atwith; // this is a hack to allow you to detect which weapon spawned a SHOTSPARK1 - ActorExtra[k].temp_data[6] = hitinfo.hitwall; - ActorExtra[k].temp_data[7] = hitinfo.hitsect; - ActorExtra[k].temp_data[8] = hitinfo.hitsprite; - - if (hitinfo.hitsprite >= 0) - { - A_DamageObject(hitinfo.hitsprite,k); - if (sprite[hitinfo.hitsprite].picnum != APLAYER) - { - l = A_Spawn(k,SMALLSMOKE); - ActorExtra[l].temp_data[6] = hitinfo.hitwall; - ActorExtra[l].temp_data[7] = hitinfo.hitsect; - ActorExtra[l].temp_data[8] = hitinfo.hitsprite; - } - else sprite[k].xrepeat = sprite[k].yrepeat = 0; - } - else if (hitinfo.hitwall >= 0) - A_DamageWall(k,hitinfo.hitwall,&hitinfo.pos,SHOTSPARK1); - } - - if ((krand()&255) < 4) - S_PlaySoundXYZ(PISTOL_RICOCHET,k, &hitinfo.pos); - - return -1; - - case FIRELASER__STATIC: - case SPIT__STATIC: - case COOLEXPLOSION1__STATIC: - - if (s->extra >= 0) s->shade = -96; - - scount = 1; - if (atwith == SPIT) vel = 292; - else - { - if (atwith == COOLEXPLOSION1) - { - if (s->picnum == BOSS2) vel = 644; - else vel = 348; - srcvect.z -= (4<<7); - } - else - { - vel = 840; - srcvect.z -= (4<<7); - } - } - - if (p >= 0) - { - // j = A_FindTargetSprite( s, AUTO_AIM_ANGLE ); - Gv_SetVar(g_iAimAngleVarID,AUTO_AIM_ANGLE,i,p); - X_OnEvent(EVENT_GETAUTOAIMANGLE, i, p, -1); - j=-1; - if (Gv_GetVar(g_iAimAngleVarID,i,p) > 0) - { - j = A_FindTargetSprite(s, Gv_GetVar(g_iAimAngleVarID,i,p),atwith); - } - - if (j >= 0) - { - dal = ((sprite[j].yrepeat*tilesizy[sprite[j].picnum])<<1)-(12<<8); - hitinfo.pos.x = ldist(&sprite[g_player[p].ps->i], &sprite[j]); - if (hitinfo.pos.x == 0) hitinfo.pos.x++; - zvel = ((sprite[j].z-srcvect.z-dal)*vel) / hitinfo.pos.x; - sa = getangle(sprite[j].x-srcvect.x,sprite[j].y-srcvect.y); - } - else - zvel = (100-g_player[p].ps->horiz-g_player[p].ps->horizoff)*98; - } - else - { - j = A_FindPlayer(s,&x); - // sa = getangle(g_player[j].ps->oposx-sx,g_player[j].ps->oposy-sy); - sa += 16-(krand()&31); - hitinfo.pos.x = ldist(&sprite[g_player[j].ps->i],s); - if (hitinfo.pos.x == 0) hitinfo.pos.x++; - zvel = ((g_player[j].ps->oposz - srcvect.z + (3<<8))*vel) / hitinfo.pos.x; - } - if (ActorExtra[i].temp_data[9]) zvel = ActorExtra[i].temp_data[9]; - oldzvel = zvel; - - if (atwith == SPIT) - { - sizx = 18; - sizy = 18,srcvect.z -= (10<<8); - } - else - { - if (atwith == FIRELASER) - { - if (p >= 0) - { - - sizx = 34; - sizy = 34; - } - else - { - sizx = 18; - sizy = 18; - } - } - else - { - sizx = 18; - sizy = 18; - } - } - - if (p >= 0) sizx = 7,sizy = 7; - - while (scount > 0) - { - j = A_InsertSprite(sect,srcvect.x,srcvect.y,srcvect.z, - atwith,-127,sizx,sizy,sa,vel,zvel,i,4); - sprite[j].extra += (krand()&7); - - if (atwith == COOLEXPLOSION1) - { - sprite[j].shade = 0; - if (PN == BOSS2) - { - l = sprite[j].xvel; - sprite[j].xvel = 1024; - A_SetSprite(j,CLIPMASK0); - sprite[j].xvel = l; - sprite[j].ang += 128-(krand()&255); - } - } - - sprite[j].cstat = 128; - sprite[j].clipdist = 4; - - sa = s->ang+32-(krand()&63); - zvel = oldzvel+512-(krand()&1023); - - scount--; - } - - return j; - - case FREEZEBLAST__STATIC: - srcvect.z += (3<<8); - case RPG__STATIC: - - if (s->extra >= 0) s->shade = -96; - - scount = 1; - vel = 644; - - j = -1; - - if (p >= 0) - { - // j = A_FindTargetSprite( s, AUTO_AIM_ANGLE ); // 48 - Gv_SetVar(g_iAimAngleVarID,AUTO_AIM_ANGLE,i,p); - X_OnEvent(EVENT_GETAUTOAIMANGLE, i, p, -1); - j=-1; - if (Gv_GetVar(g_iAimAngleVarID,i,p) > 0) - { - j = A_FindTargetSprite(s, Gv_GetVar(g_iAimAngleVarID,i,p),atwith); - } - - if (j >= 0) - { - dal = ((sprite[j].yrepeat*tilesizy[sprite[j].picnum])<<1)+(8<<8); - hitinfo.pos.x = ldist(&sprite[g_player[p].ps->i], &sprite[j]); - if (hitinfo.pos.x == 0) hitinfo.pos.x++; - zvel = ((sprite[j].z-srcvect.z-dal)*vel) / hitinfo.pos.x; - if (sprite[j].picnum != RECON) - sa = getangle(sprite[j].x-srcvect.x,sprite[j].y-srcvect.y); - } - else zvel = (100-g_player[p].ps->horiz-g_player[p].ps->horizoff)*81; - if (atwith == RPG) - A_PlaySound(RPG_SHOOT,i); - } - else - { - j = A_FindPlayer(s,&x); - sa = getangle(g_player[j].ps->oposx-srcvect.x,g_player[j].ps->oposy-srcvect.y); - if (PN == BOSS3) - srcvect.z -= (32<<8); - else if (PN == BOSS2) - { - vel += 128; - srcvect.z += 24<<8; - } - - l = ldist(&sprite[g_player[j].ps->i],s); - if (l == 0) - l++; - zvel = ((g_player[j].ps->oposz-srcvect.z)*vel) / l; - - if (A_CheckEnemySprite(s) && (s->hitag&face_player_smart)) - sa = s->ang+(krand()&31)-16; - } - - if (p >= 0 && j >= 0) - l = j; - else l = -1; - if (ActorExtra[i].temp_data[9]) zvel = ActorExtra[i].temp_data[9]; - j = A_InsertSprite(sect, - srcvect.x+(sintable[(348+sa+512)&2047]/448), - srcvect.y+(sintable[(sa+348)&2047]/448), - srcvect.z-(1<<8),atwith,0,14,14,sa,vel,zvel,i,4); - - sprite[j].extra += (krand()&7); - if (atwith != FREEZEBLAST) - sprite[j].yvel = l; - else - { - sprite[j].yvel = g_numFreezeBounces; - sprite[j].xrepeat >>= 1; - sprite[j].yrepeat >>= 1; - sprite[j].zvel -= (2<<4); - } - - if (p == -1) - { - if (PN == BOSS3) - { - if (krand()&1) - { - sprite[j].x -= sintable[sa&2047]>>6; - sprite[j].y -= sintable[(sa+1024+512)&2047]>>6; - sprite[j].ang -= 8; - } - else - { - sprite[j].x += sintable[sa&2047]>>6; - sprite[j].y += sintable[(sa+1024+512)&2047]>>6; - sprite[j].ang += 4; - } - sprite[j].xrepeat = 42; - sprite[j].yrepeat = 42; - } - else if (PN == BOSS2) - { - sprite[j].x -= sintable[sa&2047]/56; - sprite[j].y -= sintable[(sa+1024+512)&2047]/56; - sprite[j].ang -= 8+(krand()&255)-128; - sprite[j].xrepeat = 24; - sprite[j].yrepeat = 24; - } - else if (atwith != FREEZEBLAST) - { - sprite[j].xrepeat = 30; - sprite[j].yrepeat = 30; - sprite[j].extra >>= 2; - } - } - - else if (*aplWeaponWorksLike[g_player[p].ps->curr_weapon] == DEVISTATOR_WEAPON) - { - sprite[j].extra >>= 2; - sprite[j].ang += 16-(krand()&31); - sprite[j].zvel += 256-(krand()&511); - - if (g_player[p].ps->hbomb_hold_delay) - { - sprite[j].x -= sintable[sa&2047]/644; - sprite[j].y -= sintable[(sa+1024+512)&2047]/644; - } - else - { - sprite[j].x += sintable[sa&2047]>>8; - sprite[j].y += sintable[(sa+1024+512)&2047]>>8; - } - sprite[j].xrepeat >>= 1; - sprite[j].yrepeat >>= 1; - } - - sprite[j].cstat = 128; - if (atwith == RPG) - sprite[j].clipdist = 4; - else - sprite[j].clipdist = 40; - - return j; - - case HANDHOLDINGLASER__STATIC: - - if (p >= 0) - zvel = (100-g_player[p].ps->horiz-g_player[p].ps->horizoff)*32; - else zvel = 0; - if (ActorExtra[i].temp_data[9]) zvel = ActorExtra[i].temp_data[9]; - - srcvect.z -= g_player[p].ps->pyoff; - hitscan((const vec3_t *)&srcvect,sect, - sintable[(sa+512)&2047], - sintable[sa&2047], - zvel<<6,&hitinfo,CLIPMASK1); - - srcvect.z += g_player[p].ps->pyoff; - j = 0; - if (hitinfo.hitsprite >= 0) break; - - if (hitinfo.hitwall >= 0 && hitinfo.hitsect >= 0) - if (((hitinfo.pos.x-srcvect.x)*(hitinfo.pos.x-srcvect.x)+(hitinfo.pos.y-srcvect.y)*(hitinfo.pos.y-srcvect.y)) < (290*290)) - { - if (wall[hitinfo.hitwall].nextsector >= 0) - { - if (sector[wall[hitinfo.hitwall].nextsector].lotag <= 2 && sector[hitinfo.hitsect].lotag <= 2) - j = 1; - } - else if (sector[hitinfo.hitsect].lotag <= 2) - j = 1; - } - - if (j == 1) - { - int32_t lTripBombControl=Gv_GetVarByLabel("TRIPBOMB_CONTROL", TRIPBOMB_TRIPWIRE, g_player[p].ps->i, p); - k = A_InsertSprite(hitinfo.hitsect,hitinfo.pos.x,hitinfo.pos.y,hitinfo.pos.z,TRIPBOMB,-16,4,5,sa,0,0,i,6); - if (lTripBombControl & TRIPBOMB_TIMER) - { - int32_t lLifetime=Gv_GetVarByLabel("STICKYBOMB_LIFETIME", NAM_GRENADE_LIFETIME, g_player[p].ps->i, p); - int32_t lLifetimeVar=Gv_GetVarByLabel("STICKYBOMB_LIFETIME_VAR", NAM_GRENADE_LIFETIME_VAR, g_player[p].ps->i, p); - // set timer. blows up when at zero.... - ActorExtra[k].temp_data[7]=lLifetime - + mulscale(krand(),lLifetimeVar, 14) - - lLifetimeVar; - ActorExtra[k].temp_data[6]=1; - } - else - - sprite[k].hitag = k; - A_PlaySound(LASERTRIP_ONWALL,k); - sprite[k].xvel = -20; - A_SetSprite(k,CLIPMASK0); - sprite[k].cstat = 16; - ActorExtra[k].temp_data[5] = sprite[k].ang = getangle(wall[hitinfo.hitwall].x-wall[wall[hitinfo.hitwall].point2].x,wall[hitinfo.hitwall].y-wall[wall[hitinfo.hitwall].point2].y)-512; - - - } - return j?k:-1; - - case BOUNCEMINE__STATIC: - case MORTER__STATIC: - - if (s->extra >= 0) s->shade = -96; - - j = g_player[A_FindPlayer(s,&x)].ps->i; - x = ldist(&sprite[j],s); - - zvel = -x>>1; - - if (zvel < -4096) - zvel = -2048; - vel = x>>4; - if (ActorExtra[i].temp_data[9]) zvel = ActorExtra[i].temp_data[9]; - A_InsertSprite(sect, - srcvect.x+(sintable[(512+sa+512)&2047]>>8), - srcvect.y+(sintable[(sa+512)&2047]>>8), - srcvect.z+(6<<8),atwith,-64,32,32,sa,vel,zvel,i,1); - break; - - case GROWSPARK__STATIC: - - if (p >= 0) - { - // j = A_FindTargetSprite( s, AUTO_AIM_ANGLE ); - Gv_SetVar(g_iAimAngleVarID,AUTO_AIM_ANGLE,i,p); - X_OnEvent(EVENT_GETAUTOAIMANGLE, i, p, -1); - j=-1; - if (Gv_GetVar(g_iAimAngleVarID,i,p) > 0) - { - j = A_FindTargetSprite(s, Gv_GetVar(g_iAimAngleVarID,i,p),atwith); - } - - if (j >= 0) - { - dal = ((sprite[j].yrepeat*tilesizy[sprite[j].picnum])<<1)+(5<<8); - if (((sprite[j].picnum >= GREENSLIME)&&(sprite[j].picnum <= GREENSLIME+7))||(sprite[j].picnum ==ROTATEGUN)) - { - dal -= (8<<8); - - } - hitinfo.pos.x = ldist(&sprite[g_player[p].ps->i], &sprite[j]); - if (hitinfo.pos.x == 0) - hitinfo.pos.x++; - zvel = ((sprite[j].z-srcvect.z-dal)<<8) / hitinfo.pos.x; - sa = getangle(sprite[j].x-srcvect.x,sprite[j].y-srcvect.y); - } - else - { - sa += 16-(krand()&31); - zvel = (100-g_player[p].ps->horiz-g_player[p].ps->horizoff)<<5; - zvel += 128-(krand()&255); - } - - srcvect.z -= (2<<8); - } - else - { - j = A_FindPlayer(s,&x); - srcvect.z -= (4<<8); - hitinfo.pos.x = ldist(&sprite[g_player[j].ps->i], s); - if (hitinfo.pos.x == 0) - hitinfo.pos.x++; - zvel = ((g_player[j].ps->posz-srcvect.z) <<8) / hitinfo.pos.x; - zvel += 128-(krand()&255); - sa += 32-(krand()&63); - } - - k = 0; - - // RESHOOTGROW: - if (sect < 0) break; - - s->cstat &= ~257; - if (ActorExtra[i].temp_data[9]) zvel = ActorExtra[i].temp_data[9]; - hitscan((const vec3_t *)&srcvect,sect, - sintable[(sa+512)&2047], - sintable[sa&2047], - zvel<<6,&hitinfo,CLIPMASK1); - - s->cstat |= 257; - - j = A_InsertSprite(sect,hitinfo.pos.x,hitinfo.pos.y,hitinfo.pos.z,GROWSPARK,-16,28,28,sa,0,0,i,1); - - sprite[j].pal = 2; - sprite[j].cstat |= 130; - sprite[j].xrepeat = sprite[j].yrepeat = 1; - - if (hitinfo.hitwall == -1 && hitinfo.hitsprite == -1 && hitinfo.hitsect >= 0) - { - if (zvel < 0 && (sector[hitinfo.hitsect].ceilingstat&1) == 0) - Sect_DamageCeiling(hitinfo.hitsect); - } - else if (hitinfo.hitsprite >= 0) A_DamageObject(hitinfo.hitsprite,j); - else if (hitinfo.hitwall >= 0 && wall[hitinfo.hitwall].picnum != ACCESSSWITCH && wall[hitinfo.hitwall].picnum != ACCESSSWITCH2) - { - /* if(wall[hitinfo.hitwall].overpicnum == MIRROR && k == 0) - { - l = getangle( - wall[wall[hitinfo.hitwall].point2].x-wall[hitinfo.hitwall].x, - wall[wall[hitinfo.hitwall].point2].y-wall[hitinfo.hitwall].y); - - sx = hitinfo.pos.x; - sy = hitinfo.pos.y; - srcvect.z = hitinfo.pos.z; - sect = hitinfo.hitsect; - sa = ((l<<1) - sa)&2047; - sx += sintable[(sa+512)&2047]>>12; - sy += sintable[sa&2047]>>12; - - k++; - goto RESHOOTGROW; - } - else */ - A_DamageWall(j,hitinfo.hitwall,&hitinfo.pos,atwith); - } - - break; - - case SHRINKER__STATIC: - if (s->extra >= 0) s->shade = -96; - if (p >= 0) - { - // j = A_FindTargetSprite( s, AUTO_AIM_ANGLE ); - Gv_SetVar(g_iAimAngleVarID,AUTO_AIM_ANGLE,i,p); - X_OnEvent(EVENT_GETAUTOAIMANGLE, i, p, -1); - j=-1; - if (Gv_GetVar(g_iAimAngleVarID,i,p) > 0) - { - j = A_FindTargetSprite(s, Gv_GetVar(g_iAimAngleVarID,i,p),atwith); - } - - if (j >= 0) - { - dal = ((sprite[j].yrepeat*tilesizy[sprite[j].picnum])<<1); - hitinfo.pos.x = ldist(&sprite[g_player[p].ps->i], &sprite[j]); - if (hitinfo.pos.x == 0) - hitinfo.pos.x++; - zvel = ((sprite[j].z-srcvect.z-dal-(4<<8))*768) / hitinfo.pos.x; - sa = getangle(sprite[j].x-srcvect.x,sprite[j].y-srcvect.y); - } - else zvel = (100-g_player[p].ps->horiz-g_player[p].ps->horizoff)*98; - } - else if (s->statnum != 3) - { - j = A_FindPlayer(s,&x); - l = ldist(&sprite[g_player[j].ps->i],s); - if (l == 0) - l++; - zvel = ((g_player[j].ps->oposz-srcvect.z)*512) / l ; - } - else zvel = 0; - if (ActorExtra[i].temp_data[9]) zvel = ActorExtra[i].temp_data[9]; - j = A_InsertSprite(sect, - srcvect.x+(sintable[(512+sa+512)&2047]>>12), - srcvect.y+(sintable[(sa+512)&2047]>>12), - srcvect.z+(2<<8),SHRINKSPARK,-16,28,28,sa,768,zvel,i,4); - - sprite[j].cstat = 128; - sprite[j].clipdist = 32; - - - return j; - } - } - return -1; -} - -static void P_DisplaySpitAnim(int32_t snum) -{ - int32_t i, a, x, y, z; - - if (g_player[snum].ps->loogcnt == 0) return; - - y = (g_player[snum].ps->loogcnt<<2); - for (i=0;inumloogs;i++) - { - a = klabs(sintable[((g_player[snum].ps->loogcnt+i)<<5)&2047])>>5; - z = 4096+((g_player[snum].ps->loogcnt+i)<<9); - x = (-g_player[snum].sync->avel)+(sintable[((g_player[snum].ps->loogcnt+i)<<6)&2047]>>10); - - rotatesprite( - (g_player[snum].ps->loogiex[i]+x)<<16,(200+g_player[snum].ps->loogiey[i]-y)<<16,z-(i<<8),256-a, - LOOGIE,0,0,2,0,0,xdim-1,ydim-1); - } -} - -static int32_t P_DisplayFistAnim(int32_t gs,int32_t snum) -{ - int32_t looking_arc,fisti,fistpal; - int32_t fistzoom, fistz; - - fisti = g_player[snum].ps->fist_incs; - if (fisti > 32) fisti = 32; - if (fisti <= 0) return 0; - - looking_arc = klabs(g_player[snum].ps->look_ang)/9; - - fistzoom = 65536L - (sintable[(512+(fisti<<6))&2047]<<2); - if (fistzoom > 90612L) - fistzoom = 90612L; - if (fistzoom < 40920) - fistzoom = 40290; - fistz = 194 + (sintable[((6+fisti)<<7)&2047]>>9); - - if (sprite[g_player[snum].ps->i].pal == 1) - fistpal = 1; - else if (g_player[snum].ps->cursectnum >= 0) - fistpal = sector[g_player[snum].ps->cursectnum].floorpal; - else fistpal = 0; - - rotatesprite( - (-fisti+222+(g_player[snum].sync->avel>>4))<<16, - (looking_arc+fistz)<<16, - fistzoom,0,FIST,gs,fistpal,2,0,0,xdim-1,ydim-1); - - return 1; -} - -#define weapsc(sc) scale(sc,ud.weaponscale,100) - -static void G_DrawTileScaled(int32_t x, int32_t y, int32_t tilenum, int32_t shade, int32_t orientation, int32_t p) -{ - int32_t a = 0; - int32_t xoff = 192; - - switch (g_currentweapon) - { - case DEVISTATOR_WEAPON: - case TRIPBOMB_WEAPON: - xoff = 160; - break; - default: - if (orientation & 262144) - { - xoff = 160; - orientation &= ~262144; - } - break; - } - - if (orientation&4) - a = 1024; - -#if defined(POLYMOST) && defined(USE_OPENGL) - if (getrendermode() >= 3 && usemodels && md_tilehasmodel(tilenum,p) > 0) - y += (224-weapsc(224)); -#endif - rotatesprite(weapsc((orientation&256)?x:(x<<16))+((xoff-weapsc(xoff))<<16), - weapsc((orientation&256)?y:(y<<16))+((200-weapsc(200))<<16), - weapsc(65536L),a,tilenum,shade,p,2|orientation,windowx1,windowy1,windowx2,windowy2); -} - -static void G_DrawWeaponTile(int32_t x, int32_t y, int32_t tilenum, int32_t shade, int32_t orientation, int32_t p) -{ - if (!ud.drawweapon) - return; - else if (ud.drawweapon == 1) - G_DrawTileScaled(x,y,tilenum,shade,orientation,p); - else if (ud.drawweapon == 2) - { - switch (g_currentweapon) - { - case PISTOL_WEAPON: - case CHAINGUN_WEAPON: - case RPG_WEAPON: - case FREEZE_WEAPON: - case SHRINKER_WEAPON: - case GROW_WEAPON: - case DEVISTATOR_WEAPON: - case TRIPBOMB_WEAPON: - case HANDREMOTE_WEAPON: - case HANDBOMB_WEAPON: - case SHOTGUN_WEAPON: - rotatesprite(160<<16,(180+(g_player[screenpeek].ps->weapon_pos*g_player[screenpeek].ps->weapon_pos))<<16,scale(65536,ud.statusbarscale,100),0,g_currentweapon==GROW_WEAPON?GROWSPRITEICON:WeaponPickupSprites[g_currentweapon],0,0,2,windowx1,windowy1,windowx2,windowy2); - break; - } - } -} - -static int32_t P_DisplayKneeAnim(int32_t gs,int32_t snum) -{ - static int8_t knee_y[] = {0,-8,-16,-32,-64,-84,-108,-108,-108,-72,-32,-8}; - int32_t looking_arc, pal = g_player[snum].ps->palookup; - - if (g_player[snum].ps->knee_incs > 11 || g_player[snum].ps->knee_incs == 0 || sprite[g_player[snum].ps->i].extra <= 0) return 0; - - looking_arc = knee_y[g_player[snum].ps->knee_incs] + klabs(g_player[snum].ps->look_ang)/9; - - looking_arc -= (g_player[snum].ps->hard_landing<<3); - - if (sprite[g_player[snum].ps->i].pal == 1) - pal = 1; - else if (g_player[snum].ps->cursectnum >= 0) - { - pal = sector[g_player[snum].ps->cursectnum].floorpal; - if (pal == 0) - pal = g_player[snum].ps->palookup; - } - - G_DrawTileScaled(105+(g_player[snum].sync->avel>>4)-(g_player[snum].ps->look_ang>>1)+(knee_y[g_player[snum].ps->knee_incs]>>2),looking_arc+280-((g_player[snum].ps->horiz-g_player[snum].ps->horizoff)>>4),KNEE,gs,4+262144,pal); - - return 1; -} - -static int32_t P_DisplayKnuckleAnim(int32_t gs,int32_t snum) -{ - static char knuckle_frames[] = {0,1,2,2,3,3,3,2,2,1,0}; - int32_t looking_arc, pal = 0; - - if (g_player[snum].ps->knuckle_incs == 0 || sprite[g_player[snum].ps->i].extra <= 0) return 0; - - looking_arc = klabs(g_player[snum].ps->look_ang)/9; - - looking_arc -= (g_player[snum].ps->hard_landing<<3); - - if (sprite[g_player[snum].ps->i].pal == 1) - pal = 1; - else if (g_player[snum].ps->cursectnum >= 0) - pal = sector[g_player[snum].ps->cursectnum].floorpal; - - G_DrawTileScaled(160+(g_player[snum].sync->avel>>4)-(g_player[snum].ps->look_ang>>1),looking_arc+180-((g_player[snum].ps->horiz-g_player[snum].ps->horizoff)>>4),CRACKKNUCKLES+knuckle_frames[g_player[snum].ps->knuckle_incs>>1],gs,4+262144,pal); - - return 1; -} - -int32_t lastvisinc; - -void P_FireWeapon(DukePlayer_t *p) -{ - int32_t i, snum = sprite[p->i].yvel; - - Gv_SetVar(g_iReturnVarID,0,p->i,snum); - X_OnEvent(EVENT_DOFIRE, p->i, snum, -1); - - if (Gv_GetVar(g_iReturnVarID,p->i,snum) == 0) - { - if (p->weapon_pos != 0) return; - - if (aplWeaponWorksLike[p->curr_weapon][snum]!=KNEE_WEAPON) - p->ammo_amount[p->curr_weapon]--; - - if (aplWeaponFireSound[p->curr_weapon][snum]) - { - A_PlaySound(aplWeaponFireSound[p->curr_weapon][snum],p->i); - } - - Gv_SetVar(g_iWeaponVarID,p->curr_weapon,p->i,snum); - Gv_SetVar(g_iWorksLikeVarID,aplWeaponWorksLike[p->curr_weapon][snum], p->i, snum); -// OSD_Printf("doing %d %d %d\n",aplWeaponShoots[p->curr_weapon][snum],p->curr_weapon,snum); - A_Shoot(p->i,aplWeaponShoots[p->curr_weapon][snum]); - for (i=1;icurr_weapon][snum];i++) - { - if (aplWeaponFlags[p->curr_weapon][snum] & WEAPON_FIREEVERYOTHER) - { - // this makes the projectiles fire on a delay from player code - ActorExtra[p->i].temp_data[7] = (aplWeaponShotsPerBurst[p->curr_weapon][snum])<<1; - } - else - { - if (aplWeaponFlags[p->curr_weapon][snum] & WEAPON_AMMOPERSHOT) - { - if (p->ammo_amount[p->curr_weapon] > 0) - p->ammo_amount[p->curr_weapon]--; - else break; - } - A_Shoot(p->i,aplWeaponShoots[p->curr_weapon][snum]); - } - } - - if (!(aplWeaponFlags[p->curr_weapon][snum] & WEAPON_NOVISIBLE)) - { - lastvisinc = totalclock+32; - p->visibility = 0; - } - - /* if( //!(aplWeaponFlags[p->curr_weapon][snum] & WEAPON_CHECKATRELOAD) && - aplWeaponReload[p->curr_weapon][snum] > aplWeaponTotalTime[p->curr_weapon][snum] - && p->ammo_amount[p->curr_weapon] > 0 - && (aplWeaponClip[p->curr_weapon][snum]) - && ((p->ammo_amount[p->curr_weapon]%(aplWeaponClip[p->curr_weapon][snum]))==0)) - { - p->kickback_pic=aplWeaponTotalTime[p->curr_weapon][snum]; - } */ - } -} - -void P_DoWeaponSpawn(DukePlayer_t *p) -{ - int32_t j, snum = sprite[p->i].yvel; - - if (!aplWeaponSpawn[p->curr_weapon][snum]) - return; - - j = A_Spawn(p->i, aplWeaponSpawn[p->curr_weapon][snum]); - - if ((aplWeaponFlags[p->curr_weapon][snum] & WEAPON_SPAWNTYPE3)) - { - // like chaingun shells - sprite[j].ang += 1024; - sprite[j].ang &= 2047; - sprite[j].xvel += 32; - sprite[j].z += (3<<8); - } - - A_SetSprite(j,CLIPMASK0); - -} - -void P_DisplayScubaMask(int32_t snum) -{ - int32_t p; - - if (sprite[g_player[snum].ps->i].pal == 1) - p = 1; - else if (g_player[snum].ps->cursectnum >= 0) - p = sector[g_player[snum].ps->cursectnum].floorpal; - else p = 0; - - if (g_player[snum].ps->scuba_on) - { - rotatesprite(43<<16,(200-tilesizy[SCUBAMASK])<<16,65536,0,SCUBAMASK,0,p,2+16,windowx1,windowy1,windowx2,windowy2); - rotatesprite((320-43)<<16,(200-tilesizy[SCUBAMASK])<<16,65536,1024,SCUBAMASK,0,p,2+4+16,windowx1,windowy1,windowx2,windowy2); - } -} - -static int32_t P_DisplayTipAnim(int32_t gs,int32_t snum) -{ - int32_t p,looking_arc; - static int16_t tip_y[] = {0,-8,-16,-32,-64,-84,-108,-108,-108,-108,-108,-108,-108,-108,-108,-108,-96,-72,-64,-32,-16}; - - if (g_player[snum].ps->tipincs == 0) return 0; - - looking_arc = klabs(g_player[snum].ps->look_ang)/9; - looking_arc -= (g_player[snum].ps->hard_landing<<3); - - if (sprite[g_player[snum].ps->i].pal == 1) - p = 1; - else - p = sector[g_player[snum].ps->cursectnum].floorpal; - - /* if(g_player[snum].ps->access_spritenum >= 0) - p = sprite[g_player[snum].ps->access_spritenum].pal; - else - p = wall[g_player[snum].ps->access_wallnum].pal; - */ - G_DrawTileScaled(170+(g_player[snum].sync->avel>>4)-(g_player[snum].ps->look_ang>>1), - (tip_y[g_player[snum].ps->tipincs]>>1)+looking_arc+240-((g_player[snum].ps->horiz-g_player[snum].ps->horizoff)>>4),TIP+((26-g_player[snum].ps->tipincs)>>4),gs,262144,p); - - return 1; -} - -static int32_t P_DisplayAccessAnim(int32_t gs,int32_t snum) -{ - static int16_t access_y[] = {0,-8,-16,-32,-64,-84,-108,-108,-108,-108,-108,-108,-108,-108,-108,-108,-96,-72,-64,-32,-16}; - int32_t looking_arc; - int32_t p; - - if (g_player[snum].ps->access_incs == 0 || sprite[g_player[snum].ps->i].extra <= 0) return 0; - - looking_arc = access_y[g_player[snum].ps->access_incs] + klabs(g_player[snum].ps->look_ang)/9; - looking_arc -= (g_player[snum].ps->hard_landing<<3); - - if (g_player[snum].ps->access_spritenum >= 0) - p = sprite[g_player[snum].ps->access_spritenum].pal; - else p = 0; - // else - // p = wall[g_player[snum].ps->access_wallnum].pal; - - if ((g_player[snum].ps->access_incs-3) > 0 && (g_player[snum].ps->access_incs-3)>>3) - G_DrawTileScaled(170+(g_player[snum].sync->avel>>4)-(g_player[snum].ps->look_ang>>1)+(access_y[g_player[snum].ps->access_incs]>>2),looking_arc+266-((g_player[snum].ps->horiz-g_player[snum].ps->horizoff)>>4),HANDHOLDINGLASER+(g_player[snum].ps->access_incs>>3),gs,262144,p); - else - G_DrawTileScaled(170+(g_player[snum].sync->avel>>4)-(g_player[snum].ps->look_ang>>1)+(access_y[g_player[snum].ps->access_incs]>>2),looking_arc+266-((g_player[snum].ps->horiz-g_player[snum].ps->horizoff)>>4),HANDHOLDINGACCESS,gs,4+262144,p); - - return 1; -} - - -static int32_t fistsign; - -void P_DisplayWeapon(int32_t snum) -{ - int32_t gun_pos, looking_arc, cw; - int32_t weapon_xoffset, i, j; - int32_t o = 0,pal = 0; - DukePlayer_t *p = g_player[snum].ps; - int16_t *kb = &p->kickback_pic; - int32_t gs; - - looking_arc = klabs(p->look_ang)/9; - - gs = sprite[p->i].shade; - if (gs > 24) gs = 24; - - if (p->newowner >= 0 || ud.camerasprite >= 0 || p->over_shoulder_on > 0 || (sprite[p->i].pal != 1 && sprite[p->i].extra <= 0) || P_DisplayFistAnim(gs,snum) || P_DisplayKnuckleAnim(gs,snum) || P_DisplayTipAnim(gs,snum) || P_DisplayAccessAnim(gs,snum)) - return; - - P_DisplayKneeAnim(gs,snum); - - gun_pos = 80-(p->weapon_pos*p->weapon_pos); - - weapon_xoffset = (160)-90; - - if (ud.weaponsway) - { - weapon_xoffset -= (sintable[((p->weapon_sway>>1)+512)&2047]/(1024+512)); - - if (sprite[p->i].xrepeat < 32) - gun_pos -= klabs(sintable[(p->weapon_sway<<2)&2047]>>9); - else gun_pos -= klabs(sintable[(p->weapon_sway>>1)&2047]>>10); - } - else gun_pos -= 16; - - weapon_xoffset -= 58 + p->weapon_ang; - gun_pos -= (p->hard_landing<<3); - - if (p->last_weapon >= 0) - cw = aplWeaponWorksLike[p->last_weapon][snum]; - else - cw = aplWeaponWorksLike[p->curr_weapon][snum]; - - g_gun_pos=gun_pos; - g_looking_arc=looking_arc; - g_currentweapon=cw; - g_weapon_xoffset=weapon_xoffset; - g_gs=gs; - g_kb=*kb; - g_looking_angSR1=p->look_ang>>1; - - Gv_SetVar(g_iReturnVarID,0,p->i,snum); - X_OnEvent(EVENT_DISPLAYWEAPON, p->i, screenpeek, -1); - - if (Gv_GetVar(g_iReturnVarID,p->i,snum) == 0) - { - j = 14-p->quick_kick; - if (j != 14 || p->last_quick_kick) - { - if (sprite[p->i].pal == 1) - pal = 1; - else - { - if (p->cursectnum >= 0) - pal = sector[p->cursectnum].floorpal; - if (pal == 0) - pal = p->palookup; - } - - guniqhudid = 100; - if (j < 6 || j > 12) - G_DrawTileScaled(weapon_xoffset+80-(p->look_ang>>1), - looking_arc+250-gun_pos,KNEE,gs,o|4|262144,pal); - else G_DrawTileScaled(weapon_xoffset+160-16-(p->look_ang>>1), - looking_arc+214-gun_pos,KNEE+1,gs,o|4|262144,pal); - guniqhudid = 0; - } - - if (sprite[p->i].xrepeat < 40) - { - if (p->jetpack_on == 0) - { - i = sprite[p->i].xvel; - looking_arc += 32-(i>>1); - fistsign += i>>1; - } - cw = weapon_xoffset; - weapon_xoffset += sintable[(fistsign)&2047]>>10; - G_DrawTile(weapon_xoffset+250-(p->look_ang>>1), - looking_arc+258-(klabs(sintable[(fistsign)&2047]>>8)), - FIST,gs,o); - weapon_xoffset = cw; - weapon_xoffset -= sintable[(fistsign)&2047]>>10; - G_DrawTile(weapon_xoffset+40-(p->look_ang>>1), - looking_arc+200+(klabs(sintable[(fistsign)&2047]>>8)), - FIST,gs,o|4); - } - else switch (cw) - - { - - case KNEE_WEAPON: - - Gv_SetVar(g_iReturnVarID,0,g_player[screenpeek].ps->i,screenpeek); - X_OnEvent(EVENT_DRAWWEAPON,g_player[screenpeek].ps->i,screenpeek, -1); - if (Gv_GetVar(g_iReturnVarID,g_player[screenpeek].ps->i,screenpeek) == 0) - { - if ((*kb) > 0) - { - if (sprite[p->i].pal == 1) - pal = 1; - else - { - if (p->cursectnum >= 0) - pal = sector[p->cursectnum].floorpal; - if (pal == 0) - pal = p->palookup; - } - guniqhudid = cw; - if ((*kb) < 5 || (*kb) > 9) - G_DrawTileScaled(weapon_xoffset+220-(p->look_ang>>1), - looking_arc+250-gun_pos,KNEE,gs,o,pal); - else - G_DrawTileScaled(weapon_xoffset+160-(p->look_ang>>1), - looking_arc+214-gun_pos,KNEE+1,gs,o,pal); - guniqhudid = 0; - } - } - break; - - case TRIPBOMB_WEAPON: - - Gv_SetVar(g_iReturnVarID,0,g_player[screenpeek].ps->i,screenpeek); - X_OnEvent(EVENT_DRAWWEAPON,g_player[screenpeek].ps->i,screenpeek, -1); - if (Gv_GetVar(g_iReturnVarID,g_player[screenpeek].ps->i,screenpeek) == 0) - { - if (sprite[p->i].pal == 1) - pal = 1; - else if (p->cursectnum >= 0) - pal = sector[p->cursectnum].floorpal; - else pal = 0; - - weapon_xoffset += 8; - gun_pos -= 10; - - if ((*kb) > 6) - looking_arc += ((*kb)<<3); - else if ((*kb) < 4) - { - guniqhudid = cw<<2; - G_DrawWeaponTile(weapon_xoffset+142-(p->look_ang>>1), - looking_arc+234-gun_pos,HANDHOLDINGLASER+3,gs,o,pal); - } - - guniqhudid = cw; - G_DrawWeaponTile(weapon_xoffset+130-(p->look_ang>>1), - looking_arc+249-gun_pos, - HANDHOLDINGLASER+((*kb)>>2),gs,o,pal); - - guniqhudid = cw<<1; - G_DrawWeaponTile(weapon_xoffset+152-(p->look_ang>>1), - looking_arc+249-gun_pos, - HANDHOLDINGLASER+((*kb)>>2),gs,o|4,pal); - guniqhudid = 0; - } - break; - - case RPG_WEAPON: - - Gv_SetVar(g_iReturnVarID,0,g_player[screenpeek].ps->i,screenpeek); - X_OnEvent(EVENT_DRAWWEAPON,g_player[screenpeek].ps->i,screenpeek, -1); - if (Gv_GetVar(g_iReturnVarID,g_player[screenpeek].ps->i,screenpeek) == 0) - { - if (sprite[p->i].pal == 1) - pal = 1; - else if (p->cursectnum >= 0) - pal = sector[p->cursectnum].floorpal; - else pal = 0; - - weapon_xoffset -= sintable[(768+((*kb)<<7))&2047]>>11; - gun_pos += sintable[(768+((*kb)<<7))&2047]>>11; - - if (*kb > 0) - { - if (*kb < 8) - { - G_DrawWeaponTile(weapon_xoffset+164,(looking_arc<<1)+176-gun_pos, - RPGGUN+((*kb)>>1),gs,o,pal); - } - } - - G_DrawWeaponTile(weapon_xoffset+164,(looking_arc<<1)+176-gun_pos, - RPGGUN,gs,o,pal); - } - break; - - case SHOTGUN_WEAPON: - - Gv_SetVar(g_iReturnVarID,0,g_player[screenpeek].ps->i,screenpeek); - X_OnEvent(EVENT_DRAWWEAPON,g_player[screenpeek].ps->i,screenpeek, -1); - if (Gv_GetVar(g_iReturnVarID,g_player[screenpeek].ps->i,screenpeek) == 0) - { - if (sprite[p->i].pal == 1) - pal = 1; - else if (p->cursectnum >= 0) - pal = sector[p->cursectnum].floorpal; - else pal = 0; - - - weapon_xoffset -= 8; - - switch (*kb) - { - case 1: - case 2: - guniqhudid = cw<<1; - G_DrawWeaponTile(weapon_xoffset+168-(p->look_ang>>1),looking_arc+201-gun_pos, - SHOTGUN+2,-128,o,pal); - case 0: - case 6: - case 7: - case 8: - guniqhudid = cw; - G_DrawWeaponTile(weapon_xoffset+146-(p->look_ang>>1),looking_arc+202-gun_pos, - SHOTGUN,gs,o,pal); - guniqhudid = 0; - break; - case 3: - case 4: - case 5: - case 9: - case 10: - case 11: - case 12: - if (*kb > 1 && *kb < 5) - { - gun_pos -= 40; - weapon_xoffset += 20; - - guniqhudid = cw<<1; - G_DrawWeaponTile(weapon_xoffset+178-(p->look_ang>>1),looking_arc+194-gun_pos, - SHOTGUN+1+((*(kb)-1)>>1),-128,o,pal); - } - guniqhudid = cw; - G_DrawWeaponTile(weapon_xoffset+158-(p->look_ang>>1),looking_arc+220-gun_pos, - SHOTGUN+3,gs,o,pal); - guniqhudid = 0; - break; - case 13: - case 14: - case 15: - guniqhudid = cw; - G_DrawWeaponTile(32+weapon_xoffset+166-(p->look_ang>>1),looking_arc+210-gun_pos, - SHOTGUN+4,gs,o,pal); - guniqhudid = 0; - break; - case 16: - case 17: - case 18: - case 19: - guniqhudid = cw; - G_DrawWeaponTile(64+weapon_xoffset+170-(p->look_ang>>1),looking_arc+196-gun_pos, - SHOTGUN+5,gs,o,pal); - guniqhudid = 0; - break; - case 20: - case 21: - case 22: - case 23: - guniqhudid = cw; - G_DrawWeaponTile(64+weapon_xoffset+176-(p->look_ang>>1),looking_arc+196-gun_pos, - SHOTGUN+6,gs,o,pal); - guniqhudid = 0; - break; - case 24: - case 25: - case 26: - case 27: - guniqhudid = cw; - G_DrawWeaponTile(64+weapon_xoffset+170-(p->look_ang>>1),looking_arc+196-gun_pos, - SHOTGUN+5,gs,o,pal); - guniqhudid = 0; - break; - case 28: - case 29: - case 30: - guniqhudid = cw; - G_DrawWeaponTile(32+weapon_xoffset+156-(p->look_ang>>1),looking_arc+206-gun_pos, - SHOTGUN+4,gs,o,pal); - guniqhudid = 0; - break; - } - } - break; - - - case CHAINGUN_WEAPON: - - Gv_SetVar(g_iReturnVarID,0,g_player[screenpeek].ps->i,screenpeek); - X_OnEvent(EVENT_DRAWWEAPON,g_player[screenpeek].ps->i,screenpeek, -1); - if (Gv_GetVar(g_iReturnVarID,g_player[screenpeek].ps->i,screenpeek) == 0) - { - if (sprite[p->i].pal == 1) - pal = 1; - else if (p->cursectnum >= 0) - pal = sector[p->cursectnum].floorpal; - else pal = 0; - - if (*kb > 0) - gun_pos -= sintable[(*kb)<<7]>>12; - - if (*kb > 0 && sprite[p->i].pal != 1) weapon_xoffset += 1-(rand()&3); - - G_DrawWeaponTile(weapon_xoffset+168-(p->look_ang>>1),looking_arc+260-gun_pos, - CHAINGUN,gs,o,pal); - switch (*kb) - { - case 0: - G_DrawWeaponTile(weapon_xoffset+178-(p->look_ang>>1),looking_arc+233-gun_pos, - CHAINGUN+1,gs,o,pal); - break; - default: - if (*kb > *aplWeaponFireDelay[CHAINGUN_WEAPON] && *kb < *aplWeaponTotalTime[CHAINGUN_WEAPON]) - { - i = 0; - if (sprite[p->i].pal != 1) i = rand()&7; - G_DrawWeaponTile(i+weapon_xoffset-4+140-(p->look_ang>>1),i+looking_arc-((*kb)>>1)+208-gun_pos, - CHAINGUN+5+((*kb-4)/5),gs,o,pal); - if (sprite[p->i].pal != 1) i = rand()&7; - G_DrawWeaponTile(i+weapon_xoffset-4+184-(p->look_ang>>1),i+looking_arc-((*kb)>>1)+208-gun_pos, - CHAINGUN+5+((*kb-4)/5),gs,o,pal); - } - if (*kb < *aplWeaponTotalTime[CHAINGUN_WEAPON]-4) - { - i = rand()&7; - G_DrawWeaponTile(i+weapon_xoffset-4+162-(p->look_ang>>1),i+looking_arc-((*kb)>>1)+208-gun_pos, - CHAINGUN+5+((*kb-2)/5),gs,o,pal); - G_DrawWeaponTile(weapon_xoffset+178-(p->look_ang>>1),looking_arc+233-gun_pos, - CHAINGUN+1+((*kb)>>1),gs,o,pal); - } - else G_DrawWeaponTile(weapon_xoffset+178-(p->look_ang>>1),looking_arc+233-gun_pos, - CHAINGUN+1,gs,o,pal); - break; - } - } - break; - - case PISTOL_WEAPON: - - Gv_SetVar(g_iReturnVarID,0,g_player[screenpeek].ps->i,screenpeek); - X_OnEvent(EVENT_DRAWWEAPON,g_player[screenpeek].ps->i,screenpeek, -1); - if (Gv_GetVar(g_iReturnVarID,g_player[screenpeek].ps->i,screenpeek) == 0) - { - if (sprite[p->i].pal == 1) - pal = 1; - else if (p->cursectnum >= 0) - pal = sector[p->cursectnum].floorpal; - else pal = 0; - - if ((*kb) < *aplWeaponTotalTime[PISTOL_WEAPON]+1) - { - static int16_t kb_frames[] = {0,1,2}; - int32_t l = 195-12+weapon_xoffset; - - if ((*kb) == *aplWeaponFireDelay[PISTOL_WEAPON]) - l -= 3; - - guniqhudid = cw; - G_DrawWeaponTile((l-(p->look_ang>>1)),(looking_arc+244-gun_pos),FIRSTGUN+kb_frames[*kb>2?0:*kb],gs,2,pal); - guniqhudid = 0; - } - else - { - - if ((*kb) < *aplWeaponReload[PISTOL_WEAPON]-17) - { - guniqhudid = cw; - G_DrawWeaponTile(194-(p->look_ang>>1),looking_arc+230-gun_pos,FIRSTGUN+4,gs,o,pal); - guniqhudid = 0; - } - else if ((*kb) < *aplWeaponReload[PISTOL_WEAPON]-12) - { - G_DrawWeaponTile(244-((*kb)<<3)-(p->look_ang>>1),looking_arc+130-gun_pos+((*kb)<<4),FIRSTGUN+6,gs,o,pal); - guniqhudid = cw; - G_DrawWeaponTile(224-(p->look_ang>>1),looking_arc+220-gun_pos,FIRSTGUN+5,gs,o,pal); - guniqhudid = 0; - } - else if ((*kb) < *aplWeaponReload[PISTOL_WEAPON]-7) - { - G_DrawWeaponTile(124+((*kb)<<1)-(p->look_ang>>1),looking_arc+430-gun_pos-((*kb)<<3),FIRSTGUN+6,gs,o,pal); - guniqhudid = cw; - G_DrawWeaponTile(224-(p->look_ang>>1),looking_arc+220-gun_pos,FIRSTGUN+5,gs,o,pal); - guniqhudid = 0; - } - - else if ((*kb) < *aplWeaponReload[PISTOL_WEAPON]-4) - { - G_DrawWeaponTile(184-(p->look_ang>>1),looking_arc+235-gun_pos,FIRSTGUN+8,gs,o,pal); - guniqhudid = cw; - G_DrawWeaponTile(224-(p->look_ang>>1),looking_arc+210-gun_pos,FIRSTGUN+5,gs,o,pal); - guniqhudid = 0; - } - else if ((*kb) < *aplWeaponReload[PISTOL_WEAPON]-2) - { - G_DrawWeaponTile(164-(p->look_ang>>1),looking_arc+245-gun_pos,FIRSTGUN+8,gs,o,pal); - guniqhudid = cw; - G_DrawWeaponTile(224-(p->look_ang>>1),looking_arc+220-gun_pos,FIRSTGUN+5,gs,o,pal); - guniqhudid = 0; - } - else if ((*kb) < *aplWeaponReload[PISTOL_WEAPON]) - { - guniqhudid = cw; - G_DrawWeaponTile(194-(p->look_ang>>1),looking_arc+235-gun_pos,FIRSTGUN+5,gs,o,pal); - guniqhudid = 0; - } - - } - } - - break; - case HANDBOMB_WEAPON: - { - Gv_SetVar(g_iReturnVarID,0,g_player[screenpeek].ps->i,screenpeek); - X_OnEvent(EVENT_DRAWWEAPON,g_player[screenpeek].ps->i,screenpeek, -1); - if (Gv_GetVar(g_iReturnVarID,g_player[screenpeek].ps->i,screenpeek) == 0) - { - if (sprite[p->i].pal == 1) - pal = 1; - else if (p->cursectnum >= 0) - pal = sector[p->cursectnum].floorpal; - else pal = 0; - guniqhudid = cw; - if ((*kb)) - { - if ((*kb) < (*aplWeaponTotalTime[p->curr_weapon])) - { - - static char throw_frames[] - = {0,0,0,0,0,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2}; - - if ((*kb) < 7) - gun_pos -= 10*(*kb); //D - else if ((*kb) < 12) - gun_pos += 20*((*kb)-10); //U - else if ((*kb) < 20) - gun_pos -= 9*((*kb)-14); //D - - G_DrawWeaponTile(weapon_xoffset+190-(p->look_ang>>1),looking_arc+250-gun_pos,HANDTHROW+throw_frames[(*kb)],gs,o,pal); - } - } - else - G_DrawWeaponTile(weapon_xoffset+190-(p->look_ang>>1),looking_arc+260-gun_pos,HANDTHROW,gs,o,pal); - guniqhudid = 0; - } - } - break; - - case HANDREMOTE_WEAPON: - { - Gv_SetVar(g_iReturnVarID,0,g_player[screenpeek].ps->i,screenpeek); - X_OnEvent(EVENT_DRAWWEAPON,g_player[screenpeek].ps->i,screenpeek, -1); - if (Gv_GetVar(g_iReturnVarID,g_player[screenpeek].ps->i,screenpeek) == 0) - { - static char remote_frames[] = {0,1,1,2,1,1,0,0,0,0,0}; - if (sprite[p->i].pal == 1) - pal = 1; - else if (p->cursectnum >= 0) - pal = sector[p->cursectnum].floorpal; - else pal = 0; - - weapon_xoffset = -48; - guniqhudid = cw; - if ((*kb)) - G_DrawWeaponTile(weapon_xoffset+150-(p->look_ang>>1),looking_arc+258-gun_pos,HANDREMOTE+remote_frames[(*kb)],gs,o,pal); - else - G_DrawWeaponTile(weapon_xoffset+150-(p->look_ang>>1),looking_arc+258-gun_pos,HANDREMOTE,gs,o,pal); - guniqhudid = 0; - } - } - break; - - case DEVISTATOR_WEAPON: - - Gv_SetVar(g_iReturnVarID,0,g_player[screenpeek].ps->i,screenpeek); - X_OnEvent(EVENT_DRAWWEAPON,g_player[screenpeek].ps->i,screenpeek, -1); - if (Gv_GetVar(g_iReturnVarID,g_player[screenpeek].ps->i,screenpeek) == 0) - { - if (sprite[p->i].pal == 1) - pal = 1; - else if (p->cursectnum >= 0) - pal = sector[p->cursectnum].floorpal; - else pal = 0; - - if ((*kb) < (*aplWeaponTotalTime[DEVISTATOR_WEAPON]+1) && (*kb) > 0) - { - static char cycloidy[] = {0,4,12,24,12,4,0}; - - i = ksgn((*kb)>>2); - - if (p->hbomb_hold_delay) - { - guniqhudid = cw; - G_DrawWeaponTile((cycloidy[*kb]>>1)+weapon_xoffset+268-(p->look_ang>>1),cycloidy[*kb]+looking_arc+238-gun_pos,DEVISTATOR+i,-32,o,pal); - guniqhudid = cw<<1; - G_DrawWeaponTile(weapon_xoffset+30-(p->look_ang>>1),looking_arc+240-gun_pos,DEVISTATOR,gs,o|4,pal); - guniqhudid = 0; - } - else - { - guniqhudid = cw<<1; - G_DrawWeaponTile(-(cycloidy[*kb]>>1)+weapon_xoffset+30-(p->look_ang>>1),cycloidy[*kb]+looking_arc+240-gun_pos,DEVISTATOR+i,-32,o|4,pal); - guniqhudid = cw; - G_DrawWeaponTile(weapon_xoffset+268-(p->look_ang>>1),looking_arc+238-gun_pos,DEVISTATOR,gs,o,pal); - guniqhudid = 0; - } - } - else - { - guniqhudid = cw; - G_DrawWeaponTile(weapon_xoffset+268-(p->look_ang>>1),looking_arc+238-gun_pos,DEVISTATOR,gs,o,pal); - guniqhudid = cw<<1; - G_DrawWeaponTile(weapon_xoffset+30-(p->look_ang>>1),looking_arc+240-gun_pos,DEVISTATOR,gs,o|4,pal); - guniqhudid = 0; - } - } - break; - - case FREEZE_WEAPON: - - Gv_SetVar(g_iReturnVarID,0,g_player[screenpeek].ps->i,screenpeek); - X_OnEvent(EVENT_DRAWWEAPON,g_player[screenpeek].ps->i,screenpeek, -1); - if (Gv_GetVar(g_iReturnVarID,g_player[screenpeek].ps->i,screenpeek) == 0) - { - if (sprite[p->i].pal == 1) - pal = 1; - else if (p->cursectnum >= 0) - pal = sector[p->cursectnum].floorpal; - else pal = 0; - if ((*kb) < (aplWeaponTotalTime[p->curr_weapon][snum]+1) && (*kb) > 0) - { - static char cat_frames[] = { 0,0,1,1,2,2 }; - - if (sprite[p->i].pal != 1) - { - weapon_xoffset += rand()&3; - looking_arc += rand()&3; - } - gun_pos -= 16; - guniqhudid = 0; - G_DrawWeaponTile(weapon_xoffset+210-(p->look_ang>>1),looking_arc+261-gun_pos,FREEZE+2,-32,o,pal); - guniqhudid = cw; - G_DrawWeaponTile(weapon_xoffset+210-(p->look_ang>>1),looking_arc+235-gun_pos,FREEZE+3+cat_frames[*kb%6],-32,o,pal); - guniqhudid = 0; - } - else - { - guniqhudid = cw; - G_DrawWeaponTile(weapon_xoffset+210-(p->look_ang>>1),looking_arc+261-gun_pos,FREEZE,gs,o,pal); - guniqhudid = 0; - } - } - break; - - case GROW_WEAPON: - - Gv_SetVar(g_iReturnVarID,0,g_player[screenpeek].ps->i,screenpeek); - X_OnEvent(EVENT_DRAWWEAPON,g_player[screenpeek].ps->i,screenpeek, -1); - if (Gv_GetVar(g_iReturnVarID,g_player[screenpeek].ps->i,screenpeek) == 0) - { - weapon_xoffset += 28; - looking_arc += 18; - if (sprite[p->i].pal == 1) - pal = 1; - else if (p->cursectnum >= 0) - pal = sector[p->cursectnum].floorpal; - else pal = 0; - { - if ((*kb) < aplWeaponTotalTime[p->curr_weapon][snum] && (*kb) > 0) - { - if (sprite[p->i].pal != 1) - { - weapon_xoffset += rand()&3; - gun_pos += (rand()&3); - } - - guniqhudid = cw<<1; - G_DrawWeaponTile(weapon_xoffset+184-(p->look_ang>>1), - looking_arc+240-gun_pos,SHRINKER+3+((*kb)&3),-32, - o,2); - - guniqhudid = cw; - G_DrawWeaponTile(weapon_xoffset+188-(p->look_ang>>1), - looking_arc+240-gun_pos,SHRINKER-1,gs,o,pal); - guniqhudid = 0; - } - else - { - guniqhudid = cw<<1; - G_DrawWeaponTile(weapon_xoffset+184-(p->look_ang>>1), - looking_arc+240-gun_pos,SHRINKER+2, - 16-(sintable[p->random_club_frame&2047]>>10), - o,2); - - guniqhudid = cw; - G_DrawWeaponTile(weapon_xoffset+188-(p->look_ang>>1), - looking_arc+240-gun_pos,SHRINKER-2,gs,o,pal); - guniqhudid = 0; - } - } - } - break; - - case SHRINKER_WEAPON: - - Gv_SetVar(g_iReturnVarID,0,g_player[screenpeek].ps->i,screenpeek); - X_OnEvent(EVENT_DRAWWEAPON,g_player[screenpeek].ps->i,screenpeek, -1); - if (Gv_GetVar(g_iReturnVarID,g_player[screenpeek].ps->i,screenpeek) == 0) - { - weapon_xoffset += 28; - looking_arc += 18; - if (sprite[p->i].pal == 1) - pal = 1; - else if (p->cursectnum >= 0) - pal = sector[p->cursectnum].floorpal; - else pal = 0; - if (((*kb) > 0) && ((*kb) < aplWeaponTotalTime[p->curr_weapon][snum])) - { - if (sprite[p->i].pal != 1) - { - weapon_xoffset += rand()&3; - gun_pos += (rand()&3); - } - guniqhudid = cw<<1; - G_DrawWeaponTile(weapon_xoffset+184-(p->look_ang>>1), - looking_arc+240-gun_pos,SHRINKER+3+((*kb)&3),-32, - o,0); - guniqhudid = cw; - G_DrawWeaponTile(weapon_xoffset+188-(p->look_ang>>1), - looking_arc+240-gun_pos,SHRINKER+1,gs,o,pal); - guniqhudid = 0; - - } - else - { - guniqhudid = cw<<1; - G_DrawWeaponTile(weapon_xoffset+184-(p->look_ang>>1), - looking_arc+240-gun_pos,SHRINKER+2, - 16-(sintable[p->random_club_frame&2047]>>10), - o,0); - guniqhudid = cw; - G_DrawWeaponTile(weapon_xoffset+188-(p->look_ang>>1), - looking_arc+240-gun_pos,SHRINKER,gs,o,pal); - guniqhudid = 0; - } - } - break; - - } - } - P_DisplaySpitAnim(snum); - -} - -#define TURBOTURNTIME (TICRATE/8) // 7 -#define NORMALTURN 15 -#define PREAMBLETURN 5 -#define NORMALKEYMOVE 40 -#define MAXVEL ((NORMALKEYMOVE*2)+10) -#define MAXSVEL ((NORMALKEYMOVE*2)+10) -#define MAXANGVEL 127 -#define MAXHORIZ 127 - -int32_t g_myAimMode = 0, g_myAimStat = 0, g_oldAimStat = 0; -int32 mouseyaxismode = -1; -int32_t jump_input = 0; - -void getinput(int32_t snum) -{ - int32_t j, daang; - static ControlInfo info[2]; - int32 tics; - boolean running; - int32 turnamount; - int32 keymove; - int32 momx = 0,momy = 0; - DukePlayer_t *p = g_player[snum].ps; - - if ((p->gm&MODE_MENU) || (p->gm&MODE_TYPE) || (ud.pause_on && !KB_KeyPressed(sc_Pause)) || (numplayers > 1 && totalclock < 10)) - // HACK: kill getinput() for the first 10 tics of a new map in multi - { - if (!(p->gm&MODE_MENU)) - CONTROL_GetInput(&info[0]); - memset(&info[1], 0, sizeof(info[1])); - loc.fvel = vel = 0; - loc.svel = svel = 0; - loc.avel = angvel = 0; - loc.horz = horiz = 0; - loc.bits = (((int32_t)g_gameQuit)<team)<<6; - loc.extbits |= (1<<7); - return; - } - - if (ud.mouseaiming) - g_myAimMode = BUTTON(gamefunc_Mouse_Aiming); - else - { - g_oldAimStat = g_myAimStat; - g_myAimStat = BUTTON(gamefunc_Mouse_Aiming); - if (g_myAimStat > g_oldAimStat) - { - g_myAimMode ^= 1; - P_DoQuote(44+g_myAimMode,p); - } - } - - { - int32 i; - if (g_myAimMode) i = analog_lookingupanddown; - else i = ud.config.MouseAnalogueAxes[1]; - - if (i != mouseyaxismode) - { - CONTROL_MapAnalogAxis(1, i, controldevice_mouse); - mouseyaxismode = i; - } - } - - CONTROL_GetInput(&info[0]); - - if (ud.config.MouseDeadZone) - { - if (info[0].dpitch > 0) - { - if (info[0].dpitch > ud.config.MouseDeadZone) - info[0].dpitch -= ud.config.MouseDeadZone; - else info[0].dpitch = 0; - } - else if (info[0].dpitch < 0) - { - if (info[0].dpitch < -ud.config.MouseDeadZone) - info[0].dpitch += ud.config.MouseDeadZone; - else info[0].dpitch = 0; - } - if (info[0].dyaw > 0) - { - if (info[0].dyaw > ud.config.MouseDeadZone) - info[0].dyaw -= ud.config.MouseDeadZone; - else info[0].dyaw = 0; - } - else if (info[0].dyaw < 0) - { - if (info[0].dyaw < -ud.config.MouseDeadZone) - info[0].dyaw += ud.config.MouseDeadZone; - else info[0].dyaw = 0; - } - } - - if (ud.config.MouseBias) - { - if (klabs(info[0].dyaw) > klabs(info[0].dpitch)) - info[0].dpitch /= ud.config.MouseBias; - else info[0].dyaw /= ud.config.MouseBias; - } - - tics = totalclock-lastcontroltime; - lastcontroltime = totalclock; - - if (multiflag == 1) - { - loc.bits = 1<on_ground) - jump_input = 4; - - loc.bits = (jump_input > 0 || BUTTON(gamefunc_Jump))<curr_weapon][snum] & WEAPON_SEMIAUTO && BUTTON(gamefunc_Fire)) - CONTROL_ClearButton(gamefunc_Fire); - - if (jump_input > 0) - jump_input--; - - j=0; - - if (BUTTON(gamefunc_Weapon_1)) - j = 1; - if (BUTTON(gamefunc_Weapon_2)) - j = 2; - if (BUTTON(gamefunc_Weapon_3)) - j = 3; - if (BUTTON(gamefunc_Weapon_4)) - j = 4; - if (BUTTON(gamefunc_Weapon_5)) - j = 5; - if (BUTTON(gamefunc_Weapon_6)) - j = 6; - if (BUTTON(gamefunc_Weapon_7)) - j = 7; - if (BUTTON(gamefunc_Weapon_8)) - j = 8; - if (BUTTON(gamefunc_Weapon_9)) - j = 9; - if (BUTTON(gamefunc_Weapon_10)) - j = 10; - if (BUTTON(gamefunc_Previous_Weapon)) - j = 11; - if (BUTTON(gamefunc_Next_Weapon)) - j = 12; - - loc.bits |= j<>6; - - if (running) - { - turnamount = NORMALTURN<<1; - keymove = NORMALKEYMOVE<<1; - } - else - { - turnamount = NORMALTURN; - keymove = NORMALKEYMOVE; - } - - if (BUTTON(gamefunc_Strafe)) - { - if (BUTTON(gamefunc_Turn_Left) && !(g_player[snum].ps->movement_lock&4)) - svel -= -keymove; - if (BUTTON(gamefunc_Turn_Right) && !(g_player[snum].ps->movement_lock&8)) - svel -= keymove; - } - else - { - if (BUTTON(gamefunc_Turn_Left)) - { - turnheldtime += tics; - if (turnheldtime>=TURBOTURNTIME) - angvel -= turnamount; - else - angvel -= PREAMBLETURN; - } - else if (BUTTON(gamefunc_Turn_Right)) - { - turnheldtime += tics; - if (turnheldtime>=TURBOTURNTIME) - angvel += turnamount; - else - angvel += PREAMBLETURN; - } - else - turnheldtime=0; - } - - if (BUTTON(gamefunc_Strafe_Left) && !(g_player[snum].ps->movement_lock&4)) - svel += keymove; - if (BUTTON(gamefunc_Strafe_Right) && !(g_player[snum].ps->movement_lock&8)) - svel += -keymove; - if (BUTTON(gamefunc_Move_Forward) && !(g_player[snum].ps->movement_lock&1)) - vel += keymove; - if (BUTTON(gamefunc_Move_Backward) && !(g_player[snum].ps->movement_lock&2)) - vel += -keymove; - - if (vel < -MAXVEL) vel = -MAXVEL; - if (vel > MAXVEL) vel = MAXVEL; - if (svel < -MAXSVEL) svel = -MAXSVEL; - if (svel > MAXSVEL) svel = MAXSVEL; - if (angvel < -MAXANGVEL) angvel = -MAXANGVEL; - if (angvel > MAXANGVEL) angvel = MAXANGVEL; - if (horiz < -MAXHORIZ) horiz = -MAXHORIZ; - if (horiz > MAXHORIZ) horiz = MAXHORIZ; - - loc.extbits = 0; - if (apScriptGameEvent[EVENT_PROCESSINPUT] || apScriptGameEvent[EVENT_MOVEFORWARD]) - loc.extbits |= BUTTON(gamefunc_Move_Forward) || (vel > 0); - if (apScriptGameEvent[EVENT_PROCESSINPUT] || apScriptGameEvent[EVENT_MOVEBACKWARD]) - loc.extbits |= (BUTTON(gamefunc_Move_Backward) || (vel < 0))<<1; - if (apScriptGameEvent[EVENT_PROCESSINPUT] || apScriptGameEvent[EVENT_STRAFELEFT]) - loc.extbits |= (BUTTON(gamefunc_Strafe_Left) || (svel > 0))<<2; - if (apScriptGameEvent[EVENT_PROCESSINPUT] || apScriptGameEvent[EVENT_STRAFERIGHT]) - loc.extbits |= (BUTTON(gamefunc_Strafe_Right) || (svel < 0))<<3; - if (apScriptGameEvent[EVENT_PROCESSINPUT] || apScriptGameEvent[EVENT_TURNLEFT]) - loc.extbits |= BUTTON(gamefunc_Turn_Left)<<4; - if (apScriptGameEvent[EVENT_PROCESSINPUT] || apScriptGameEvent[EVENT_TURNRIGHT]) - loc.extbits |= BUTTON(gamefunc_Turn_Right)<<5; - // used for changing team - loc.extbits |= (g_player[snum].pteam != g_player[snum].ps->team)<<6; - - if (ud.scrollmode && ud.overhead_on) - { - ud.folfvel = vel; - ud.folavel = angvel; - loc.fvel = 0; - loc.svel = 0; - loc.avel = 0; - loc.horz = 0; - return; - } - - if (numplayers > 1) - daang = myang; - else daang = p->ang; - - momx = mulscale9(vel,sintable[(daang+2560)&2047]); - momy = mulscale9(vel,sintable[(daang+2048)&2047]); - - momx += mulscale9(svel,sintable[(daang+2048)&2047]); - momy += mulscale9(svel,sintable[(daang+1536)&2047]); - - momx += fricxv; - momy += fricyv; + zvel = (100-g_player[p].ps->horiz-g_player[p].ps->horizoff)<<5; + zvel += (zRange/2)-(krand()&(zRange-1)); + } + } + else + { + sa += (angRange/2)-(krand()&(angRange-1)); + if (j == -1) + { + // no target + zvel = (100-g_player[p].ps->horiz-g_player[p].ps->horizoff)<<5; + } + zvel += (zRange/2)-(krand()&(zRange-1)); + } + srcvect.z -= (2<<8); + } + else + { + j = A_FindPlayer(s,&x); + srcvect.z -= (4<<8); + hitinfo.pos.x = ldist(&sprite[g_player[j].ps->i], s); + if (hitinfo.pos.x == 0) + hitinfo.pos.x++; + zvel = ((g_player[j].ps->posz-srcvect.z) <<8) / hitinfo.pos.x; + if (s->picnum != BOSS1) + { + zvel += 128-(krand()&255); + sa += 32-(krand()&63); + } + else + { + zvel += 128-(krand()&255); + sa = getangle(g_player[j].ps->posx-srcvect.x,g_player[j].ps->posy-srcvect.y)+64-(krand()&127); + } + } + + if (ProjectileData[atwith].cstat >= 0) s->cstat &= ~ProjectileData[atwith].cstat; + else s->cstat &= ~257; + + if (ActorExtra[i].temp_data[9]) zvel = ActorExtra[i].temp_data[9]; + hitscan((const vec3_t *)&srcvect,sect, + sintable[(sa+512)&2047], + sintable[sa&2047], + zvel<<6,&hitinfo,CLIPMASK1); + + + if (ProjectileData[atwith].cstat >= 0) s->cstat |= ProjectileData[atwith].cstat; + else s->cstat |= 257; + + if (hitinfo.hitsect < 0) return -1; + + if ((ProjectileData[atwith].range > 0) && + ((klabs(srcvect.x-hitinfo.pos.x)+klabs(srcvect.y-hitinfo.pos.y)) > ProjectileData[atwith].range)) + return -1; + + if (ProjectileData[atwith].trail >= 0) + { + A_HitscanProjTrail(&srcvect,&hitinfo.pos,sa,atwith); + } + + if (ProjectileData[atwith].workslike & PROJECTILE_WATERBUBBLES) + { + if ((krand()&15) == 0 && sector[hitinfo.hitsect].lotag == 2) + A_DoWaterTracers(hitinfo.pos.x,hitinfo.pos.y,hitinfo.pos.z,srcvect.x,srcvect.y,srcvect.z,8-(ud.multimode>>1)); + } + + if (p >= 0) + { + k = A_InsertSprite(hitinfo.hitsect,hitinfo.pos.x,hitinfo.pos.y,hitinfo.pos.z,SHOTSPARK1,-15,10,10,sa,0,0,i,4); + sprite[k].extra = ProjectileData[atwith].extra; + if (ProjectileData[atwith].extra_rand > 0) + sprite[k].extra += (krand()%ProjectileData[atwith].extra_rand); + sprite[k].yvel = atwith; // this is a hack to allow you to detect which weapon spawned a SHOTSPARK1 + ActorExtra[k].temp_data[6] = hitinfo.hitwall; + ActorExtra[k].temp_data[7] = hitinfo.hitsect; + ActorExtra[k].temp_data[8] = hitinfo.hitsprite; + + if (hitinfo.hitwall == -1 && hitinfo.hitsprite == -1) + { + if (zvel < 0) + { + if (sector[hitinfo.hitsect].ceilingstat&1) + { + sprite[k].xrepeat = 0; + sprite[k].yrepeat = 0; + return -1; + } + else + Sect_DamageCeiling(hitinfo.hitsect); + } + if (ProjectileData[atwith].spawns >= 0) + { + wh=A_Spawn(k,ProjectileData[atwith].spawns); + if (ProjectileData[atwith].sxrepeat > 4) sprite[wh].xrepeat=ProjectileData[atwith].sxrepeat; + if (ProjectileData[atwith].syrepeat > 4) sprite[wh].yrepeat=ProjectileData[atwith].syrepeat; + ActorExtra[wh].temp_data[6] = hitinfo.hitwall; + ActorExtra[wh].temp_data[7] = hitinfo.hitsect; + ActorExtra[wh].temp_data[8] = hitinfo.hitsprite; + } + } + + if (hitinfo.hitsprite >= 0) + { + A_DamageObject(hitinfo.hitsprite,k); + if (sprite[hitinfo.hitsprite].picnum == APLAYER && (ud.ffire == 1 || (!GTFLAGS(GAMETYPE_PLAYERSFRIENDLY) && GTFLAGS(GAMETYPE_TDM) && g_player[sprite[hitinfo.hitsprite].yvel].ps->team != g_player[sprite[i].yvel].ps->team))) + { + l = A_Spawn(k,JIBS6); + sprite[k].xrepeat = sprite[k].yrepeat = 0; + sprite[l].z += (4<<8); + sprite[l].xvel = 16; + sprite[l].xrepeat = sprite[l].yrepeat = 24; + sprite[l].ang += 64-(krand()&127); + } + else + { + if (ProjectileData[atwith].spawns >= 0) + { + wh=A_Spawn(k,ProjectileData[atwith].spawns); + if (ProjectileData[atwith].sxrepeat > 4) sprite[wh].xrepeat=ProjectileData[atwith].sxrepeat; + if (ProjectileData[atwith].syrepeat > 4) sprite[wh].yrepeat=ProjectileData[atwith].syrepeat; + ActorExtra[wh].temp_data[6] = hitinfo.hitwall; + ActorExtra[wh].temp_data[7] = hitinfo.hitsect; + ActorExtra[wh].temp_data[8] = hitinfo.hitsprite; + } + } + if (p >= 0 && ( + sprite[hitinfo.hitsprite].picnum == DIPSWITCH || + sprite[hitinfo.hitsprite].picnum == DIPSWITCH+1 || + sprite[hitinfo.hitsprite].picnum == DIPSWITCH2 || + sprite[hitinfo.hitsprite].picnum == DIPSWITCH2+1 || + sprite[hitinfo.hitsprite].picnum == DIPSWITCH3 || + sprite[hitinfo.hitsprite].picnum == DIPSWITCH3+1 || + sprite[hitinfo.hitsprite].picnum == HANDSWITCH || + sprite[hitinfo.hitsprite].picnum == HANDSWITCH+1)) + { + P_ActivateSwitch(p,hitinfo.hitsprite,1); + return -1; + } + } + else if (hitinfo.hitwall >= 0) + { + if (ProjectileData[atwith].spawns >= 0) + { + wh=A_Spawn(k,ProjectileData[atwith].spawns); + if (ProjectileData[atwith].sxrepeat > 4) sprite[wh].xrepeat=ProjectileData[atwith].sxrepeat; + if (ProjectileData[atwith].syrepeat > 4) sprite[wh].yrepeat=ProjectileData[atwith].syrepeat; + ActorExtra[wh].temp_data[6] = hitinfo.hitwall; + ActorExtra[wh].temp_data[7] = hitinfo.hitsect; + ActorExtra[wh].temp_data[8] = hitinfo.hitsprite; + } + if (CheckDoorTile(wall[hitinfo.hitwall].picnum) == 1) + goto DOSKIPBULLETHOLE; + if (p >= 0 && ( + wall[hitinfo.hitwall].picnum == DIPSWITCH || + wall[hitinfo.hitwall].picnum == DIPSWITCH+1 || + wall[hitinfo.hitwall].picnum == DIPSWITCH2 || + wall[hitinfo.hitwall].picnum == DIPSWITCH2+1 || + wall[hitinfo.hitwall].picnum == DIPSWITCH3 || + wall[hitinfo.hitwall].picnum == DIPSWITCH3+1 || + wall[hitinfo.hitwall].picnum == HANDSWITCH || + wall[hitinfo.hitwall].picnum == HANDSWITCH+1)) + { + P_ActivateSwitch(p,hitinfo.hitwall,0); + return -1; + } + + if (wall[hitinfo.hitwall].hitag != 0 || (wall[hitinfo.hitwall].nextwall >= 0 && wall[wall[hitinfo.hitwall].nextwall].hitag != 0)) + goto DOSKIPBULLETHOLE; + + if (hitinfo.hitsect >= 0 && sector[hitinfo.hitsect].lotag == 0) + if (wall[hitinfo.hitwall].overpicnum != BIGFORCE) + if ((wall[hitinfo.hitwall].nextsector >= 0 && sector[wall[hitinfo.hitwall].nextsector].lotag == 0) || + (wall[hitinfo.hitwall].nextsector == -1 && sector[hitinfo.hitsect].lotag == 0)) + if ((wall[hitinfo.hitwall].cstat&16) == 0) + { + if (wall[hitinfo.hitwall].nextsector >= 0) + { + l = headspritesect[wall[hitinfo.hitwall].nextsector]; + while (l >= 0) + { + if (sprite[l].statnum == 3 && sprite[l].lotag == 13) + goto DOSKIPBULLETHOLE; + l = nextspritesect[l]; + } + } + + l = headspritestat[STAT_MISC]; + while (l >= 0) + { + if (sprite[l].picnum == ProjectileData[atwith].decal) + if (dist(&sprite[l],&sprite[k]) < (12+(krand()&7))) + goto DOSKIPBULLETHOLE; + l = nextspritestat[l]; + } + if (ProjectileData[atwith].decal >= 0) + { + l = A_Spawn(k,ProjectileData[atwith].decal); + sprite[l].xvel = -1; + sprite[l].ang = getangle(wall[hitinfo.hitwall].x-wall[wall[hitinfo.hitwall].point2].x, + wall[hitinfo.hitwall].y-wall[wall[hitinfo.hitwall].point2].y)+512; + if (ProjectileData[atwith].workslike & PROJECTILE_RANDDECALSIZE) + { + wh = (krand()&ProjectileData[atwith].xrepeat); + if (wh < ProjectileData[atwith].yrepeat) + wh = ProjectileData[atwith].yrepeat; + sprite[l].xrepeat = wh; + sprite[l].yrepeat = wh; + } + else + { + sprite[l].xrepeat = ProjectileData[atwith].xrepeat; + sprite[l].yrepeat = ProjectileData[atwith].yrepeat; + } + sprite[l].cstat = 16+(krand()&12); + sprite[l].x -= mulscale13(1,sintable[(sprite[l].ang+2560)&2047]); + sprite[l].y -= mulscale13(1,sintable[(sprite[l].ang+2048)&2047]); + + A_SetSprite(l,CLIPMASK0); + A_AddToDeleteQueue(l); + } + } + +DOSKIPBULLETHOLE: + + if (wall[hitinfo.hitwall].cstat&2) + if (wall[hitinfo.hitwall].nextsector >= 0) + if (hitinfo.pos.z >= (sector[wall[hitinfo.hitwall].nextsector].floorz)) + hitinfo.hitwall = wall[hitinfo.hitwall].nextwall; + + A_DamageWall(k,hitinfo.hitwall,&hitinfo.pos,atwith); + } + } + else + { + k = A_InsertSprite(hitinfo.hitsect,hitinfo.pos.x,hitinfo.pos.y,hitinfo.pos.z,SHOTSPARK1,-15,24,24,sa,0,0,i,4); + sprite[k].extra = ProjectileData[atwith].extra; + if (ProjectileData[atwith].extra_rand > 0) + sprite[k].extra += (krand()%ProjectileData[atwith].extra_rand); + sprite[k].yvel = atwith; // this is a hack to allow you to detect which weapon spawned a SHOTSPARK1 + ActorExtra[k].temp_data[6] = hitinfo.hitwall; + ActorExtra[k].temp_data[7] = hitinfo.hitsect; + ActorExtra[k].temp_data[8] = hitinfo.hitsprite; + + if (hitinfo.hitsprite >= 0) + { + A_DamageObject(hitinfo.hitsprite,k); + if (sprite[hitinfo.hitsprite].picnum != APLAYER) + { + if (ProjectileData[atwith].spawns >= 0) + { + wh=A_Spawn(k,ProjectileData[atwith].spawns); + if (ProjectileData[atwith].sxrepeat > 4) sprite[wh].xrepeat=ProjectileData[atwith].sxrepeat; + if (ProjectileData[atwith].syrepeat > 4) sprite[wh].yrepeat=ProjectileData[atwith].syrepeat; + ActorExtra[wh].temp_data[6] = hitinfo.hitwall; + ActorExtra[wh].temp_data[7] = hitinfo.hitsect; + ActorExtra[wh].temp_data[8] = hitinfo.hitsprite; + } + } + else sprite[k].xrepeat = sprite[k].yrepeat = 0; + } + else if (hitinfo.hitwall >= 0) + A_DamageWall(k,hitinfo.hitwall,&hitinfo.pos,atwith); + } + + if ((krand()&255) < 4) + if (ProjectileData[atwith].isound >= 0) + { + S_PlaySoundXYZ(ProjectileData[atwith].isound,k,&hitinfo.pos); + } + + return -1; + } + + if (ProjectileData[atwith].workslike & PROJECTILE_RPG) + { + + /* if(ProjectileData[atwith].workslike & PROJECTILE_FREEZEBLAST) + sz += (3<<8);*/ + + if (s->extra >= 0) s->shade = ProjectileData[atwith].shade; + + scount = 1; + vel = ProjectileData[atwith].vel; + + j = -1; + + if (p >= 0) + { + // j = A_FindTargetSprite( s, AUTO_AIM_ANGLE ); // 48 + Gv_SetVar(g_iAimAngleVarID,AUTO_AIM_ANGLE,i,p); + X_OnEvent(EVENT_GETAUTOAIMANGLE, i, p, -1); + j=-1; + if (Gv_GetVar(g_iAimAngleVarID,i,p) > 0) + { + j = A_FindTargetSprite(s, Gv_GetVar(g_iAimAngleVarID,i,p),atwith); + } + if (j >= 0) + { + dal = ((sprite[j].yrepeat*tilesizy[sprite[j].picnum])<<1)+(8<<8); + hitinfo.pos.x = ldist(&sprite[g_player[p].ps->i], &sprite[j]); + + if (hitinfo.pos.x == 0) + hitinfo.pos.x++; + + zvel = ((sprite[j].z-srcvect.z-dal)*vel) / hitinfo.pos.x; + + if (sprite[j].picnum != RECON) + sa = getangle(sprite[j].x-srcvect.x,sprite[j].y-srcvect.y); + } + // else zvel = (100-g_player[p].ps->horiz-g_player[p].ps->horizoff)*81; + else zvel = (100-g_player[p].ps->horiz-g_player[p].ps->horizoff)*(ProjectileData[atwith].vel/8); + + if (ProjectileData[atwith].sound >= 0) + A_PlaySound(ProjectileData[atwith].sound,i); + } + else + { + if (!(ProjectileData[atwith].workslike & PROJECTILE_NOAIM)) + { + j = A_FindPlayer(s,&x); + sa = getangle(g_player[j].ps->oposx-srcvect.x,g_player[j].ps->oposy-srcvect.y); + + l = ldist(&sprite[g_player[j].ps->i],s); + if (l == 0) + l++; + zvel = ((g_player[j].ps->oposz-srcvect.z)*vel) / l; + + if (A_CheckEnemySprite(s) && (s->hitag&face_player_smart)) + sa = s->ang+(krand()&31)-16; + } + } + + + + if (p >= 0 && j >= 0) + l = j; + else l = -1; + + /* j = A_InsertSprite(sect, + sx+(sintable[(348+sa+512)&2047]/448), + sy+(sintable[(sa+348)&2047]/448), + sz-(1<<8),atwith,0,14,14,sa,vel,zvel,i,4);*/ + if (ActorExtra[i].temp_data[9]) zvel = ActorExtra[i].temp_data[9]; + j = A_InsertSprite(sect, + srcvect.x+(sintable[(348+sa+512)&2047]/ProjectileData[atwith].offset), + srcvect.y+(sintable[(sa+348)&2047]/ProjectileData[atwith].offset), + srcvect.z-(1<<8),atwith,0,14,14,sa,vel,zvel,i,4); + + sprite[j].xrepeat=ProjectileData[atwith].xrepeat; + sprite[j].yrepeat=ProjectileData[atwith].yrepeat; + + + if (ProjectileData[atwith].extra_rand > 0) + sprite[j].extra += (krand()&ProjectileData[atwith].extra_rand); + if (!(ProjectileData[atwith].workslike & PROJECTILE_BOUNCESOFFWALLS)) + sprite[j].yvel = l; + else + { + if (ProjectileData[atwith].bounces >= 1) sprite[j].yvel = ProjectileData[atwith].bounces; + else sprite[j].yvel = g_numFreezeBounces; + // sprite[j].xrepeat >>= 1; + // sprite[j].yrepeat >>= 1; + sprite[j].zvel -= (2<<4); + } + /* + if(p == -1) + { + if(!(ProjectileData[atwith].workslike & PROJECTILE_BOUNCESOFFWALLS)) + { + sprite[j].xrepeat = ProjectileData[atwith].xrepeat; // 30 + sprite[j].yrepeat = ProjectileData[atwith].yrepeat; + sprite[j].extra >>= 2; + } + } + */ + if (ProjectileData[atwith].cstat >= 0) sprite[j].cstat = ProjectileData[atwith].cstat; + else sprite[j].cstat = 128; + if (ProjectileData[atwith].clipdist >= 0) sprite[j].clipdist = ProjectileData[atwith].clipdist; + else sprite[j].clipdist = 40; + + Bmemcpy(&ActorExtra[j].projectile, &ProjectileData[sprite[j].picnum], sizeof(ProjectileData[sprite[j].picnum])); + + // sa = s->ang+32-(krand()&63); + // zvel = oldzvel+512-(krand()&1023); + + return j; + } + + } + else + { + switch (DynamicTileMap[atwith]) + { + case BLOODSPLAT1__STATIC: + case BLOODSPLAT2__STATIC: + case BLOODSPLAT3__STATIC: + case BLOODSPLAT4__STATIC: + + if (p >= 0) + sa += 64 - (krand()&127); + else sa += 1024 + 64 - (krand()&127); + zvel = 1024-(krand()&2047); + case KNEE__STATIC: + if (atwith == KNEE) + { + if (p >= 0) + { + zvel = (100-g_player[p].ps->horiz-g_player[p].ps->horizoff)<<5; + srcvect.z += (6<<8); + sa += 15; + } + else + { + j = g_player[A_FindPlayer(s,&x)].ps->i; + zvel = ((sprite[j].z-srcvect.z)<<8) / (x+1); + sa = getangle(sprite[j].x-srcvect.x,sprite[j].y-srcvect.y); + } + } + + if (ActorExtra[i].temp_data[9]) zvel = ActorExtra[i].temp_data[9]; + hitscan((const vec3_t *)&srcvect,sect, + sintable[(sa+512)&2047], + sintable[sa&2047],zvel<<6, + &hitinfo,CLIPMASK1); + + if (atwith == BLOODSPLAT1 || atwith == BLOODSPLAT2 || atwith == BLOODSPLAT3 || atwith == BLOODSPLAT4) + { + if (FindDistance2D(srcvect.x-hitinfo.pos.x,srcvect.y-hitinfo.pos.y) < 1024) + if (hitinfo.hitwall >= 0 && wall[hitinfo.hitwall].overpicnum != BIGFORCE) + if ((wall[hitinfo.hitwall].nextsector >= 0 && hitinfo.hitsect >= 0 && + sector[wall[hitinfo.hitwall].nextsector].lotag == 0 && + sector[hitinfo.hitsect].lotag == 0 && + sector[wall[hitinfo.hitwall].nextsector].lotag == 0 && + (sector[hitinfo.hitsect].floorz-sector[wall[hitinfo.hitwall].nextsector].floorz) > (16<<8)) || + (wall[hitinfo.hitwall].nextsector == -1 && sector[hitinfo.hitsect].lotag == 0)) + if ((wall[hitinfo.hitwall].cstat&16) == 0) + { + if (wall[hitinfo.hitwall].nextsector >= 0) + { + k = headspritesect[wall[hitinfo.hitwall].nextsector]; + while (k >= 0) + { + if (sprite[k].statnum == 3 && sprite[k].lotag == 13) + return -1; + k = nextspritesect[k]; + } + } + + if (wall[hitinfo.hitwall].nextwall >= 0 && + wall[wall[hitinfo.hitwall].nextwall].hitag != 0) + return -1; + + if (wall[hitinfo.hitwall].hitag == 0) + { + k = A_Spawn(i,atwith); + sprite[k].xvel = -12; + sprite[k].ang = getangle(wall[hitinfo.hitwall].x-wall[wall[hitinfo.hitwall].point2].x, + wall[hitinfo.hitwall].y-wall[wall[hitinfo.hitwall].point2].y)+512; + sprite[k].x = hitinfo.pos.x; + sprite[k].y = hitinfo.pos.y; + sprite[k].z = hitinfo.pos.z; + sprite[k].cstat |= (krand()&4); + A_SetSprite(k,CLIPMASK0); + setsprite(k,(vec3_t *)&sprite[k]); + if (PN == OOZFILTER || PN == NEWBEAST) + sprite[k].pal = 6; + } + } + return -1; + } + + if (hitinfo.hitsect < 0) break; + + if ((klabs(srcvect.x-hitinfo.pos.x)+klabs(srcvect.y-hitinfo.pos.y)) < 1024) + { + if (hitinfo.hitwall >= 0 || hitinfo.hitsprite >= 0) + { + j = A_InsertSprite(hitinfo.hitsect,hitinfo.pos.x,hitinfo.pos.y,hitinfo.pos.z,KNEE,-15,0,0,sa,32,0,i,4); + sprite[j].extra += (krand()&7); + if (p >= 0) + { + k = A_Spawn(j,SMALLSMOKE); + sprite[k].z -= (8<<8); + A_PlaySound(KICK_HIT,j); + ActorExtra[k].temp_data[6] = hitinfo.hitwall; + ActorExtra[k].temp_data[7] = hitinfo.hitsect; + ActorExtra[k].temp_data[8] = hitinfo.hitsprite; + } + + if (p >= 0 && g_player[p].ps->steroids_amount > 0 && g_player[p].ps->steroids_amount < 400) + sprite[j].extra += (g_player[p].ps->max_player_health>>2); + + if (hitinfo.hitsprite >= 0 && sprite[hitinfo.hitsprite].picnum != ACCESSSWITCH && sprite[hitinfo.hitsprite].picnum != ACCESSSWITCH2) + { + A_DamageObject(hitinfo.hitsprite,j); + if (p >= 0) P_ActivateSwitch(p,hitinfo.hitsprite,1); + } + + else if (hitinfo.hitwall >= 0) + { + if (wall[hitinfo.hitwall].cstat&2) + if (wall[hitinfo.hitwall].nextsector >= 0) + if (hitinfo.pos.z >= (sector[wall[hitinfo.hitwall].nextsector].floorz)) + hitinfo.hitwall = wall[hitinfo.hitwall].nextwall; + + if (hitinfo.hitwall >= 0 && wall[hitinfo.hitwall].picnum != ACCESSSWITCH && wall[hitinfo.hitwall].picnum != ACCESSSWITCH2) + { + A_DamageWall(j,hitinfo.hitwall,&hitinfo.pos,atwith); + if (p >= 0) P_ActivateSwitch(p,hitinfo.hitwall,0); + } + } + } + else if (p >= 0 && zvel > 0 && sector[hitinfo.hitsect].lotag == 1) + { + j = A_Spawn(g_player[p].ps->i,WATERSPLASH2); + sprite[j].x = hitinfo.pos.x; + sprite[j].y = hitinfo.pos.y; + sprite[j].ang = g_player[p].ps->ang; // Total tweek + sprite[j].xvel = 32; + A_SetSprite(i,CLIPMASK0); + sprite[j].xvel = 0; + + } + } + + break; + + case SHOTSPARK1__STATIC: + case SHOTGUN__STATIC: + case CHAINGUN__STATIC: + + if (s->extra >= 0) s->shade = -96; + + if (p >= 0) + { + int32_t angRange=32; + int32_t zRange=256; + + Gv_SetVar(g_iAimAngleVarID,AUTO_AIM_ANGLE,i,p); + X_OnEvent(EVENT_GETAUTOAIMANGLE, i, p, -1); + j=-1; + if (Gv_GetVar(g_iAimAngleVarID,i,p) > 0) + { + j = A_FindTargetSprite(s, Gv_GetVar(g_iAimAngleVarID,i,p),atwith); + } + if (j >= 0) + { + dal = ((sprite[j].yrepeat*tilesizy[sprite[j].picnum])<<1)+(5<<8); + if (((sprite[j].picnum>=GREENSLIME)&&(sprite[j].picnum<=GREENSLIME+7))||(sprite[j].picnum==ROTATEGUN)) + { + + dal -= (8<<8); + + } + hitinfo.pos.x = ldist(&sprite[g_player[p].ps->i], &sprite[j]); + if (hitinfo.pos.x == 0) hitinfo.pos.x++; + zvel = ((sprite[j].z-srcvect.z-dal)<<8) / hitinfo.pos.x; + sa = getangle(sprite[j].x-srcvect.x,sprite[j].y-srcvect.y); + } + + Gv_SetVar(g_iAngRangeVarID,angRange, i,p); + Gv_SetVar(g_iZRangeVarID,zRange,i,p); + + X_OnEvent(EVENT_GETSHOTRANGE, i,p, -1); + + angRange=Gv_GetVar(g_iAngRangeVarID,i,p); + zRange=Gv_GetVar(g_iZRangeVarID,i,p); + + if (atwith == SHOTSPARK1__STATIC && !WW2GI && !NAM) + { + if (!g_player[p].ps->auto_aim) + { + zvel = (100-g_player[p].ps->horiz-g_player[p].ps->horizoff)<<5; + if (ActorExtra[i].temp_data[9]) zvel = ActorExtra[i].temp_data[9]; + hitscan((const vec3_t *)&srcvect,sect,sintable[(sa+512)&2047],sintable[sa&2047], + zvel<<6,&hitinfo,CLIPMASK1); + if (hitinfo.hitsprite != -1) + { + if (sprite[hitinfo.hitsprite].statnum == 1 || sprite[hitinfo.hitsprite].statnum == 2 || sprite[hitinfo.hitsprite].statnum == 10 || sprite[hitinfo.hitsprite].statnum == 13) + j = hitinfo.hitsprite; + } + } + + if (j == -1) + { + sa += (angRange/2)-(krand()&(angRange-1)); + zvel = (100-g_player[p].ps->horiz-g_player[p].ps->horizoff)<<5; + zvel += (zRange/2)-(krand()&(zRange-1)); + } + } + else + { + sa += (angRange/2)-(krand()&(angRange-1)); + if (j == -1) + { + // no target + zvel = (100-g_player[p].ps->horiz-g_player[p].ps->horizoff)<<5; + } + zvel += (zRange/2)-(krand()&(zRange-1)); + } + + srcvect.z -= (2<<8); + } + else + { + j = A_FindPlayer(s,&x); + srcvect.z -= (4<<8); + hitinfo.pos.x = ldist(&sprite[g_player[j].ps->i], s); + if (hitinfo.pos.x == 0) + hitinfo.pos.x++; + zvel = ((g_player[j].ps->posz-srcvect.z) <<8) / hitinfo.pos.x; + if (s->picnum != BOSS1) + { + zvel += 128-(krand()&255); + sa += 32-(krand()&63); + } + else + { + zvel += 128-(krand()&255); + sa = getangle(g_player[j].ps->posx-srcvect.x,g_player[j].ps->posy-srcvect.y)+64-(krand()&127); + } + } + + s->cstat &= ~257; + if (ActorExtra[i].temp_data[9]) zvel = ActorExtra[i].temp_data[9]; + hitscan((const vec3_t *)&srcvect,sect, + sintable[(sa+512)&2047], + sintable[sa&2047], + zvel<<6,&hitinfo,CLIPMASK1); + s->cstat |= 257; + + if (hitinfo.hitsect < 0) return -1; + + if ((krand()&15) == 0 && sector[hitinfo.hitsect].lotag == 2) + A_DoWaterTracers(hitinfo.pos.x,hitinfo.pos.y,hitinfo.pos.z, + srcvect.x,srcvect.y,srcvect.z,8-(ud.multimode>>1)); + + if (p >= 0) + { + k = A_InsertSprite(hitinfo.hitsect,hitinfo.pos.x,hitinfo.pos.y,hitinfo.pos.z,SHOTSPARK1,-15,10,10,sa,0,0,i,4); + sprite[k].extra = *actorscrptr[atwith]; + sprite[k].extra += (krand()%6); + sprite[k].yvel = atwith; // this is a hack to allow you to detect which weapon spawned a SHOTSPARK1 + ActorExtra[k].temp_data[6] = hitinfo.hitwall; + ActorExtra[k].temp_data[7] = hitinfo.hitsect; + ActorExtra[k].temp_data[8] = hitinfo.hitsprite; + + + if (hitinfo.hitwall == -1 && hitinfo.hitsprite == -1) + { + if (zvel < 0) + { + if (sector[hitinfo.hitsect].ceilingstat&1) + { + sprite[k].xrepeat = 0; + sprite[k].yrepeat = 0; + return -1; + } + else + Sect_DamageCeiling(hitinfo.hitsect); + } + l = A_Spawn(k,SMALLSMOKE); + ActorExtra[l].temp_data[6] = hitinfo.hitwall; + ActorExtra[l].temp_data[7] = hitinfo.hitsect; + ActorExtra[l].temp_data[8] = hitinfo.hitsprite; + } + + if (hitinfo.hitsprite >= 0) + { + A_DamageObject(hitinfo.hitsprite,k); + if (sprite[hitinfo.hitsprite].picnum == APLAYER && (ud.ffire == 1 || (!GTFLAGS(GAMETYPE_PLAYERSFRIENDLY) && GTFLAGS(GAMETYPE_TDM) && g_player[sprite[hitinfo.hitsprite].yvel].ps->team != g_player[sprite[i].yvel].ps->team))) + { + l = A_Spawn(k,JIBS6); + sprite[k].xrepeat = sprite[k].yrepeat = 0; + sprite[l].z += (4<<8); + sprite[l].xvel = 16; + sprite[l].xrepeat = sprite[l].yrepeat = 24; + sprite[l].ang += 64-(krand()&127); + } + else + { + l = A_Spawn(k,SMALLSMOKE); + ActorExtra[l].temp_data[6] = hitinfo.hitwall; + ActorExtra[l].temp_data[7] = hitinfo.hitsect; + ActorExtra[l].temp_data[8] = hitinfo.hitsprite; + } + + if (p >= 0 && ( + sprite[hitinfo.hitsprite].picnum == DIPSWITCH || + sprite[hitinfo.hitsprite].picnum == DIPSWITCH+1 || + sprite[hitinfo.hitsprite].picnum == DIPSWITCH2 || + sprite[hitinfo.hitsprite].picnum == DIPSWITCH2+1 || + sprite[hitinfo.hitsprite].picnum == DIPSWITCH3 || + sprite[hitinfo.hitsprite].picnum == DIPSWITCH3+1 || + sprite[hitinfo.hitsprite].picnum == HANDSWITCH || + sprite[hitinfo.hitsprite].picnum == HANDSWITCH+1)) + { + P_ActivateSwitch(p,hitinfo.hitsprite,1); + return -1; + } + } + else if (hitinfo.hitwall >= 0) + { + l = A_Spawn(k,SMALLSMOKE); + ActorExtra[l].temp_data[6] = hitinfo.hitwall; + ActorExtra[l].temp_data[7] = hitinfo.hitsect; + ActorExtra[l].temp_data[8] = hitinfo.hitsprite; + + if (CheckDoorTile(wall[hitinfo.hitwall].picnum) == 1) + goto SKIPBULLETHOLE; + if (p >= 0 && ( + wall[hitinfo.hitwall].picnum == DIPSWITCH || + wall[hitinfo.hitwall].picnum == DIPSWITCH+1 || + wall[hitinfo.hitwall].picnum == DIPSWITCH2 || + wall[hitinfo.hitwall].picnum == DIPSWITCH2+1 || + wall[hitinfo.hitwall].picnum == DIPSWITCH3 || + wall[hitinfo.hitwall].picnum == DIPSWITCH3+1 || + wall[hitinfo.hitwall].picnum == HANDSWITCH || + wall[hitinfo.hitwall].picnum == HANDSWITCH+1)) + { + P_ActivateSwitch(p,hitinfo.hitwall,0); + return -1; + } + + if (wall[hitinfo.hitwall].hitag != 0 || (wall[hitinfo.hitwall].nextwall >= 0 && wall[wall[hitinfo.hitwall].nextwall].hitag != 0)) + goto SKIPBULLETHOLE; + + if (hitinfo.hitsect >= 0 && sector[hitinfo.hitsect].lotag == 0) + if (wall[hitinfo.hitwall].overpicnum != BIGFORCE) + if ((wall[hitinfo.hitwall].nextsector >= 0 && sector[wall[hitinfo.hitwall].nextsector].lotag == 0) || + (wall[hitinfo.hitwall].nextsector == -1 && sector[hitinfo.hitsect].lotag == 0)) + if ((wall[hitinfo.hitwall].cstat&16) == 0) + { + if (wall[hitinfo.hitwall].nextsector >= 0) + { + l = headspritesect[wall[hitinfo.hitwall].nextsector]; + while (l >= 0) + { + if (sprite[l].statnum == 3 && sprite[l].lotag == 13) + goto SKIPBULLETHOLE; + l = nextspritesect[l]; + } + } + + l = headspritestat[STAT_MISC]; + while (l >= 0) + { + if (sprite[l].picnum == BULLETHOLE) + if (dist(&sprite[l],&sprite[k]) < (12+(krand()&7))) + goto SKIPBULLETHOLE; + l = nextspritestat[l]; + } + l = A_Spawn(k,BULLETHOLE); + sprite[l].xvel = -1; + sprite[l].x = hitinfo.pos.x; + sprite[l].y = hitinfo.pos.y; + sprite[l].z = hitinfo.pos.z; + + sprite[l].ang = getangle(wall[hitinfo.hitwall].x-wall[wall[hitinfo.hitwall].point2].x, + wall[hitinfo.hitwall].y-wall[wall[hitinfo.hitwall].point2].y)+512; + + sprite[l].x -= mulscale13(1,sintable[(sprite[l].ang+2560)&2047]); + sprite[l].y -= mulscale13(1,sintable[(sprite[l].ang+2048)&2047]); + A_SetSprite(l,CLIPMASK0); + } + +SKIPBULLETHOLE: + + if (wall[hitinfo.hitwall].cstat&2) + if (wall[hitinfo.hitwall].nextsector >= 0) + if (hitinfo.pos.z >= (sector[wall[hitinfo.hitwall].nextsector].floorz)) + hitinfo.hitwall = wall[hitinfo.hitwall].nextwall; + + A_DamageWall(k,hitinfo.hitwall,&hitinfo.pos,SHOTSPARK1); + } + } + else + { + k = A_InsertSprite(hitinfo.hitsect,hitinfo.pos.x,hitinfo.pos.y,hitinfo.pos.z,SHOTSPARK1,-15,24,24,sa,0,0,i,4); + sprite[k].extra = *actorscrptr[atwith]; + sprite[k].yvel = atwith; // this is a hack to allow you to detect which weapon spawned a SHOTSPARK1 + ActorExtra[k].temp_data[6] = hitinfo.hitwall; + ActorExtra[k].temp_data[7] = hitinfo.hitsect; + ActorExtra[k].temp_data[8] = hitinfo.hitsprite; + + if (hitinfo.hitsprite >= 0) + { + A_DamageObject(hitinfo.hitsprite,k); + if (sprite[hitinfo.hitsprite].picnum != APLAYER) + { + l = A_Spawn(k,SMALLSMOKE); + ActorExtra[l].temp_data[6] = hitinfo.hitwall; + ActorExtra[l].temp_data[7] = hitinfo.hitsect; + ActorExtra[l].temp_data[8] = hitinfo.hitsprite; + } + else sprite[k].xrepeat = sprite[k].yrepeat = 0; + } + else if (hitinfo.hitwall >= 0) + A_DamageWall(k,hitinfo.hitwall,&hitinfo.pos,SHOTSPARK1); + } + + if ((krand()&255) < 4) + S_PlaySoundXYZ(PISTOL_RICOCHET,k, &hitinfo.pos); + + return -1; + + case FIRELASER__STATIC: + case SPIT__STATIC: + case COOLEXPLOSION1__STATIC: + + if (s->extra >= 0) s->shade = -96; + + scount = 1; + if (atwith == SPIT) vel = 292; + else + { + if (atwith == COOLEXPLOSION1) + { + if (s->picnum == BOSS2) vel = 644; + else vel = 348; + srcvect.z -= (4<<7); + } + else + { + vel = 840; + srcvect.z -= (4<<7); + } + } + + if (p >= 0) + { + // j = A_FindTargetSprite( s, AUTO_AIM_ANGLE ); + Gv_SetVar(g_iAimAngleVarID,AUTO_AIM_ANGLE,i,p); + X_OnEvent(EVENT_GETAUTOAIMANGLE, i, p, -1); + j=-1; + if (Gv_GetVar(g_iAimAngleVarID,i,p) > 0) + { + j = A_FindTargetSprite(s, Gv_GetVar(g_iAimAngleVarID,i,p),atwith); + } + + if (j >= 0) + { + dal = ((sprite[j].yrepeat*tilesizy[sprite[j].picnum])<<1)-(12<<8); + hitinfo.pos.x = ldist(&sprite[g_player[p].ps->i], &sprite[j]); + if (hitinfo.pos.x == 0) hitinfo.pos.x++; + zvel = ((sprite[j].z-srcvect.z-dal)*vel) / hitinfo.pos.x; + sa = getangle(sprite[j].x-srcvect.x,sprite[j].y-srcvect.y); + } + else + zvel = (100-g_player[p].ps->horiz-g_player[p].ps->horizoff)*98; + } + else + { + j = A_FindPlayer(s,&x); + // sa = getangle(g_player[j].ps->oposx-sx,g_player[j].ps->oposy-sy); + sa += 16-(krand()&31); + hitinfo.pos.x = ldist(&sprite[g_player[j].ps->i],s); + if (hitinfo.pos.x == 0) hitinfo.pos.x++; + zvel = ((g_player[j].ps->oposz - srcvect.z + (3<<8))*vel) / hitinfo.pos.x; + } + if (ActorExtra[i].temp_data[9]) zvel = ActorExtra[i].temp_data[9]; + oldzvel = zvel; + + if (atwith == SPIT) + { + sizx = 18; + sizy = 18,srcvect.z -= (10<<8); + } + else + { + if (atwith == FIRELASER) + { + if (p >= 0) + { + + sizx = 34; + sizy = 34; + } + else + { + sizx = 18; + sizy = 18; + } + } + else + { + sizx = 18; + sizy = 18; + } + } + + if (p >= 0) sizx = 7,sizy = 7; + + while (scount > 0) + { + j = A_InsertSprite(sect,srcvect.x,srcvect.y,srcvect.z, + atwith,-127,sizx,sizy,sa,vel,zvel,i,4); + sprite[j].extra += (krand()&7); + + if (atwith == COOLEXPLOSION1) + { + sprite[j].shade = 0; + if (PN == BOSS2) + { + l = sprite[j].xvel; + sprite[j].xvel = 1024; + A_SetSprite(j,CLIPMASK0); + sprite[j].xvel = l; + sprite[j].ang += 128-(krand()&255); + } + } + + sprite[j].cstat = 128; + sprite[j].clipdist = 4; + + sa = s->ang+32-(krand()&63); + zvel = oldzvel+512-(krand()&1023); + + scount--; + } + + return j; + + case FREEZEBLAST__STATIC: + srcvect.z += (3<<8); + case RPG__STATIC: + + if (s->extra >= 0) s->shade = -96; + + scount = 1; + vel = 644; + + j = -1; + + if (p >= 0) + { + // j = A_FindTargetSprite( s, AUTO_AIM_ANGLE ); // 48 + Gv_SetVar(g_iAimAngleVarID,AUTO_AIM_ANGLE,i,p); + X_OnEvent(EVENT_GETAUTOAIMANGLE, i, p, -1); + j=-1; + if (Gv_GetVar(g_iAimAngleVarID,i,p) > 0) + { + j = A_FindTargetSprite(s, Gv_GetVar(g_iAimAngleVarID,i,p),atwith); + } + + if (j >= 0) + { + dal = ((sprite[j].yrepeat*tilesizy[sprite[j].picnum])<<1)+(8<<8); + hitinfo.pos.x = ldist(&sprite[g_player[p].ps->i], &sprite[j]); + if (hitinfo.pos.x == 0) hitinfo.pos.x++; + zvel = ((sprite[j].z-srcvect.z-dal)*vel) / hitinfo.pos.x; + if (sprite[j].picnum != RECON) + sa = getangle(sprite[j].x-srcvect.x,sprite[j].y-srcvect.y); + } + else zvel = (100-g_player[p].ps->horiz-g_player[p].ps->horizoff)*81; + if (atwith == RPG) + A_PlaySound(RPG_SHOOT,i); + } + else + { + j = A_FindPlayer(s,&x); + sa = getangle(g_player[j].ps->oposx-srcvect.x,g_player[j].ps->oposy-srcvect.y); + if (PN == BOSS3) + srcvect.z -= (32<<8); + else if (PN == BOSS2) + { + vel += 128; + srcvect.z += 24<<8; + } + + l = ldist(&sprite[g_player[j].ps->i],s); + if (l == 0) + l++; + zvel = ((g_player[j].ps->oposz-srcvect.z)*vel) / l; + + if (A_CheckEnemySprite(s) && (s->hitag&face_player_smart)) + sa = s->ang+(krand()&31)-16; + } + + if (p >= 0 && j >= 0) + l = j; + else l = -1; + if (ActorExtra[i].temp_data[9]) zvel = ActorExtra[i].temp_data[9]; + j = A_InsertSprite(sect, + srcvect.x+(sintable[(348+sa+512)&2047]/448), + srcvect.y+(sintable[(sa+348)&2047]/448), + srcvect.z-(1<<8),atwith,0,14,14,sa,vel,zvel,i,4); + + sprite[j].extra += (krand()&7); + if (atwith != FREEZEBLAST) + sprite[j].yvel = l; + else + { + sprite[j].yvel = g_numFreezeBounces; + sprite[j].xrepeat >>= 1; + sprite[j].yrepeat >>= 1; + sprite[j].zvel -= (2<<4); + } + + if (p == -1) + { + if (PN == BOSS3) + { + if (krand()&1) + { + sprite[j].x -= sintable[sa&2047]>>6; + sprite[j].y -= sintable[(sa+1024+512)&2047]>>6; + sprite[j].ang -= 8; + } + else + { + sprite[j].x += sintable[sa&2047]>>6; + sprite[j].y += sintable[(sa+1024+512)&2047]>>6; + sprite[j].ang += 4; + } + sprite[j].xrepeat = 42; + sprite[j].yrepeat = 42; + } + else if (PN == BOSS2) + { + sprite[j].x -= sintable[sa&2047]/56; + sprite[j].y -= sintable[(sa+1024+512)&2047]/56; + sprite[j].ang -= 8+(krand()&255)-128; + sprite[j].xrepeat = 24; + sprite[j].yrepeat = 24; + } + else if (atwith != FREEZEBLAST) + { + sprite[j].xrepeat = 30; + sprite[j].yrepeat = 30; + sprite[j].extra >>= 2; + } + } + + else if (*aplWeaponWorksLike[g_player[p].ps->curr_weapon] == DEVISTATOR_WEAPON) + { + sprite[j].extra >>= 2; + sprite[j].ang += 16-(krand()&31); + sprite[j].zvel += 256-(krand()&511); + + if (g_player[p].ps->hbomb_hold_delay) + { + sprite[j].x -= sintable[sa&2047]/644; + sprite[j].y -= sintable[(sa+1024+512)&2047]/644; + } + else + { + sprite[j].x += sintable[sa&2047]>>8; + sprite[j].y += sintable[(sa+1024+512)&2047]>>8; + } + sprite[j].xrepeat >>= 1; + sprite[j].yrepeat >>= 1; + } + + sprite[j].cstat = 128; + if (atwith == RPG) + sprite[j].clipdist = 4; + else + sprite[j].clipdist = 40; + + return j; + + case HANDHOLDINGLASER__STATIC: + + if (p >= 0) + zvel = (100-g_player[p].ps->horiz-g_player[p].ps->horizoff)*32; + else zvel = 0; + if (ActorExtra[i].temp_data[9]) zvel = ActorExtra[i].temp_data[9]; + + srcvect.z -= g_player[p].ps->pyoff; + hitscan((const vec3_t *)&srcvect,sect, + sintable[(sa+512)&2047], + sintable[sa&2047], + zvel<<6,&hitinfo,CLIPMASK1); + + srcvect.z += g_player[p].ps->pyoff; + j = 0; + if (hitinfo.hitsprite >= 0) break; + + if (hitinfo.hitwall >= 0 && hitinfo.hitsect >= 0) + if (((hitinfo.pos.x-srcvect.x)*(hitinfo.pos.x-srcvect.x)+(hitinfo.pos.y-srcvect.y)*(hitinfo.pos.y-srcvect.y)) < (290*290)) + { + if (wall[hitinfo.hitwall].nextsector >= 0) + { + if (sector[wall[hitinfo.hitwall].nextsector].lotag <= 2 && sector[hitinfo.hitsect].lotag <= 2) + j = 1; + } + else if (sector[hitinfo.hitsect].lotag <= 2) + j = 1; + } + + if (j == 1) + { + int32_t lTripBombControl=Gv_GetVarByLabel("TRIPBOMB_CONTROL", TRIPBOMB_TRIPWIRE, g_player[p].ps->i, p); + k = A_InsertSprite(hitinfo.hitsect,hitinfo.pos.x,hitinfo.pos.y,hitinfo.pos.z,TRIPBOMB,-16,4,5,sa,0,0,i,6); + if (lTripBombControl & TRIPBOMB_TIMER) + { + int32_t lLifetime=Gv_GetVarByLabel("STICKYBOMB_LIFETIME", NAM_GRENADE_LIFETIME, g_player[p].ps->i, p); + int32_t lLifetimeVar=Gv_GetVarByLabel("STICKYBOMB_LIFETIME_VAR", NAM_GRENADE_LIFETIME_VAR, g_player[p].ps->i, p); + // set timer. blows up when at zero.... + ActorExtra[k].temp_data[7]=lLifetime + + mulscale(krand(),lLifetimeVar, 14) + - lLifetimeVar; + ActorExtra[k].temp_data[6]=1; + } + else + + sprite[k].hitag = k; + A_PlaySound(LASERTRIP_ONWALL,k); + sprite[k].xvel = -20; + A_SetSprite(k,CLIPMASK0); + sprite[k].cstat = 16; + ActorExtra[k].temp_data[5] = sprite[k].ang = getangle(wall[hitinfo.hitwall].x-wall[wall[hitinfo.hitwall].point2].x,wall[hitinfo.hitwall].y-wall[wall[hitinfo.hitwall].point2].y)-512; + + + } + return j?k:-1; + + case BOUNCEMINE__STATIC: + case MORTER__STATIC: + + if (s->extra >= 0) s->shade = -96; + + j = g_player[A_FindPlayer(s,&x)].ps->i; + x = ldist(&sprite[j],s); + + zvel = -x>>1; + + if (zvel < -4096) + zvel = -2048; + vel = x>>4; + if (ActorExtra[i].temp_data[9]) zvel = ActorExtra[i].temp_data[9]; + A_InsertSprite(sect, + srcvect.x+(sintable[(512+sa+512)&2047]>>8), + srcvect.y+(sintable[(sa+512)&2047]>>8), + srcvect.z+(6<<8),atwith,-64,32,32,sa,vel,zvel,i,1); + break; + + case GROWSPARK__STATIC: + + if (p >= 0) + { + // j = A_FindTargetSprite( s, AUTO_AIM_ANGLE ); + Gv_SetVar(g_iAimAngleVarID,AUTO_AIM_ANGLE,i,p); + X_OnEvent(EVENT_GETAUTOAIMANGLE, i, p, -1); + j=-1; + if (Gv_GetVar(g_iAimAngleVarID,i,p) > 0) + { + j = A_FindTargetSprite(s, Gv_GetVar(g_iAimAngleVarID,i,p),atwith); + } + + if (j >= 0) + { + dal = ((sprite[j].yrepeat*tilesizy[sprite[j].picnum])<<1)+(5<<8); + if (((sprite[j].picnum >= GREENSLIME)&&(sprite[j].picnum <= GREENSLIME+7))||(sprite[j].picnum ==ROTATEGUN)) + { + dal -= (8<<8); + + } + hitinfo.pos.x = ldist(&sprite[g_player[p].ps->i], &sprite[j]); + if (hitinfo.pos.x == 0) + hitinfo.pos.x++; + zvel = ((sprite[j].z-srcvect.z-dal)<<8) / hitinfo.pos.x; + sa = getangle(sprite[j].x-srcvect.x,sprite[j].y-srcvect.y); + } + else + { + sa += 16-(krand()&31); + zvel = (100-g_player[p].ps->horiz-g_player[p].ps->horizoff)<<5; + zvel += 128-(krand()&255); + } + + srcvect.z -= (2<<8); + } + else + { + j = A_FindPlayer(s,&x); + srcvect.z -= (4<<8); + hitinfo.pos.x = ldist(&sprite[g_player[j].ps->i], s); + if (hitinfo.pos.x == 0) + hitinfo.pos.x++; + zvel = ((g_player[j].ps->posz-srcvect.z) <<8) / hitinfo.pos.x; + zvel += 128-(krand()&255); + sa += 32-(krand()&63); + } + + k = 0; + + // RESHOOTGROW: + if (sect < 0) break; + + s->cstat &= ~257; + if (ActorExtra[i].temp_data[9]) zvel = ActorExtra[i].temp_data[9]; + hitscan((const vec3_t *)&srcvect,sect, + sintable[(sa+512)&2047], + sintable[sa&2047], + zvel<<6,&hitinfo,CLIPMASK1); + + s->cstat |= 257; + + j = A_InsertSprite(sect,hitinfo.pos.x,hitinfo.pos.y,hitinfo.pos.z,GROWSPARK,-16,28,28,sa,0,0,i,1); + + sprite[j].pal = 2; + sprite[j].cstat |= 130; + sprite[j].xrepeat = sprite[j].yrepeat = 1; + + if (hitinfo.hitwall == -1 && hitinfo.hitsprite == -1 && hitinfo.hitsect >= 0) + { + if (zvel < 0 && (sector[hitinfo.hitsect].ceilingstat&1) == 0) + Sect_DamageCeiling(hitinfo.hitsect); + } + else if (hitinfo.hitsprite >= 0) A_DamageObject(hitinfo.hitsprite,j); + else if (hitinfo.hitwall >= 0 && wall[hitinfo.hitwall].picnum != ACCESSSWITCH && wall[hitinfo.hitwall].picnum != ACCESSSWITCH2) + { + /* if(wall[hitinfo.hitwall].overpicnum == MIRROR && k == 0) + { + l = getangle( + wall[wall[hitinfo.hitwall].point2].x-wall[hitinfo.hitwall].x, + wall[wall[hitinfo.hitwall].point2].y-wall[hitinfo.hitwall].y); + + sx = hitinfo.pos.x; + sy = hitinfo.pos.y; + srcvect.z = hitinfo.pos.z; + sect = hitinfo.hitsect; + sa = ((l<<1) - sa)&2047; + sx += sintable[(sa+512)&2047]>>12; + sy += sintable[sa&2047]>>12; + + k++; + goto RESHOOTGROW; + } + else */ + A_DamageWall(j,hitinfo.hitwall,&hitinfo.pos,atwith); + } + + break; + + case SHRINKER__STATIC: + if (s->extra >= 0) s->shade = -96; + if (p >= 0) + { + // j = A_FindTargetSprite( s, AUTO_AIM_ANGLE ); + Gv_SetVar(g_iAimAngleVarID,AUTO_AIM_ANGLE,i,p); + X_OnEvent(EVENT_GETAUTOAIMANGLE, i, p, -1); + j=-1; + if (Gv_GetVar(g_iAimAngleVarID,i,p) > 0) + { + j = A_FindTargetSprite(s, Gv_GetVar(g_iAimAngleVarID,i,p),atwith); + } + + if (j >= 0) + { + dal = ((sprite[j].yrepeat*tilesizy[sprite[j].picnum])<<1); + hitinfo.pos.x = ldist(&sprite[g_player[p].ps->i], &sprite[j]); + if (hitinfo.pos.x == 0) + hitinfo.pos.x++; + zvel = ((sprite[j].z-srcvect.z-dal-(4<<8))*768) / hitinfo.pos.x; + sa = getangle(sprite[j].x-srcvect.x,sprite[j].y-srcvect.y); + } + else zvel = (100-g_player[p].ps->horiz-g_player[p].ps->horizoff)*98; + } + else if (s->statnum != 3) + { + j = A_FindPlayer(s,&x); + l = ldist(&sprite[g_player[j].ps->i],s); + if (l == 0) + l++; + zvel = ((g_player[j].ps->oposz-srcvect.z)*512) / l ; + } + else zvel = 0; + if (ActorExtra[i].temp_data[9]) zvel = ActorExtra[i].temp_data[9]; + j = A_InsertSprite(sect, + srcvect.x+(sintable[(512+sa+512)&2047]>>12), + srcvect.y+(sintable[(sa+512)&2047]>>12), + srcvect.z+(2<<8),SHRINKSPARK,-16,28,28,sa,768,zvel,i,4); + + sprite[j].cstat = 128; + sprite[j].clipdist = 32; + + + return j; + } + } + return -1; +} + +static void P_DisplaySpitAnim(int32_t snum) +{ + int32_t i, a, x, y, z; + + if (g_player[snum].ps->loogcnt == 0) return; + + y = (g_player[snum].ps->loogcnt<<2); + for (i=0;inumloogs;i++) + { + a = klabs(sintable[((g_player[snum].ps->loogcnt+i)<<5)&2047])>>5; + z = 4096+((g_player[snum].ps->loogcnt+i)<<9); + x = (-g_player[snum].sync->avel)+(sintable[((g_player[snum].ps->loogcnt+i)<<6)&2047]>>10); + + rotatesprite( + (g_player[snum].ps->loogiex[i]+x)<<16,(200+g_player[snum].ps->loogiey[i]-y)<<16,z-(i<<8),256-a, + LOOGIE,0,0,2,0,0,xdim-1,ydim-1); + } +} + +static int32_t P_DisplayFistAnim(int32_t gs,int32_t snum) +{ + int32_t looking_arc,fisti,fistpal; + int32_t fistzoom, fistz; + + fisti = g_player[snum].ps->fist_incs; + if (fisti > 32) fisti = 32; + if (fisti <= 0) return 0; + + looking_arc = klabs(g_player[snum].ps->look_ang)/9; + + fistzoom = 65536L - (sintable[(512+(fisti<<6))&2047]<<2); + if (fistzoom > 90612L) + fistzoom = 90612L; + if (fistzoom < 40920) + fistzoom = 40290; + fistz = 194 + (sintable[((6+fisti)<<7)&2047]>>9); + + if (sprite[g_player[snum].ps->i].pal == 1) + fistpal = 1; + else if (g_player[snum].ps->cursectnum >= 0) + fistpal = sector[g_player[snum].ps->cursectnum].floorpal; + else fistpal = 0; + + rotatesprite( + (-fisti+222+(g_player[snum].sync->avel>>4))<<16, + (looking_arc+fistz)<<16, + fistzoom,0,FIST,gs,fistpal,2,0,0,xdim-1,ydim-1); + + return 1; +} + +#define weapsc(sc) scale(sc,ud.weaponscale,100) + +static void G_DrawTileScaled(int32_t x, int32_t y, int32_t tilenum, int32_t shade, int32_t orientation, int32_t p) +{ + int32_t a = 0; + int32_t xoff = 192; + + switch (g_currentweapon) + { + case DEVISTATOR_WEAPON: + case TRIPBOMB_WEAPON: + xoff = 160; + break; + default: + if (orientation & 262144) + { + xoff = 160; + orientation &= ~262144; + } + break; + } + + if (orientation&4) + a = 1024; + +#if defined(POLYMOST) && defined(USE_OPENGL) + if (getrendermode() >= 3 && usemodels && md_tilehasmodel(tilenum,p) > 0) + y += (224-weapsc(224)); +#endif + rotatesprite(weapsc((orientation&256)?x:(x<<16))+((xoff-weapsc(xoff))<<16), + weapsc((orientation&256)?y:(y<<16))+((200-weapsc(200))<<16), + weapsc(65536L),a,tilenum,shade,p,2|orientation,windowx1,windowy1,windowx2,windowy2); +} + +static void G_DrawWeaponTile(int32_t x, int32_t y, int32_t tilenum, int32_t shade, int32_t orientation, int32_t p) +{ + if (!ud.drawweapon) + return; + else if (ud.drawweapon == 1) + G_DrawTileScaled(x,y,tilenum,shade,orientation,p); + else if (ud.drawweapon == 2) + { + switch (g_currentweapon) + { + case PISTOL_WEAPON: + case CHAINGUN_WEAPON: + case RPG_WEAPON: + case FREEZE_WEAPON: + case SHRINKER_WEAPON: + case GROW_WEAPON: + case DEVISTATOR_WEAPON: + case TRIPBOMB_WEAPON: + case HANDREMOTE_WEAPON: + case HANDBOMB_WEAPON: + case SHOTGUN_WEAPON: + rotatesprite(160<<16,(180+(g_player[screenpeek].ps->weapon_pos*g_player[screenpeek].ps->weapon_pos))<<16,scale(65536,ud.statusbarscale,100),0,g_currentweapon==GROW_WEAPON?GROWSPRITEICON:WeaponPickupSprites[g_currentweapon],0,0,2,windowx1,windowy1,windowx2,windowy2); + break; + } + } +} + +static int32_t P_DisplayKneeAnim(int32_t gs,int32_t snum) +{ + static int8_t knee_y[] = {0,-8,-16,-32,-64,-84,-108,-108,-108,-72,-32,-8}; + int32_t looking_arc, pal = g_player[snum].ps->palookup; + + if (g_player[snum].ps->knee_incs > 11 || g_player[snum].ps->knee_incs == 0 || sprite[g_player[snum].ps->i].extra <= 0) return 0; + + looking_arc = knee_y[g_player[snum].ps->knee_incs] + klabs(g_player[snum].ps->look_ang)/9; + + looking_arc -= (g_player[snum].ps->hard_landing<<3); + + if (sprite[g_player[snum].ps->i].pal == 1) + pal = 1; + else if (g_player[snum].ps->cursectnum >= 0) + { + pal = sector[g_player[snum].ps->cursectnum].floorpal; + if (pal == 0) + pal = g_player[snum].ps->palookup; + } + + G_DrawTileScaled(105+(g_player[snum].sync->avel>>4)-(g_player[snum].ps->look_ang>>1)+(knee_y[g_player[snum].ps->knee_incs]>>2),looking_arc+280-((g_player[snum].ps->horiz-g_player[snum].ps->horizoff)>>4),KNEE,gs,4+262144,pal); + + return 1; +} + +static int32_t P_DisplayKnuckleAnim(int32_t gs,int32_t snum) +{ + static char knuckle_frames[] = {0,1,2,2,3,3,3,2,2,1,0}; + int32_t looking_arc, pal = 0; + + if (g_player[snum].ps->knuckle_incs == 0 || sprite[g_player[snum].ps->i].extra <= 0) return 0; + + looking_arc = klabs(g_player[snum].ps->look_ang)/9; + + looking_arc -= (g_player[snum].ps->hard_landing<<3); + + if (sprite[g_player[snum].ps->i].pal == 1) + pal = 1; + else if (g_player[snum].ps->cursectnum >= 0) + pal = sector[g_player[snum].ps->cursectnum].floorpal; + + G_DrawTileScaled(160+(g_player[snum].sync->avel>>4)-(g_player[snum].ps->look_ang>>1),looking_arc+180-((g_player[snum].ps->horiz-g_player[snum].ps->horizoff)>>4),CRACKKNUCKLES+knuckle_frames[g_player[snum].ps->knuckle_incs>>1],gs,4+262144,pal); + + return 1; +} + +int32_t lastvisinc; + +void P_FireWeapon(DukePlayer_t *p) +{ + int32_t i, snum = sprite[p->i].yvel; + + Gv_SetVar(g_iReturnVarID,0,p->i,snum); + X_OnEvent(EVENT_DOFIRE, p->i, snum, -1); + + if (Gv_GetVar(g_iReturnVarID,p->i,snum) == 0) + { + if (p->weapon_pos != 0) return; + + if (aplWeaponWorksLike[p->curr_weapon][snum]!=KNEE_WEAPON) + p->ammo_amount[p->curr_weapon]--; + + if (aplWeaponFireSound[p->curr_weapon][snum]) + { + A_PlaySound(aplWeaponFireSound[p->curr_weapon][snum],p->i); + } + + Gv_SetVar(g_iWeaponVarID,p->curr_weapon,p->i,snum); + Gv_SetVar(g_iWorksLikeVarID,aplWeaponWorksLike[p->curr_weapon][snum], p->i, snum); +// OSD_Printf("doing %d %d %d\n",aplWeaponShoots[p->curr_weapon][snum],p->curr_weapon,snum); + A_Shoot(p->i,aplWeaponShoots[p->curr_weapon][snum]); + for (i=1;icurr_weapon][snum];i++) + { + if (aplWeaponFlags[p->curr_weapon][snum] & WEAPON_FIREEVERYOTHER) + { + // this makes the projectiles fire on a delay from player code + ActorExtra[p->i].temp_data[7] = (aplWeaponShotsPerBurst[p->curr_weapon][snum])<<1; + } + else + { + if (aplWeaponFlags[p->curr_weapon][snum] & WEAPON_AMMOPERSHOT) + { + if (p->ammo_amount[p->curr_weapon] > 0) + p->ammo_amount[p->curr_weapon]--; + else break; + } + A_Shoot(p->i,aplWeaponShoots[p->curr_weapon][snum]); + } + } + + if (!(aplWeaponFlags[p->curr_weapon][snum] & WEAPON_NOVISIBLE)) + { + lastvisinc = totalclock+32; + p->visibility = 0; + } + + /* if( //!(aplWeaponFlags[p->curr_weapon][snum] & WEAPON_CHECKATRELOAD) && + aplWeaponReload[p->curr_weapon][snum] > aplWeaponTotalTime[p->curr_weapon][snum] + && p->ammo_amount[p->curr_weapon] > 0 + && (aplWeaponClip[p->curr_weapon][snum]) + && ((p->ammo_amount[p->curr_weapon]%(aplWeaponClip[p->curr_weapon][snum]))==0)) + { + p->kickback_pic=aplWeaponTotalTime[p->curr_weapon][snum]; + } */ + } +} + +void P_DoWeaponSpawn(DukePlayer_t *p) +{ + int32_t j, snum = sprite[p->i].yvel; + + if (!aplWeaponSpawn[p->curr_weapon][snum]) + return; + + j = A_Spawn(p->i, aplWeaponSpawn[p->curr_weapon][snum]); + + if ((aplWeaponFlags[p->curr_weapon][snum] & WEAPON_SPAWNTYPE3)) + { + // like chaingun shells + sprite[j].ang += 1024; + sprite[j].ang &= 2047; + sprite[j].xvel += 32; + sprite[j].z += (3<<8); + } + + A_SetSprite(j,CLIPMASK0); + +} + +void P_DisplayScubaMask(int32_t snum) +{ + int32_t p; + + if (sprite[g_player[snum].ps->i].pal == 1) + p = 1; + else if (g_player[snum].ps->cursectnum >= 0) + p = sector[g_player[snum].ps->cursectnum].floorpal; + else p = 0; + + if (g_player[snum].ps->scuba_on) + { + rotatesprite(43<<16,(200-tilesizy[SCUBAMASK])<<16,65536,0,SCUBAMASK,0,p,2+16,windowx1,windowy1,windowx2,windowy2); + rotatesprite((320-43)<<16,(200-tilesizy[SCUBAMASK])<<16,65536,1024,SCUBAMASK,0,p,2+4+16,windowx1,windowy1,windowx2,windowy2); + } +} + +static int32_t P_DisplayTipAnim(int32_t gs,int32_t snum) +{ + int32_t p,looking_arc; + static int16_t tip_y[] = {0,-8,-16,-32,-64,-84,-108,-108,-108,-108,-108,-108,-108,-108,-108,-108,-96,-72,-64,-32,-16}; + + if (g_player[snum].ps->tipincs == 0) return 0; + + looking_arc = klabs(g_player[snum].ps->look_ang)/9; + looking_arc -= (g_player[snum].ps->hard_landing<<3); + + if (sprite[g_player[snum].ps->i].pal == 1) + p = 1; + else + p = sector[g_player[snum].ps->cursectnum].floorpal; + + /* if(g_player[snum].ps->access_spritenum >= 0) + p = sprite[g_player[snum].ps->access_spritenum].pal; + else + p = wall[g_player[snum].ps->access_wallnum].pal; + */ + G_DrawTileScaled(170+(g_player[snum].sync->avel>>4)-(g_player[snum].ps->look_ang>>1), + (tip_y[g_player[snum].ps->tipincs]>>1)+looking_arc+240-((g_player[snum].ps->horiz-g_player[snum].ps->horizoff)>>4),TIP+((26-g_player[snum].ps->tipincs)>>4),gs,262144,p); + + return 1; +} + +static int32_t P_DisplayAccessAnim(int32_t gs,int32_t snum) +{ + static int16_t access_y[] = {0,-8,-16,-32,-64,-84,-108,-108,-108,-108,-108,-108,-108,-108,-108,-108,-96,-72,-64,-32,-16}; + int32_t looking_arc; + int32_t p; + + if (g_player[snum].ps->access_incs == 0 || sprite[g_player[snum].ps->i].extra <= 0) return 0; + + looking_arc = access_y[g_player[snum].ps->access_incs] + klabs(g_player[snum].ps->look_ang)/9; + looking_arc -= (g_player[snum].ps->hard_landing<<3); + + if (g_player[snum].ps->access_spritenum >= 0) + p = sprite[g_player[snum].ps->access_spritenum].pal; + else p = 0; + // else + // p = wall[g_player[snum].ps->access_wallnum].pal; + + if ((g_player[snum].ps->access_incs-3) > 0 && (g_player[snum].ps->access_incs-3)>>3) + G_DrawTileScaled(170+(g_player[snum].sync->avel>>4)-(g_player[snum].ps->look_ang>>1)+(access_y[g_player[snum].ps->access_incs]>>2),looking_arc+266-((g_player[snum].ps->horiz-g_player[snum].ps->horizoff)>>4),HANDHOLDINGLASER+(g_player[snum].ps->access_incs>>3),gs,262144,p); + else + G_DrawTileScaled(170+(g_player[snum].sync->avel>>4)-(g_player[snum].ps->look_ang>>1)+(access_y[g_player[snum].ps->access_incs]>>2),looking_arc+266-((g_player[snum].ps->horiz-g_player[snum].ps->horizoff)>>4),HANDHOLDINGACCESS,gs,4+262144,p); + + return 1; +} + + +static int32_t fistsign; + +void P_DisplayWeapon(int32_t snum) +{ + int32_t gun_pos, looking_arc, cw; + int32_t weapon_xoffset, i, j; + int32_t o = 0,pal = 0; + DukePlayer_t *p = g_player[snum].ps; + int16_t *kb = &p->kickback_pic; + int32_t gs; + + looking_arc = klabs(p->look_ang)/9; + + gs = sprite[p->i].shade; + if (gs > 24) gs = 24; + + if (p->newowner >= 0 || ud.camerasprite >= 0 || p->over_shoulder_on > 0 || (sprite[p->i].pal != 1 && sprite[p->i].extra <= 0) || P_DisplayFistAnim(gs,snum) || P_DisplayKnuckleAnim(gs,snum) || P_DisplayTipAnim(gs,snum) || P_DisplayAccessAnim(gs,snum)) + return; + + P_DisplayKneeAnim(gs,snum); + + gun_pos = 80-(p->weapon_pos*p->weapon_pos); + + weapon_xoffset = (160)-90; + + if (ud.weaponsway) + { + weapon_xoffset -= (sintable[((p->weapon_sway>>1)+512)&2047]/(1024+512)); + + if (sprite[p->i].xrepeat < 32) + gun_pos -= klabs(sintable[(p->weapon_sway<<2)&2047]>>9); + else gun_pos -= klabs(sintable[(p->weapon_sway>>1)&2047]>>10); + } + else gun_pos -= 16; + + weapon_xoffset -= 58 + p->weapon_ang; + gun_pos -= (p->hard_landing<<3); + + if (p->last_weapon >= 0) + cw = aplWeaponWorksLike[p->last_weapon][snum]; + else + cw = aplWeaponWorksLike[p->curr_weapon][snum]; + + g_gun_pos=gun_pos; + g_looking_arc=looking_arc; + g_currentweapon=cw; + g_weapon_xoffset=weapon_xoffset; + g_gs=gs; + g_kb=*kb; + g_looking_angSR1=p->look_ang>>1; + + Gv_SetVar(g_iReturnVarID,0,p->i,snum); + X_OnEvent(EVENT_DISPLAYWEAPON, p->i, screenpeek, -1); + + if (Gv_GetVar(g_iReturnVarID,p->i,snum) == 0) + { + j = 14-p->quick_kick; + if (j != 14 || p->last_quick_kick) + { + if (sprite[p->i].pal == 1) + pal = 1; + else + { + if (p->cursectnum >= 0) + pal = sector[p->cursectnum].floorpal; + if (pal == 0) + pal = p->palookup; + } + + guniqhudid = 100; + if (j < 6 || j > 12) + G_DrawTileScaled(weapon_xoffset+80-(p->look_ang>>1), + looking_arc+250-gun_pos,KNEE,gs,o|4|262144,pal); + else G_DrawTileScaled(weapon_xoffset+160-16-(p->look_ang>>1), + looking_arc+214-gun_pos,KNEE+1,gs,o|4|262144,pal); + guniqhudid = 0; + } + + if (sprite[p->i].xrepeat < 40) + { + if (p->jetpack_on == 0) + { + i = sprite[p->i].xvel; + looking_arc += 32-(i>>1); + fistsign += i>>1; + } + cw = weapon_xoffset; + weapon_xoffset += sintable[(fistsign)&2047]>>10; + G_DrawTile(weapon_xoffset+250-(p->look_ang>>1), + looking_arc+258-(klabs(sintable[(fistsign)&2047]>>8)), + FIST,gs,o); + weapon_xoffset = cw; + weapon_xoffset -= sintable[(fistsign)&2047]>>10; + G_DrawTile(weapon_xoffset+40-(p->look_ang>>1), + looking_arc+200+(klabs(sintable[(fistsign)&2047]>>8)), + FIST,gs,o|4); + } + else switch (cw) + + { + + case KNEE_WEAPON: + + Gv_SetVar(g_iReturnVarID,0,g_player[screenpeek].ps->i,screenpeek); + X_OnEvent(EVENT_DRAWWEAPON,g_player[screenpeek].ps->i,screenpeek, -1); + if (Gv_GetVar(g_iReturnVarID,g_player[screenpeek].ps->i,screenpeek) == 0) + { + if ((*kb) > 0) + { + if (sprite[p->i].pal == 1) + pal = 1; + else + { + if (p->cursectnum >= 0) + pal = sector[p->cursectnum].floorpal; + if (pal == 0) + pal = p->palookup; + } + guniqhudid = cw; + if ((*kb) < 5 || (*kb) > 9) + G_DrawTileScaled(weapon_xoffset+220-(p->look_ang>>1), + looking_arc+250-gun_pos,KNEE,gs,o,pal); + else + G_DrawTileScaled(weapon_xoffset+160-(p->look_ang>>1), + looking_arc+214-gun_pos,KNEE+1,gs,o,pal); + guniqhudid = 0; + } + } + break; + + case TRIPBOMB_WEAPON: + + Gv_SetVar(g_iReturnVarID,0,g_player[screenpeek].ps->i,screenpeek); + X_OnEvent(EVENT_DRAWWEAPON,g_player[screenpeek].ps->i,screenpeek, -1); + if (Gv_GetVar(g_iReturnVarID,g_player[screenpeek].ps->i,screenpeek) == 0) + { + if (sprite[p->i].pal == 1) + pal = 1; + else if (p->cursectnum >= 0) + pal = sector[p->cursectnum].floorpal; + else pal = 0; + + weapon_xoffset += 8; + gun_pos -= 10; + + if ((*kb) > 6) + looking_arc += ((*kb)<<3); + else if ((*kb) < 4) + { + guniqhudid = cw<<2; + G_DrawWeaponTile(weapon_xoffset+142-(p->look_ang>>1), + looking_arc+234-gun_pos,HANDHOLDINGLASER+3,gs,o,pal); + } + + guniqhudid = cw; + G_DrawWeaponTile(weapon_xoffset+130-(p->look_ang>>1), + looking_arc+249-gun_pos, + HANDHOLDINGLASER+((*kb)>>2),gs,o,pal); + + guniqhudid = cw<<1; + G_DrawWeaponTile(weapon_xoffset+152-(p->look_ang>>1), + looking_arc+249-gun_pos, + HANDHOLDINGLASER+((*kb)>>2),gs,o|4,pal); + guniqhudid = 0; + } + break; + + case RPG_WEAPON: + + Gv_SetVar(g_iReturnVarID,0,g_player[screenpeek].ps->i,screenpeek); + X_OnEvent(EVENT_DRAWWEAPON,g_player[screenpeek].ps->i,screenpeek, -1); + if (Gv_GetVar(g_iReturnVarID,g_player[screenpeek].ps->i,screenpeek) == 0) + { + if (sprite[p->i].pal == 1) + pal = 1; + else if (p->cursectnum >= 0) + pal = sector[p->cursectnum].floorpal; + else pal = 0; + + weapon_xoffset -= sintable[(768+((*kb)<<7))&2047]>>11; + gun_pos += sintable[(768+((*kb)<<7))&2047]>>11; + + if (*kb > 0) + { + if (*kb < 8) + { + G_DrawWeaponTile(weapon_xoffset+164,(looking_arc<<1)+176-gun_pos, + RPGGUN+((*kb)>>1),gs,o,pal); + } + } + + G_DrawWeaponTile(weapon_xoffset+164,(looking_arc<<1)+176-gun_pos, + RPGGUN,gs,o,pal); + } + break; + + case SHOTGUN_WEAPON: + + Gv_SetVar(g_iReturnVarID,0,g_player[screenpeek].ps->i,screenpeek); + X_OnEvent(EVENT_DRAWWEAPON,g_player[screenpeek].ps->i,screenpeek, -1); + if (Gv_GetVar(g_iReturnVarID,g_player[screenpeek].ps->i,screenpeek) == 0) + { + if (sprite[p->i].pal == 1) + pal = 1; + else if (p->cursectnum >= 0) + pal = sector[p->cursectnum].floorpal; + else pal = 0; + + + weapon_xoffset -= 8; + + switch (*kb) + { + case 1: + case 2: + guniqhudid = cw<<1; + G_DrawWeaponTile(weapon_xoffset+168-(p->look_ang>>1),looking_arc+201-gun_pos, + SHOTGUN+2,-128,o,pal); + case 0: + case 6: + case 7: + case 8: + guniqhudid = cw; + G_DrawWeaponTile(weapon_xoffset+146-(p->look_ang>>1),looking_arc+202-gun_pos, + SHOTGUN,gs,o,pal); + guniqhudid = 0; + break; + case 3: + case 4: + case 5: + case 9: + case 10: + case 11: + case 12: + if (*kb > 1 && *kb < 5) + { + gun_pos -= 40; + weapon_xoffset += 20; + + guniqhudid = cw<<1; + G_DrawWeaponTile(weapon_xoffset+178-(p->look_ang>>1),looking_arc+194-gun_pos, + SHOTGUN+1+((*(kb)-1)>>1),-128,o,pal); + } + guniqhudid = cw; + G_DrawWeaponTile(weapon_xoffset+158-(p->look_ang>>1),looking_arc+220-gun_pos, + SHOTGUN+3,gs,o,pal); + guniqhudid = 0; + break; + case 13: + case 14: + case 15: + guniqhudid = cw; + G_DrawWeaponTile(32+weapon_xoffset+166-(p->look_ang>>1),looking_arc+210-gun_pos, + SHOTGUN+4,gs,o,pal); + guniqhudid = 0; + break; + case 16: + case 17: + case 18: + case 19: + guniqhudid = cw; + G_DrawWeaponTile(64+weapon_xoffset+170-(p->look_ang>>1),looking_arc+196-gun_pos, + SHOTGUN+5,gs,o,pal); + guniqhudid = 0; + break; + case 20: + case 21: + case 22: + case 23: + guniqhudid = cw; + G_DrawWeaponTile(64+weapon_xoffset+176-(p->look_ang>>1),looking_arc+196-gun_pos, + SHOTGUN+6,gs,o,pal); + guniqhudid = 0; + break; + case 24: + case 25: + case 26: + case 27: + guniqhudid = cw; + G_DrawWeaponTile(64+weapon_xoffset+170-(p->look_ang>>1),looking_arc+196-gun_pos, + SHOTGUN+5,gs,o,pal); + guniqhudid = 0; + break; + case 28: + case 29: + case 30: + guniqhudid = cw; + G_DrawWeaponTile(32+weapon_xoffset+156-(p->look_ang>>1),looking_arc+206-gun_pos, + SHOTGUN+4,gs,o,pal); + guniqhudid = 0; + break; + } + } + break; + + + case CHAINGUN_WEAPON: + + Gv_SetVar(g_iReturnVarID,0,g_player[screenpeek].ps->i,screenpeek); + X_OnEvent(EVENT_DRAWWEAPON,g_player[screenpeek].ps->i,screenpeek, -1); + if (Gv_GetVar(g_iReturnVarID,g_player[screenpeek].ps->i,screenpeek) == 0) + { + if (sprite[p->i].pal == 1) + pal = 1; + else if (p->cursectnum >= 0) + pal = sector[p->cursectnum].floorpal; + else pal = 0; + + if (*kb > 0) + gun_pos -= sintable[(*kb)<<7]>>12; + + if (*kb > 0 && sprite[p->i].pal != 1) weapon_xoffset += 1-(rand()&3); + + G_DrawWeaponTile(weapon_xoffset+168-(p->look_ang>>1),looking_arc+260-gun_pos, + CHAINGUN,gs,o,pal); + switch (*kb) + { + case 0: + G_DrawWeaponTile(weapon_xoffset+178-(p->look_ang>>1),looking_arc+233-gun_pos, + CHAINGUN+1,gs,o,pal); + break; + default: + if (*kb > *aplWeaponFireDelay[CHAINGUN_WEAPON] && *kb < *aplWeaponTotalTime[CHAINGUN_WEAPON]) + { + i = 0; + if (sprite[p->i].pal != 1) i = rand()&7; + G_DrawWeaponTile(i+weapon_xoffset-4+140-(p->look_ang>>1),i+looking_arc-((*kb)>>1)+208-gun_pos, + CHAINGUN+5+((*kb-4)/5),gs,o,pal); + if (sprite[p->i].pal != 1) i = rand()&7; + G_DrawWeaponTile(i+weapon_xoffset-4+184-(p->look_ang>>1),i+looking_arc-((*kb)>>1)+208-gun_pos, + CHAINGUN+5+((*kb-4)/5),gs,o,pal); + } + if (*kb < *aplWeaponTotalTime[CHAINGUN_WEAPON]-4) + { + i = rand()&7; + G_DrawWeaponTile(i+weapon_xoffset-4+162-(p->look_ang>>1),i+looking_arc-((*kb)>>1)+208-gun_pos, + CHAINGUN+5+((*kb-2)/5),gs,o,pal); + G_DrawWeaponTile(weapon_xoffset+178-(p->look_ang>>1),looking_arc+233-gun_pos, + CHAINGUN+1+((*kb)>>1),gs,o,pal); + } + else G_DrawWeaponTile(weapon_xoffset+178-(p->look_ang>>1),looking_arc+233-gun_pos, + CHAINGUN+1,gs,o,pal); + break; + } + } + break; + + case PISTOL_WEAPON: + + Gv_SetVar(g_iReturnVarID,0,g_player[screenpeek].ps->i,screenpeek); + X_OnEvent(EVENT_DRAWWEAPON,g_player[screenpeek].ps->i,screenpeek, -1); + if (Gv_GetVar(g_iReturnVarID,g_player[screenpeek].ps->i,screenpeek) == 0) + { + if (sprite[p->i].pal == 1) + pal = 1; + else if (p->cursectnum >= 0) + pal = sector[p->cursectnum].floorpal; + else pal = 0; + + if ((*kb) < *aplWeaponTotalTime[PISTOL_WEAPON]+1) + { + static int16_t kb_frames[] = {0,1,2}; + int32_t l = 195-12+weapon_xoffset; + + if ((*kb) == *aplWeaponFireDelay[PISTOL_WEAPON]) + l -= 3; + + guniqhudid = cw; + G_DrawWeaponTile((l-(p->look_ang>>1)),(looking_arc+244-gun_pos),FIRSTGUN+kb_frames[*kb>2?0:*kb],gs,2,pal); + guniqhudid = 0; + } + else + { + + if ((*kb) < *aplWeaponReload[PISTOL_WEAPON]-17) + { + guniqhudid = cw; + G_DrawWeaponTile(194-(p->look_ang>>1),looking_arc+230-gun_pos,FIRSTGUN+4,gs,o,pal); + guniqhudid = 0; + } + else if ((*kb) < *aplWeaponReload[PISTOL_WEAPON]-12) + { + G_DrawWeaponTile(244-((*kb)<<3)-(p->look_ang>>1),looking_arc+130-gun_pos+((*kb)<<4),FIRSTGUN+6,gs,o,pal); + guniqhudid = cw; + G_DrawWeaponTile(224-(p->look_ang>>1),looking_arc+220-gun_pos,FIRSTGUN+5,gs,o,pal); + guniqhudid = 0; + } + else if ((*kb) < *aplWeaponReload[PISTOL_WEAPON]-7) + { + G_DrawWeaponTile(124+((*kb)<<1)-(p->look_ang>>1),looking_arc+430-gun_pos-((*kb)<<3),FIRSTGUN+6,gs,o,pal); + guniqhudid = cw; + G_DrawWeaponTile(224-(p->look_ang>>1),looking_arc+220-gun_pos,FIRSTGUN+5,gs,o,pal); + guniqhudid = 0; + } + + else if ((*kb) < *aplWeaponReload[PISTOL_WEAPON]-4) + { + G_DrawWeaponTile(184-(p->look_ang>>1),looking_arc+235-gun_pos,FIRSTGUN+8,gs,o,pal); + guniqhudid = cw; + G_DrawWeaponTile(224-(p->look_ang>>1),looking_arc+210-gun_pos,FIRSTGUN+5,gs,o,pal); + guniqhudid = 0; + } + else if ((*kb) < *aplWeaponReload[PISTOL_WEAPON]-2) + { + G_DrawWeaponTile(164-(p->look_ang>>1),looking_arc+245-gun_pos,FIRSTGUN+8,gs,o,pal); + guniqhudid = cw; + G_DrawWeaponTile(224-(p->look_ang>>1),looking_arc+220-gun_pos,FIRSTGUN+5,gs,o,pal); + guniqhudid = 0; + } + else if ((*kb) < *aplWeaponReload[PISTOL_WEAPON]) + { + guniqhudid = cw; + G_DrawWeaponTile(194-(p->look_ang>>1),looking_arc+235-gun_pos,FIRSTGUN+5,gs,o,pal); + guniqhudid = 0; + } + + } + } + + break; + case HANDBOMB_WEAPON: + { + Gv_SetVar(g_iReturnVarID,0,g_player[screenpeek].ps->i,screenpeek); + X_OnEvent(EVENT_DRAWWEAPON,g_player[screenpeek].ps->i,screenpeek, -1); + if (Gv_GetVar(g_iReturnVarID,g_player[screenpeek].ps->i,screenpeek) == 0) + { + if (sprite[p->i].pal == 1) + pal = 1; + else if (p->cursectnum >= 0) + pal = sector[p->cursectnum].floorpal; + else pal = 0; + guniqhudid = cw; + if ((*kb)) + { + if ((*kb) < (*aplWeaponTotalTime[p->curr_weapon])) + { + + static char throw_frames[] + = {0,0,0,0,0,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2}; + + if ((*kb) < 7) + gun_pos -= 10*(*kb); //D + else if ((*kb) < 12) + gun_pos += 20*((*kb)-10); //U + else if ((*kb) < 20) + gun_pos -= 9*((*kb)-14); //D + + G_DrawWeaponTile(weapon_xoffset+190-(p->look_ang>>1),looking_arc+250-gun_pos,HANDTHROW+throw_frames[(*kb)],gs,o,pal); + } + } + else + G_DrawWeaponTile(weapon_xoffset+190-(p->look_ang>>1),looking_arc+260-gun_pos,HANDTHROW,gs,o,pal); + guniqhudid = 0; + } + } + break; + + case HANDREMOTE_WEAPON: + { + Gv_SetVar(g_iReturnVarID,0,g_player[screenpeek].ps->i,screenpeek); + X_OnEvent(EVENT_DRAWWEAPON,g_player[screenpeek].ps->i,screenpeek, -1); + if (Gv_GetVar(g_iReturnVarID,g_player[screenpeek].ps->i,screenpeek) == 0) + { + static char remote_frames[] = {0,1,1,2,1,1,0,0,0,0,0}; + if (sprite[p->i].pal == 1) + pal = 1; + else if (p->cursectnum >= 0) + pal = sector[p->cursectnum].floorpal; + else pal = 0; + + weapon_xoffset = -48; + guniqhudid = cw; + if ((*kb)) + G_DrawWeaponTile(weapon_xoffset+150-(p->look_ang>>1),looking_arc+258-gun_pos,HANDREMOTE+remote_frames[(*kb)],gs,o,pal); + else + G_DrawWeaponTile(weapon_xoffset+150-(p->look_ang>>1),looking_arc+258-gun_pos,HANDREMOTE,gs,o,pal); + guniqhudid = 0; + } + } + break; + + case DEVISTATOR_WEAPON: + + Gv_SetVar(g_iReturnVarID,0,g_player[screenpeek].ps->i,screenpeek); + X_OnEvent(EVENT_DRAWWEAPON,g_player[screenpeek].ps->i,screenpeek, -1); + if (Gv_GetVar(g_iReturnVarID,g_player[screenpeek].ps->i,screenpeek) == 0) + { + if (sprite[p->i].pal == 1) + pal = 1; + else if (p->cursectnum >= 0) + pal = sector[p->cursectnum].floorpal; + else pal = 0; + + if ((*kb) < (*aplWeaponTotalTime[DEVISTATOR_WEAPON]+1) && (*kb) > 0) + { + static char cycloidy[] = {0,4,12,24,12,4,0}; + + i = ksgn((*kb)>>2); + + if (p->hbomb_hold_delay) + { + guniqhudid = cw; + G_DrawWeaponTile((cycloidy[*kb]>>1)+weapon_xoffset+268-(p->look_ang>>1),cycloidy[*kb]+looking_arc+238-gun_pos,DEVISTATOR+i,-32,o,pal); + guniqhudid = cw<<1; + G_DrawWeaponTile(weapon_xoffset+30-(p->look_ang>>1),looking_arc+240-gun_pos,DEVISTATOR,gs,o|4,pal); + guniqhudid = 0; + } + else + { + guniqhudid = cw<<1; + G_DrawWeaponTile(-(cycloidy[*kb]>>1)+weapon_xoffset+30-(p->look_ang>>1),cycloidy[*kb]+looking_arc+240-gun_pos,DEVISTATOR+i,-32,o|4,pal); + guniqhudid = cw; + G_DrawWeaponTile(weapon_xoffset+268-(p->look_ang>>1),looking_arc+238-gun_pos,DEVISTATOR,gs,o,pal); + guniqhudid = 0; + } + } + else + { + guniqhudid = cw; + G_DrawWeaponTile(weapon_xoffset+268-(p->look_ang>>1),looking_arc+238-gun_pos,DEVISTATOR,gs,o,pal); + guniqhudid = cw<<1; + G_DrawWeaponTile(weapon_xoffset+30-(p->look_ang>>1),looking_arc+240-gun_pos,DEVISTATOR,gs,o|4,pal); + guniqhudid = 0; + } + } + break; + + case FREEZE_WEAPON: + + Gv_SetVar(g_iReturnVarID,0,g_player[screenpeek].ps->i,screenpeek); + X_OnEvent(EVENT_DRAWWEAPON,g_player[screenpeek].ps->i,screenpeek, -1); + if (Gv_GetVar(g_iReturnVarID,g_player[screenpeek].ps->i,screenpeek) == 0) + { + if (sprite[p->i].pal == 1) + pal = 1; + else if (p->cursectnum >= 0) + pal = sector[p->cursectnum].floorpal; + else pal = 0; + if ((*kb) < (aplWeaponTotalTime[p->curr_weapon][snum]+1) && (*kb) > 0) + { + static char cat_frames[] = { 0,0,1,1,2,2 }; + + if (sprite[p->i].pal != 1) + { + weapon_xoffset += rand()&3; + looking_arc += rand()&3; + } + gun_pos -= 16; + guniqhudid = 0; + G_DrawWeaponTile(weapon_xoffset+210-(p->look_ang>>1),looking_arc+261-gun_pos,FREEZE+2,-32,o,pal); + guniqhudid = cw; + G_DrawWeaponTile(weapon_xoffset+210-(p->look_ang>>1),looking_arc+235-gun_pos,FREEZE+3+cat_frames[*kb%6],-32,o,pal); + guniqhudid = 0; + } + else + { + guniqhudid = cw; + G_DrawWeaponTile(weapon_xoffset+210-(p->look_ang>>1),looking_arc+261-gun_pos,FREEZE,gs,o,pal); + guniqhudid = 0; + } + } + break; + + case GROW_WEAPON: + + Gv_SetVar(g_iReturnVarID,0,g_player[screenpeek].ps->i,screenpeek); + X_OnEvent(EVENT_DRAWWEAPON,g_player[screenpeek].ps->i,screenpeek, -1); + if (Gv_GetVar(g_iReturnVarID,g_player[screenpeek].ps->i,screenpeek) == 0) + { + weapon_xoffset += 28; + looking_arc += 18; + if (sprite[p->i].pal == 1) + pal = 1; + else if (p->cursectnum >= 0) + pal = sector[p->cursectnum].floorpal; + else pal = 0; + { + if ((*kb) < aplWeaponTotalTime[p->curr_weapon][snum] && (*kb) > 0) + { + if (sprite[p->i].pal != 1) + { + weapon_xoffset += rand()&3; + gun_pos += (rand()&3); + } + + guniqhudid = cw<<1; + G_DrawWeaponTile(weapon_xoffset+184-(p->look_ang>>1), + looking_arc+240-gun_pos,SHRINKER+3+((*kb)&3),-32, + o,2); + + guniqhudid = cw; + G_DrawWeaponTile(weapon_xoffset+188-(p->look_ang>>1), + looking_arc+240-gun_pos,SHRINKER-1,gs,o,pal); + guniqhudid = 0; + } + else + { + guniqhudid = cw<<1; + G_DrawWeaponTile(weapon_xoffset+184-(p->look_ang>>1), + looking_arc+240-gun_pos,SHRINKER+2, + 16-(sintable[p->random_club_frame&2047]>>10), + o,2); + + guniqhudid = cw; + G_DrawWeaponTile(weapon_xoffset+188-(p->look_ang>>1), + looking_arc+240-gun_pos,SHRINKER-2,gs,o,pal); + guniqhudid = 0; + } + } + } + break; + + case SHRINKER_WEAPON: + + Gv_SetVar(g_iReturnVarID,0,g_player[screenpeek].ps->i,screenpeek); + X_OnEvent(EVENT_DRAWWEAPON,g_player[screenpeek].ps->i,screenpeek, -1); + if (Gv_GetVar(g_iReturnVarID,g_player[screenpeek].ps->i,screenpeek) == 0) + { + weapon_xoffset += 28; + looking_arc += 18; + if (sprite[p->i].pal == 1) + pal = 1; + else if (p->cursectnum >= 0) + pal = sector[p->cursectnum].floorpal; + else pal = 0; + if (((*kb) > 0) && ((*kb) < aplWeaponTotalTime[p->curr_weapon][snum])) + { + if (sprite[p->i].pal != 1) + { + weapon_xoffset += rand()&3; + gun_pos += (rand()&3); + } + guniqhudid = cw<<1; + G_DrawWeaponTile(weapon_xoffset+184-(p->look_ang>>1), + looking_arc+240-gun_pos,SHRINKER+3+((*kb)&3),-32, + o,0); + guniqhudid = cw; + G_DrawWeaponTile(weapon_xoffset+188-(p->look_ang>>1), + looking_arc+240-gun_pos,SHRINKER+1,gs,o,pal); + guniqhudid = 0; + + } + else + { + guniqhudid = cw<<1; + G_DrawWeaponTile(weapon_xoffset+184-(p->look_ang>>1), + looking_arc+240-gun_pos,SHRINKER+2, + 16-(sintable[p->random_club_frame&2047]>>10), + o,0); + guniqhudid = cw; + G_DrawWeaponTile(weapon_xoffset+188-(p->look_ang>>1), + looking_arc+240-gun_pos,SHRINKER,gs,o,pal); + guniqhudid = 0; + } + } + break; + + } + } + P_DisplaySpitAnim(snum); + +} + +#define TURBOTURNTIME (TICRATE/8) // 7 +#define NORMALTURN 15 +#define PREAMBLETURN 5 +#define NORMALKEYMOVE 40 +#define MAXVEL ((NORMALKEYMOVE*2)+10) +#define MAXSVEL ((NORMALKEYMOVE*2)+10) +#define MAXANGVEL 127 +#define MAXHORIZ 127 + +int32_t g_myAimMode = 0, g_myAimStat = 0, g_oldAimStat = 0; +int32 mouseyaxismode = -1; +int32_t jump_input = 0; + +void getinput(int32_t snum) +{ + int32_t j, daang; + static ControlInfo info[2]; + int32 tics; + boolean running; + int32 turnamount; + int32 keymove; + int32 momx = 0,momy = 0; + DukePlayer_t *p = g_player[snum].ps; + + if ((p->gm&MODE_MENU) || (p->gm&MODE_TYPE) || (ud.pause_on && !KB_KeyPressed(sc_Pause)) || (numplayers > 1 && totalclock < 10)) + // HACK: kill getinput() for the first 10 tics of a new map in multi + { + if (!(p->gm&MODE_MENU)) + CONTROL_GetInput(&info[0]); + memset(&info[1], 0, sizeof(info[1])); + loc.fvel = vel = 0; + loc.svel = svel = 0; + loc.avel = angvel = 0; + loc.horz = horiz = 0; + loc.bits = (((int32_t)g_gameQuit)<team)<<6; + loc.extbits |= (1<<7); + return; + } + + if (ud.mouseaiming) + g_myAimMode = BUTTON(gamefunc_Mouse_Aiming); + else + { + g_oldAimStat = g_myAimStat; + g_myAimStat = BUTTON(gamefunc_Mouse_Aiming); + if (g_myAimStat > g_oldAimStat) + { + g_myAimMode ^= 1; + P_DoQuote(44+g_myAimMode,p); + } + } + + { + int32 i; + if (g_myAimMode) i = analog_lookingupanddown; + else i = ud.config.MouseAnalogueAxes[1]; + + if (i != mouseyaxismode) + { + CONTROL_MapAnalogAxis(1, i, controldevice_mouse); + mouseyaxismode = i; + } + } + + CONTROL_GetInput(&info[0]); + + if (ud.config.MouseDeadZone) + { + if (info[0].dpitch > 0) + { + if (info[0].dpitch > ud.config.MouseDeadZone) + info[0].dpitch -= ud.config.MouseDeadZone; + else info[0].dpitch = 0; + } + else if (info[0].dpitch < 0) + { + if (info[0].dpitch < -ud.config.MouseDeadZone) + info[0].dpitch += ud.config.MouseDeadZone; + else info[0].dpitch = 0; + } + if (info[0].dyaw > 0) + { + if (info[0].dyaw > ud.config.MouseDeadZone) + info[0].dyaw -= ud.config.MouseDeadZone; + else info[0].dyaw = 0; + } + else if (info[0].dyaw < 0) + { + if (info[0].dyaw < -ud.config.MouseDeadZone) + info[0].dyaw += ud.config.MouseDeadZone; + else info[0].dyaw = 0; + } + } + + if (ud.config.MouseBias) + { + if (klabs(info[0].dyaw) > klabs(info[0].dpitch)) + info[0].dpitch /= ud.config.MouseBias; + else info[0].dyaw /= ud.config.MouseBias; + } + + tics = totalclock-lastcontroltime; + lastcontroltime = totalclock; + + if (multiflag == 1) + { + loc.bits = 1<on_ground) + jump_input = 4; + + loc.bits = (jump_input > 0 || BUTTON(gamefunc_Jump))<curr_weapon][snum] & WEAPON_SEMIAUTO && BUTTON(gamefunc_Fire)) + CONTROL_ClearButton(gamefunc_Fire); + + if (jump_input > 0) + jump_input--; + + j=0; + + if (BUTTON(gamefunc_Weapon_1)) + j = 1; + if (BUTTON(gamefunc_Weapon_2)) + j = 2; + if (BUTTON(gamefunc_Weapon_3)) + j = 3; + if (BUTTON(gamefunc_Weapon_4)) + j = 4; + if (BUTTON(gamefunc_Weapon_5)) + j = 5; + if (BUTTON(gamefunc_Weapon_6)) + j = 6; + if (BUTTON(gamefunc_Weapon_7)) + j = 7; + if (BUTTON(gamefunc_Weapon_8)) + j = 8; + if (BUTTON(gamefunc_Weapon_9)) + j = 9; + if (BUTTON(gamefunc_Weapon_10)) + j = 10; + if (BUTTON(gamefunc_Previous_Weapon)) + j = 11; + if (BUTTON(gamefunc_Next_Weapon)) + j = 12; + + loc.bits |= j<>6; + + if (running) + { + turnamount = NORMALTURN<<1; + keymove = NORMALKEYMOVE<<1; + } + else + { + turnamount = NORMALTURN; + keymove = NORMALKEYMOVE; + } + + if (BUTTON(gamefunc_Strafe)) + { + if (BUTTON(gamefunc_Turn_Left) && !(g_player[snum].ps->movement_lock&4)) + svel -= -keymove; + if (BUTTON(gamefunc_Turn_Right) && !(g_player[snum].ps->movement_lock&8)) + svel -= keymove; + } + else + { + if (BUTTON(gamefunc_Turn_Left)) + { + turnheldtime += tics; + if (turnheldtime>=TURBOTURNTIME) + angvel -= turnamount; + else + angvel -= PREAMBLETURN; + } + else if (BUTTON(gamefunc_Turn_Right)) + { + turnheldtime += tics; + if (turnheldtime>=TURBOTURNTIME) + angvel += turnamount; + else + angvel += PREAMBLETURN; + } + else + turnheldtime=0; + } + + if (BUTTON(gamefunc_Strafe_Left) && !(g_player[snum].ps->movement_lock&4)) + svel += keymove; + if (BUTTON(gamefunc_Strafe_Right) && !(g_player[snum].ps->movement_lock&8)) + svel += -keymove; + if (BUTTON(gamefunc_Move_Forward) && !(g_player[snum].ps->movement_lock&1)) + vel += keymove; + if (BUTTON(gamefunc_Move_Backward) && !(g_player[snum].ps->movement_lock&2)) + vel += -keymove; + + if (vel < -MAXVEL) vel = -MAXVEL; + if (vel > MAXVEL) vel = MAXVEL; + if (svel < -MAXSVEL) svel = -MAXSVEL; + if (svel > MAXSVEL) svel = MAXSVEL; + if (angvel < -MAXANGVEL) angvel = -MAXANGVEL; + if (angvel > MAXANGVEL) angvel = MAXANGVEL; + if (horiz < -MAXHORIZ) horiz = -MAXHORIZ; + if (horiz > MAXHORIZ) horiz = MAXHORIZ; + + loc.extbits = 0; + if (apScriptGameEvent[EVENT_PROCESSINPUT] || apScriptGameEvent[EVENT_MOVEFORWARD]) + loc.extbits |= BUTTON(gamefunc_Move_Forward) || (vel > 0); + if (apScriptGameEvent[EVENT_PROCESSINPUT] || apScriptGameEvent[EVENT_MOVEBACKWARD]) + loc.extbits |= (BUTTON(gamefunc_Move_Backward) || (vel < 0))<<1; + if (apScriptGameEvent[EVENT_PROCESSINPUT] || apScriptGameEvent[EVENT_STRAFELEFT]) + loc.extbits |= (BUTTON(gamefunc_Strafe_Left) || (svel > 0))<<2; + if (apScriptGameEvent[EVENT_PROCESSINPUT] || apScriptGameEvent[EVENT_STRAFERIGHT]) + loc.extbits |= (BUTTON(gamefunc_Strafe_Right) || (svel < 0))<<3; + if (apScriptGameEvent[EVENT_PROCESSINPUT] || apScriptGameEvent[EVENT_TURNLEFT]) + loc.extbits |= BUTTON(gamefunc_Turn_Left)<<4; + if (apScriptGameEvent[EVENT_PROCESSINPUT] || apScriptGameEvent[EVENT_TURNRIGHT]) + loc.extbits |= BUTTON(gamefunc_Turn_Right)<<5; + // used for changing team + loc.extbits |= (g_player[snum].pteam != g_player[snum].ps->team)<<6; + + if (ud.scrollmode && ud.overhead_on) + { + ud.folfvel = vel; + ud.folavel = angvel; + loc.fvel = 0; + loc.svel = 0; + loc.avel = 0; + loc.horz = 0; + return; + } + + if (numplayers > 1) + daang = myang; + else daang = p->ang; + + momx = mulscale9(vel,sintable[(daang+2560)&2047]); + momy = mulscale9(vel,sintable[(daang+2048)&2047]); + + momx += mulscale9(svel,sintable[(daang+2048)&2047]); + momy += mulscale9(svel,sintable[(daang+1536)&2047]); + + momx += fricxv; + momy += fricyv; loc.fvel = momx; loc.svel = momy;