Forbidding the worm to shoot when he's not on his side (fort) : Code:
procedure InitHooks;
begin
RegisterHook('Fire', ON_BEGIN_FIRE);
end;
function Fire : boolean;
var
CurW : TWorm;
wpns : integer;
begin
CurW := GetTekWormObj;
if CurW = nil then exit;
if CurW.SelWeapon = nil then exit;
Result := True;
// Team 1 : right side
// Team 2 : left side
if CurW.Team = 2 then begin
if ObjInBox(CurW,1154,5,1916,694) then begin // Right side position
wpns := CurW.SelWeapon.WN;
case wpns of
1,2 : // All the weapons we want to forbid
begin
Result := False;
end;
end;
end;
if CurW.Team = 1 then begin
if ObjInBox(CurW,8,14,702,814) then begin // Left side position
case wpns of
1,2 :
begin
Result := False;
end;
end;
end;
end;
end;
end; // So many ends ...
Automatic placement for towers, rope races..
Code:
procedure Init;
var
i, wCount : Integer;
obj : TWPobj;
begin
wCount := 0;
for i := 1 to GetPObjCount - 1 do begin
Obj := GetPObj(i);
if Obj = nil then continue;
if Obj.ObjType = OBJ_WORM then begin
Obj.PosX := 831 + 10 * wCount; // X Pos
Obj.PosY := 351 - (wCount div 6); // Y Pos
Inc(wCount);
end;
end;
Adding gravity : Code:
if (ObjInBox(obj,1115,27,1425,356)) then begin // Position of the gravity
obj.SpY := obj.SpY + 0.7; //0.7 is the force of the gravity
end;
// Use your brain and you'll understand why I use ObjInBox for gravity