001 #ifndef HAMMER_HH
002 #define HAMMER_HH "build shit"
003 #include "Utils.HC"
004 #include "LevelEditor";
005 <1>
; 006 007 008 009 010 011 012 013 014 015 016 017 018 019 U8 *build_icon=DC2Sprite(SpriteToSquareDC(<1>,24)); 020 U8 *build_big_icon=DC2Sprite(SpriteToSquareDC(<1>,128)); 021 Bool ClipLineF64(CNode *a,CNode *b,F64 x,F64 y,F64 w,F64 h) { 022 I64 ax=a->x,ay=a->y; 023 I64 bx=b->x,by=b->y; 024 Bool ret=ClipLine(&ax,&ay,&bx,&by,x,y,x+w,y+h); 025 if(ax==bx&&ay==by) 026 return FALSE; 027 a->x=ax; 028 a->y=ay; 029 b->x=bx; 030 b->y=by; 031 return ret; 032 } 033 U0 NewLineTo(F64 x,F64 y,F64 x2,F64 y2,CD2 *lt=NULL,CD2 *wh=NULL) { 034 CLevel *l=game.level; 035 CNode *start,*end; 036 Bool ret; 037 CLine *line; 038 start=GCCAlloc(sizeof CNode); 039 QueInit(start); 040 start->x=x; 041 start->y=y; 042 end=GCCAlloc(sizeof CNode); 043 QueInit(end); 044 end->x=x2; 045 end->y=y2; 046 047 if(lt&&wh) { 048 ret=ClipLineF64(start,end,lt->x,lt->y,wh->x,wh->y); 049 if(!ret) return; 050 } 051 052 053 line=GCCAlloc(sizeof CLine); 054 QueIns(line,l->lines.last); 055 QueIns(start,l->nodes.last); 056 QueIns(end,l->nodes.last); 057 line->start=start; 058 line->end=end; 059 LevelAddLineToGrid(l,line); 060 061 } 062 Bool BuildWallFire0(F64 x,F64 y,CGameThing *from) { 063 F64 w=150,h=150,xi; 064 F64 sqrt=Sqrt(w*w+h*h)/2; 065 CI64Set *in_rad; 066 CD2 wh,xy; 067 x=FloorI64(x,w); 068 y=FloorI64(y,h); 069 070 in_rad=GetThingsInRadius(x+w/2,y+h/2,sqrt); 071 if(in_rad->cnt) { 072 return FALSE; 073 } 074 075 076 NewLineTo(x,y,x+w,y); 077 NewLineTo(x+w,y,x+w,y+h); 078 NewLineTo(x+w,y+h,x,y +h); 079 NewLineTo(x,y,x,y+h); 080 081 xy.x=x; 082 xy.y=y; 083 wh.x=w; 084 wh.y=h; 085 086 for(xi=x-w;xi<x+w*2;xi+=50) { 087 NewLineTo(xi,y+h,xi+w,y,&xy,&wh); 088 } 089 for(xi=x+w*2;xi>=x-w;xi-=50) { 090 NewLineTo(xi,y+h,xi-w,y,&xy,&wh); 091 } 092 093 return TRUE; 094 } 095 096 097 Bool BuildWallFire(F64 x,F64 y,CGameThing *from) { 098 return BuildWallFire0(x,y,from); 099 } 100 101 102 103 104 #endif