Skip to content

Commit

Permalink
source of map editor
Browse files Browse the repository at this point in the history
  • Loading branch information
HarpyWar committed Jan 22, 2013
1 parent 91ff199 commit 74b5e83
Show file tree
Hide file tree
Showing 79 changed files with 27,488 additions and 0 deletions.
757 changes: 757 additions & 0 deletions Radiant_037b/ClickPs.pas

Large diffs are not rendered by default.

95 changes: 95 additions & 0 deletions Radiant_037b/Constants_Lib.pas
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
unit Constants_Lib;

interface

//jumppad :)
const
Jump1 = 4.0;
Jump2 = 5.0;

const
//ID-øíèêè âñåõ èòåìîâ è îðóæèÿ
shotgun_ID = 2;
grenade_ID = 3;
rocket_ID = 4;
shaft_ID = 5;
railgun_ID = 6;
plasma_ID = 7;
BFG_ID = 8;

Shard_ID = 16;
Armor50_ID = 17;
Armor100_ID = 18;

Health5_ID = 19;
Health25_ID = 20;
Health50_ID = 21;
Health100_ID = 22;

REGEN_ID = 23;
BATTLESUIT_ID = 24;
HASTE_ID = 25;
QUAD_ID = 26;
FLIGHT_ID = 27;
INV_ID = 28;

const
Healthes : array [Health5_ID..Health100_ID] of word =
(5, 25, 50, 100);
Armors : array [Shard_ID..Armor100_ID] of word =
(5, 50, 100);
HealthWait: array [Health5_ID..Health100_ID] of word =
(1000, 1000, 1500, 3000);
ArmorWait : array [Shard_ID..Armor100_ID] of word =
(1000, 1500, 1500);
const
PlayerMaxHealth1 = 100;
PlayerMaxHealth2 = 200;

PlayerMaxArmor1 = 100;
PlayerMaxArmor2 = 200;

