home *** CD-ROM | disk | FTP | other *** search
/ WarCraft 2000 - Nuclear Epidemic / W2000.nrg / SOURCE.War2000 / Navorots.cpp < prev    next >
C/C++ Source or Header  |  1998-09-01  |  3KB  |  154 lines

  1. #include "ddini.h"
  2. #include "ResFile.h"
  3. #include "FastDraw.h"
  4. #include "mgraph.h"
  5. #include "mouse.h"
  6. #include "menu.h"
  7. #include "MapDiscr.h"
  8. #include "multipl.h"
  9. #include "fog.h"
  10. #include "walls.h"
  11. #include "Nature.h"
  12. #include "Nucl.h"
  13. #include "TopZones.h"
  14. #include "Megapolis.h"
  15. #include "mode.h"
  16. void TeleLink(OneObject* OBJ){
  17.     if(!OBJ->Teleport)return;
  18.     for(int i=1;i<3;i++)
  19.         for(int j=1;j<4;j++){
  20.             int yy=OBJ->y+j;
  21.             int xx=OBJ->x+i;
  22.             word MID=Mops[yy][xx];
  23.             if(!(MID==OBJ->Index||MID==0xFFFF)){
  24.                 OneObject* OB=Group[MID];
  25.                 if(OB&&!OB->capBuilding){
  26.                     word mtype=OB->NIndex;
  27.                     word N=OB->NNUM;
  28.                     //OB->Die();
  29.                     OBJ->MakeDamage(0,18,NULL);
  30.                     int xd=OBJ->DstX;
  31.                     int yd=OBJ->DstY;
  32.                     int Lx=1;
  33.                     int dx;
  34.                     int dy;
  35.                     do{
  36.                         for(dy=yd;dy<yd+Lx;dy++)
  37.                             for(dx=xd;dx<xd+Lx;dx++)
  38.                                 if(dx>0&&dy>0&&dx<=msx&&dy<=msy&&!LLock[dy][dx])goto telp;
  39.                         Lx++;
  40.                     }while(Lx<50);
  41. telp:                OB->ClearOrders();
  42.                     OB->x=dx;
  43.                     OB->y=dy;
  44.                     Mops[OB->y][OB->x]=OB->Index;
  45.                     LLock[OB->y][OB->x]=1;
  46.                     Mops[yy][xx]=0xFFFF;
  47.                     CreateExObjD(WPLIST[21],xx<<7,yy<<7,0,0,255,NULL);
  48.                 };
  49.             };
  50.             Mops[yy][xx]=OBJ->Index;
  51.             LLock[yy][xx]=0;
  52.             TrMap[yy][xx]=0;
  53.         };
  54. };
  55. void OneObject::SetDstPoint(byte xd,byte yd){
  56.     if(!Ready)return;
  57.     if(!Ref.General->CanDest)return;
  58.     if(x>0&&y>0&&x<=msx&&y<=msy){
  59.         if(xd>=x&&yd>=y&&xd<x+Lx&&yd<y+Ly){
  60.             DstX=0;
  61.             DstY=0;
  62.             Teleport=false;
  63.             return;
  64.         };
  65.         DstX=xd;
  66.         DstY=yd;
  67.         if(capTeleport){
  68.             if(LocalOrder){
  69.                 Teleport=true;
  70.                 return;
  71.             };
  72.             Teleport=true;
  73.             for(int i=1;i<3;i++)
  74.                 for(int j=1;j<4;j++){
  75.                     if(Mops[y+j][x+i]==Index){
  76.                         //Mops[y+j][x+i]=Index;
  77.                         LLock[y+j][x+i]=0;
  78.                         TrMap[y+j][x+i]=0;
  79.                     };
  80.                 };
  81.             Order1* ORD=GetOrdBlock();
  82.             if(ORD){
  83.                 LocalOrder=ORD;
  84.                 ORD->OrderType=100;
  85.                 ORD->DoLink=&TeleLink;
  86.             };
  87.             return;
  88.         };
  89.     };
  90. };
  91. byte DestnX[512];
  92. byte DestnY[512];
  93. int NDestn;
  94. void InitDestn(){
  95.     NDestn=0;
  96. };
  97. void AddDestn(byte x,byte y){
  98.     if(NDestn<512){
  99.         DestnX[NDestn]=x;
  100.         DestnY[NDestn]=y;
  101.         NDestn++;
  102.     };
  103. };
  104. extern RLCTable RCross;
  105. extern RLCTable mRCross;
  106. extern int tmtmt;
  107. void miniShowDestn(){
  108.     if((tmtmt&7)<3)return;
  109.     int smx=mapx+smaplx;
  110.     int smy=mapy+smaply;
  111.     byte x,y;
  112.     for(int i=0;i<NDestn;i++){
  113.         x=DestnX[i];
  114.         y=DestnY[i];
  115.         if(x>=mapx&&y>mapy&&x<smx&&y<smy){
  116.             ShowRLCItem(smapx+(int(x-mapx)<<4),smapy+(int(y-mapy)<<4),&RCross,0,MyNation);
  117.         };
  118.     };
  119. };
  120. void ShowDestn(){
  121.     if(MiniMode){
  122.         miniShowDestn();
  123.         return;
  124.     };
  125.     if((tmtmt&7)<3)return;
  126.     int smx=mapx+smaplx;
  127.     int smy=mapy+smaply;
  128.     byte x,y;
  129.     for(int i=0;i<NDestn;i++){
  130.         x=DestnX[i];
  131.         y=DestnY[i];
  132.         if(x>=mapx&&y>mapy&&x<smx&&y<smy){
  133.             ShowRLCItem(smapx+(int(x-mapx)<<5),smapy+(int(y-mapy)<<5),&RCross,0,MyNation);
  134.         };
  135.     };
  136. };
  137. void ShowMiniDestn(){
  138.     if((tmtmt&7)<5)return;
  139.     int x,y;
  140.     for(int i=0;i<NDestn;i++){
  141.         x=minix+(DestnX[i]>>1);
  142.         y=miniy+(DestnY[i]>>1);
  143.         Hline(x,y,x,clrYello);
  144.         //Vline(x,y-1,y+1,clrYello);
  145.     };
  146. };
  147. void PerformAction(OneObject* OB,int x,int y){
  148.     if(OB->capBuilding)return;
  149.     if(OB->capBuild){
  150.         byte rk=GetResourceKind(x,y);
  151.         if(rk!=0)OB->TakeResource(x,y,rk,16);
  152.         else OB->SendTo(x,y,16);
  153.     }else OB->SendTo(x,y,0);
  154. };