/* * Copyright (C) 1999 Peter Amstutz * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of *the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA * 02111-1307 USA */ #include #include "../log.h" #include "../ballistics.h" #include "../terrain.h" #include "../aiexterns.h" #include "dirtcurtain.h" Shellstat_bal wepDirtCurtainGuidance(void* info, struct Projectilepos_bal *prjpos, Shellstat_bal (*initexplosion)(struct Projectilepos_bal *prjpos, void** explosioninfo), void **explosioninfo) { Shellstat_bal res; Player_pl *plhit = NULL; int ix, iy; prjpos->rox=prjpos->ox=prjpos->x; prjpos->roy=prjpos->oy=prjpos->y; prjpos->x+=prjpos->vx; prjpos->y+=prjpos->vy; prjpos->vy-=bal_grav/bal_lerp_tweak; if((res=balEnvironmentAdjustProjPos(prjpos))!=FLYING || balCheckIntersect(prjpos->ox, prjpos->oy, prjpos->x, prjpos->y, &plhit, &ix, &iy)) { if(plLookupPlayer(prjpos->id)) { logPrintf(DEBUG, "Intersection at (%i, %i) of %s's shot\n", ix, iy, plLookupPlayer(prjpos->id)->name); } else { logPrintf(DEBUG, "Intersection at (%i, %i) of null's shot\n", ix, iy); } if(plhit!=NULL) logPrintf(DEBUG, "and hit %s\n", plhit->name); switch(res) { case HOLDING: /* wtf ??? */ break; case FLYING: prjpos->x=ix; prjpos->y=iy; /* fall through */ case EXPLODING: /*return FREEING;*/ return initexplosion(prjpos, explosioninfo); break; case FREEING: return FREEING; break; } } if((abs(prjpos->x-prjpos->ox)>DIRT_RADIUS) || (abs(prjpos->y-prjpos->oy)>DIRT_RADIUS)) { /* Add the dirt */ terAddCircle(prjpos->ox, prjpos->oy, DIRT_RADIUS); } return FLYING; } Shellstat_bal wepDirtCurtainExplosionInit(struct Projectilepos_bal *prjpos, void** explosioninfo) { struct SimpleExplosion_wep *e = (struct SimpleExplosion_wep*)malloc(sizeof(struct SimpleExplosion_wep)); e->x=prjpos->x; e->y=prjpos->y; e->r=1; e->dx=2; e->id=prjpos->id; e->max_radius=2; e->wid = prjpos->wid; *((struct SimpleExplosion_wep**)explosioninfo)=e; return EXPLODING; }