HealthTickerWait = 50;
SwitchTickerWait = 10;//ñìåíà îðóæèÿ ÏÎËÍÀß
{ SwitchTicker2Wait = 5;//ñìåíà îðóæèÿ - ñëåä. îðóæèå}

const
WPN_Count = 9;

type
TWPNArray = array [0.. WPN_Count-1] of word;

const
//XProger: îðóæèå
WPN_GAUNTLET = 0;
WPN_MACHINEGUN = 1;
WPN_SHOTGUN = 2;
WPN_GRENADE = 3;
WPN_ROCKET = 4;
WPN_LIGHTING = 5;
WPN_RAILGUN = 6;
WPN_PLASMA = 7;
WPN_BFG = 8;

WPN_AMMO = 8;

const

WPN_Wait : TWPNArray=
(0, 1000, 1000, 1000, 1000, 1500, 1000, 1000, 1500);
Ammo_Wait = 1000;

Def_Ammo : TWpnArray =
(1, 100, 10, 10, 10, 120, 10, 50, 20);
Ammo_Box: TWpnArray =
(0, 50, 5, 5, 5, 60, 5, 25, 10);
Max_Ammo: TWpnArray =
(0, 200, 100, 100, 100, 200, 100, 100, 100);


PowerUp_Wait = 5000;
PowerUp_StartTime = 2600;

implementation

end.
293 changes: 293 additions & 0 deletions Radiant_037b/Generate_Lib.pas
Original file line number Diff line number Diff line change
@@ -0,0 +1,293 @@
unit Generate_Lib;

interface

uses Constants_Lib;

const
//ÖÅÍÛ íà îðóæèå:
WPN_Costs :TWPNArray =
(0, 10, 20, 30, 35, 40, 60, 70, 120);
Heal_costs : array [Health5_ID..Health100_ID] of word =
(5, 25, 50, 100);

type
TRoom =
class
constructor Create(fx1, fy1, fx2, fy2: integer);
private
function GetHeight: integer;
function Getwidth: integer;
procedure SetHeight(const Value: integer);
procedure SetWidth(const Value: integer);
protected
yy: array [0..30] of integer;//ìàññèâ óðîâíÿ...
public
x1, y1, x2, y2: integer;
brick: integer;
prevroom, nextroom: TRoom;
property Width: integer read Getwidth write SetWidth;
property Height: integer read GetHeight write SetHeight;

procedure SplitH(minw, maxw: integer);
procedure SplitV(minh, maxh: integer);

procedure FillPrepare;
procedure FillSurf;
procedure Fill;
end;

var
rooms: array [1..100000] of TRoom;
rc: integer;

function AddRoom(r: TRoom): TRoom;
procedure RDelete(i: integer);
procedure RClear;

implementation

uses Main, MapObj_Lib, TFKEntries;

function AddRoom(r: TRoom): TRoom;
begin
Inc(rc);
rooms[rc]:=r;
result:=r;
end;

procedure RDelete(i: integer);
begin
end;

procedure RClear;
var
i: integer;
begin
for i:=1 to rc do rooms[i].Free;
rc:=0;
end;

//ôóíêöèè ïîìîùè â ïîñòàíîâêå ïðåäìåòîâ
function PlaceWeapon(x, y: integer; MaxCost: integer): integer;
var
i, m: integer;
struct: TMapObjStruct;
begin
for m:=1 to 8 do
if WPN_Costs[m]>MaxCost then
break;
i:=random(m)+1;
Result:=i;
if i>0 then
begin
FillChar(struct, sizeof(struct), 0);
struct.width:=1;
struct.height:=1;
struct.x:=x;
struct.y:=y;
struct.weaponID:=i;
if i>1 then
struct.ObjType:=otWeapon
else
struct.ObjType:=otAmmo;
Map.Obj.Add(struct).SetDefValues;
end;
end;

procedure PlaceAmmo(x, y: integer; wpn: integer);
var
struct: TMapObjStruct;
begin
FillChar(struct, sizeof(struct), 0);
struct.width:=1;
struct.height:=1;
struct.x:=x;
struct.y:=y;
struct.weaponID:=wpn;
struct.ObjType:=otAmmo;
Map.Obj.Add(struct).SetDefValues;
end;

procedure PlaceJumpPad(x, y, height: integer);
var
struct: TMapObjStruct;
begin
FillChar(struct, sizeof(struct), 0);
struct.width:=1;
struct.height:=1;
struct.x:=x;
struct.y:=y;
struct.ObjType:=otJumpPad;
if Height>5 then
struct.jumpspeed:=5.0
else struct.jumpspeed:=4.0;
Map.Obj.Add(struct).SetDefValues;
end;

procedure PlaceRespawn(x, y: integer);
var
struct: TMapObjStruct;
begin
FillChar(struct, sizeof(struct), 0);
struct.width:=1;
struct.height:=1;
struct.x:=x;
struct.y:=y;
struct.ObjType:=otRespawn;
struct.orient:=0;
Map.Obj.Add(struct).SetDefValues;
end;

procedure PlaceTeleport(x1, y1, x2, y2: integer);
var
struct: TMapObjStruct;
begin
FillChar(struct, sizeof(struct), 0);
struct.width:=1;
struct.height:=1;
struct.x:=x1;
struct.y:=y1;
struct.gotox:=x2;
struct.gotoy:=y2;
struct.ObjType:=otTeleport;
struct.orient:=0;
Map.Obj.Add(struct).SetDefValues;
end;

function PlaceHealth(x, y, maxcost: integer): integer;
var
struct: TMapObjStruct;
i, m: integer;
begin
FillChar(struct, sizeof(struct), 0);
struct.width:=1;
struct.height:=1;
struct.x:=x;
struct.y:=y;
struct.ObjType:=otHealth;
for m:=Health5_ID to Health100_ID do
if heal_costs[m]>maxcost then
Break;
i:=random(m-Health5_ID)+Health5_ID;
struct.itemID:=i;
if m>Health5_ID then
Map.Obj.Add(struct).SetDefValues
else i:=0;
Result:=i;
end;


{ TRoom }

constructor TRoom.Create(fx1, fy1, fx2, fy2: integer);
begin
x1:=fx1;y1:=fy1;x2:=fx2;y2:=fy2;
end;

procedure TRoom.Fill;
var
j: integer;
begin
//çàïîëíÿåì - ñòàâèì îäíî îðóæèå, ðåñïàóí è òåëåïîðò â ñëåä. êîìíàòó
with Map do
begin
if nextroom<>nil then
PlaceTeleport(x2, y2-yy[x2-x1], nextroom.x1+2, nextroom.y2);
if prevroom<>nil then
PlaceTeleport(x1+1, y2-yy[1], prevroom.x2-1, prevroom.y2);
//òåïåðü ðåñïàóí, åñëè øèðèíà ïîçâîëÿåò
if Self.Width>3 then
begin
if random(4)>1 then
begin
j:=x1+Self.Width div 2;
PlaceRespawn(j, y2-yy[j-x1]);
end;
j:=x1+Self.Width div 2+random(3)-1;
if random(3)>0 then
PlaceWeapon(j, y2-yy[j-x1], 100)
else
PlaceHealth(j, y2-yy[j-x1], 100);
end;
end;
end;

procedure TRoom.FillPrepare;
begin
yy[0]:=0;
yy[width-1]:=0;
end;

procedure TRoom.FillSurf;
var
maxh: integer;
i, j: integer;
begin
maxh:=height-4;
if maxh>2 then maxh:=2;
if random(3)>1 then maxh:=1;
//çàïîëíÿåì Surface;
for i:=1 to width-2 do
yy[i]:=random(maxh);
//òåïåðü ïåðåõîäèì ê çàëèâó áðèêîâ
with Map do
for i:=x1 to x2 do
for j:=0 to yy[i-x1]-1 do
begin
brk[i, y2-j]:=brick;
brk.blocked[i, y2-j]:=true;
end;
end;

function TRoom.GetHeight: integer;
begin
Result:=y2-y1+1;
end;

function TRoom.Getwidth: integer;
begin
Result:=x2-x1+1;
end;

procedure TRoom.SetHeight(const Value: integer);
begin
y2:=y1+Value-1;
end;

procedure TRoom.SetWidth(const Value: integer);
begin
x2:=x1+Value-1;
end;

procedure TRoom.SplitH(minw, maxw: integer);
var
max, w: integer;
begin
while Width>(minw+maxw) div 2 do
begin
max:=Width-minw;
if max>maxw then max:=maxw;
if max<minw then Exit;
w:=random(max-minw+1)+minw;
AddRoom(TRoom.Create(x1, y1, x1+w-1, y2));
x1:=x1+w;
end;
end;

procedure TRoom.SplitV(minh, maxh: integer);
var
max, h: integer;
begin
while Height>(minh+maxh) div 2 do
begin
max:=Height-minh;
if max>maxh then max:=maxh;
if max<minh then Exit;
h:=random(max-minh+1)+minh;
AddRoom(TRoom.Create(x1, y1, x2, y1+h-1));
y1:=y1+h;
end;
end;

end.
Loading

0 comments on commit 74b5e83

Please sign in to comment.