Mind-Warp PaVilion
  Home   Forum   Torrents Artwork Frappr Login Register  
March 12, 2010, 10:01:26 PM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: Go MWP [gomwp.org] Announced. You can read about it by clicking here.
 
   Forum   Calendar Help  
Pages: [1]   Go Down
  Add bookmark  |  Print  
Author Topic: Toss Code  (Read 496 times)
0 Members and 1 Other are viewing this topic.
Niborevoli
Jr. Member
*
Offline Offline

Posts: 28


Hide Posts
« on: February 14, 2009, 09:41:11 PM »

Bewley, a little bird says you want the toss code.

I've been meaning to prepare another vanilla PK release with this and other fixes included but haven't gotten around to it, so I'll try to extract the relevant bits here.

I was not too careful in marking my changes in SH's source so I'll do my best to extract them but its possible I've missed something.

The three components are fiddling with the size if needed (not get stuck in places where they ought to fit), the origin (so the item doesn't hang on the player, or on ledges at extreme angles), and the initial velocity (the "fling" direction and speed). I generally have tweaked the numbers to retain the original feel of a 'toss' (a little bit 'up') while giving direction control.

beartrap.qc: in beartrap_dropBearTrap
change the setsize to:  setsize (bt, '-16 -16 -0', '16 16 8');

change the setorigin from/to:
  //setorigin (bt, self.origin);   //efc beartrap aim
  setorigin (bt, self.origin + self.view_ofs + v_forward * 12);   // trap needs to start a little higher and a bit infront of player 

then replace/comment out line that looks something like (numbers were modded in this one by SH and me)
    bt.velocity = (v_forward * (420 + random() * 20)) + (v_up * (200 + random() * 20));   //SH*   //efc beartrap aim

with this:
Code:
   //efc beartrap aim start
  makevectors (self.v_angle);
bt.velocity = aim(self, 800);
bt.velocity = bt.velocity * (700 + random() * 20) + '0 0 200';
bt.angles_y = vectoyaw (bt.velocity);     // orient the trap in the direction of flight.
//efc beartrap aim end

Thats the basic deal.

Here is that whole beartrap function in case I left something out. It also has various junk modded by SH but you should be able to figure out which is which now.
Code:
void() beartrap_dropBearTrap =
{
  local entity bt;

  if (self.pk_beartrapammo <= 0)
return;

  if (!self.button0)
{
  player_run ();
    return;
  }

  bt = spawn();
  bt.owner = self;
  bt.movetype = MOVETYPE_TOSS;
  bt.solid = SOLID_TRIGGER;
  bt.classname = "beartrap";
  bt.takedamage = TRUE;
  bt.health = 240; //was 50, testing to make it harder to rjump them off of player  SH*
  bt.th_die = beartrapDie;
  bt.netname = "Bear Trap";

// For the correct death messages
bt.pk_currentitem = PK_IT_BEARTRAP;
bt.weapon = IT_AXE;

// Used to give a few seconds go get away from the trap
bt.beartrap_time = time + 5; //was 2    SH*

  // Kill it after 180 secs if nobody walks over it
  bt.think = beartrapDie;
  bt.nextthink = time + 180;

  setmodel (bt, "progs/beartrap.mdl");
  //setsize (bt, '-25 -24 -0', '25 25 8');
  setsize (bt, '-16 -16 -0', '16 16 8');

  // Throw away from you
  makevectors (self.angles);
 
  //setorigin (bt, self.origin);   //efc beartrap aim
  setorigin (bt, self.origin + self.view_ofs + v_forward * 12);   // trap needs to start a little higher and a bit infront of player 
 
  //bt.velocity = (v_forward * (420 + random() * 20)) + (v_up * (200 + random() * 20));   //SH*   //efc beartrap aim

   //efc beartrap aim start
  makevectors (self.v_angle);
bt.velocity = aim(self, 800);
bt.velocity = bt.velocity * (700 + random() * 20) + '0 0 200';
bt.angles_y = vectoyaw (bt.velocity);     // orient the trap in the direction of flight.
//efc beartrap aim end
 
  bt.touch = beartrapTouch;

sound(self, CHAN_AUTO, "weapons/btrap/bdrop_1.wav", 1, ATTN_NORM);

// PAINKEEP SPLASH Make this entity splash
AddToSplash(bt);
};



gravity well is similar:
gravity.qc: drop_gravity

Now that you understand the basic idea, I will just paste this one in whole, since there are several pieces in there. Note: There are some SH modified bits in here. You probably want to keep your original version of those.

Code:
void() drop_gravity =
{
local entity egravity;

// create a gravity object
egravity = spawn();
egravity.classname = "gravity";
egravity.owner = self;
egravity.solid = SOLID_TRIGGER;
egravity.movetype = MOVETYPE_TOSS;

// set it's placement and velocity
//setorigin(egravity, self.origin + self.view_ofs);  //efc
makevectors (self.angles);
setorigin(egravity, self.origin + self.view_ofs + v_forward * 12);  //efc- start higher and further out

//egravity.velocity = self.velocity * 0.5;  // efc - this doesn't do anything (gets overwritten)
setmodel(egravity, "progs/cube.mdl");
// TODO get acurate sizing
//setsize(egravity, '-32 -32 -32', '32 32 32');
setsize(egravity, '-16 -16 -16', '16 16 16');   // efc somewhat more accurate

/*
egravity.think = gravity_explode;
egravity.nextthink = time + 1.0;
egravity.attack_finished = time + 2.1;
*/
egravity.think = gravity_explode;
egravity.nextthink = time + 2.0;
//sound (self, CHAN_BODY, "misc/grav/grav_sh.wav", 1, ATTN_NORM); //Changed to grav_sh.wav--made wav file longer and louder. SH* Need to precache in weapons.qc line 62 also***
sound (self, CHAN_BODY, "misc/grav/grav_ergo.wav", 1, ATTN_NORM); //Changed to grav_ergo.wav--used the PKA roar sound. SH* Need to precache in weapons.qc line 63 also***
  // Throw away from you
  //makevectors (self.angles);
  //egravity.velocity = (v_forward * (600 + random() * 20)) + (v_up * (300 + random() * 150));  //Version 666f upped these 4 values by 50%  SH*
   
   makevectors (self.v_angle);   //efc aim
egravity.velocity = aim(self, 800);    //efc aim
egravity.velocity = egravity.velocity * (600 + random() * 20) + '0 0 375';   //efc aim
 
 
// For the correct death messages
egravity.pk_currentitem = PK_IT_GRAVITYWELL;
egravity.weapon = IT_AXE;

// PAINKEEP SPLASH Make this entity splash
AddToSplash(egravity);
};


The last one is turret.qc: float() turret_dropTurret

Unfortunately this is a bit of a mess since turrets are really two entities so there were more changes to get it working right, and there have been several unrelated modifications. It looks like no setsize change was required here. Hopefully you can figure out which parts you want to keep. If you have any problems let me know.

Code:
//+pk112 Changed this to return a boolean (float) - false if it failed, so it doesn't
//+pk112 decrement your ammo count.
//void() turret_dropTurret = //-pk112
float() turret_dropTurret = //+pk112
{
local entity turret;
local vector dir;

if(self.pk_turretammo <= 0)
{
return FALSE; //pk112
}

if(!self.button0)
{
  player_run ();
    return FALSE; //pk112
}

  // check if near a wall
  makevectors(self.v_angle);
  dir = self.origin + self.view_ofs;
  traceline (dir, dir + v_forward * 50, FALSE, self);

  makevectors (self.angles);
  if(trace_fraction != 1.0 && !trace_ent.takedamage)
  {
  // To near a wall, can't throw turret
    // PKQW
    sprint(self, PRINT_HIGH, "Don't throw the turret when you are so close to a fuckin' wall!!\n");
    return FALSE; //pk112
  }

turret = spawn ();
turret.owner = self;
turret.movetype = MOVETYPE_STEP;
// turret.movetype = MOVETYPE_TOSS;
// turret.solid = SOLID_BBOX;
turret.solid = SOLID_NOT;
turret.classname = "turret";
  turret.takedamage = TRUE;
  turret.health = 300;
  turret.th_die = turret_deathAnim;
  turret.ammo_cells = 40; //was 40  SH*

// set direction
turret.angles = self.angles;
turret.v_angle = self.v_angle;

// set turret duration
turret.turret_timeout = time + 120; //was 20  SH*

// set when the turret can target the owner
turret.turret_ownertimeout = time + 50.5; //Changed so sentries will not shoot owner -=most of the time=-   SH*

// look for enemy
turret.nextthink = time + 0.1;
turret.think = turret_searchForEnemy;

setmodel (turret, "progs/turtop.mdl");
setsize (turret, '-15 -14 -18', '21 7 10');
// Throw away from you
   makevectors (self.angles);   
setorigin (turret, self.origin + self.view_ofs + v_forward * 20);   //efc put this back in
//setorigin (turret, self.origin);


turret.turret_base = spawn ();
turret.turret_base.owner = turret;
turret.turret_base.movetype = MOVETYPE_TOSS;
// turret.turret_base.solid = SOLID_BBOX;
turret.turret_base.solid = SOLID_NOT;
turret.turret_base.classname = "turret_base";
  turret.turret_base.takedamage = TRUE;
  turret.turret_base.health = 300;
  turret.turret_base.th_die = turret_deathAnimBase;

  // Throw away from you
   makevectors (self.v_angle);
// efc turret.velocity = turret.turret_base.velocity = (v_forward * (300 + random() * 150)) + (v_up * (300 + random() * 10));  //ver 666f upped these values by 50%  SH*
turret.velocity = aim(self, 800);  //efc aiming
turret.velocity = turret.velocity * (500 + random() * 20) + '0 0 200'; //efc aiming


// set direction
//turret.turret_base.angles = self.angles;   //efc fix bases at weird angles
turret.turret_base.v_angle = self.v_angle;

// set turret duration
turret.turret_timeout = time + 90;

// look for enemy
turret.nextthink = time + 0.1;
turret.think = turret_searchForEnemy;

setmodel(turret.turret_base, "progs/turstand.mdl");
// setsize(turret.turret_base, '-15 -14 -18', '9 14 1');
setsize (turret, '-5 -5 -18', '5 5 1');
// setorigin (turret.turret_base, self.origin + self.view_ofs);
//setorigin (turret.turret_base, self.origin);  // efc
setorigin (turret.turret_base, turret.origin);  // efc
turret.turret_base.velocity = turret.velocity; //efc aiming

// PAINKEEP SPLASH Make this entity splash
AddToSplash(turret);

return TRUE; //+pk112
};

Again, try this out, and if you have problems let me know. If it is more convenient for diff'ing, you can grab these files from the weenieville site.




Logged
5h17h34d
VIP Member
Hero Member
*****
Offline Offline

Posts: 531


:P


WWW Hide Posts
« Reply #1 on: February 15, 2009, 01:41:57 AM »

I generally remarked my changes with //SH*

Logged

---------------------------
http://weenieville.net/
---------------------------
Pages: [1]   Go Up
  Add bookmark  |  Print  
 
Jump to:  

Google
Page created in 0.258 seconds with 22 queries.
Google visited last this page January 17, 2010, 03:48:52 AM
Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC

Home | Torrent Tracker | Forum | Artwork Gallery