Code: Select all
{
K_FIRE [72] // FIRE KEY - LEFT MOUSE
K_AIM [73] // AIM KEY - RIGHT MOUSE
K_FOR [15] // FORWARD - W
K_BAK [27] // BACK - S
K_LEFT [26] // STRAFE LEFT - A
K_RIGHT [28] // STRAFE RIGHT - D
K_RUN [36] // RUN - LEFT SHIFT KEY
K_SelectLeft [14] // Left select on gun select mode - Q
K_SelectRight [16] // Right select on gun select mode - E
K_Interact [18] // Open doors - T
K_Marker [17] // Open gun select mode
K_1 [1] //Swap to gun slot 1 - 1
K_2 [2] //Swap to gun slot 2 - 2
K_3 [3] //Swap to gun slot 3 - 1
K_Shift [36] // Contol key shift
K_Reload [17] //Reload gun
//Player Positions
Position [1] //1-Standing, 2-Crouching, 3-Crawling
Aim [0] //1-Looking down sight, 2-Not looking down sight
FLOATAIM [0.0] //To allow the person to look around slowly
//Weapon Variables
//Guns
VariableSlot [1]
WSlot1 [2]
WSlot2 [3]
WSlot3 [4]
NewSlot [0]
UpdateWeapons [1]
//Grenades
GSlot1 [2]
GSlot2 [3]
GSlot3 [4]
//Player Attributes
points [100]
Lvl [1]
NxtLvl [50]
Lvl2 [50]
Lvl3 [500]
Lvl4 [5000]
ANIM [string] // Do Not Edit
ANC [0] // Do Not Edit
LASTANC [0] // Do Not Edit
DIR [0] // Do Not Edit
AT [0.5] // Do Not Edit
INTER [string] // Do Not Edit
TM [0] // Do Not Edit
SPEED [0] // Do Not Edit
Spawn[()
{
Console(true);
BoxWidth(24);
SetGroup("friendly");
AttributeOrder(health, 100, "Die");
LowLevel("Setup");
}]
Setup[()
{
AttachCamera();
self.yaw_speed=256;
ANC=0;
LASTANC=0;
TM=self.time;
self.think="RunPlayer";
}]
RunPlayer[()
{
debug(self.key_pressed);
PlayerRender(false);
// handle health status
if(self.health > 0)
{
PawnRender(false);
}
else
{
HighLevel("Die");
return 0;
}
self.ideal_yaw=self.player_yaw;
ChangeYaw();
DIR=0; // Default straight
SPEED=0; // Default - no motion
AT=0.1; // Default
if(IsKeyDown(K_FOR))
{
// forward
SPEED=Integer(200);
}
if(IsKeyDown(K_BAK))
{
// back
DIR=ConvertDegrees(180);
SPEED=Integer(200);
}
if(IsKeyDown(K_LEFT))
{
// make strafe transition smoother
AT=0.5;
DIR=ConvertDegrees(90);
SPEED=Integer(200);
}
if(IsKeyDown(K_RIGHT))
{
// make strafe transition smoother
AT=0.5;
DIR=ConvertDegrees(270);
SPEED=Integer(200);
}
if(IsKeyDown(K_RUN))
{
if(AIM = 0)
{
//left shift key - toggle run
SPEED=SPEED+(SPEED/2);
}
}
if(IsKeyDown(K_AIM))
{
SPEED = SPEED/2;
}
walkmove(self.current_yaw+DIR,SPEED);
debug(AIM);
////////////////////////////////////////////EXTRAS////////////////////////////////////////////////////////////
if(IsKeyDown(K_AIM))
{
Aim=1;
DrawFlipBookImage("Flipbook1",31,0,0,255,255,255,255,1.0);
}
else
{
Aim=0;
}
//Leveling
if(Lvl < 4)
{
switch(Lvl)
{
case 1
{
NxtLvl = Lvl2;
}
case 2
{
NxtLvl = Lvl3;
}
case 3
{
NxtLvl = Lvl4;
}
}
if(GetAttribute("xp", "Player") >= NxtLvl)
{
Lvl = Lvl+1;
SetAttribute("xp", 0, "Player");
}
}
DrawText(Lvl,300,500,255,10,255,255,255);
DrawText(NxtLvl,400,500,255,10,255,255,255);
SetAttribute("shownxp", Integer((GetAttribute("xp", "Player") / NxtLvl) * 100), "Player");
//Swap guns
//slot one
if(IsKeyDown(K_1))
{
if (VariableSlot > 1)
{
NewSlot=1;
UpdateWeapons=1;
}
}
//slot 2
if(IsKeyDown(K_2))
{
if (VariableSlot != 2)
{
if(WSlot2 > 0)
{
NewSlot=2;
UpdateWeapons=1;
}
}
}
//slot 3
if(IsKeyDown(K_3))
{
if (VariableSlot < 3)
{
if(WSlot2 > 0)
{
if (WSlot3 > 0)
{
NewSlot=3;
UpdateWeapons=1;
}
}
else
{
NewSlot=2;
UpdateWeapons=1;
}
}
}
if(UpdateWeapons = 1)
{
Updateweapons=0;
switch(NewSlot)
{
case 1
{
SetPlayerWeapon(WSlot1);
VariableSlot=1;
}
case 2
{
SetPlayerWeapon(WSlot2);
VariableSlot=2;
}
case 3
{
SetPlayerWeapon(WSlot3);
VariableSlot=3;
}
}
}
DrawText(toString(points),735,545,255,10,255,255,255);
DrawText("points: ",660,545,255,10,255,255,255);
//Show current guns / ammo / grenades
DrawText("/",68,555,255,10,255,255,255);
DrawFlipBookImage("Flipbook1",self.player_weapon + 15,38,502,255,255,255,255,1.0);
switch(VariableSlot)
{
case 1
{
DrawFlipBookImage("Flipbook1",WSlot1+7,41,453,255,255,255,255,1.0);
DrawFlipBookImage("Flipbook1",WSlot2,146,466,255,255,255,255,1.0);
DrawFlipBookImage("Flipbook1",WSlot3,225,510,255,255,255,255,1.0);
}
case 2
{
DrawFlipBookImage("Flipbook1",WSlot1,41,453,255,255,255,255,1.0);
DrawFlipBookImage("Flipbook1",WSlot2+7,146,466,255,255,255,255,1.0);
DrawFlipBookImage("Flipbook1",WSlot3,225,510,255,255,255,255,1.0);
}
case 3
{
DrawFlipBookImage("Flipbook1",WSlot1,41,453,255,255,255,255,1.0);
DrawFlipBookImage("Flipbook1",WSlot2,146,466,255,255,255,255,1.0);
DrawFlipBookImage("Flipbook1",WSlot3+7,225,510,255,255,255,255,1.0);
}
}
}]
Die[()
{
// SetPosition(self.entity_name, X, Y, Z);
self.think="Setup";
}]
}
Thanks