diff --git a/dollop of sauce - decomp/G_boxes.c b/dollop of sauce - decomp/G_boxes.c index 6b6b11b..6bb29a7 100644 --- a/dollop of sauce - decomp/G_boxes.c +++ b/dollop of sauce - decomp/G_boxes.c @@ -15,336 +15,3 @@ #define PUSHSPEED (3*8192) #define BOXFUDGEX (6*8192) - -void ClearPlayerPlatform(int numo) -{ - int p; - - for (p=0;pcuranim].framelist[obj->phase]; -#if _DEBUG - if (frame==0) - DebugXMessage("frame0 in box"); -#endif - - width=frames[frame].dx*32768; - height=frames[frame].dy*32768; - - - x0=obj->xpos-width-16*65536; - y0=obj->ypos+frames[frame].ty2*65536-18*65536; //18=distance between playermid and playerfeet - - x1=obj->xpos+width+16*65536; - y1=y0+height*2; - - - hitsides=0; - for (p=0;pypos>y0+65536) && (play->yposxpos>x0-width) && (play->xposxspeed>=0) && (play->xpos<=x0) && (play->xpos+play->xspeed>x0-BOXFUDGEX)) - { - play->xpos=x0-BOXFUDGEX+PUSHSPEED; - play->xspeed=0; - if (play->xacc>0) play->xacc=0; //not really necessary - hitsides+=1; - hit=1; - } - if ((play->xspeed<=0) && (play->xpos>=x1) && (play->xpos+play->xspeedxpos=x1+BOXFUDGEX-PUSHSPEED; - play->xspeed=0; - if (play->xacc<0) play->xacc=0; //not really necessary - hitsides-=1; - hit=1; - } - } //if apx near - - if (hit) - { - play->pushobject=numo; - if (play->push<60) play->push=60; - play->platform=numo; - play->platformtype=0; //still falling! - } else - if ((play->pushobject==numo) && (play->platform==numo)) - { - play->pushobject=0; - play->platform=0; - play->platformtype=0; - play->movexspeed=0; - play->moveyspeed=0; - } - - -//PLAYER ABOVE IT (STAND ON IT) - if (!hit && (play->xpos>x0+BOXFUDGEX) && (play->xposypos>=y0) && - (play->ypos<(y0+y1)/2) && - (play->yspeed>-65536)) - { - if (play->downattackdownattack=DOWNATTACKLEN; - - play->ypos=y0+32767; //round off - play->platform=numo; - play->platformtype=1; //no falling - play->movexspeed=obj->xspeed; //no extra speed here - play->moveyspeed=0; - hit=-2; - platformhit=1; - } - } - - if ((!hit) && (platformhit==0)) - { - if (play->platform==numo) //clear the platform number! - { - play->pushobject=0; - play->platform=0; - play->platformtype=0; - play->movexspeed=0; - play->moveyspeed=0; - } - } - - } //for p - - return(hitsides); -} //CheckPlayerSolidBox - - - - - -void ClearSolidBox(int numo) -{ - int p; - Tplayer *play; - - - for (p=0;ppushobject==numo) || (play->platform==numo)) - { - play->pushobject=0; - play->platform=0; - play->platformtype=0; - play->movexspeed=0; - play->moveyspeed=0; - } - } - - gameobj[numo].xspeed=0; //no more movement -} //ClearSolidBox() - - - -void CollideSolidBox(int num,int *newxpos,int *newypos) -{ - int hitl,hitr; - int n; - Omonster *obj; - int frame,dx,dy; -// int speed=0; - int width,height; - - - obj=(Omonster *)(&gameobj[num]); - - frame=anims[obj->curanim].framelist[obj->phase]; - width=(frames[frame].dx-4)*32768; - height=(frames[frame].dy-4)*32768; - - - if (*newxposxpos) - { - if (CheckPixel(*newxpos-width,*newypos)) - *newxpos=obj->xpos; - } else - if (*newxpos>obj->xpos) - { - if (CheckPixel(*newxpos+width,*newypos)) - *newxpos=obj->xpos; - } - - for (n=1;nxpos; - *newypos=obj->ypos; - break; - } - } - } - - - dy=(frames[frame].ty2+frames[frame].dy)*65536; - hitl=CheckPixel(*newxpos-width,*newypos+dy); - hitr=CheckPixel(*newxpos+width,*newypos+dy); - - if ((!hitl) && (!hitr)) - { - obj->state=sFALL; - } - else - { - if (obj->freeze) - obj->state=sFREEZE; - else - obj->state=sSLEEP; - } -} //CollideSolidBox() - - - -int PushSolidBox(int num,int direction) -{ - int hitl,hitr; - int n; - Omonster *obj; - int frame,dx,dy; - int newxpos=0; - int speed=0; - int width,height; - - obj=(Omonster *)(&gameobj[num]); - - frame=anims[obj->curanim].framelist[obj->phase]; - width=(frames[frame].dx-4)*32768; - height=(frames[frame].dy-4)*32768; - - - if (direction<0) - { - if (!CheckPixel(obj->xpos-width,obj->ypos)) - newxpos=obj->xpos-PUSHSPEED; - } else - if (direction>0) - { - if (!CheckPixel(obj->xpos+width,obj->ypos)) - newxpos=obj->xpos+PUSHSPEED; - } - - if (newxpos) //only when moved - { - for (n=1;nypos)xpos; - obj->xpos=newxpos; - } - } - - -// px=obj->xpos+(frames[obj->curframe].tx2*65536); -// py=(frames[obj->curframe].ty2+frames[obj->curframe].dy)*65536; -// hitdx=(frames[obj->curframe].dx*65536)/2; - - - dy=(frames[frame].ty2+frames[frame].dy)*65536; - hitl=CheckPixel(obj->xpos-width,obj->ypos+dy); - hitr=CheckPixel(obj->xpos+width,obj->ypos+dy); - - if ((!hitl) && (!hitr)) - { - obj->state=sFALL; - } - else - { - if (RandFac(15)==0) - { - if ((direction<0) && hitr) - AddExplosion(obj->xpos+width,obj->ypos+dy,AnimBase[mAMMO]+mAMMO_POOF2); - else - if ((direction>0) && hitl) - AddExplosion(obj->xpos-width,obj->ypos+dy,AnimBase[mAMMO]+mAMMO_POOF2); - } - - - if (obj->freeze) - obj->state=sFREEZE; - else - obj->state=sSLEEP; - } - - return(speed); -} //PushSolidBox() - - diff --git a/dollop of sauce - decomp/G_bullet.c b/dollop of sauce - decomp/G_bullet.c index 767ed90..a3fd222 100644 --- a/dollop of sauce - decomp/G_bullet.c +++ b/dollop of sauce - decomp/G_bullet.c @@ -18,734 +18,6 @@ #include "G_Hit.h" #include "G_Collision.h" -/* - add an explosion at a certain position. - no checking -*/ -void AddExplosion(int rx,int ry,int anim) -{ - int res; - - res=AddObject(rx,ry,aEXPLOSION,0); - if (res>0) - gameobj[res].curanim=anim; - -} //AddExplosion - - - -/* - show little flare sprite at gun exhaust point of - this character. calls AddSprite to put it at all - local viewports -*/ -void GunFlare(int nump) -{ - Tplayer *play; - int rx,ry; - Tframes *frame; - int fr; - - - play=&player[nump]; - - frame=&frames[play->curframe]; - - if (play->direction<0) - rx=play->xpos-((frame->tx2-frame->tx3)*65536); - else - rx=play->xpos+((frame->tx2-frame->tx3)*65536); - - ry=play->ypos+((frame->ty2-frame->ty3)*65536); - - if (play->fly<0) - ry+=-8*65536+sintable(gamecounter*12)*8; - - fr=anims[AnimBase[mAMMO]+mAMMO_GUN0SHOT].framelist[0]; - - AddSprite(rx,ry,SPRITELAYER,play->direction,spriteNORMAL,0,fr); - -} //GunFlare() - - - - - -static void FixupBullet(int nump,int res,int firetype,int uid,int subnum) -{ - Tplayer *play; - Obullets *bull; - int l; - - play=&player[nump]; - - if (res>0) - { - bull=(Obullets *)(&gameobj[res]); - - if (play->swim) - { - if (play->yspeed<-2*65536) - bull->yspeed=-2*65536-bull->xspeed; - else - if (play->yspeed>2*65536) - bull->yspeed=2*65536+bull->xspeed; - } - - if ((play->firedirection==8) && bull->upanim)//firing up! - { - l=(bull->lifetime*2)/3; - bull->yspeed=-bull->xspeed; - bull->yacc=-bull->xacc; - bull->xspeed=0; - bull->xacc=0; - bull->curanim=(Word16)bull->upanim; - bull->direction=0; //! - bull->lifetime=l; - } - else - { - bull->direction=play->direction; - bull->xspeed=play->direction*bull->xspeed; - bull->xacc=play->direction*bull->xacc; - - bull->pxspeed=play->xspeed; - bull->pyspeed=0;//play->yspeed/8; - - - if (bull->pxspeed>8*65536) bull->pxspeed=8*65536; - else - if (bull->pxspeed<-8*65536) bull->pxspeed=-8*65536; - - } - if (uid) - UID[res]=uid; - } -} //FixUpBullet() - - - - - - -/* - add special rocket bullets, which are 3 rockets flying - in slightly different angles -*/ -static void Add3Bullet(int rx,int ry,int nump,int uid) -{ - int res; - Obullets *obj; - Tplayer *play; - int gun; - - ASSERT(numpgunpower[4]==1) - gun=aPLAYERBULLETP5; - else - gun=aPLAYERBULLET5; - - - res=AddObject(rx,ry,gun,PLAYSLOT+nump); - if (res>0) - { - obj=(Obullets *)(&gameobj[res]); - - if (play->firedirection==8) - { - if (gun==aPLAYERBULLETP5) - obj->curanim=AnimBase[mAMMO]+mAMMO_GUN5PU; - else - obj->curanim=AnimBase[mAMMO]+mAMMO_GUN5U; - - obj->yspeed=-obj->xspeed; - obj->yacc=-obj->xacc; - obj->xspeed=-1*65536; - obj->xacc=0; - } - else - { - if (gun==aPLAYERBULLETP5) - obj->curanim=AnimBase[mAMMO]+mAMMO_GUN5P; - else - obj->curanim=AnimBase[mAMMO]+mAMMO_GUN5; - - obj->xspeed=play->direction*obj->xspeed+play->xspeed; - obj->xacc=play->direction*obj->xacc; - obj->direction=play->direction; - - if (play->swim) - { - if (play->yspeed<-2*65536) - obj->yspeed=-3*65536-obj->xspeed; - else - if (play->yspeed>2*65536) - obj->yspeed=1*65536+obj->xspeed; - else - obj->yspeed=-1*65536; - } else - obj->yspeed=-1*65536; - } - - if (uid) - UID[res]=uid; - } - - if (gun==aPLAYERBULLETP5) - { - res=AddObject(rx,ry,gun,PLAYSLOT+nump); - if (res>0) - { - obj=(Obullets *)(&gameobj[res]); - if (play->firedirection==8) - { - obj->curanim=AnimBase[mAMMO]+mAMMO_GUN5PU; - obj->yspeed=-obj->xspeed; - obj->yacc=-obj->xacc; - obj->xspeed=0; - obj->xacc=0; - obj->direction=0; //! - } - else - { - obj->curanim=AnimBase[mAMMO]+mAMMO_GUN5P; - obj->direction=play->direction; - obj->xspeed=play->direction*obj->xspeed+play->xspeed; - obj->xacc=play->direction*obj->xacc; - - if (play->swim) - { - if (play->yspeed<-2*65536) - obj->yspeed=-2*65536-obj->xspeed; - else - if (play->yspeed>2*65536) - obj->yspeed=2*65536+obj->xspeed; - else - obj->yspeed=0; - } else - obj->yspeed=0; - } - } - - if (uid) - UID[res]=uid; - } - - res=AddObject(rx,ry,gun,PLAYSLOT+nump); - if (res>0) - { - obj=(Obullets *)(&gameobj[res]); - - if (play->firedirection==8) - { - if (gun==aPLAYERBULLETP5) - obj->curanim=AnimBase[mAMMO]+mAMMO_GUN5PU; - else - obj->curanim=AnimBase[mAMMO]+mAMMO_GUN5U; - - obj->yspeed=-obj->xspeed; - obj->yacc=-obj->xacc; - obj->xspeed=1*65536; - obj->xacc=0; - } - else - { - if (gun==aPLAYERBULLETP5) - obj->curanim=AnimBase[mAMMO]+mAMMO_GUN5P; - else - obj->curanim=AnimBase[mAMMO]+mAMMO_GUN5; - - obj->direction=play->direction; - obj->xspeed=play->direction*obj->xspeed+play->xspeed; - obj->xacc=play->direction*obj->xacc; - - if (play->swim) - { - if (play->yspeed<-2*65536) - obj->yspeed=-1*65536-obj->xspeed; - else - if (play->yspeed>2*65536) - obj->yspeed=3*65536+obj->xspeed; - else - obj->yspeed=1*65536; - } else - obj->yspeed=1*65536; - } - - if (uid) - UID[res]=uid; - - } -} //Add3Bullet - - - - - -static int bouncesampsn[6]={sAMMO_GUNFLPL,sAMMO_GUNFLP,sAMMO_GUNFLP1, - sAMMO_GUNFLP2,sAMMO_GUNFLP3,sAMMO_GUNFLP4}; -static int bouncesampsp[6]={sAMMO_BMP1,sAMMO_BMP2,sAMMO_BMP3, - sAMMO_BMP4,sAMMO_BMP5,sAMMO_BMP6}; -static int gun0spaz[3]={sAMMO_GUN3PLOP,sAMMO_GUN1,sAMMO_GUN2}; -static int icegunn[3]={sAMMO_ICEGUN,sAMMO_ICEGUN2,sAMMO_ICEGUNPU}; -static int icegunp[4]={sAMMO_ICEPU1,sAMMO_ICEPU2,sAMMO_ICEPU3,sAMMO_ICEPU4}; - - -static void AddBulletSounds(int nump,int rx,int ry) -{ - Tplayer *play; - int rnd; - int power; - int firetype; - - - play=&player[nump]; - - if ((play->firetype==0) && (play->shield>0)) - firetype=9+play->shieldtype; - else - firetype=play->firetype; - - power=play->gunpower[play->firetype]; - - switch (firetype) - { - case 0: - if (power) - { - if (play->character==mSPAZ) - { - if (RandFac(1)) - PlaySample(rx,ry,sAMMO_FUMP,0,0); - else - PlaySample(rx,ry,sAMMO_GUN3PLOP,0,0); - } else - PlaySample(rx,ry,sAMMO_FUMP,0,22050); - } - else - { - if (play->character==mJAZZ) - PlaySample(rx,ry,sAMMO_GUNJAZZ,0,22050); - else - { - rnd=(RandFac(255))%3; - PlaySample(rx,ry,gun0spaz[rnd],0,22050); - } - } - break; - - case 1: - if (power) - { - rnd=(RandFac(255))%6; - if (play->character==mJAZZ) - PlaySample(rx,ry,bouncesampsp[rnd],0,11025); - else - PlaySample(rx,ry,bouncesampsp[rnd],0,22050); - } - else - { - rnd=(RandFac(255))%6; - if (play->character==mJAZZ) - PlaySample(rx,ry,bouncesampsn[rnd],0,11025); - else - PlaySample(rx,ry,bouncesampsn[rnd],0,22050); - } - break; - - case 2: - if (power) - { - rnd=RandFac(3); - PlaySample(rx,ry,icegunp[rnd],0,0); - } - else - { - rnd=(RandFac(255))%3; - PlaySample(rx,ry,icegunn[rnd],0,0); - } - break; - - case 3: - if (sndAudio) - PlaySample(rx,ry,sAMMO_MISSILE,0,0); - break; - - case 4: - if (sndAudio) - PlaySample(rx,ry,sAMMO_LAZRAYS,0,0); - break; - - case 5: - //PlaySample(rx,ry,sGUNSM1,0,0); - break; - - case 6: //TNT!!!!!!! - - break; - - case 7: - PlaySample(rx,ry,sAMMO_GUNVELOCITY,0,0); - break; - - case 8: - PlaySample(rx,ry,sAMMO_LASER2+RandFac(1),0,0); - break; - - case 10: - if (RandFac(1)) - PlaySample(rx,ry,sAMMO_FIREGUN1A,0,11025-3000); - else - PlaySample(rx,ry,sAMMO_FIREGUN2A,0,11025-3000); - break; - - case 11: - if (RandFac(1)) - PlaySample(rx,ry,sAMMO_BLUB1,0,0); - else - PlaySample(rx,ry,sAMMO_BLUB2,0,0); - break; - - case 12: - PlaySample(rx,ry,sCOMMON_ELECTRIC1,0,0); - break; - - case 13: - PlaySample(rx,ry,sAMMO_LASER,0,0); - break; - - default: - break; - }; //switch firetype -} //AddBulletSounds() - - - - -int AddRealBullet(int rx,int ry,int nump,int uid,int firetype,int power) -{ - int res; - Obullets *bull; - Tplayer *play; - int rnd; - - play=&player[nump]; - - if (MultiPlayerConnection>gameLOCAL) - { - //if server: - Net_AddBullet(nump,firetype,rx,ry); //not always sent, when this is received - - } //send over net - - - switch (firetype) - { - case 0: - if (power) - res=AddObject(rx,ry,aPLAYERBULLETP1,PLAYSLOT+nump); - else - res=AddObject(rx,ry,aPLAYERBULLET1,PLAYSLOT+nump); - break; - - case 1: - if (power) - res=AddObject(rx,ry,aPLAYERBULLETP2,PLAYSLOT+nump); - else - res=AddObject(rx,ry,aPLAYERBULLET2,PLAYSLOT+nump); - break; - - case 2: - if (power) - { - res=AddObject(rx,ry,aPLAYERBULLETP3,PLAYSLOT+nump); - if (res>0) - { - bull=(Obullets *)(&gameobj[res]); - bull->var1=0; - if (uid) - UID[res]=uid; - } - - res=AddObject(rx,ry,aPLAYERBULLETP3,PLAYSLOT+nump); - if (res>0) - { - bull=(Obullets *)(&gameobj[res]); - bull->var1=512; //sinewaved! - if (uid) - UID[res]=uid; - } - } - else - { - res=AddObject(rx,ry,aPLAYERBULLET3,PLAYSLOT+nump); - } - break; - - case 3: - if (power) - res=AddObject(rx,ry,aPLAYERBULLETP4,PLAYSLOT+nump); - else - res=AddObject(rx,ry,aPLAYERBULLET4,PLAYSLOT+nump); - break; - - case 4: - Add3Bullet(rx,ry,nump,uid); - res=0; - break; - - case 5: - if (play->firedirection==8) - ry-=8*65536; - - if (power) - res=AddObject(rx,ry,aPLAYERBULLETP6,PLAYSLOT+nump); - else - res=AddObject(rx,ry,aPLAYERBULLET6,PLAYSLOT+nump); - - if (res>0) - { - bull=(Obullets *)(&gameobj[res]); - bull->xspeed=2*65536+(35-play->firespeed)*2048; - } - break; - - case 6: //TNT!!!!!!! - res=AddObject(play->xpos,play->ypos,aTNT,PLAYSLOT+nump); - - if (power && (res>0)) - ((Omonster *)(&gameobj[res]))->var1=-128*128; - break; - - case 7: -//shit bullet, remove - if (play->firedirection==8) - res=256; - else - if (play->direction==1) - { - res=512; - if (play->fireangle<128) - play->fireangle=res; - } - else - if (play->direction==-1) - { - res=0; - if (play->fireangle>384) - play->fireangle=res; - } - - if (play->fireangle>res) - play->fireangle-=64; - else - if (play->fireanglefireangle+=64; - - - rnd=2;//1+RandFac(3); - do { - - res=AddObject(rx,ry,aBULLET,PLAYSLOT+nump); - if (res>0) - { - if (uid) - UID[res]=uid; - - bull=(Obullets *)(&gameobj[res]); - - bull->ProcPtr=&cSPREAD; - bull->objtype=oPLAYERBULLET; - bull->force=1;//rnd&1; - - if (play->swim) - { - if (play->yspeed<-2*65536) - bull->yspeed=-2*65536-bull->xspeed; - else - if (play->yspeed>2*65536) - bull->yspeed=2*65536+bull->xspeed; - } - - - res=play->fireangle+Rand2Fac(31); - - power=-256-Rand2Fac(127); - bull->xspeed=play->xspeed+(power*costable(res))/64; - bull->yspeed=(power*sintable(res))/64; - } - - } while (--rnd>0); - - -/* if (power) - res=AddObject(rx,ry,aPLAYERBULLETP8,PLAYSLOT+nump); - else - res=AddObject(rx,ry,aPLAYERBULLET8,PLAYSLOT+nump); -*/ - break; - - case 8: - if (power) - res=AddObject(rx,ry,aPLAYERBULLETP9,PLAYSLOT+nump); - else - res=AddObject(rx,ry,aPLAYERBULLET9,PLAYSLOT+nump); - break; - - case 10: - - if (ry>level.waterlevel) - { - res=AddObject(rx,ry,aPLAYERBULLETC1,PLAYSLOT+nump); - if (res>0) - { - Omonster *obj=(Omonster *)&gameobj[res]; - - obj->curanim=AnimBase[mCOMMON]+mCOMMON_BUBBLES; - obj->phase=((int)RandFac(255))%3; - obj->ProcPtr=cBUBBLE; - obj->nohit=1; - obj->lighttype=0; - obj->objtype=oSPECIAL; //nonbullet - } - } - else - res=AddObject(rx,ry,aPLAYERBULLETC1,PLAYSLOT+nump); - break; - - case 11: - res=AddObject(rx,ry,aPLAYERBULLETC2,PLAYSLOT+nump); - break; - - case 12: - res=AddObject(rx,ry,aPLAYERBULLETC3,PLAYSLOT+nump); - break; - - case 13: - res=AddObject(rx,ry,aPLAYERLASER,PLAYSLOT+nump); - break; - - default: - res=0; - break; - }; //switch firetype - - if (res>0) - FixupBullet(nump,res,firetype,uid,0); - - if (sndAudio) //only for first bullet - AddBulletSounds(nump,rx,ry); - - return(res); -} //AddRealBullet - - - - -/* -AddPlayBullet() - main player addbullet routine which triggers new bullets - at player positions/gun positions. -*/ -void AddPlayBullet(int nump,int uid) -{ - Tplayer *play; - int rx,ry; -// int res; - Tframes *frame; - int power; - int firetype; - - ASSERT(numpfiretype==0) && (play->shield>0) && (uid==0)) - { - firetype=9+play->shieldtype; - power=0; - } - else - { - firetype=play->firetype; - power=play->gunpower[play->firetype]; - } - - - frame=&frames[play->curframe]; - - - if (play->firedirection==8) - { - if (play->direction<0) - rx=play->xpos-((frame->tx2-frame->tx3)*65536); - else - rx=play->xpos+((frame->tx2-frame->tx3)*65536); - - ry=play->ypos-8*65536;//+((frame->ty2-frame->ty3)*65536)+10*65536; - } - else - { - if (play->direction<0) - rx=play->xpos;//-((frame->tx2-frame->tx3)*65536)+14*65536; - else - rx=play->xpos;//+((frame->tx2-frame->tx3)*65536)-14*65536; - - ry=play->ypos+((frame->ty2-frame->ty3)*65536); - } - - if (play->fly<0) - ry+=-8*65536+sintable(gamecounter*12)*8; - - rx&=0xffff0000; //better for multiplayer..... wtfc? - ry&=0xffff0000; - - - AddRealBullet(rx,ry,nump,uid,firetype,power); -} //AddPlayBullet() - - - -/* - addbullet - this should be used for triggering bullets at AI positions - (when a monster wants to fire a bullet it should use this - routine) -*/ -int AddBullet(int numobj,int numbullet) -{ - Omonster *obj; - int rx,ry; - int res; - Tframes *frame; - - ASSERT(numobjcurframe]; - - if (obj->direction<0) - rx=obj->xpos-((frame->tx2-frame->tx3)*65536); - else - rx=obj->xpos+((frame->tx2-frame->tx3)*65536); - - ry=obj->ypos+((frame->ty2-frame->ty3)*65536); - - - res=AddObject(rx,ry,numbullet,numobj); - if (res>0) - { - gameobj[res].direction=obj->direction; - gameobj[res].xspeed=obj->direction*gameobj[res].xspeed; - gameobj[res].xacc=obj->direction*gameobj[res].xacc; - } - - return(res); -} //AddBullet() - - /* collision with laser beam. @@ -784,246 +56,3 @@ int LaserCollision(Tgameobj *obj1,Tgameobj *obj2) } //LaserCollision() - -/* - checks bullet collision for a certain bullet - - first checks bullet against all players, then - checks bullet against active players, - then checks bullet against objects - - when a player is hit (depends on gametype) - g-hit.c->HitPlayer is called - - - when an object is hit g_hit.c->HitObject is called - -*/ -void CheckBullet(int bullet) -{ - Obullets *bull; - Omonster *mons; - int num; - int nump; - int numhits; - int gotcha; - int DoHitPlayer; - Word8 data[128]; - TactPACKETS *action; - - - ASSERT(bulletgameLOCAL) && !LocalComputerIsServer) - { - DoHitPlayer=0; - } - else - DoHitPlayer=1; - -/* - we let the server do all these collisions - - - the client also does collision, but doesnt do Hitplayer! - - another approach could be for each client to process it's own LOCAL bullets, and - send 'hit' information to the server whenever one of its bullets hit a player - advantage of this might be: - - lessen workload of server - - limit amount of packets sent - - better latency/visual consistency - - hmmm -*/ - - if ((MultiPlayerType!=gameNORMAL) && (MultiPlayerType!=gameCOOPERATIVE)) - for (nump=0;numpcreator!=PLAYSLOT+nump) && player[nump].Active) - { - gotcha=0; //type of colision for network - - if ((MultiPlayerType==gameBATTLE) || (MultiPlayerType==gameCAPTURE)) - { - if (player[nump].flicker) - continue; - - if (bull->creator>=PLAYSLOT) - { - if (player[bull->creator-PLAYSLOT].flicker) - continue; - - if (MultiPlayerType==gameCAPTURE) - if (player[bull->creator-PLAYSLOT].Team==player[nump].Team) - continue; - } - } //multipalyer type before collission - - if ((bull->type&bullLASER)==bullLASER) - numhits=LaserCollision(&gameobj[bullet],(Tgameobj *)(&player[nump])); - else - numhits=PixelCollision(&gameobj[bullet],(Tgameobj *)(&player[nump])); - - if (numhits) - { - if (bull->creator>=PLAYSLOT) - { - if (bull->freeze) - { -// if (player[nump].freeze!=0xFF) - player[nump].freeze=bull->freeze; //no NRG loss! - gotcha=actPLAYERFREEZE; - } - else - { - if (bull->xspeed>0) - player[nump].xspeed=bull->force*2*65536; - else - player[nump].xspeed=-bull->force*2*65536; - - player[nump].yspeed=-(2+bull->force)*4*65536; - - if (player[nump].freeze) - { - player[nump].freeze=0; - cUNFREEZE(PLAYSLOT+nump,1); - } - //and! when unfrozen damage is done............... - - if ((MultiPlayerType==gameBATTLE) || - (MultiPlayerType==gameCAPTURE) || - (MultiPlayerType==gameTREASURE)) - { - if (DoHitPlayer) - { - if (HitPlayer(nump,bullet)) - gotcha=actPLAYERHIT; - } - } - else - { - player[nump].bemoved=8+8*bull->force; - player[nump].idletime=0; - } - } - } else - { - if (bull->freeze) - { - if (player[nump].freeze!=0xFF) - { - player[nump].freeze=bull->freeze; //no NRG loss! - gotcha=actPLAYERFREEZE; - } - } - else - { - if (DoHitPlayer) - { - if (HitPlayer(nump,bullet)) - gotcha=actPLAYERHIT; - } - } - } - - - if (DoHitPlayer) { - if ((bull->type&bullLASER)!=bullLASER) - bull->state=sEXPLODE; - } - - if ((MultiPlayerConnection>gameLOCAL) && LocalComputerIsServer) { - if (gotcha==actPLAYERFREEZE) { - if (bull->state==sEXPLODE) { - action->GENERIC.PacketID=actPLAYERFREEZEEXPLODE; - action->PLAYERFREEZEEXPLODE.UIDLow=UID[bullet]; - action->PLAYERFREEZEEXPLODE.UIDHigh=UID[bullet]>>8; - action->PLAYERFREEZEEXPLODE.nump=nump; - action->PLAYERFREEZEEXPLODE.freeze=bull->freeze; - } else { - action->GENERIC.PacketID=actPLAYERFREEZE; - action->PLAYERFREEZE.nump=nump; - action->PLAYERFREEZE.freeze=bull->freeze; - } - } else if (gotcha==actPLAYERHIT) { - action->GENERIC.PacketID=actPLAYERHIT; - action->PLAYERHIT.UIDLow=UID[bullet]; - action->PLAYERHIT.UIDHigh=UID[bullet]>>8; - action->PLAYERHIT.nump=nump; - if (player[nump].energy>0) - action->PLAYERHIT.energy=player[nump].energy; - else - action->PLAYERHIT.energy=0; - action->PLAYERHIT.explode=(bull->state==sEXPLODE); - action->PLAYERHIT.unfreeze=(player[nump].freeze==0); - } - - if (gotcha) - Server_SendActions(action,0); //send to all! - } //if network - - if (bull->state==sEXPLODE) - break; //bullet only hits one thing! - } - } //for all players - - - - - - - -//PROCESS OBJECTS!!!!!!!!! - for (num=1;numobjtype&oTYPES)==oNORMAL) || ((mons->objtype&oTYPES)==oSPECIAL))) - { - if ((bull->type&bullLASER)==bullLASER) - numhits=LaserCollision(&gameobj[bullet],&gameobj[num]); - else - numhits=PixelCollision(&gameobj[bullet],&gameobj[num]); - - if (numhits) - { - if ((bull->freeze) && ((gameobj[num].nohit&8)!=8)) - { - if (mons->freeze!=0xFF) - mons->freeze=bull->freeze; //no NRG loss! - - if (mons->state!=sFREEZE) - mons->oldstate=mons->state; - mons->state=sFREEZE; - bull->state=sEXPLODE; - } else { - HitObject(num,bull->creator,bullet); - } - - if ((bull->type&bullLASER)!=bullLASER) { - break; //bullet only hits one thing! - } - } - } - else - if ((mons->objtype&oTYPES)==oPICKUP) - { - if ((bull->type&bullLASER)==bullLASER) - numhits=LaserCollision(&gameobj[bullet],&gameobj[num]); - else - numhits=PixelCollision(&gameobj[bullet],&gameobj[num]); - if (numhits) - { - if ((mons->xspeed==0) && (mons->yspeed==0)) - { - mons->xspeed=bull->xspeed/2; - mons->yspeed=bull->yspeed/2; - mons->direction=bull->direction; - } - } //that's it! - } - } //for all active and normal objects -} //CheckBullet() - diff --git a/dollop of sauce - decomp/G_hit.c b/dollop of sauce - decomp/G_hit.c index fc14d08..9a17587 100644 --- a/dollop of sauce - decomp/G_hit.c +++ b/dollop of sauce - decomp/G_hit.c @@ -27,145 +27,6 @@ #include "N_Chat.h" #include "N_main.h" -/* - DoPoints - - gives player points for picking up something - - TODO: show score flying off -*/ -void DoPoints(int nump,int num) -{ - - //also in release, otherwise this can CRASH !!!! - if ((numpPLAYSLOT+MAXPLAYERS) || (num>=MAXOBJECTS)) - { - return; - } - - if ((gameobj[num].points>0) && - (MultiPlayerType!=gameBATTLE) && - (MultiPlayerType!=gameRACE) && - (MultiPlayerType!=gameCAPTURE) && - (MultiPlayerType!=gameTREASURE)) - { - player[nump-PLAYSLOT].score+=gameobj[num].points; - - AddParticleScore(gameobj[num].xpos,gameobj[num].ypos,gameobj[num].points); - - gameobj[num].points=0; //dont give twice for whatever reason - } -} //DoPoints() - - - -/* - plays a sample when picking up a pickup. - does frequency shifting for each consequent pickup -*/ -void PickupSample(int x,int y) -{ - static int Rate=16025; - static int Rdir=1; - static int LastGameCounter=0; - int delta; - - - delta=gamecounter-LastGameCounter; - - if (delta>AISPEED*2) - { - Rate=16025; - Rdir=1; - } - - LastGameCounter=gamecounter; - - if (Rdir==1) - { - Rate=(Rate*69433)/65536; - if (Rate>28050) - { - Rate=28050; - Rdir=0; - } - } - else - { - Rate=(Rate*58386)/65536; - if (Rate<16025) - { - Rdir=1; - Rate=16025; - } - } - PlaySample(x,y,sCOMMON_PICKUP1,63,Rate); -} //PickupSample() - - - - -/* - adds something extra when you kill something. - - adds fastfire, energy or diamonds -*/ -void AddExtra(int nump,int num,int freq) -{ - int rnd,res; - - - if (MultiPlayerType>gameCOOPERATIVE) //no gems here...... - return; - - ASSERT(num=PLAYSLOT+MAXPLAYERS)) - { - return; - } - - - player[nump-PLAYSLOT].extracounter++; //frequency counter - - if ((player[nump-PLAYSLOT].extracounter&7)==0) - { - res=AddObject(gameobj[num].xpos,gameobj[num].ypos-RandFac(32767)*32,aGUNFASTFIRE,nump); - if ((res>0) && (player[nump-PLAYSLOT].character==mSPAZ)) - gameobj[res].curanim=AnimBase[mPICKUPS]+mPICKUPS_FASTSPAZ; //change to green gun for SPAZ - } - else - { - rnd=RandFac(16383); - if ((rnd%freq)==0) //MOD! argh - { - rnd=(rnd>>8); - switch (rnd&3) { - case 0: - AddObject(gameobj[num].xpos,gameobj[num].ypos-RandFac(32767)*32,aENERGYUP,nump); - break; - case 1: - AddObject(gameobj[num].xpos,gameobj[num].ypos-RandFac(32767)*32,aREDGEM,nump); - break; - case 2: - AddObject(gameobj[num].xpos,gameobj[num].ypos-RandFac(32767)*32,aGREENGEM,nump); - break; - default: - case 3: - AddObject(gameobj[num].xpos,gameobj[num].ypos-RandFac(32767)*32,aBLUEGEM,nump); - break; - } //switch - } - } //other -} //AddExtra() - - - @@ -223,389 +84,6 @@ static int JAZZHURTSOUNDS[8]= {sJAZZSOUNDS_HEY1,sJAZZSOUNDS_HEY2,sJAZZSOUNDS_HEY3,sJAZZSOUNDS_HEY4, sJAZZSOUNDS_JAZZV1,sJAZZSOUNDS_JAZZV2,sJAZZSOUNDS_JAZZV3,sJAZZSOUNDS_JAZZV4}; -/* - hitplayer - - hit a player. - in this function all decisions are made if the player is hurt, or - if the bird/shield dissappears first -*/ -int HitPlayer(int nump,int numobj) -{ - Tplayer *play; - Obullets *bull; - Word8 objfreeze; - int t,res; - int random; - int dohurt; - int abletohit; - Word8 data[128]; - TactPACKETS *action; - - if ((numobj>0) && (numobjfreeze; - else - objfreeze=0; - - BOUNDS(nump,0,MAXPLAYERS); - play=&player[nump]; - - abletohit=dohurt=0; - - if (MultiPlayerConnection==gameLOCAL) - { - if ((play->hit<=0) && - (play->downattack>=DOWNATTACKWAIT) && - (play->invincibility==0) && - (play->rush==0) && - (level.finish==0) && - (play->flicker==0) && - (objfreeze==0)) - { - abletohit=1; - dohurt=1; - } - } - else - { //netgame - - if (LocalComputerIsServer) - { - - if (MultiPlayerType==gameCAPTURE) - { - if (numobj<=0) - res=nump; //kill yourself - else - if (numobjhit<=0) && - (play->flicker==0)) - { - abletohit=1; - } - } //net - - - if (abletohit) { - if (play->bird>0) { - //gameobj[play->bird-1].state=sHIT; - play->invincibility=-AISPEED*3; - play->flicker=-AISPEED*3; - play->bird=0; - play->hit=HITTIME; //INVINCIBLE TIME! SHOULD FLICKER... - play->idletime=0; - } else if (play->shield>0) { - play->invincibility=-AISPEED*3; - play->flicker=-AISPEED*3; - play->idletime=0; - play->shield-=5*AISPEED; - - - if (play->shieldtype==3) { //electric shield - for (t=0;t<10;t++) { - res=AddObject(play->xpos,play->ypos,aSHARD,nump+PLAYSLOT); - if (res>0) { - gameobj[res].curanim=AnimBase[mAMMO]+mAMMO_SPARK1; - gameobj[res].light=1; - gameobj[res].lighttype=2; - } else { - break; - } - } - } else if (play->shieldtype==1) { - for (t=0;t<10;t++) { - res=AddObject(play->xpos,play->ypos,aBOUNCEONCE,nump+PLAYSLOT); - if (res>0) { - gameobj[res].curanim=AnimBase[mPICKUPS]+mPICKUPS_SPRKLE; - gameobj[res].light=1; - gameobj[res].lighttype=2; - } else { - break; - } - } - } - - if (LocalComputerIsServer && (MultiPlayerConnection>gameLOCAL) && (play->localplayer==0)) { - //only in network where this computer is the server, and only to the client affected - action=Server_AddAction(actPLAYERHITSHIELD,play->Client); - action->PLAYERHITSHIELD.nump=nump; - } else { - if (play->shield<=0) { - PlaySample(play->xpos,play->ypos,sCOMMON_SHLDOF3,0,0); - play->shield=-1; //show dissappearing shield - play->invincibility=-AISPEED*3; - play->flicker=-AISPEED*3; - } - } - - if (play->character==mSPAZ) { - PlaySample(play->xpos,play->ypos,sSPAZSOUNDS_OOOH,0,0); - } else if (play->character==mJAZZ) { - PlaySample(play->xpos,play->ypos,JAZZHURTSOUNDS[RandFac(7)],0,0); - } - } else { - if ((MultiPlayerType==gameTREASURE) && - ((numobj>=PLAYSLOT) || - (numobj>0) && (numobj=PLAYSLOT) { - t=10; - } else { - bull=(Obullets *)&gameobj[numobj]; - - if ((bull->var4<=3) || (bull->var4==6)) - t=3; - else if (bull->load==aPLAYERLASER) - t=25; - else - t=10; - } - - - if (t>play->gem[1]) //just red gems - t=play->gem[1]; - - if (t) { - int xspeed,yspeed; - - if (numobj>=PLAYSLOT) { - xspeed=player[numobj-PLAYSLOT].xspeed/(2*65536); - yspeed=player[numobj-PLAYSLOT].yspeed/(2*65536); - } else if ((numobj>0) && (numobj7) xspeed=7; - - if (yspeed<-7) yspeed=-7; - else - if (yspeed>7) yspeed=7; - - if ((LocalComputerIsServer && (MultiPlayerConnection>gameLOCAL)) || - (MultiPlayerConnection==gameLOCAL)) - { - int startuid=0; - //only in local games or in network where this computer is the server - - if (MultiPlayerConnection!=gameLOCAL) { - int Temp; - action=(TactPACKETS *)(&data[0]); - action->GENERIC.PacketID=actPLAYERADDTREASUREDIAMONDS; - action->PLAYERADDTREASUREDIAMONDS.nump=nump; - random=RandFac(2047); - action->PLAYERADDTREASUREDIAMONDS.randomLow3=random; - action->PLAYERADDTREASUREDIAMONDS.randomHigh=random>>3; - startuid=play->CreateUIDCounter&1023; - action->PLAYERADDTREASUREDIAMONDS.UIDcounterLow=startuid; - action->PLAYERADDTREASUREDIAMONDS.UIDcounterHigh=startuid>>8; - action->PLAYERADDTREASUREDIAMONDS.NumGems=t; - action->PLAYERADDTREASUREDIAMONDS.xs=xspeed; - action->PLAYERADDTREASUREDIAMONDS.ys=yspeed; - Temp = play->xpos/65536; - action->PLAYERADDTREASUREDIAMONDS.xposLow=Temp; - action->PLAYERADDTREASUREDIAMONDS.xposHigh=Temp>>8; - Temp = play->ypos/65536; - action->PLAYERADDTREASUREDIAMONDS.yposLow=Temp; - action->PLAYERADDTREASUREDIAMONDS.yposHigh=Temp>>8; - - - Server_SendActions(action,0); - - RandInit(random); - } //!local! - - xspeed*=4096; - yspeed*=2*65536; - - //when you update this code, update in n_action : Client_ProcessAction too!!! - do { - res=AddObject(play->xpos,play->ypos,aREDGEM,nump+PLAYSLOT); - if (res>0) - { - gameobj[res].xspeed=xspeed*RandFac(63); - gameobj[res].yspeed=yspeed-RandFac(32767)*16; - - gameobj[res].objtype=oWAITPICKUP; //wait a bit - gameobj[res].ProcPtr=&cDiamondsAreForever; - - UID[res]=32768+(nump*1024)+(startuid&1023); - startuid++; - play->gem[1]--; - } else break; - } while (--t); - } //if we are capable of deciding ;-) - } //if t - - play->idletime=0; - } else { //!treasure game - play->idletime=0; - if (dohurt) { - int hurtamount=1; - - if (numobj>=PLAYSLOT) { //special moves! - hurtamount=2; - } else { - if ((numobj>0) && (numobjtype&bullPOWER)==bullPOWER) { - hurtamount=2; - } - } else if ((gameobj[numobj].objtype&oTYPES)==oENEMYBULLET) { - hurtamount=(short)(((Obullets *)(&gameobj[numobj]))->force); - } - } - } //playslot - - play->energy-=hurtamount; - } //dohurt - - if (play->energy<=0) - { - play->energy=0; - - if ((MultiPlayerType==gameBATTLE) && (numobj>0) && - ((MultiPlayerConnection==gameLOCAL) || - ((MultiPlayerConnection>gameLOCAL) && LocalComputerIsServer))) - { - if (numobj=0) && (res=level.extra) - { - if (player[res].finished==0) - { - play->energy=1; //dont do kill anim NOW - player[res].finished=1; - player[res].lastlapfinish=gamecounter; - if (MultiPlayerConnection>gameLOCAL) - { //finished - Server_LevelFinished(res); - } - } //finsihed - } //made number of laps ok? - } //res is okay - - //send killshit over - if ((MultiPlayerConnection>gameLOCAL) && LocalComputerIsServer) - { - action=(TactPACKETS *)(&data[0]); - action->GENERIC.PacketID=actPLAYERKILL; - action->PLAYERKILL.nump=nump; - action->PLAYERKILL.nump_frags=player[nump].lapcounter; - - if ((res>=0) && (resPLAYERKILL.creator=res; - action->PLAYERKILL.creator_frags=player[res].lapcounter; - } - else - { - action->PLAYERKILL.creator=255; - action->PLAYERKILL.creator_frags=0; - } - - Server_SendActions(action,0); - ChatAddKillMessage(res,nump); - } //mutliplayer - - //ScatterPlayerItems(nump); - - } //battle - else - if (MultiPlayerType==gameCAPTURE) - { - if (numobj<=0) - res=nump; //kill yourself - else - if (numobj=0) && (resgameLOCAL) && LocalComputerIsServer) - { - action=(TactPACKETS *)(&data[0]); - action->GENERIC.PacketID=actPLAYERKILL; - action->PLAYERKILL.nump=nump; - action->PLAYERKILL.nump_frags=player[nump].lapcounter; - action->PLAYERKILL.creator=res; - action->PLAYERKILL.creator_frags=player[res].lapcounter; - Server_SendActions(action,0); - ChatAddKillMessage(res,nump); - } - } - - if (play->Flag && LocalComputerIsServer) - { - if ((play->FlagFlag].ProcPtr==&cFLAG)) - { - Omonster *flagobj; - - flagobj=(Omonster *)(&gameobj[play->Flag]); - flagobj->var1=0; - flagobj->state=sSLEEP; - } - - play->Flag=0; - } - } else { //gamecapturetheflag - play->lives--; //is this rite?????????? - } - } //nrg<0 - - if (play->character==mSPAZ) - { - if (RandFac(1)==0) - PlaySample(play->xpos,play->ypos,sSPAZSOUNDS_AUTSCH1,0,0); - else - PlaySample(play->xpos,play->ypos,sSPAZSOUNDS_AUTSCH2,0,0); - } - else - if (play->character==mJAZZ) - PlaySample(play->xpos,play->ypos,JAZZHURTSOUNDS[RandFac(7)],0,0); - - } - - play->hit=HITTIME; //INVINCIBLE TIME! SHOULD FLICKER... - } - } - -// player[nump].hpole=0; -// player[nump].vpole=0; - - return(abletohit); -} //HitPlayer() - - /* hitplayer, and throw him around a bit. diff --git a/dollop of sauce - decomp/g_Ai.c b/dollop of sauce - decomp/g_Ai.c index fc89c94..614bdf3 100644 --- a/dollop of sauce - decomp/g_Ai.c +++ b/dollop of sauce - decomp/g_Ai.c @@ -6923,1627 +6923,6 @@ void copter(int num) -void monkey(int num) -{ - Omonster *obj; - int nump; - int hit1,hit2,px,py; - int res; - Obullets *bobj; - - obj=(Omonster *)(&gameobj[num]); - - switch (obj->state) - { - case sSTART: - if (obj->var4==1) - { - obj->state=sIDLE; - obj->var1=2; - } - else - { - obj->state=sWALK; - } - - PutWalkerOnGround(num); - break; - - - case sWALK: - obj->counter++; - obj->xspeed=obj->direction*((65536+sintable((ABS(obj->phase-7)*32)&511) )/2); - - obj->xpos+=obj->xspeed; - obj->ypos+=obj->yspeed; - - if (obj->xspeed>6*65536) obj->xspeed=6*65536; - else - if (obj->xspeed<-6*65536) obj->xspeed=-6*65536; - - //CHECKING FOR BOUNCING OF WALLS OR RAVINES - if (obj->xspeed<0) - px=-frames[obj->curframe].tx2-frames[obj->curframe].dx; - else - px=frames[obj->curframe].dx+frames[obj->curframe].tx2; - - py=frames[obj->curframe].ty2-frames[obj->curframe].ty; - - hit1=CheckPixel(obj->xpos+(px*65536),obj->ypos+(py<<16)); - - hit2=CheckPixel(obj->xpos+(px*65536),obj->ypos+((py-16)<<16)); - - if ((hit2==1) || (hit1==0) || (tileattr==areaSTOPENEMY)) //bounce of wall - { - if (obj->xspeed>=0) - px=-frames[obj->curframe].tx2-frames[obj->curframe].dx; - else - px=frames[obj->curframe].dx+frames[obj->curframe].tx2; - - hit2=CheckPixel(obj->xpos+(px*65536),obj->ypos+((py-16)<<16)); - - if (hit2==1) //dont do the direction swap - { - obj->state=sWAIT; - } - else - { - obj->xspeed=-obj->xspeed; - obj->xpos+=obj->xspeed; - } - } - - if (obj->xspeed<0) - obj->direction=-1; - else - obj->direction=1; - - //check other objects, if not/.... TO DO - - if ((obj->counter&7)==0) - { - obj->phase++; - if (obj->phase>=anims[obj->curanim].numframes) - obj->phase=0; - } - obj->curframe=anims[obj->curanim].framelist[obj->phase]; - - DrawGameobj(num); - - - nump=GetNearestPlayer(num,256*256); - - if (nump>=0) - { - if (player[nump].xposxpos) - obj->direction=-1; - else - if (player[nump].xpos>obj->xpos) - obj->direction=1; - - if (Distance<256*256) - { - obj->var6=player[nump].xpos;//nump; - obj->state=sEXTRA; - obj->curanim=AnimBase[mMONKEY]+mMONKEY_STOP; - obj->phase=0; - obj->counter=0; - } - } - else - if (obj->counter>AISPEED*4) - { - obj->state=sIDLE; - obj->curanim=AnimBase[mMONKEY]+mMONKEY_STOP; - obj->phase=0; - obj->counter=0; - } - break; - - - case sWAIT: - if ((gamecounter&7)==0) - obj->phase++; - if (obj->phase>=anims[obj->curanim].numframes) - obj->phase=0; - obj->curframe=anims[obj->curanim].framelist[obj->phase]; - DrawGameobj(num); - break; - - - case sIDLE: - if (obj->var1==0) - { - obj->curanim=AnimBase[mMONKEY]+mMONKEY_STOP; - obj->counter++; - if (obj->counter>4) - { - obj->phase++; - obj->counter=0; - if (obj->phase>=anims[obj->curanim].numframes) - { - obj->phase=0; - obj->curanim=AnimBase[mMONKEY]+mMONKEY_IDLE; - obj->var1=2; - } - } - } - else - if (obj->var1==1) - { - obj->curanim=AnimBase[mMONKEY]+mMONKEY_START; - obj->counter++; - if (obj->counter>4) - { - obj->phase++; - obj->counter=0; - if (obj->phase>=anims[obj->curanim].numframes) - { - nump=GetNearestPlayer(num,256*256);//100*100); - if (nump>=0) - { - obj->var6=player[nump].xpos;//nump; - obj->state=sEXTRA; - obj->curanim=AnimBase[mMONKEY]+mMONKEY_STOP; - obj->phase=0; - obj->counter=0; - } - else - { - obj->phase=0; - obj->curanim=AnimBase[mMONKEY]+mMONKEY_WALK; - obj->state=sWALK; - } - } - } - } - else - { - - obj->var5++; - if (obj->var5>5) - { - obj->var5=0; - obj->phase++; - } - if (obj->phase>=anims[obj->curanim].numframes) - obj->phase=0; - - - obj->counter++; - - if (obj->var4==0) - { - if (obj->counter>AISPEED) - { - obj->counter=0; - obj->var1=1; - } - } - else - { - if (obj->counter>(3-level.difficulty)*AISPEED) - { - nump=GetNearestPlayer(num,256*256); - if (nump>=0) - { - obj->var6=player[nump].xpos;//nump; - if (player[nump].xposxpos) - obj->direction=-1; - else - if (player[nump].xpos>obj->xpos) - obj->direction=1; - - obj->var2=Distance; - obj->state=sATTACK; - obj->counter=0; - obj->curanim=AnimBase[mMONKEY]+mMONKEY_THROW; - obj->phase=0; - } - } - } - } - - obj->curframe=anims[obj->curanim].framelist[obj->phase]; - DrawGameobj(num); - break; - - - case sEXTRA: - obj->counter++; - if (obj->counter>4) - { - obj->phase++; - obj->counter=0; - if (obj->phase>=anims[obj->curanim].numframes) - { - obj->phase=0; - obj->curanim=AnimBase[mMONKEY]+mMONKEY_THROW; - obj->state=sATTACK; - } - } - - obj->curframe=anims[obj->curanim].framelist[obj->phase]; - DrawGameobj(num); - break; - - case sATTACK: - - obj->counter++; - if (obj->counter>4) - { - obj->phase++; - obj->counter=0; - - if (obj->phase==8) - { - res=AddBullet(num,aBULLET); - - if (res>=0) - { //BANANABUL - bobj=(Obullets *)(&gameobj[res]); - bobj->ProcPtr=&cBANANA; - - bobj->xspeed=(obj->var6-bobj->xpos)/32; - //bobj->xspeed=(player[obj->var6].xpos-bobj->xpos)/32; - //bobj->yspeed=(player[obj->var6].ypos+16*65536-bobj->ypos)/32; - bobj->state=sFLY; - bobj->direction=obj->direction; - bobj->xspeed+=bobj->direction*8192; //extra little speed - - bobj->force=1; - bobj->objtype=oENEMYBULLET; - bobj->curanim=AnimBase[mMONKEY]+mMONKEY_BANANA; - bobj->killanim=AnimBase[mMONKEY]+mMONKEY_BANASPLT; - bobj->lifetime=AISPEED/2; - bobj->lighttype=2; - }; - - - } - else - if (obj->phase>=anims[obj->curanim].numframes) - { - obj->curanim=AnimBase[mMONKEY]+mMONKEY_IDLE; - obj->phase=0; - obj->state=sIDLE; - if (obj->var4==0) obj->var1=1; - obj->counter=0; - } - } - - obj->curframe=anims[obj->curanim].framelist[obj->phase]; - DrawGameobj(num); - break; - - - case sFREEZE: - if (obj->freeze>0) obj->freeze--; - if (obj->freeze==0) obj->state=obj->oldstate; - DrawGameobj(num); - break; - - case sKILL: - cKILL(num); - break; - - case sDEACTIVATE: - cDEACTIVATE(num); - break; - - default: - FAIL("monkey(): Illegal state: obj:%i, type:%i, state:%i",num,obj->load,obj->state); - break; - } //obj->state -} //monkey() - - - - -void cDESTRUCTSCENERY(int num) -{ - Omonster *obj; - int x,y,tile,calc; -//#ifdef _DEBUGSTATE -// char s[10]; -//#endif - - - obj=(Omonster *)(&gameobj[num]); - - switch (obj->state) - { - case sSTART: - x=obj->xorg/(32*65536); - y=obj->yorg/(32*65536); - - tile=GetSpriteLayerTile(x,y); - - obj->var1=tile; //org animtile - obj->var2=GetDestructAnimTileFrames(tile)-1; - obj->var3=GetDestructAnimTile(tile,0); - PutSpriteLayerTile(x, y, (Word16)obj->var3); - - obj->energy=(Word8)obj->var2; - obj->phase=0; - - obj->nohit=3; - - obj->curframe=anims[obj->curanim].framelist[0]; //collision checking! - obj->state=sSLEEP; - obj->xpos+=65536; - - if (obj->load==aCOLLAPSESCENERY) - { - obj->ypos-=8*65536; - obj->var4=AISPEED*GetEventParm(x,y,0,10)/4; - } - else - if (obj->load==aSTOMPSCENERY) - { - obj->curanim=AnimBase[mDESTSCEN]+mDESTSCEN_64; - obj->curframe=anims[obj->curanim].framelist[0]; //collision checking! - //obj->ypos-=10*65536; //trigger differently! - } - else - { - x=obj->xorg/(32*65536); - y=obj->yorg/(32*65536); - calc=GetEventParm(x,y,10,5); //speed dest - - if (calc) //wider: better collision - obj->curanim=AnimBase[mDESTSCEN]+mDESTSCEN_48; - else - obj->curanim=AnimBase[mDESTSCEN]+mDESTSCEN_48BULLET; - - obj->curframe=anims[obj->curanim].framelist[0]; //collision checking! - obj->ypos+=65536; - obj->xpos-=65536; - - } - - //obj->var5 : this tile has changed (if not, we can deactivate it) - // this to eat up less object space - break; - - case sFREEZE: - if (obj->freeze>0) obj->freeze--; - if (obj->freeze==0) obj->state=obj->oldstate; - else - if (((obj->freeze<32) && ((framecounter&3)<2)) || (obj->freeze>32)) - { - calc=anims[AnimBase[mDESTSCEN]+mDESTSCEN_ICED].framelist[0]; - - AddSprite(obj->xorg,obj->yorg,SPRITELAYER,0,spriteNORMAL,0,calc); - } - break; - - - case sSLEEP: - //obj->curframe=anims[AnimBase[mDESTSCEN]+mDESTSCEN_32].framelist[0]; - //already set! - - if ((obj->load==aCOLLAPSESCENERY) && (obj->counter)) - { //COLLAPSING!!! - obj->counter++; - if (obj->counter>obj->var4) - obj->state=sEXTRA; - } - break; - - - case sHIT: //hit, show next tile in anim - obj->phase=obj->var2-obj->energy; - tile=GetDestructAnimTile(obj->var1,obj->phase); - x=obj->xorg/(32*65536); - y=obj->yorg/(32*65536); - - PutSpriteLayerTile(x, y, (Word16)tile); - obj->state=sSLEEP; - obj->var5++; - break; - - - case sEXTRA: - x=obj->xorg/(32*65536); - y=obj->yorg/(32*65536); - - calc=GetEventParm(x,y,10,5); - obj->phase=0; - - if (calc==0) - obj->var4=7; - else - obj->var4=AISPEED/calc; - - obj->counter=obj->var4; - PlaySample(obj->xpos,obj->ypos,sCOMMON_COLLAPS,0,0); - - - obj->state=sFALL; - //break; //fallthru - - case sFALL: - obj->counter++; - if (obj->counter>obj->var4) - { - obj->counter=0; - obj->phase++; - if (obj->phase>=obj->var2) - { - obj->state=sKILL; - obj->phase=(Word8)obj->var2; - } - } - - if (obj->state==sKILL) - { - x=obj->xorg/(32*65536); - y=obj->yorg/(32*65536); - tile=GetDestructAnimTile(obj->var1,obj->var2+1); - AddParticleTile(x,y,tile,1); - //PlaySample(obj->xpos,obj->ypos,sCOMMON_DAMPED1,128,0); -// PlaySample(obj->xpos,obj->ypos,sCOMMON_COLLAPS,0,0); - - - obj->nohit=3+8; - obj->freeze=0; - obj->state=sDONE; - obj->curframe=0; - obj->counter=AISPEED*30; - } - - tile=GetDestructAnimTile(obj->var1,obj->phase); - x=obj->xorg/(32*65536); - y=obj->yorg/(32*65536); - PutSpriteLayerTile(x, y, (Word16)tile); - obj->var5++; - break; - - - case sKILL: - x=obj->xorg/(32*65536); - y=obj->yorg/(32*65536); - tile=GetDestructAnimTile(obj->var1,obj->var2+1); - AddParticleTile(x,y,tile,0); - PlaySample(obj->xpos,obj->ypos,sCOMMON_DAMPED1,128,0); - - tile=GetDestructAnimTile(obj->var1,obj->var2); - PutSpriteLayerTile(x, y, (Word16)tile); - - obj->nohit=3+8; - obj->freeze=0; - obj->state=sDONE; - obj->counter=AISPEED*30; - obj->curframe=0; - obj->var5++; - obj->light=0; - break; - - - case sDONE: //wait a few secs, then reappear - - if ((NumPlayers==1) || (MultiPlayerConnection>gameLOCAL)) - break; //never display again! - - obj->counter--; - - if (obj->counter<=0) - { - if (obj->var1) //not initialised yet (start skipped because instant deactivation) - { - GetNearestPlayer(num,64*64); - if (Distance>=64*64) - { - x=obj->xorg/(32*65536); - y=obj->yorg/(32*65536); - PutSpriteLayerTile(x, y, (Word16)obj->var1); - obj->state=sSLEEP; - - obj->energy=(Word8)obj->var2; - obj->phase=0; - obj->nohit=3; - obj->curframe=anims[obj->curanim].framelist[0]; //collision checking! - } - } - else - { - MyDeleteObject(num);//obj->code=NULL; - SetEventByte(obj->xorg/(32*65536),obj->yorg/(32*65536),obj->load); //get original block coords - } - } - break; - - case sDEACTIVATE: - - if (obj->var1==0) //not initialized yet, jumped directly in deactivate!!! - goto SkipAllThis; - - - if (InViewArea(obj->xpos,obj->ypos)) //reenable!!!! - { - if (obj->nohit==3+8) - obj->state=sDONE; - else - obj->state=sSLEEP; - } - - if ((obj->var5==0) || ReInitializingObjects) //only then, otherwise keep active - { - x=obj->xorg/(32*65536); - y=obj->yorg/(32*65536); - PutSpriteLayerTile(x, y, (Word16)obj->var1); - -SkipAllThis: - SetEventByte(obj->xorg/(32*65536),obj->yorg/(32*65536),obj->load); //get original block coords - - MyDeleteObject(num); - } - break; - - default: - FAIL("cDESTRUCTSCENERY(): Illegal state: obj:%i, type:%i, state:%i",num,obj->load,obj->state); - break; - } //switch -} //cDESTRUCTSCENERY - - - - -void cTRIGGERSCENERY(int num) -{ - Omonster *obj; - int x,y,tile,calc; - - obj=(Omonster *)(&gameobj[num]); - - switch (obj->state) - { - case sSTART: - x=obj->xorg/(32*65536); - y=obj->yorg/(32*65536); - - obj->var4=GetEventParm(x,y,0,5); - tile=GetSpriteLayerTile(x, y); - - obj->var1=tile; //org animtile - obj->var2=GetDestructAnimTileFrames(tile)-1; - - if (obj->var2<0) - { - DebugXMessage("WARNING: Trigger Scenery at position %i,%i needs at least 2 animation frames. TriggerScenery now deactivated",x,y); - obj->var2=0; - } - else - if (obj->var2<=0) - obj->var2=1; - obj->var3=GetDestructAnimTile(tile,0); - - PutSpriteLayerTile(x, y, (Word16)obj->var3); - - obj->phase=0; - - obj->nohit=3; - - obj->curanim=0; - obj->curframe=0; //collision checking! - obj->state=sSLEEP; - break; - - case sSLEEP: - if ((TriggerSceneryActive[obj->var4]) && (obj->var5<2)) - { - obj->counter++; - if ((obj->counter&3)==0) - { - calc=1+(obj->counter/4); - if (calc>=obj->var2) - { - calc=obj->var2; - obj->var5=2; - } - else - obj->var5=1; //changed! - - tile=GetDestructAnimTile(obj->var1,calc); - x=obj->xorg/(32*65536); - y=obj->yorg/(32*65536); - - PutSpriteLayerTile(x, y, (Word16)tile); - - } - } - else - if ((TriggerSceneryActive[obj->var4]==0) && obj->var5) - { - obj->var5=0; //reset it back!!! - - x=obj->xorg/(32*65536); - y=obj->yorg/(32*65536); - PutSpriteLayerTile(x, y, (Word16)obj->var3); - } - break; - -//if not yet changed, we can deactivate this object completely. otherwise, keep it active! - case sDEACTIVATE: - obj->state=sSLEEP; - - if ((obj->var5==0) || ReInitializingObjects) //only then, otherwise keep active - { - x=obj->xorg/(32*65536); - y=obj->yorg/(32*65536); - - if (obj->var1) //not initialised yet (start skipped because instant deactivation) - PutSpriteLayerTile(x, y, (Word16)obj->var1); - - SetEventByte(x,y,obj->load); //get original block coords - - MyDeleteObject(num);//obj->code=NULL; - } - break; - - default: - FAIL("cTRIGGERSCENERY(): Illegal state: obj:%i, type:%i, state:%i",num,obj->load,obj->state); - break; - } //switch -} //cTRIGGERSCENERY - - - - -void cGEMSTOMP(int num) -{ - Omonster *obj; - Omonster *obj2; - int t,cobj,numgems; - - - - obj=(Omonster *)(&gameobj[num]); - - switch (obj->state) - { - case sSTART: - obj->curframe=anims[obj->curanim].framelist[0]; //collision checking! - obj->state=sSLEEP; - obj->ypos-=4*65536; - break; - - case sSLEEP: - //do nothin! - break; - - case sKILL: - AddExplosion(obj->xpos,obj->ypos,AnimBase[mAMMO]+mAMMO_BOOM1); - - numgems=5+RandFac(7); - for (t=0;txpos+Rand2Fac(32767)*16,obj->ypos-(16+RandFac(15))*65536,aREDGEMTEMP,0); - if (cobj>0) - { - obj2=(Omonster *)(&gameobj[cobj]); - obj2->xspeed=Rand2Fac(32767)*32; - obj2->yspeed=-(int)RandFac(32767)*16; - obj2->var3=AISPEED/4; - obj2->objtype=oWAITPICKUP; - }; - }; - - MyDeleteObject(num);//obj->code=NULL; - break; - - - case sDEACTIVATE: - cDEACTIVATE(num); - break; - - default: - FAIL("cGEMSTOMP(): Illegal state: obj:%i, type:%i, state:%i",num,obj->load,obj->state); - break; - }; //switch - -} //cGEMSTOMP - - - -void raven(int num) -{ - Omonster *obj; - int oldy; - Word8 oldfreeze; - int nump; - int wantx,wanty; - int wantsx,wantsy,maxspeed; - - - obj=(Omonster *)(&gameobj[num]); - - - switch (obj->state) - { - case sSTART: - obj->state=sIDLE; - break; - - case sIDLE: - obj->curanim=AnimBase[mRAVEN]+mRAVEN_FLYCYC; - - obj->phase=(Word8)((gamecounter/6)%anims[obj->curanim].numframes); - obj->curframe=anims[obj->curanim].framelist[obj->phase]; - - obj->ypos+=sintable(gamecounter*4); - DrawGameobj(num); - - nump=GetNearestPlayer(num,192*192); - if (nump>=0) - { - obj->state=sFLOAT; - obj->counter=(768-64)/4; - - if (obj->xposvar2=768; - obj->var3=4; - } else - { - obj->var2=256; - obj->var3=-4; - }; - - obj->var1=nump; - }; - break; - - case sFLOAT: - obj->var2+=obj->var3; - obj->counter--; - if (obj->counter>0) - { - wantx=player[obj->var1].xpos+sintable(obj->var2)*96; - wanty=player[obj->var1].ypos-64*65536; - - maxspeed=(2+level.difficulty)*65536; - - wantsx=wantx-obj->xpos; - if (wantsx<-maxspeed) wantsx=-maxspeed; - else - if (wantsx>maxspeed) wantsx=maxspeed; - - wantsy=wanty-obj->ypos; - if (wantsy<-maxspeed) wantsy=-maxspeed; - else - if (wantsy>maxspeed) wantsy=maxspeed; - - obj->xpos+=wantsx; - obj->ypos+=wantsy; - - if (wantsx<-16384) - obj->direction=-1; - else - if (wantsx>16384) - obj->direction=1; - - } else - { - obj->state=sATTACK; - obj->counter=AISPEED*2; - obj->curanim=AnimBase[mRAVEN]+mRAVEN_ATTACK; - obj->var5=(player[obj->var1].xpos-obj->xpos); - - }; - - obj->phase=(Word8)((gamecounter/6)%anims[obj->curanim].numframes); - obj->curframe=anims[obj->curanim].framelist[obj->phase]; - - obj->ypos+=sintable(gamecounter*4); - DrawGameobj(num); - break; - - case sATTACK: - wantsx=obj->var5; - - maxspeed=(3+level.difficulty)*65536; - - if (wantsx>maxspeed) - wantsx=maxspeed; - else - if (wantsx<-maxspeed) - wantsx=-maxspeed; - - obj->xspeed=wantsx/4; - obj->yspeed=32768; - - obj->xpos+=obj->xspeed; - obj->ypos+=obj->yspeed; - - if (obj->xspeed<-16384) obj->direction=-1; - else - if (obj->xspeed>16384) obj->direction=1; - - obj->phase=(Word8)((gamecounter/6)%anims[obj->curanim].numframes); - obj->curframe=anims[obj->curanim].framelist[obj->phase]; - DrawGameobj(num); - - obj->counter--; - if ((obj->counter<0) || (obj->ypos+28*65536>player[obj->var1].ypos)) - { - obj->state=sSTOP; - obj->counter=0; - obj->curanim=AnimBase[mRAVEN]+mRAVEN_FLYCYC; - }; - break; - - - case sSTOP: - wantsx=(obj->xorg-obj->xpos); - wantsy=(obj->yorg-obj->ypos); - - maxspeed=(4+level.difficulty)*65536; - - if (wantsx>maxspeed) - wantsx=maxspeed; - else - if (wantsx<-maxspeed) - wantsx=-maxspeed; - - if (wantsy>maxspeed) - wantsy=maxspeed; - else - if (wantsy<-maxspeed) - wantsy=-maxspeed; - - obj->xspeed=(obj->xspeed+wantsx)/2; - obj->yspeed=(obj->yspeed+wantsy)/2; - - obj->xpos+=obj->xspeed; - obj->ypos+=obj->yspeed; - - if (obj->xspeed<0) obj->direction=-1; - else - if (obj->xspeed>0) obj->direction=1; - - obj->phase=(Word8)((gamecounter/6)%anims[obj->curanim].numframes); - obj->curframe=anims[obj->curanim].framelist[obj->phase]; - DrawGameobj(num); - - if (((obj->xpos/4096)==(obj->xorg/4096)) && ((obj->ypos/4096)==(obj->yorg/4096))) - { - obj->state=sIDLE; - obj->counter=0; - }; - break; - - case sFREEZE: - if (obj->freeze>0) obj->freeze--; - if (obj->freeze==0) obj->state=obj->oldstate; - - if (obj->freeze<30) - { - oldy=obj->ypos; obj->ypos+=4*Rand2Fac(16383); - oldfreeze=obj->freeze; obj->freeze=(Word8)RandFac(1); //let freeze anim flicker - - DrawGameobj(num); - obj->freeze=oldfreeze; - obj->ypos=oldy; - } else - DrawGameobj(num); - - break; - - case sKILL: - cKILL(num); - break; - - case sDEACTIVATE: - cDEACTIVATE(num); - break; - - default: - FAIL("raven(): Illegal state: obj:%i, type:%i, state:%i",num,obj->load,obj->state); - break; - }; //switch -} //raven() - - - - -void gemring(int num) -{ - Omonster *obj=(Omonster *)(&gameobj[num]); - Tplayer *play; - int px,py; - int numgems,fase=0; - int frame; - int nump; - int size=0; - int slot; - - - obj->counter++; - - if (obj->state==sSTART) - obj->state=sSLEEP; - else if (obj->state==sDEACTIVATE) - { - cDEACTIVATE(num); - return; - } - - - if (obj->state==sSLEEP) - { - nump=GetNearestPlayer(num,64*64); - if (nump>=0) - { - obj->state=sHIT; - - play=&player[nump]; - play->gem[1]+=8; - if ((play->lastgemcounter/100)<(play->gem[1]/100)) - { - slot=FindEmptyMessage(nump,3); - play->Display[slot].State=3; - play->Display[slot].Var1=10; - play->Display[slot].Counter=128; - } - else - { - slot=FindEmptyMessage(nump,4); - play->Display[slot].State=4; - play->Display[slot].Var1=1; - play->Display[slot].Counter=0; - } - play->Display[slot].Xpos=obj->xpos-play->viewstartx; - play->Display[slot].Ypos=obj->ypos-play->viewstarty; - } - - obj->var3=64+sintable(obj->counter*8)/4096; - - size=80-(obj->var3-64)/2; - obj->phase=(obj->counter/4)&7; - - fase=obj->counter*8; - } - else if (obj->state==sHIT) - { - obj->var2++; - obj->var3+=obj->var2/8; - - fase=obj->counter*8+obj->var3; - if (obj->var3>500) - { - MyDeleteObject(num);//obj->code=NULL; - return; - } - - size=80-(obj->var2/2)-sintable(obj->counter*8)/8192; - if (size<50) size=50; - - obj->phase=(obj->counter/2)&7; - - } - - - obj->curframe=anims[obj->curanim].framelist[obj->phase]; - - - for (numgems=0;numgems<8;numgems++) - { - fase+=128; - - px=obj->xpos+(sintable(fase)*obj->var3)/2; - py=obj->ypos+(costable(fase)*obj->var3)/2; - - - frame=anims[obj->curanim].framelist[obj->phase]; - if (obj->state==sSLEEP) - AddRotSprite(num,px,py,SPRITELAYER,(512+64+fase)/4,size,frame,0); - else - AddRotSprite(num,px,py,SPRITELAYER,(512+64+fase+obj->var2*8)/4,size,frame,0); - } - - -} //gemring() - - - -void rottree(int num) -{ - Omonster *obj; - Tplayer *play; - int px,py; - int frame; - int angle; - int hit=0; - int sy; - int calc,p,x0,y0,x1,y1,dx,dy; - - - obj=(Omonster *)(&gameobj[num]); - - - switch (obj->state) - { - case sSTART: - px=obj->xpos/(32*65536); - py=obj->ypos/(32*65536); - calc=GetEventParm(px,py,0,5); - - if (calc==0) - obj->ypos+=24*65536; - else - obj->ypos+=calc*65536; - - obj->xpos+=(16+GetEventParm(px,py,5,-6))*65536; - - obj->phase=0; - obj->curframe=anims[obj->curanim].framelist[obj->phase]; - - obj->var6=frames[obj->curframe].dy; - - obj->counter=0; - - obj->var3=0*256; //angle*256 - obj->var4=0; //speed - obj->state=sSLEEP; - break; - - case sFREEZE: - if (obj->freeze>0) - { - obj->freeze--; - if (obj->freeze==0) - obj->state=obj->oldstate; - }; - case sSLEEP: - angle=obj->var3/1024; - AddRotSprite(num,obj->xpos,obj->ypos,SPRITELAYER,angle,64,obj->curframe,0); - //staat rechtovereind: kan misschien sneller gedisplayed worden? (bijvoorbeeld de oude RLE sprite) - - if (obj->load!=aROTSMALLTREE) - { //this one is not solid! - - p=CheckPlayerSolidBox(num); - - if (p) //high speed collision, fall over - { - - }; - -/* -//collision! walk against it - frame=anims[obj->curanim].framelist[obj->phase]; - - x0=obj->xpos-frames[frame].dx*2*32768; - y0=obj->ypos-frames[frame].dy*65536; - - x1=obj->xpos+frames[frame].dx*2*32768; - y1=obj->ypos+16*65536; - - for (p=0;pypos>y0) && (play->yposxpos>x0-16*65536) && (play->xposxspeed>=0) && (play->xpos<=x0) && (play->xpos+play->xspeed>x0-4*65536)) - { - play->xpos=x0-4*65536; - play->xspeed=0;//-play->xspeed/2;//-32768; - }; - if ((play->xspeed<=0) && (play->xpos>=x1) && (play->xpos+play->xspeedxpos=x1+4*65536; - play->xspeed=0;//-play->xspeed/2;//32768; - }; - }; //if apx near - }; //for p -*/ - }; //if !small tree - break; - - case sHIT: - obj->curframe=0; //delete from collision stuff! - frame=anims[obj->curanim].framelist[obj->phase]; - obj->counter++; - - - if (obj->var3>0) - obj->var4+=obj->var2+64; - else - if (obj->var3<0) - obj->var4+=obj->var2-64; - else - obj->var4+=obj->var2; - - - obj->var3+=obj->var4; - - -//check collision: - - x0=(sintable(obj->var3/256)*obj->var6)/32; - y0=(costable(obj->var3/256)*obj->var6)/32; - - px=obj->xpos-x0; - py=obj->ypos-y0; - for (sy=0;sy<31;sy++) - { - hit=CheckPixel(px,py); - - if (hit) break; - - //AddSprite(px,py,SPRITELAYER-1,1,spriteNORMAL,0,anims[AnimBase[mAMMO]+mAMMO_BOMB].framelist[0]); - - px-=x0; - py-=y0;//-65536; - }; - - -//end of tree only - px=obj->xpos-sintable(obj->var3/256)*obj->var6; - py=obj->ypos-costable(obj->var3/256)*obj->var6; - - if (CheckForSpring(num,px,py)) - { - obj->var3-=obj->var4; //angle - - obj->var4=-obj->var4; - obj->var2=-obj->var2*2; - - hit=0; - }; - - - if (hit) - { - if (ABS(obj->var4)>256) - { - //PlaySample(px,py,sCOMMON_DAMPED1,128,0); - if (obj->load==aROTSMALLTREE) - PlaySample(px,py,sSMALTREE_GROUND,0,0); - - AddExplosion(px,py+10*65536,AnimBase[mAMMO]+mAMMO_BOOM1); - }; - - obj->var3-=obj->var4; - obj->var4=-obj->var4/4; - obj->var2=-obj->var2/4; - if (ABS(obj->var4)<32) - { - obj->state=sDONE; - obj->nohit=1; - }; - }; - - angle=obj->var3/1024; - AddRotSprite(num,obj->xpos,obj->ypos,SPRITELAYER,angle,64,frame,0); - ClearSolidBox(num); - break; - - case sDONE: - frame=anims[obj->curanim].framelist[obj->phase]; - angle=obj->var3/1024; - AddRotSprite(num,obj->xpos,obj->ypos,SPRITELAYER,angle,64,frame,0); - - -//collision! walk over it - - x0=obj->xpos; - y0=obj->ypos; - - x1=obj->xpos-sintable(angle*4)*frames[frame].dy; - y1=obj->ypos-costable(angle*4)*frames[frame].dy; - - //AddSprite(x0,y0,SPRITELAYER,1,spriteNORMAL,0,anims[AnimBase[mAMMO]+mAMMO_BOMB].framelist[0]); - //AddSprite(x1,y1,SPRITELAYER,1,spriteNORMAL,0,anims[AnimBase[mAMMO]+mAMMO_BOMB].framelist[0]); - - - if (x1xpos>x0) && (play->xposxpos-x0)/65536))/dx; - - if ((play->ypos>calc-28*65536) && - (play->yposyspeed>-65536)) - { - - if (play->downattackdownattack=DOWNATTACKLEN; - - play->ypos=calc-28*65536+32767; //round off - play->platform=num; - play->platformtype=1; - play->movexspeed=0; //no extra speed here - play->moveyspeed=0; - - hit=1; - }; - }; - - if (hit==0) - { - if (play->platform==num) - { - play->platform=0; - play->platformtype=0; - play->movexspeed=0; - play->moveyspeed=0; - }; - }; - }; - break; - - - case sKILL: - cKILL(num); - ClearSolidBox(num); - break; - - case sDEACTIVATE: - cDEACTIVATE(num); - ClearSolidBox(num); - break; - - default: - FAIL("rottree(): Illegal state: obj:%i, type:%i, state:%i",num,obj->load,obj->state); - break; - }; //switch - -} //rottree() - - - -void cAMBIENT(int num) -{ - Omonster *obj; - int volume; - - obj=(Omonster *)(&gameobj[num]); - - - if (obj->state==sDEACTIVATE) - cDEACTIVATE(num); - else - if (obj->state==sKILL) - MyDeleteObject(num);//obj->code=NULL; - else - if (obj->state==sSTART) - { - obj->var1=GetEventParm(obj->xpos/(32*65536),obj->ypos/(32*65536),0,8); - if (obj->var1==0) - obj->var1=sWIND_WIND2A; - else - if (obj->var1==1) - obj->var1=sCOMMON_BURNIN; - else - if (obj->var1==2) - obj->var1=sSCIENCE_PLOPKAOS; - - obj->var2=GetEventParm(obj->xpos/(32*65536),obj->ypos/(32*65536),8,16)/3; - - obj->var3=GetEventParm(obj->xpos/(32*65536),obj->ypos/(32*65536),16,1); - obj->var4=GetEventParm(obj->xpos/(32*65536),obj->ypos/(32*65536),17,1); - obj->state=sSLEEP; - } - else - { - if (obj->var4) - { - volume=obj->var2+ - sintable(gamecounter*4)/8192+ - sintable(gamecounter*6)/8192; - - } else - volume=obj->var2; - - - if (obj->var3) - { - obj->channel=PlayLoopSample(0,0,obj->var1,volume,0,obj->channel); - obj->xpos=player[0].xpos; - obj->ypos=player[0].ypos; - } - else - obj->channel=PlayLoopSample(obj->xpos,obj->ypos,obj->var1,volume,0,obj->channel); - - }; - -} //cAMBIENT() - - - - - - -void CirclePlatform(int num) -{ - Omonster *obj; - int n,xp,yp,angle; - int t,tx,ty,dx; - int newxpos,newypos; - int frame; - int radius,radadd; - int negacc; - int angleadd; - int res; - int oldangle=0; - - obj=(Omonster *)(&gameobj[num]); - - switch (obj->state) { - case sSTART: - xp=obj->xpos/(32*65536); - yp=obj->ypos/(32*65536); - obj->var2=GetEventParm(xp,yp,2,-6); //speed - obj->var3=GetEventParm(xp,yp,8,4); //number of elements - obj->phase=0; - obj->curframe=anims[obj->curanim].framelist[0]; - - if (obj->var2==0) { - obj->state=sPUSH; - obj->counter=obj->var5=0; - } else { - if (GetEventParm(xp,yp,12,1)) { - obj->var4=1; - } - obj->state=sACTION; - obj->var1=256*GetEventParm(xp,yp,0,2); //sync - obj->var6=obj->var2; - obj->counter=gamecounter; - obj->var5=obj->counter*obj->var2+obj->var1; - } - break; - - case sPUSH: - oldangle=obj->var5; - obj->counter=obj->counter&(256*1024-1); - - if (obj->counter>256*511) { - negacc=obj->counter/256-1024; - } else { - negacc=obj->counter/256; - } - if ((obj->var4>32) && (negacc>0)) { - negacc+=32; - } else if ((obj->var4<-32) && (negacc<0)) { - negacc-=32; - } - obj->var4-=negacc; - - if (obj->var4>12*256) obj->var4=12*256; - else - if (obj->var4<-12*256) obj->var4=-12*256; - - obj->var6=obj->var4/256; - - if (((obj->counter<256) || (obj->counter>1023*256)) && (ABS(obj->var4)<32)) - { - obj->var4=0; - obj->counter=0; - }; - - obj->counter+=obj->var4; //counter=angle*256 - obj->var5=obj->counter/256; - break; - - case sACTION: - oldangle=obj->var5; - obj->counter++; - obj->var5=obj->counter*obj->var2+obj->var1; - obj->var6=obj->var2; - - if (obj->var4==1) - oldangle=1024+sintable(obj->var5)/256; - //drawing is done below! - break; - - - case sFREEZE: - oldangle=obj->var5; - - obj->freeze--; - if (obj->freeze<=0) - { - if (obj->var2==0) - { - obj->state=sPUSH; - obj->var5=obj->counter/256; - } - else - { - if (GetEventParm(obj->xpos/(32*65536),obj->ypos/(32*65536),12,1)) - obj->state=sFLY; - else - obj->state=sACTION; - //obj->var5=(obj->counter+obj->var1*256)*obj->var2; - }; - }; - //still drawn below - break; - - case sKILL: - ClearPlayerPlatform(num); //clear remaining platform - - frame=anims[obj->killanim].framelist[0]; - radadd=frames[frame].dx-1; - radius=0; - - - angleadd=-obj->var6; - angle=obj->var5-angleadd*obj->var3; - - for (n=0;nvar3;n++) - { - xp=obj->xorg+radius*sintable(angle); - yp=obj->yorg+radius*costable(angle); - - AddSprite(xp,yp,SPRITELAYER,1,spriteNORMAL,0,frame); - - res=AddObject(xp,yp,aSHARD,0); - if (res>0) - { - gameobj[res].curanim=obj->killanim; - gameobj[res].state=sACTION; - if ((angle&1023)>512) - ((Omonster *)(&gameobj[res]))->xspeed=8192; - else - ((Omonster *)(&gameobj[res]))->xspeed=-8192; - }; - - angle+=angleadd; - radius+=radadd; - }; - - newxpos=obj->xorg+radius*sintable(angle); - newypos=obj->yorg+radius*costable(angle); - - obj->xspeed=0;//(newxpos-obj->xpos)/8; - obj->yspeed=0;//newypos-obj->ypos; - - obj->xpos=newxpos; - obj->ypos=newypos; - - DrawGameobj(num); - obj->objtype=oPARTICLE; - obj->nohit=3; - obj->energy=10; - obj->state=sACTION; - obj->ProcPtr=&cRANDPART; - - return; - break; - - - case sDEACTIVATE: - ClearPlayerPlatform(num); //clear remaining platform - cDEACTIVATE(num); - break; - - default: - FAIL("CirclePlatform(): Illegal state: obj:%i, type:%i, state:%i",num,obj->load,obj->state); - break; - }; //obj->state - - -//do common stuff - - - - -//DRAW:: - - frame=anims[obj->killanim].framelist[0]; - radadd=frames[frame].dx-1; - radius=0; - - - angleadd=-obj->var6; - angle=oldangle-angleadd*obj->var3; - - - for (n=0;nvar3;n++) - { - xp=obj->xorg+radius*sintable(angle); - yp=obj->yorg+radius*costable(angle); - - if (obj->freeze) - AddSprite(xp,yp,SPRITELAYER,1,spriteFREEZE,0,frame); - else - AddSprite(xp,yp,SPRITELAYER,1,spriteNORMAL,0,frame); - - angle+=angleadd; - radius+=radadd; - }; - - newxpos=obj->xorg+radius*sintable(angle); - newypos=obj->yorg+radius*costable(angle); - - - obj->xspeed=newxpos-obj->xpos; - obj->yspeed=newypos-obj->ypos; - - obj->xpos=newxpos; - obj->ypos=newypos; - - DrawGameobj(num); - - - if (obj->load!=aSPIKEBOLL) //only when you can stand on it! - { //collision - - dx=frames[obj->curframe].dx; - - for (t=0;txpos)/65536; - ty=(player[t].ypos-obj->ypos)/65536; - - - if (player[t].platform==num) - { - if ((tx>-dx/2) && (tx-28) && (ty<0)) - { - player[t].downattack=DOWNATTACKLEN+AISPEED; //disable - //need +aispeed because of diving! - - player[t].platform_rely=-24*65536; - - player[t].movexspeed=0;//obj->xspeed; - player[t].moveyspeed=0;//obj->yspeed; - } else - { - player[t].platform=0; - player[t].platformtype=0; - player[t].movexspeed=0; - player[t].moveyspeed=0; - }; - - } else - { - if ((tx>-dx/2) && (tx-28) && (ty<-20) && - (player[t].yspeed>obj->yspeed-65536)) - { - player[t].downattack=DOWNATTACKLEN+AISPEED; //disable - - player[t].platform_rely=-24*65536; - player[t].platform_relx=player[t].xpos-obj->xpos; - - player[t].platform=num; - player[t].platformtype=2; - - player[t].movexspeed=0;//obj->xspeed; - player[t].moveyspeed=0;//obj->yspeed; - } - } - } - } - -} //CirclePlatform() - - void cGENERATOR(int num) { diff --git a/dollop of sauce - decomp/g_aisetup.c b/dollop of sauce - decomp/g_aisetup.c index 93c009c..83409a2 100644 --- a/dollop of sauce - decomp/g_aisetup.c +++ b/dollop of sauce - decomp/g_aisetup.c @@ -134,407 +134,6 @@ void SetupEnemies2(void); // Extremely long functions take extremely long to compile when global optimizations are on -void SetupBullets(void) -{ - Obullets *obj; - Omonster *mons; - -//BULLET1 - obj=(Obullets *)(&loadobj[aPLAYERBULLET1]); - obj->xspeed=6*65536; - //obj->yspeed=0; - obj->xacc=8192; - obj->force=1; - obj->ProcPtr=&cBULLET1; - obj->objtype=oPLAYERBULLET; - obj->killanim=AnimBase[mAMMO]+mAMMO_XPLOS1; - obj->curanim=AnimBase[mAMMO]+mAMMO_GUN1; - obj->upanim=AnimBase[mAMMO]+mAMMO_GUN1U; - obj->type=bullNORMAL; - obj->lighttype=2; - obj->var4=1; - obj->lifetime=AISPEED/2; - -//BULLET2 - obj=(Obullets *)(&loadobj[aPLAYERBULLET2]); - obj->xspeed=5*65536; - obj->yspeed=65536; - obj->xacc=16384; - obj->yacc=6000; - obj->force=1; - obj->ProcPtr=&cBOUNCE; - obj->objtype=oPLAYERBULLET; - obj->killanim=AnimBase[mAMMO]+mAMMO_BOOM3; - obj->curanim=AnimBase[mAMMO]+mAMMO_GUN2; - obj->upanim=AnimBase[mAMMO]+mAMMO_GUN2; - //obj->type=bullNORMAL; - obj->lighttype=2; - obj->var4=2; - obj->lifetime=(AISPEED*3)/2; - -//BULLET3 : FREEZER - obj=(Obullets *)(&loadobj[aPLAYERBULLET3]); - obj->xspeed=6*65536; - obj->xacc=8192; - obj->force=2; - obj->ProcPtr=&cBULLET1; - obj->freeze=200; //set this to length of freeze!!! - obj->objtype=oPLAYERBULLET; - obj->killanim=AnimBase[mAMMO]+mAMMO_XPLOS3; - obj->curanim=AnimBase[mAMMO]+mAMMO_GUN3; - obj->upanim=AnimBase[mAMMO]+mAMMO_GUN3U; - //obj->type=bullNORMAL; - obj->lighttype=2; - obj->var4=3; - obj->lifetime=AISPEED/2; - - -//BULLET4 - obj=(Obullets *)(&loadobj[aPLAYERBULLET4]); - obj->xspeed=2*65536; - obj->xacc=16384; - obj->yacc=256; - obj->force=2; - obj->ProcPtr=&cSEEKINGROCKET; - obj->objtype=oPLAYERBULLET; - obj->killanim=AnimBase[mAMMO]+mAMMO_BOOM4; - obj->curanim=AnimBase[mAMMO]+mAMMO_GUN4NR; - obj->upanim=AnimBase[mAMMO]+mAMMO_GUN4NU; - //obj->type=bullNORMAL; - obj->lighttype=2; - obj->var4=4; - obj->lifetime=2*AISPEED; - -//BULLET5 - obj=(Obullets *)(&loadobj[aPLAYERBULLET5]); - obj->xspeed=65536; - //obj->yspeed=0; - obj->xacc=4096*3; - obj->ProcPtr=&rocket1; - obj->force=2; - obj->objtype=oPLAYERBULLET; - obj->killanim=AnimBase[mAMMO]+mAMMO_BOOM2; - obj->curanim=AnimBase[mAMMO]+mAMMO_GUN5; - obj->upanim=AnimBase[mAMMO]+mAMMO_GUN5U; - //obj->type=bullNORMAL; - obj->lighttype=2; - obj->var4=5; - obj->lifetime=40; - - -//BULLET6-flamer - obj=(Obullets *)(&loadobj[aPLAYERBULLET6]); - obj->xspeed=4*65536; - obj->xacc=8192; - obj->ProcPtr=&flamebullet; - obj->force=1; - obj->objtype=oPLAYERBULLET; - //obj->killanim=AnimBase[mAMMO]+mAMMO_XPLOS2; - obj->curanim=AnimBase[mAMMO]+mAMMO_GUN6; - obj->upanim=obj->curanim; - obj->type=bullFLAMER; - obj->lighttype=0; - obj->var4=6; - obj->lifetime=AISPEED/2; - -//BULLET8 - obj=(Obullets *)(&loadobj[aPLAYERBULLET8]); - obj->xspeed=2*65536; - //obj->yspeed=0; - obj->xacc=8192; - obj->force=2; - obj->ProcPtr=&cBULLET1; - obj->objtype=oPLAYERBULLET; - obj->killanim=AnimBase[mAMMO]+mAMMO_XPLOS1; - obj->curanim=AnimBase[mAMMO]+mAMMO_GUN8; - obj->upanim=AnimBase[mAMMO]+mAMMO_GUN8U; - //obj->type=bullNORMAL; - obj->lighttype=2; - obj->var4=8; - obj->lifetime=AISPEED/2; - -//BULLET9 - obj=(Obullets *)(&loadobj[aPLAYERBULLET9]); - obj->ProcPtr=&cBLAMMER; - obj->curanim=obj->upanim=AnimBase[mAMMO]+mAMMO_XPLOS2; //collision! whatever - obj->phase=0; - obj->objtype=oPLAYERBULLET; - obj->force=1; - obj->type=bullFLAMER; - obj->lighttype=2; - obj->xspeed=4*65536; - obj->yspeed=0; - obj->lifetime=AISPEED/2; - -/* - obj->xspeed=2*65536; - //obj->yspeed=0; - obj->xacc=8192; - obj->force=2; - obj->code=&cBULLET1; - obj->objtype=oPLAYERBULLET; - obj->killanim=AnimBase[mAMMO]+mAMMO_XPLOS1; - obj->curanim=AnimBase[mAMMO]+mAMMO_GUN9; - obj->upanim=AnimBase[mAMMO]+mAMMO_GUN9; - //obj->type=bullNORMAL; - obj->lighttype=2; - obj->var4=9; -*/ - - -//PBULLET1 - obj=(Obullets *)(&loadobj[aPLAYERBULLETP1]); - obj->xspeed=7*65536; - //obj->yspeed=0; - obj->xacc=4096*3; - obj->force=2; - obj->ProcPtr=&cBULLET1; - obj->objtype=oPLAYERBULLET; - obj->killanim=AnimBase[mAMMO]+mAMMO_XPLOS1; - obj->curanim=AnimBase[mAMMO]+mAMMO_GUN1P; - obj->upanim=AnimBase[mAMMO]+mAMMO_GUN1UP; - obj->type=bullPOWER; - obj->lighttype=1; - obj->var4=1; - obj->lifetime=30; - -//PBULLET2 - obj=(Obullets *)(&loadobj[aPLAYERBULLETP2]); - obj->xspeed=5*65536; - obj->yspeed=65536; - obj->xacc=16384; - obj->yacc=6000; - obj->force=2; - obj->ProcPtr=&cBOUNCE2; - obj->objtype=oPLAYERBULLET; - obj->killanim=AnimBase[mAMMO]+mAMMO_BOOM3; - obj->curanim=AnimBase[mAMMO]+mAMMO_GUN2P; - obj->upanim=AnimBase[mAMMO]+mAMMO_GUN2P; - obj->type=bullPOWER; - obj->lighttype=2; - obj->var4=2; - obj->lifetime=(AISPEED*3)/2; - - -//PBULLET3 : FREEZER - obj=(Obullets *)(&loadobj[aPLAYERBULLETP3]); - obj->xspeed=7*65536; - obj->xacc=4096*3; - obj->force=2; - obj->ProcPtr=&cSINEBULLET1; - obj->freeze=254; //set this to length of freeze!!! - obj->objtype=oPLAYERBULLET; - obj->killanim=AnimBase[mAMMO]+mAMMO_XPLOS3; - obj->curanim=AnimBase[mAMMO]+mAMMO_GUN3P; - obj->upanim=AnimBase[mAMMO]+mAMMO_GUN3UP; - obj->type=bullPOWER; - obj->lighttype=2; - obj->var4=3; - obj->lifetime=30; - - -//PBULLET4 - obj=(Obullets *)(&loadobj[aPLAYERBULLETP4]); - obj->xspeed=32768*3; - obj->xacc=16384; - obj->yacc=256; - obj->force=3; - obj->ProcPtr=&cSEEKINGROCKET; - obj->objtype=oPLAYERBULLET; - obj->killanim=AnimBase[mAMMO]+mAMMO_BOOM4; - obj->curanim=AnimBase[mAMMO]+mAMMO_GUN4PR; - obj->upanim=AnimBase[mAMMO]+mAMMO_GUN4PU; - obj->type=bullPOWER; - obj->lighttype=2; - obj->var4=4; - obj->lifetime=2*AISPEED; - - -//PBULLET5 - obj=(Obullets *)(&loadobj[aPLAYERBULLETP5]); - obj->xspeed=32768*3; - //obj->yspeed=0; - obj->xacc=4096*3; - obj->ProcPtr=&rocket1; - obj->force=2; - obj->objtype=oPLAYERBULLET; - obj->killanim=AnimBase[mAMMO]+mAMMO_BOOM2; - obj->curanim=AnimBase[mAMMO]+mAMMO_GUN5P; - obj->upanim=AnimBase[mAMMO]+mAMMO_GUN5PU; - obj->type=bullPOWER; - obj->lighttype=2; - obj->var4=5; - obj->lifetime=AISPEED/2; - - -//PBULLET6-flamer - obj=(Obullets *)(&loadobj[aPLAYERBULLETP6]); - obj->xspeed=4*65536; - obj->xacc=8192; - obj->ProcPtr=&flamebullet; - obj->force=1; //too strong already - obj->objtype=oPLAYERBULLET; - //obj->killanim=AnimBase[mAMMO]+mAMMO_XPLOS2; - obj->curanim=AnimBase[mAMMO]+mAMMO_GUN6P; - obj->upanim=AnimBase[mAMMO]+mAMMO_GUN6P; - obj->type=bullFLAMER+bullPOWER; - obj->lighttype=0; - obj->var4=6; - obj->lifetime=AISPEED/2; - - -//PBULLET8 - obj=(Obullets *)(&loadobj[aPLAYERBULLETP8]); - obj->xspeed=4*65536; - //obj->yspeed=0; - obj->xacc=4096*4; - obj->force=3; - obj->ProcPtr=&cBULLET1; - obj->objtype=oPLAYERBULLET; - obj->killanim=AnimBase[mAMMO]+mAMMO_XPLOS1; - obj->curanim=AnimBase[mAMMO]+mAMMO_GUN8P; - obj->upanim=AnimBase[mAMMO]+mAMMO_GUN8UP; - obj->type=bullPOWER; - obj->lighttype=1; - obj->var4=8; - obj->lifetime=AISPEED/2; - -//PBULLET9 - obj=(Obullets *)(&loadobj[aPLAYERBULLETP9]); - - obj->ProcPtr=&cBLAMMER; - obj->curanim=obj->upanim=AnimBase[mAMMO]+mAMMO_XPLOS2; //collision! whatever - obj->phase=0; - obj->objtype=oPLAYERBULLET; - obj->force=1; - obj->type=bullFLAMER; - obj->lighttype=2; - obj->xspeed=4*65536; - obj->yspeed=0; - obj->lifetime=AISPEED/2; - -//PCRAZYBULLET 1- fire - obj=(Obullets *)(&loadobj[aPLAYERBULLETC1]); - obj->xspeed=2*65536; - obj->xacc=8192; - obj->ProcPtr=&cBULLET1; - obj->force=3; - obj->objtype=oPLAYERBULLET; - //obj->killanim=AnimBase[mAMMO]+mAMMO_XPLOS2; - obj->curanim=AnimBase[mAMMO]+mAMMO_FIRESHOT; - obj->type=bullFLAMER; - obj->lighttype=2; - obj->var4=6; - obj->lifetime=(AISPEED*2)/3; - - -//PCRAZYBULLET 2 -bubble - obj=(Obullets *)(&loadobj[aPLAYERBULLETC2]); - obj->xspeed=2*65536; - obj->xacc=8192; - obj->ProcPtr=&cBUBBLYSPRAY; - obj->force=1; - obj->objtype=oPLAYERBULLET; - //obj->killanim=AnimBase[mAMMO]+mAMMO_XPLOS2; - obj->curanim=AnimBase[mAMMO]+mAMMO_BUB; - obj->type=bullPOWER; - obj->lighttype=1; - obj->var4=1; - obj->lifetime=(AISPEED*2)/3; - - -//PCRAZYBULLET 3 -electricity - obj=(Obullets *)(&loadobj[aPLAYERBULLETC3]); - obj->xspeed=2*65536; - obj->xacc=8192; - obj->ProcPtr=&cBULLET1; - obj->force=3; - obj->objtype=oPLAYERBULLET; - //obj->killanim=AnimBase[mAMMO]+mAMMO_XPLOS2; - obj->curanim=AnimBase[mAMMO]+mAMMO_ELECSHOT; - obj->type=bullPOWER; - obj->lighttype=1; - obj->var4=1; - obj->lifetime=(AISPEED*2)/3; - -//LASER - obj=(Obullets *)(&loadobj[aPLAYERLASER]); - obj->xspeed=16*65536; //for moving objects around! - obj->xacc=4*65536; - obj->ProcPtr=&cLASER; - obj->force=8; - obj->objtype=oPLAYERBULLET; - //obj->killanim=AnimBase[mAMMO]+mAMMO_XPLOS2; - //obj->curanim=AnimBase[mAMMO]+mAMMO_ELECSHOT; - obj->type=bullPOWER+bullLASER+bullFLAMER; - obj->lighttype=6; - obj->light=127; - obj->var4=8; //goes through anything - - -//TNNT - obj=(Obullets *)(&loadobj[aTNT]); - obj->ProcPtr=&cTNT; - obj->energy=1; //minimum, always gets killed - obj->objtype=oSPECIAL; - obj->curanim=AnimBase[mAMMO]+mAMMO_GUN7ITEM; - obj->killanim=AnimBase[mAMMO]+mAMMO_TNTEXPL; - //obj->type=bullPOWER; - obj->lighttype=1; - obj->var4=7; - obj->lifetime=255; - - - -//BOMB - obj=(Obullets *)(&loadobj[aBOMB]); - obj->ProcPtr=&bomb; - obj->objtype=oSPECIAL; - obj->direction=1; - //obj->energy=0; - obj->curanim=AnimBase[mAMMO]+mAMMO_BOMB; - obj->killanim=AnimBase[mAMMO]+mAMMO_XPLOS2; - obj->lighttype=2; - obj->lifetime=AISPEED*3/2; - - -//BANANA - obj=(Obullets *)(&loadobj[aBANANA]); - obj->ProcPtr=&floating; - obj->objtype=oPICKUP; - obj->direction=1; - obj->curanim=AnimBase[mPICKUPS]+mPICKUPS_BANANA; - obj->killanim=AnimBase[mPICKUPS]+mPICKUPS_SPRKLE; - obj->points=50; - obj->lifetime=AISPEED/2; - - - -/////////////////////////////////// - -//GENERAL SHARD - mons=(Omonster *)(&loadobj[aSHARD]); - mons->ProcPtr=&cRANDPART; - mons->objtype=oPARTICLE; - -//GENERAL SHARD2 - mons=(Omonster *)(&loadobj[aBOUNCEONCE]); - mons->ProcPtr=&cRANDPART2; - mons->objtype=oPARTICLE; - - -//GENERAL SMOKE/EXPLOSION PARTICLE - mons=(Omonster *)(&loadobj[aEXPLOSION]); - mons->ProcPtr=&cEXPLOSION; - mons->objtype=oPARTICLE; - mons->lighttype=1; -// mons->curanim=AnimBase[mAMMO]+mAMMO_POOF1; - - -} //SetupBullets() - - - /* blah points costs @@ -2578,82 +2177,6 @@ void SetupEnemies2(void) } //SetupEnemies() -void ReInitObjects(int nump) -{ - int num,x,y; - Word32 *event; - -/* this flag lets objects know that the sDEACTIVATE state means they should restore - because the whole level is reinitialized (not a sDEACTIVATE because of out-of-screen - clipping -*/ - ReInitializingObjects=1; - - - for (num=1;num> 16; - int yPixel = y >> 16; - int xTile = xPixel >> 5; - int yTile = yPixel >> 5; - int res; - - if (((Word32)xPixel > (Word32)level.pixelwidth) || ((Word32)yPixel > (Word32)level.pixelheight)) - { - return(-2); - } - - tile=GetSpriteLayerTile(xTile, yTile); - - if (tile) - { - tileattr=GetEvent(xTile, yTile); - //if ((tileattr&31) && (SOLIDAREA[tileattr&31]==0)) return 0; //check for attr - - res=GetBit(tile, (xPixel & 31), (yPixel & 31)); - return(res); - } - else - { - return(0); - } -} //CheckPixel - - - -int CheckFullPixel(int x,int y) -{ - int tile; - int tx,ty; - int res; - - tx=x/65536; - ty=y/65536; - - if (((Word)tx>(Word)level.pixelwidth) || - ((Word)ty>(Word)level.pixelheight)) - { - return(-2); - } - - - tile=GetSpriteLayerTile(tx/32, ty/32); - - if (tile) - { - tileattr=GetEvent(tx/32,ty/32); - - if ((tileattr==areaONEWAY) || - (tileattr==areaVINE) || - (tileattr==areaHOOK)) - { - return(0); - } - else - { - res=GetBit(tile,tx&31,ty&31); - return(res); - } - } - else - return(0); - -} //CheckFullPixel - - - - - - - int BCheckHline(int tile0,int tile1,int xs,int dx,int y) { int check=0; @@ -168,536 +88,8 @@ int CheckHBlock(int tile0,int tile1,int tile2,int tile3,int xs,int ys) return(yt); } //CheckHBlock() - -int CheckHLine(int x1,int dx,int y) -{ - int blockx,blocky; - int fractx,fracty; - int tile; - int x; - int check; - int xcheckend; - - x=x1; - check=0; - - blocky=y/32; - fracty=y&31; - - if ((blocky<0) || - (blocky>level.blockheight)) - { - return(0); - } - - do - { - fractx=x&31; - blockx=x/32; - if ((blockx<0) || - (blockx>(int)level.blockwidth)) - tile=0; - else - tile=GetSpriteLayerTile(blockx, blocky); - - if (tile) - tileattr=GetEvent(blockx,blocky); - - xcheckend=fractx+dx; - if (xcheckend>=31) - { - if (tile) check=GetRBits(tile,fractx,fracty); - dx-=32-fractx; - x+=32-fractx; //should be 0 on next iter - } - else - if (fractx==0) - { - if (tile) check=GetLBits(tile,xcheckend,fracty); - dx=0; //we should stop after this - } - else - { - if (tile) check=GetBits(tile,fractx,xcheckend,fracty); - dx=0; //we should stop after this - }; - - } while ((!check) && (dx>0)); - - return(check); -} //CheckHLine() - - -//this one checks for REAL solid pixels inside, will exit -//only when it found a real pixel inside a block will attr 0 -int TCheckHLine(int x1,int dx,int y) -{ - int blockx,blocky; - int fractx,fracty; - int tile; - int x; - int check; - int xcheckend; - - x=x1; - check=0; - - blocky=y/32; - fracty=y&31; - - if ((blocky<0) || - (blocky>level.blockheight)) - { - return(0); - } - - - do - { - fractx=x&31; - blockx=x/32; - if ((blockx<0) || - (blockx>(int)level.blockwidth)) - tile=0; - else - tile=GetSpriteLayerTile(blockx, blocky); - - if (tile) - { - tileattr=GetEvent(blockx,blocky); - if ((tileattr) && - (tileattr<29) && - (SOLIDAREA[tileattr&31]==0)) tile=0; - } - - xcheckend=fractx+dx; - if (xcheckend>=31) - { - if (tile) check=GetRBits(tile,fractx,fracty); - dx-=32-fractx; - x+=32-fractx; //should be 0 on next iter - } - else - if (fractx==0) - { - if (tile) check=GetLBits(tile,xcheckend,fracty); - dx=0; //we should stop after this - } - else - { - if (tile) check=GetBits(tile,fractx,xcheckend,fracty); - dx=0; //we should stop after this - } - - } while ((!check) && (dx>0)); - - return(check); -} //TCheckHLine() - - - -int CheckVLine(int x,int y1,int dy) -{ - int blockx,blocky; - int fractx,fracty; - int tile; - int y; - int y2; - int check; - int start; - - y=y1; y2=y1+dy; - start=1; - check=0; - - blockx=x/32; fractx=x&31; - blocky=y/32; - - if ((blockx<0) || - (blockx>(int)level.blockwidth)) - { - return(0); - } - - - do{ - fracty=y&31; - if ((!fracty) || (start)) - { - blocky=y/32; - if ((blocky<0) || - (blocky>level.blockheight)) - tile=0; - else - tile=GetSpriteLayerTile(blockx, blocky); - - if (tile) - { - start=0; - tileattr=GetEvent(blockx,blocky); - } - } - - if (tile) - check=GetBit(tile,fractx,fracty); - - y++; - } while ((!check) && (y<=y2)); - - return(y-y1); -} //CheckVLine() - - -int PixelCollision(Tgameobj *obj1,Tgameobj *obj2) -{ - Tframes *frame1; - Tframes *frame2; - int x1,y1,dx1,dy1; - int x2,y2,dx2,dy2; - int xb,xe,yb,ye; - int pix1,pix2; - int lx,ly; - Word32 bofs1; - Word32 bofs2; - int dir1; - int dir2; - Word32 bit1; - Word32 bit2; - Word32 mask1; - Word32 mask2; - Word32 sx1,sx2; - Word32 numhits=0; - Word32 *maskptr1; - Word32 *maskptr2; - - - if ((obj1->curframe<=0) || (obj1->curframe>=MAXFRAMES) || - (obj2->curframe<=0) || (obj2->curframe>=MAXFRAMES)) - return(0); //0 frame, outta here - -// ASSERT(obj1->curframecurframecurframe]; - frame2=&frames[obj2->curframe]; - - if ((frame1->mask==NULL) || (frame2->mask==NULL)) - { - return(0); - } - - - x1=(obj1->xpos/65536); - dx1=frame1->dx; - dir1=obj1->direction; - - y1=(obj1->ypos/65536)+frame1->ty2; - dy1=frame1->dy; - - x2=(obj2->xpos/65536); - dx2=frame2->dx; - dir2=obj2->direction; - - y2=(obj2->ypos/65536)+frame2->ty2; - dy2=frame2->dy; - - if (dir1<0) - { - x1-=frame1->tx2; - sx1=x1-dx1; - } - else - { - dir1=1; //override for dir2==0 - x1+=frame1->tx2; - sx1=x1; - } - - if (dir2<0) - { - x2-=frame2->tx2; - sx2=x2-dx2; - } - else - { - dir2=1; //override for dir2==0 - x2+=frame2->tx2; - sx2=x2; - } - - - if (((sx1+dx1)>sx2) && (sx1<(sx2+dx2)) && - ((y1+dy1)>y2) && (y1<(y2+dy2))) - { //TOUCHIN! - if (sx1>sx2) xb=sx1; else xb=sx2; - if ((sx1+dx1)<(sx2+dx2)) xe=sx1+dx1; else xe=sx2+dx2; - - if (y1>y2) yb=y1; else yb=y2; - if ((y1+dy1)<(y2+dy2)) ye=y1+dy1; else ye=y2+dy2; - - - if (dir1<0) - bofs1=((yb-y1)*dx1)+x1-xb; - else - bofs1=((yb-y1)*dx1)-x1+xb; - - if (dir2<0) - bofs2=((yb-y2)*dx2)+x2-xb; - else - bofs2=((yb-y2)*dx2)-x2+xb; - - - if ((dir1>0) && (dir2>0)) - { - xe-=xb; - for (ly=yb;lymask+(bofs1/32); - maskptr2=frame2->mask+(bofs2/32); - - bit1=1<<(bofs1&31); - bit2=1<<(bofs2&31); - - mask1=*maskptr1++; - mask2=*maskptr2++; - - lx=xe; - do { - pix1=mask1&bit1; //get bit (just !=0 is enough) - pix2=mask2&bit2; - - if (pix1 && pix2) { - - numhits++; //HIT ! - if (numhits>7) goto EXITNOW; - } - - bit1<<=1; //shift test position - if (bit1==0) //shifted all out, read next - { - bit1=1; //test first bit - mask1=*maskptr1++; //next maskofs - } - - bit2<<=1; //shift test position - if (bit2==0) //shifted all out - { - bit2=1; //bit is now 1 (test first bit) - mask2=*maskptr2++; //next maskofs - } - } while (--lx>0); //just a counter, not used inside the loop - bofs1+=dx1; - bofs2+=dx2; - - } //for ly - } - else - if ((dir1>0) && (dir2<0)) - { - xe-=xb; - for (ly=yb;lymask+(bofs1/32); - maskptr2=frame2->mask+(bofs2/32); - - bit1=1<<(bofs1&31); - bit2=1<<(bofs2&31); - - mask1=*maskptr1++; - mask2=*maskptr2--; - - lx=xe; - do { - pix1=mask1&bit1; //get bit (just !=0 is enough) - pix2=mask2&bit2; - - if (pix1 && pix2) { - numhits++; //HIT ! - if (numhits>7) goto EXITNOW; - } - - bit1<<=1; //shift test position - if (bit1==0) //shifted all out, read next - { - bit1=1; //test first bit - mask1=*maskptr1++; //next maskofs - } - - bit2>>=1; //shift test position - if (bit2==0) //shifted all out - { - bit2=1<<31; //bit is now 1 (test first bit) - mask2=*maskptr2--; //next maskofs - } - } while (--lx>0); //just a counter, not used inside the loop - bofs1+=dx1; - bofs2+=dx2; - } //for ly - } - else - if ((dir1<0) && (dir2>0)) - { - xe-=xb; - for (ly=yb;lymask+(bofs1/32); - maskptr2=frame2->mask+(bofs2/32); - - bit1=1<<(bofs1&31); - bit2=1<<(bofs2&31); - - mask1=*maskptr1--; - mask2=*maskptr2++; - - lx=xe; - do { - pix1=mask1&bit1; //get bit (just !=0 is enough) - pix2=mask2&bit2; - - if (pix1 && pix2) { - numhits++; //HIT ! - if (numhits>7) goto EXITNOW; - } - - bit1>>=1; //shift test position - if (bit1==0) //shifted all out, read next - { - bit1=1<<31; //test first bit - mask1=*maskptr1--; //next maskofs - } - - bit2<<=1; //shift test position - if (bit2==0) //shifted all out - { - bit2=1; //bit is now 1 (test first bit) - mask2=*maskptr2++; //next maskofs - } - } while (--lx>0); //just a counter, not used inside the loop - bofs1+=dx1; - bofs2+=dx2; - } //for ly - } - else - if ((dir1<0) && (dir2<0)) - { - xe-=xb; - for (ly=yb;lymask+(bofs1/32); - maskptr2=frame2->mask+(bofs2/32); - - bit1=1<<(bofs1&31); - bit2=1<<(bofs2&31); - - mask1=*maskptr1--; - mask2=*maskptr2--; - - lx=xe; - do { - pix1=mask1&bit1; //get bit (just !=0 is enough) - pix2=mask2&bit2; - - if (pix1 && pix2) { - numhits++; //HIT ! - if (numhits>7) goto EXITNOW; - } - - bit1>>=1; //shift test position - if (bit1==0) //shifted all out, read next - { - bit1=1<<31; //test first bit - mask1=*maskptr1--; //next maskofs - } - - bit2>>=1; //shift test position - if (bit2==0) //shifted all out - { - bit2=1<<31; //bit is now 1 (test first bit) - mask2=*maskptr2--; //next maskofs - } - } while (--lx>0); //just a counter, not used inside the loop - bofs1+=dx1; - bofs2+=dx2; - } //for ly - } -EXITNOW: - return(numhits); - } // else - return(0); -} //PixelCollision() - - -int OnScreen(int x,int y) -{ - int nump; - int px,py; - int width,height; - - width=ScreenWidth*65536/2; - height=ScreenHeight*65536/2; - -//for all localplayers - - for (nump=0;nump(px+width)) || - (y<(py-height)) || - (y>(py+height))) - continue; - else - { - return(1); - } - } - return(0); -} //OnScreen() - - #define INVIEWACTIVEX 320*3*65536 #define INVIEWACTIVEY 200*4*65536 -int InViewArea(int x,int y) -{ - int nump; - int px,py; - - for (nump=0;nump(px+INVIEWACTIVEX)) || - (y<(py-INVIEWACTIVEY)) || - (y>(py+INVIEWACTIVEY))) - continue; - else - { - return(1); - } - } - return(0); -} //InViewArea - - - -int CheckInLevel(int x,int y) -{ - if ((x<-320*65536) || (y<-200*65536) || (x>=320*65536+level.fixwidth) || (y>=200*65536+level.fixheight)) - return 0; - else - return 1; -} //CheckInLevel() - - - @@ -730,60 +122,3 @@ void PutObjectOnGround(int num) - -void PutWalkerOnGround(int num) -{ - Tgameobj *obj; - int px,py; - - - obj=&gameobj[num]; - - obj->curframe=anims[obj->curanim].framelist[0]; - - obj->ypos-=15*65536; //start a bit higher - - px=obj->xpos+(((frames[obj->curframe].dx/2)+frames[obj->curframe].tx2)*65536); - py=(frames[obj->curframe].ty2-frames[obj->curframe].ty)*65536; - - // Move object down until we've hit something - for (; obj->yposypos+=65536) - if (CheckPixel(px, obj->ypos+py)) break; - -} //PutWalkerOnGround() - - - - -int CheckForSpring(int num,int x,int y) -{ - int t,dx,dy; - Omonster *mons; - - for (t=1;t-8*65536) && (dx<8*65536)) - { - dy=y-gameobj[t].ypos; - - if ((dy>-16*65536) && (dy<4*65536)) - { - mons=(Omonster *)(&gameobj[t]); - if ((mons->var3>=mons->var2) && (mons->xspeed==0)) - { - mons->state=sSPRING; - mons->special=num; - mons->var3=0; - return(t); - } - } - } - } - return(0); -} //CheckForSpring() - - - diff --git a/re/jj2/ida/Jazz2.exe.i64 b/re/jj2/ida/Jazz2.exe.i64 index 0119c69..63be807 100644 Binary files a/re/jj2/ida/Jazz2.exe.i64 and b/re/jj2/ida/Jazz2.exe.i64 differ