Yeah,I'm looking at one of your script right now and I can't figure out where to start
Code: Select all
{
DAMAGEATTRIBUTE [hp]
currentweapon [-1]
firemode [1]
zoom [1]
zoomtimer [0]
unzoomtimer [1000000]
mouseleft_pressed [false]
mouseright_pressed [false]
reloading [false]
temp [0]
baseaccx [0]
baseaccy [0]
tilttime [0]
tiltmin [0]
tiltmax [0]
tiltamount [0]
tilt [0]
rotatetime [0]
rotatemin [0]
rotatemax [0]
rotateamount [0]
rotate [0]
offsetX [0]
offsetY [0]
offsetZ [0]
OFFSETY [75]
muzzleoffsetX [0]
muzzleoffsetY [0]
muzzleoffsetZ [0]
muzzle []
hylsy []
hylsyx [0]
hylsyy [0]
hylsyz [0]
hdelay [0]
htimer [1000000]
accuracy [0]
accpershot [0]
accreturn [0]
bullet [nobullet]
firerate [0]
sound []
emptysound []
fullauto [0]
crosshair [0]
clipsize [0]
bullets [0]
bulletspershot [0]
ammoattribute []
firetime [0]
acc [0]
acctimer [0]
burstacc [0]
maxacc [0]
offsettemp [0]
offsettime [0]
infotext []
infotime [0]
IDLE []
SHOOT []
RELOAD []
ARM []
WEAPON
{
{
IDLE [smg_idle]
SHOOT [smg_shoot]
RELOAD [smg_reload]
ARM [smg_arm]
ACCURACY [40]
ACCPERSHOT [20]
MAXACCURACY [100]
FIRERATE [0.08]
BULLET [smgbullet]
OFFSETX [2]
OFFSETY [0]
OFFSETZ [-5]
MUZZLEOFFSETX [0.5]
MUZZLEOFFSETY [0.5]
MUZZLEOFFSETZ [0]
MUZZLE [Muzzle_smg]
HYLSY [hylsybullet]
HYLSYX [-3.5]
HYLSYY [-2]
HYLSYZ [6.5]
HDELAY [0]
SOUND [weapon_smg.wav]
EMPTYSOUND [weapon_click.wav]
HEARRANGE [600]
AUTO [1]
CROSSHAIR [1]
CLIPSIZE [25]
BULLETSPERSHOT [1]
BURSTACC [0]
AMMOATTRIBUTE [ammosmg]
TILTMIN [-120]
TILTMAX [50]
TILT [0.1]
ROTATEMIN [-30]
ROTATEMAX [30]
ROTATE [0.1]
WEAPON [SMG]
}
{
IDLE [tommy_idle]
SHOOT [tommy_shoot]
RELOAD [tommy_reload]
ARM [tommy_arm]
ACCURACY [25]
ACCPERSHOT [20]
MAXACCURACY [80]
FIRERATE [0.1]
BULLET [tommybullet]
OFFSETX [2]
OFFSETY [0]
OFFSETZ [-6.5]
MUZZLEOFFSETX [0.5]
MUZZLEOFFSETY [0.5]
MUZZLEOFFSETZ [0]
MUZZLE [Muzzle_tommy]
HYLSY [hylsybullet]
HYLSYX [-3]
HYLSYY [-4]
HYLSYZ [2]
HDELAY [0]
SOUND [weapon_tommy.wav]
EMPTYSOUND [weapon_click.wav]
HEARRANGE [1400]
AUTO [1]
CROSSHAIR [2]
CLIPSIZE [70]
BULLETSPERSHOT [1]
BURSTACC [0]
AMMOATTRIBUTE [ammotommy]
TILTMIN [-10]
TILTMAX [10]
TILT [0.1]
ROTATEMIN [-60]
ROTATEMAX [60]
ROTATE [0.1]
WEAPON [Tommy]
}
{
IDLE [sniper_idle]
SHOOT [sniper_shoot]
RELOAD [sniper_reload]
ARM [sniper_arm]
ACCURACY [5]
ACCPERSHOT [20]
MAXACCURACY [30]
FIRERATE [1.4]
BULLET [sniperbullet]
OFFSETX [2]
OFFSETY [0]
OFFSETZ [-5]
MUZZLEOFFSETX [0]
MUZZLEOFFSETY [0]
MUZZLEOFFSETZ [0]
MUZZLE [Muzzle_sniper]
HYLSY [hylsybullet]
HYLSYX [-4]
HYLSYY [-4]
HYLSYZ [10]
HDELAY [0.75]
SOUND [weapon_sniper.wav]
EMPTYSOUND [weapon_click.wav]
HEARRANGE [2000]
AUTO [0]
CROSSHAIR [5]
CLIPSIZE [5]
BULLETSPERSHOT [1]
BURSTACC [0]
AMMOATTRIBUTE [ammosniper]
TILTMIN [-40]
TILTMAX [0]
TILT [0.2]
ROTATEMIN [-10]
ROTATEMAX [10]
ROTATE [0.2]
WEAPON [Sniper]
}
}
Spawn[ ()
{
Console(false);
Gravity(false);
SetNoCollision();
HideFromRadar(true);
BoxWidth(0);
BoxHeight(20);
LowLevel("Setup");
} ]
Setup[ ()
{
self.ThinkTime = 0;
self.yaw_speed = 10000;
self.pitch_speed = 10000;
PawnRender(false);
ActivateHudElement("ammo_primary",false);
ActivateHudElement("clips_primary",false);
if(GetAttribute("weapon_primary","Player") != -1)
{
currentweapon = GetAttribute("weapon_primary","Player");
changeweaponinfo(currentweapon);
bullets = GetAttribute("ammo_primary","Player");
SetAttribute("clips_primary",GetAttribute(ammoattribute,"Player"),"Player");
HighLevel("ChangeWeapon_start");
return 0;
}
self.think = "wait";
} ]
ininventory[ ()
{
self.ThinkTime = 0.1;
PawnRender(false);
if(currentweapon != GetAttribute("weapon_primary","Player"))
{
currentweapon = GetAttribute("weapon_primary","Player");
if(currentweapon != -1)
{
bullets = 0;
changeweaponinfo(currentweapon);
handleammo();
}
HighLevel("ChangeWeapon");
return 0;
}
if(GetEventState("InInventory") = false)
{
if(currentweapon != -1)
{
handleammo();
}
self.think = "wait";
return 0;
}
} ]
wait[ ()
{
self.ThinkTime = 0.1;
PawnRender(false);
if(GetEventState("InInventory"))
{
ModifyAttribute(ammoattribute,bullets,"Player");
bullets = 0;
self.think = "ininventory";
return 0;
}
if((GetAttribute("WeaponSlot","Player")=1) and (GetEventState("InInventory")=false) and (currentweapon != -1))
{
AnimateHold(ARM);
ActivateHudElement("ammo_primary",true);
ActivateHudElement("clips_primary",true);
self.think = "arm";
return 0;
}
} ]
ChangeWeapon_start[ ()
{
SetWeapon(WEAPON[currentweapon].WEAPON);
LowLevel("wait");
} ]
ChangeWeapon[ ()
{
if(currentweapon = -1)
{
RemoveWeapon();
}
else
{
SetWeapon(WEAPON[currentweapon].WEAPON);
}
LowLevel("ininventory");
} ]
arm[ ()
{
self.ThinkTime = 0;
basicroutines();
PawnRender(true);
SetNoCollision();
if(self.animate_at_end)
{
AnimateHold(IDLE);
self.think = "idle";
return 0;
}
} ]
idle[ ()
{
self.ThinkTime = 0;
basicroutines();
clearkeys();
if(self.lbutton_pressed and (mouseleft_pressed = false) and (firetime < self.time))
{
if(bullets > 0)
{
fire();
AnimateHold(SHOOT);
self.think = "shoot";
return 0;
}
else
{
PlaySound(emptysound);
firetime = self.time + firerate;
if(fullauto = 0)
{
mouseleft_pressed = true;
}
}
}
if(self.rbutton_pressed and (mouseright_pressed = false))
{
altattack();
mouseright_pressed = true;
}
if(self.animate_at_end)
{
AnimateHold(IDLE);
}
if(((bullets = 0) or ((bullets < clipsize) and IsKeyDown(17))) and (GetAttribute(ammoattribute,"Player") > 0))
{
reloading = true;
}
if(reloading)
{
zoom = 1;
reloading = false;
AnimateHold(RELOAD);
self.think = "reload";
return 0;
}
} ]
shoot[ ()
{
self.ThinkTime = 0;
basicroutines();
clearkeys();
if(self.lbutton_pressed and (mouseleft_pressed = false) and (firetime < self.time))
{
if(bullets > 0)
{
fire();
AnimateHold(SHOOT);
}
else
{
PlaySound(emptysound);
firetime = self.time + firerate;
if(fullauto = 0)
{
mouseleft_pressed = true;
}
}
}
if(self.rbutton_pressed and (mouseright_pressed = false))
{
altattack();
mouseright_pressed = true;
}
if(self.animate_at_end)
{
AnimateHold(IDLE);
self.think = "idle";
}
if((bullets < clipsize) and IsKeyDown(17) and (GetAttribute(ammoattribute,"Player") > 0))
{
reloading = true;
}
} ]
reload[ ()
{
self.ThinkTime = 0;
basicroutines();
clearkeys();
if(self.animate_at_end)
{
handleammo();
AnimateHold(IDLE);
self.think = "idle";
}
} ]
basicroutines[ ()
{
if(GetEventState("crouch"))
{
if(OFFSETY > 40)
{
OFFSETY = OFFSETY - 5;
}
else
{
OFFSETY = 40;
}
}
else
{
if(OFFSETY < 75)
{
OFFSETY = OFFSETY + 5;
}
else
{
OFFSETY = 75;
}
}
PositionToPawn("player",offsetX,OFFSETY+offsetY+offsetZ*sin(-self.camera_pitch),offsetZ*cos(self.camera_pitch),true,false);
self.ideal_pitch = self.camera_pitch;
self.ideal_yaw = self.player_yaw;
ChangeYaw();
ChangePitch();
if(acctimer < self.time)
{
acctimer = self.time + 0.1;
if(acc > accuracy)
{
acc = acc - accreturn;
}
else
{
acc = accuracy + 0;
}
if(acc > maxacc)
{
acc = maxacc + 0;
}
}
if(GetEventState("InInventory") = false)
{
if(GetEventState("fall"))
{
accuracy = WEAPON[currentweapon].ACCURACY*2;
accpershot = WEAPON[currentweapon].ACCPERSHOT*2;
}
else
{
if(GetEventState("move") and (offsettime < self.time))
{
if(GetEventState("crouch") or GetEventState("walk"))
{
offsettemp = offsettemp+0.05;
offsettime = self.time + 0.01;
accuracy = WEAPON[currentweapon].ACCURACY + 0;
accpershot = WEAPON[currentweapon].ACCPERSHOT + 0;
}
else
{
offsettemp = offsettemp+0.1;
offsettime = self.time + 0.01;
accuracy = WEAPON[currentweapon].ACCURACY*1.5;
accpershot = WEAPON[currentweapon].ACCPERSHOT*1.5;
}
}
else
{
if(GetEventState("crouch"))
{
accuracy = WEAPON[currentweapon].ACCURACY/2;
accpershot = WEAPON[currentweapon].ACCPERSHOT/2;
}
else
{
accuracy = WEAPON[currentweapon].ACCURACY + 0;
accpershot = WEAPON[currentweapon].ACCPERSHOT + 0;
}
}
offsetZ = WEAPON[currentweapon].OFFSETZ + sin(offsettemp);
}
DrawFlipBookImage("crosshair",crosshair,GetScreenWidth()/2-16,GetScreenHeight()/2-16,255,0,0,0,20);
if(tilttime>self.time)
{
TiltCamera(tiltamount/10000);
}
if(rotatetime>self.time)
{
RotateEntity("Player",0,rotateamount/100,0);
}
}
if(currentweapon = 2)
{
if((zoom != 1) and (unzoomtimer < self.time))
{
SetCameraWindow(2);
crosshair = 5;
unzoomtimer = self.time + 1000000;
}
if(zoomtimer < self.time)
{
if(zoom = 1)
{
SetCameraWindow(2);
crosshair = 5;
}
if(zoom = 2)
{
SetCameraWindow(1);
crosshair = 6;
}
if(zoom = 3)
{
SetCameraWindow(0.2);
crosshair = 6;
}
}
}
if(htimer < self.time)
{
SetTargetPoint(500 + random(-100,100),1000 + random(-100,100),0);
FireProjectile(hylsy,"shootbone",hylsyx,hylsyy,hylsyz,DAMAGEATTRIBUTE);
htimer = self.time + 1000000;
}
if((GetAttribute("WeaponSlot","Player")!=1) or GetEventState("InInventory") or (GetAttribute("weapon_primary","Player") = -1))
{
PawnRender(false);
ActivateHudElement("ammo_primary",false);
ActivateHudElement("clips_primary",false);
zoom = 1;
SetCameraWindow(2);
zoomtimer = 0;
unzoomtimer = 1000000;
reloading = false;
rotatetime = 0;
tilttime = 0;
firetime = 0;
acctimer = 0;
acc = 0;
offsettime = 0;
infotime = 0;
self.think = "wait";
}
SetAttribute("ammo_primary",bullets,"Player");
SetAttribute("clips_primary",GetAttribute(ammoattribute,"Player"),"Player");
if(infotime > self.time)
{
DrawText(infotext,GetScreenWidth()/2-6*GetStringLength(infotext),GetScreenHeight()/2 + 64,255,8,150,150,150);
}
} ]
clearkeys[ ()
{
if(self.lbutton_pressed = false)
{
mouseleft_pressed = false;
}
if(self.rbutton_pressed = false)
{
mouseright_pressed = false;
}
} ]
fire[ ()
{
baseaccx = random(-acc,acc);
baseaccy = random(-acc,acc);
htimer = self.time + hdelay;
for temp = 0 to bulletspershot
{
SetTargetPoint(baseaccx+random(-burstacc,burstacc),baseaccy+random(-burstacc,burstacc),1000);
FireProjectile(bullet,"shootbone",0,0,10,DAMAGEATTRIBUTE);
}
PlaySound(sound);
AddExplosion(muzzle,"muzzlebone",muzzleoffsetX,muzzleoffsetY,muzzleoffsetZ);
DamageAtBone(1000,WEAPON[currentweapon].HEARRANGE,"playersound","shootbone");
acc = acc + accpershot;
accreturn = acc/10;
tilttime = self.time + tilt;
rotatetime = self.time + rotate;
tiltamount = random(tiltmin,tiltmax);
rotateamount = random(rotatemin,rotatemax);
firetime = self.time + firerate;
bullets = bullets - 1;
SetAttribute("ammo_primary",bullets,"Player");
unzoomtimer = self.time + 0.2;
zoomtimer = self.time + 1.4;
if(fullauto = 0)
{
mouseleft_pressed = true;
}
} ]
altattack[ ()
{
if(currentweapon = 0)
{
if(firemode = 1)
{
firemode = 2;
fullauto = 0;
infotext = StringCopy("Switched to Semi-Automatic");
infotime = self.time + 2;
}
else
{
firemode = 1;
fullauto = 1;
infotext = StringCopy("Switched to Full-Automatic");
infotime = self.time + 2;
}
}
if(currentweapon = 2)
{
if(zoom = 1)
{
zoom = 2;
}
else
{
if(zoom = 2)
{
zoom = 3;
}
else
{
zoom = 1;
}
}
}
} ]
changeweaponinfo[ (changeto)
{
accuracy = WEAPON[changeto].ACCURACY + 0;
burstacc = WEAPON[changeto].BURSTACC + 0;
accpershot = WEAPON[changeto].ACCPERSHOT + 0;
maxacc = WEAPON[changeto].MAXACCURACY + 0;
bullet = StringCopy(WEAPON[changeto].BULLET);
ammoattribute = StringCopy(WEAPON[changeto].AMMOATTRIBUTE);
firerate = WEAPON[changeto].FIRERATE + 0;
offsetX = WEAPON[changeto].OFFSETX + 0;
offsetY = WEAPON[changeto].OFFSETY + 0;
offsetZ = WEAPON[changeto].OFFSETZ + 0;
muzzleoffsetX = WEAPON[changeto].MUZZLEOFFSETX + 0;
muzzleoffsetY = WEAPON[changeto].MUZZLEOFFSETY + 0;
muzzleoffsetZ = WEAPON[changeto].MUZZLEOFFSETZ + 0;
muzzle = StringCopy(WEAPON[changeto].MUZZLE);
hylsyx = WEAPON[changeto].HYLSYX + 0;
hylsyy = WEAPON[changeto].HYLSYY + 0;
hylsyz = WEAPON[changeto].HYLSYZ + 0;
hylsy = StringCopy(WEAPON[changeto].HYLSY);
hdelay = WEAPON[changeto].HDELAY + 0;
sound = StringCopy(WEAPON[changeto].SOUND);
emptysound = StringCopy(WEAPON[changeto].EMPTYSOUND);
fullauto = WEAPON[changeto].AUTO + 0;
crosshair = WEAPON[changeto].CROSSHAIR + 0;
clipsize = WEAPON[changeto].CLIPSIZE + 0;
bulletspershot = WEAPON[changeto].BULLETSPERSHOT + 0;
tiltmin = WEAPON[changeto].TILTMIN + 0;
tiltmax = WEAPON[changeto].TILTMAX + 0;
tilt = WEAPON[changeto].TILT + 0;
rotatemin = WEAPON[changeto].ROTATEMIN + 0;
rotatemax = WEAPON[changeto].ROTATEMAX + 0;
rotate = WEAPON[changeto].ROTATE + 0;
IDLE = StringCopy(WEAPON[changeto].IDLE);
SHOOT = StringCopy(WEAPON[changeto].SHOOT);
RELOAD = StringCopy(WEAPON[changeto].RELOAD);
ARM = StringCopy(WEAPON[changeto].ARM);
acc = accuracy + 0;
} ]
handleammo[ ()
{
if(GetAttribute(ammoattribute,"Player") < (clipsize-bullets))
{
bullets = bullets + GetAttribute(ammoattribute,"Player");
SetAttribute(ammoattribute,0,"Player");
}
else
{
ModifyAttribute(ammoattribute,bullets-clipsize,"Player");
bullets = clipsize + 0;
}
} ]
}
It's really a lot to do,but I'll get on it(or at least try to)!
can you just explain to me something?
I couldn't figure out how the weapon is attatched to the player and how do you position it?
If you help me with that I might get somewhere,looking at your scripted weapons and trying to make mine.
Oh yeah and I saw this in your script:
Code: Select all
self.yaw_speed = 10000;
self.pitch_speed = 10000;
does that mean that if I make the yaw and pitch speed smaller,the weapon will rotate slower with the player,cuz that will create the illusion that the weapon is heavy and it will be cool (like in half life 2 for example)