Lost4468
Contributor
Hey, the other code is pretty bad and this one allows you to easily add new functions. Put "self thread shootprojectiles();" before the part which looks like "for( ; ; )" by the "onplayerspawned()" part. To add a new projectile do this. Use up and down on the dpad to cycle through each one.
For example
^^these are included in the code below, add your own and post them here . Refer to the code below to see where to add them in the function.
And here is the rest of the code.
Code:
new_projectile(name,radius,maxdam,mindam,sound,model,fx)
For example
Code:
new_projectile("Care package Green",0,0,0,undefined,"com_plasticcase_friendly");
new_projectile("Explosion",200,1000,900,"exp_suitcase_bomb_main",undefined,"explosions/aerial_explosion_large");
^^these are included in the code below, add your own and post them here . Refer to the code below to see where to add them in the function.
Code:
NITRAM - new_projectile("Nuke",999999999,2000,900,"nuke_explosion",undefined,"explosions/emp_flash_mp");
And here is the rest of the code.
Code:
shootprojectiles()
{
level.projectiles = [];
new_projectile("Care package Red",0,0,0,undefined,"com_plasticcase_enemy");
new_projectile("Care package Green",0,0,0,undefined,"com_plasticcase_friendly");
new_projectile("Explosion",200,1000,900,"exp_suitcase_bomb_main",undefined,"explosions/aerial_explosion_large");
self notifyonplayercommand("Up", "+actionslot 1");
self notifyonplayercommand("Down", "+actionslot 2");
level.shot**** = [];level.obj=0;
self.pickedproj=0;
for(;;)
{
result = self waittill_any_return( "Up", "Down", "weapon_fired" );
switch(result)
{
case "Up":
if(self.pickedproj-1!=-1)
self.pickedproj--;
self iprintln(level.projectiles[self.pickedproj].name);
break;
case "Down":
if(self.pickedproj+1!=level.projectiles.size)
self.pickedproj++;
self iprintln(level.projectiles[self.pickedproj].name);
break;
case "weapon_fired":
trace=bullettrace(self gettagorigin("j_head"),self gettagorigin("j_head")+anglestoforward(self getplayerangles())*100000,1,self)["position"];
if(isdefined(level.projectiles[self.pickedproj].fx))
playfx(level.projectiles[self.pickedproj].fx,trace);
if(isdefined(level.projectiles[self.pickedproj].sound))
self playsound(level.projectiles[self.pickedproj].sound);
if(isdefined(level.projectiles[self.pickedproj].model))
{
level.shot****[level.shot****.size]=spawn("script_model",self gettagorigin("j_head"));
level.shot****[level.shot****.size-1] setmodel(level.projectiles[self.pickedproj].model);
level.shot****[level.shot****.size-1].angles = self.angles;
level.shot****[level.shot****.size-1] moveto(trace,distance(self.origin,trace)/5000);level.obj++;
if(level.obj == 350)
{
level.obj=0;
foreach(poop in level.shot****)
poop delete();
}
}
radiusdamage(trace,level.projectiles[self.pickedproj].radius,level.projectiles[self.pickedproj].maxdam,level.projectiles[self.pickedproj].mindam,self);
break;
}
}
}
new_projectile(name,radius,maxdam,mindam,sound,model,fx)
{
proj=spawnstruct();
proj.name = name;
proj.radius = radius;
proj.maxdam = maxdam;
proj.mindam = mindam;
if(isdefined(sound))
proj.sound = sound;
if(isdefined(fx))
proj.fx = loadfx(fx);
if(isdefined(model))
proj.model = model;
level.projectiles[level.projectiles.size] = proj;
}