increase wallkit thickness to make clonks not go stuck

stable-6.1
Maikel de Vries 2015-04-02 18:42:42 +02:00
parent ba1aa81c6a
commit 8b34b89f24
2 changed files with 22 additions and 16 deletions

View File

@ -1,17 +1,17 @@
/*-- WallKit preview --*/ /*-- WallKit preview --*/
// definition call: create line // definition call: create line
func Create(int x1,int y1,int x2,int y2,int clr) func Create(int x1, int y1, int x2, int y2, int clr)
{ {
var obj = CreateObjectAbove(WallKit_Preview); var obj = CreateObjectAbove(WallKit_Preview);
obj->Set(x1,y1,x2,y2,clr); obj->Set(x1, y1, x2, y2, clr);
return obj; return obj;
} }
func Set(int x1,int y1,int x2,int y2,int clr) func Set(int x1,int y1,int x2,int y2,int clr)
{ {
SetVertexXY(0, x1,y1); SetVertexXY(0, x1, y1);
SetVertexXY(1, x2,y2); SetVertexXY(1, x2, y2);
this.LineColors = [clr, clr]; this.LineColors = [clr, clr];
return; return;
} }

View File

@ -43,8 +43,9 @@ public func ControlUseCancel(object clonk, int x, int y)
private func CreateBridge(object clonk, int x, int y) private func CreateBridge(object clonk, int x, int y)
{ {
var c = Offset2BridgeCoords(clonk, x, y); var c = Offset2BridgeCoords(clonk, x, y);
x=clonk->GetX(); y=clonk->GetY(); x = clonk->GetX();
DrawMaterialQuad("Granite-granite", x+c.x1-c.dx,y+c.y1-c.dy, x+c.x1+c.dx,y+c.y1+c.dy, x+c.x2+c.dx,y+c.y2+c.dy, x+c.x2-c.dx,y+c.y2-c.dy, DMQ_Bridge); y = clonk->GetY();
DrawMaterialQuad("Granite-granite", x + c.x1 - c.dxm, y + c.y1 - c.dym, x + c.x1 + c.dxp, y + c.y1 + c.dyp, x + c.x2 + c.dxp, y + c.y2 + c.dyp, x + c.x2 - c.dxm, y + c.y2 - c.dym, DMQ_Bridge);
clonk->Sound("WallKitLock"); clonk->Sound("WallKitLock");
return true; return true;
} }
@ -55,18 +56,23 @@ private func CreateBridge(object clonk, int x, int y)
private func Offset2BridgeCoords(object clonk, int x, int y) private func Offset2BridgeCoords(object clonk, int x, int y)
{ {
// Returns starting and end point offset of bridge to be built as player points to offset x/y // Returns starting and end point offset of bridge to be built as player points to offset x/y
var dx=clonk->GetDefWidth(), dy=clonk->GetDefHeight(), ox,oy,rx,ry,l=BridgeLength; var dx = clonk->GetDefWidth(), dy = clonk->GetDefHeight(), ox, oy, rx, ry;
ox=x*2/Abs(y+!y); oy=y*2/Abs(x+!x); var l = BridgeLength;
ry=ox/=Abs(ox)+!ox; var d = BridgeThickness;
rx=oy/=Abs(oy)+!oy; ox = x * 2 / Abs(y + !y);
ox*=dx/2+2*!oy; oy = y * 2 / Abs(x + !x);
oy*=dy/2+2*!ox; ry = ox /= Abs(ox) + !ox;
l-=l*3*Abs(rx*ry)/10; rx = oy /= Abs(oy) + !oy;
return { dx=ry*BridgeThickness, dy=rx*BridgeThickness, x1=ox+(rx*=l), y1=oy-(ry*=l), x2=ox-rx, y2=oy+ry }; // Offset of the bridge: more for vertical and horizontal bridges.
ox *= dx / 2 + 3 * !oy;
oy *= dy / 2 + 3 * !ox;
// Reduce thickness and length for diagonal bridges.
l -= l * 3 * Abs(rx * ry) / 10;
d -= d * 3 * Abs(rx * ry) / 10;
return { dxp = ry * d / 2, dyp = rx * d / 2, dxm = ry * (d + 1) / 2, dym = rx * (d + 1) / 2, x1 = ox + rx * l, y1 = oy - ry * l, x2 = ox - rx * l, y2 = oy + ry * l };
} }
/* Preview */ /* Preview */
local preview; local preview;
@ -115,4 +121,4 @@ local Description = "$Description$";
local UsageHelp = "$UsageHelp$"; local UsageHelp = "$UsageHelp$";
local Rebuy = true; local Rebuy = true;
local BridgeLength = 20; local BridgeLength = 20;
local BridgeThickness = 1; local BridgeThickness = 5;