Forum

Weird Spikes Question

Discuss programming in the QuakeC language.

Moderator: InsideQC Admins

Weird Spikes Question

Postby smd » Fri Sep 28, 2007 6:17 pm

hi!
i've tried out this nice tutorial from pastor and it worked great, thx!!

my only question: is it possible that the nails dont stuck so deep in the wall?

i want them that they stuck about half so deep!

maybe someone know whats to change here !? 8)

Code: Select all
void() spike_touch =
{
local float rand;
        if (other == self.owner)
                return;

        if (other.solid == SOLID_TRIGGER)
                return; // trigger field, do nothing

        if (pointcontents(self.origin) == CONTENT_SKY)
        {
                remove(self);
                return;
        }
       
// hit something that bleeds
        if (other.takedamage)
        {
                spawn_touchblood (9);
                T_Damage (other, self, self.owner, 9);
               
                remove(self);   //add this so they don't float...
                return;         //add this to avoid errors
        }
        else
        {
                WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
               
                if (self.classname == "wizspike")
                        WriteByte (MSG_BROADCAST, TE_WIZSPIKE);
                else if (self.classname == "knightspike")
                        WriteByte (MSG_BROADCAST, TE_KNIGHTSPIKE);
                else
                        WriteByte (MSG_BROADCAST, TE_SPIKE);
                WriteCoord (MSG_BROADCAST, self.origin_x);
                WriteCoord (MSG_BROADCAST, self.origin_y);
                WriteCoord (MSG_BROADCAST, self.origin_z);
        }

        self.velocity = '0 0 0';        //add this, it makes the nail stop

        self.nextthink = time + 10;     //add this, to prevent packet overflows
        self.think = SUB_Remove;        //add this for same reason as above

};
smd
 
Posts: 26
Joined: Sun Sep 23, 2007 2:58 pm

Postby Sajt » Fri Sep 28, 2007 6:42 pm

Change this:

Code: Select all
...

self.velocity = '0 0 0';

...


To this ((I added some extra stuff too which should be there):

Code: Select all
...

self.solid = SOLID_NOT;
self.movetype = MOVETYPE_NONE;

setorigin (self, self.origin - normalize(self.velocity) * 3);
self.velocity = '0 0 0';

...
F. A. Špork, an enlightened nobleman and a great patron of art, had a stately Baroque spa complex built on the banks of the River Labe.
Sajt
 
Posts: 1215
Joined: Sat Oct 16, 2004 3:39 am

Postby smd » Fri Sep 28, 2007 10:03 pm

thank u, workssss 8)

the only problem now is that if i shoot an enemy and he falls down a few spikes always stuck in the air.

also when spikes are on a door, when the door opens, the spikes are also stucking in the air.
smd
 
Posts: 26
Joined: Sun Sep 23, 2007 2:58 pm

Postby Sajt » Fri Sep 28, 2007 10:13 pm

After ...
Code: Select all
if (other.solid == SOLID_TRIGGER)
    return; // trigger field, do nothing


add...

Code: Select all
if (other.solid != SOLID_BSP || other.movetype == MOVETYPE_PUSH)
{
    remove(self);
    return;
}


This will make them just disappear when they hit doors or dying monsters.
F. A. Špork, an enlightened nobleman and a great patron of art, had a stately Baroque spa complex built on the banks of the River Labe.
Sajt
 
Posts: 1215
Joined: Sat Oct 16, 2004 3:39 am

Postby smd » Fri Sep 28, 2007 10:42 pm

hmm..

now with this new piece of code my spikes fly through all enemys, walls...

i cant kill with spikes now

maybe i have put your code at the wrong place?

Code: Select all
.float hit_z;
void() spike_touch =
{
local float rand;
        if (other == self.owner)
                return;

        if (other.solid == SOLID_TRIGGER)
                return; // trigger field, do nothing

     if (other.solid != SOLID_BSP || other.movetype == MOVETYPE_PUSH)
     {
                remove(self);
                return;
     }

        if (pointcontents(self.origin) == CONTENT_SKY)
        {
                remove(self);
                return;
        }
       
// hit something that bleeds
        if (other.takedamage)
        {
                spawn_touchblood (9);
                T_Damage (other, self, self.owner, 9);
               
                remove(self);   //add this so they don't float...
                return;         //add this to avoid errors
        }
        else
        {
                WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
               
                if (self.classname == "wizspike")
                        WriteByte (MSG_BROADCAST, TE_WIZSPIKE);
                else if (self.classname == "knightspike")
                        WriteByte (MSG_BROADCAST, TE_KNIGHTSPIKE);
                else
                        WriteByte (MSG_BROADCAST, TE_SPIKE);
                WriteCoord (MSG_BROADCAST, self.origin_x);
                WriteCoord (MSG_BROADCAST, self.origin_y);
                WriteCoord (MSG_BROADCAST, self.origin_z);
        }

        self.solid = SOLID_NOT;
     self.movetype = MOVETYPE_NONE;

     setorigin (self, self.origin - normalize(self.velocity) * 3);
     self.velocity = '0 0 0';         //add this, it makes the nail stop

        self.nextthink = time + 10;     //add this, to prevent packet overflows
        self.think = SUB_Remove;        //add this for same reason as above

};
smd
 
Posts: 26
Joined: Sun Sep 23, 2007 2:58 pm

Postby Sajt » Sat Sep 29, 2007 8:13 am

Sorry. I think some dyslexic kid got on my inside3d account somehow and posted that. It's utter lies and untruths.

Code: Select all
.float hit_z;
void() spike_touch =
{
local float rand;
        if (other == self.owner)
                return;

        if (other.solid == SOLID_TRIGGER)
                return; // trigger field, do nothing

        if (pointcontents(self.origin) == CONTENT_SKY)
        {
                remove(self);
                return;
        }
       
// hit something that bleeds
        if (other.takedamage)
        {
                spawn_touchblood (9);
                T_Damage (other, self, self.owner, 9);
               
                remove(self);   //add this so they don't float...
                return;         //add this to avoid errors
        }

        if (other.solid != SOLID_BSP || other.movetype == MOVETYPE_PUSH)
        {
                remove(self);
                return;
        }

        WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
               
        if (self.classname == "wizspike")
                WriteByte (MSG_BROADCAST, TE_WIZSPIKE);
        else if (self.classname == "knightspike")
                WriteByte (MSG_BROADCAST, TE_KNIGHTSPIKE);
        else
                WriteByte (MSG_BROADCAST, TE_SPIKE);
        WriteCoord (MSG_BROADCAST, self.origin_x);
        WriteCoord (MSG_BROADCAST, self.origin_y);
        WriteCoord (MSG_BROADCAST, self.origin_z);

        self.solid = SOLID_NOT;
        self.movetype = MOVETYPE_NONE;

        setorigin (self, self.origin - normalize(self.velocity) * 3);
        self.velocity = '0 0 0';         //add this, it makes the nail stop

        self.nextthink = time + 10;     //add this, to prevent packet overflows
        self.think = SUB_Remove;        //add this for same reason as above

};
F. A. Špork, an enlightened nobleman and a great patron of art, had a stately Baroque spa complex built on the banks of the River Labe.
Sajt
 
Posts: 1215
Joined: Sat Oct 16, 2004 3:39 am

Postby smd » Sat Sep 29, 2007 12:55 pm

fsss....:(

this also doesnt work

now i can kill enemys, but there are no spikes visible
smd
 
Posts: 26
Joined: Sun Sep 23, 2007 2:58 pm

Postby Sajt » Sat Sep 29, 2007 2:54 pm

So worldspawn is MOVETYPE_PUSH now? They keep changing that one on me.

Just change:
Code: Select all
if (other.solid != SOLID_BSP || other.movetype == MOVETYPE_PUSH)
to:
Code: Select all
if (other != world)


I've never been good at coughing up code without testing it.
F. A. Špork, an enlightened nobleman and a great patron of art, had a stately Baroque spa complex built on the banks of the River Labe.
Sajt
 
Posts: 1215
Joined: Sat Oct 16, 2004 3:39 am

Postby smd » Sat Sep 29, 2007 4:21 pm

now everything looks nice,thx. except a little problem that when i shoot on doors or elevators there is nothing to see.
no spikes and no impact fx.

maybe you can fix this last little problem also 8)
smd
 
Posts: 26
Joined: Sun Sep 23, 2007 2:58 pm

Postby Sajt » Sat Sep 29, 2007 7:24 pm

Sigh...

Code: Select all
void() spike_stuck_think =
{
   if (self.aflag <= time)
   {
      remove (self);
      return;
   }

   setorigin(self, self.pos1 + self.owner.origin - self.pos2);

   self.nextthink = time;
};

void() spike_touch =
{
local float rand;
        if (other == self.owner)
                return;

        if (other.solid == SOLID_TRIGGER)
                return; // trigger field, do nothing

        if (pointcontents(self.origin) == CONTENT_SKY)
        {
                remove(self);
                return;
        }
       
// hit something that bleeds
        if (other.takedamage)
        {
                spawn_touchblood (9);
                T_Damage (other, self, self.owner, 9, DTYPE_SHOT);
               
                remove(self);   //add this so they don't float...
                return;         //add this to avoid errors
        }

        else if (other.solid != SOLID_BSP)
        {
                remove(self);
                return;
        }

        WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
               
        if (self.classname == "wizspike")
                WriteByte (MSG_BROADCAST, TE_WIZSPIKE);
        else if (self.classname == "knightspike")
                WriteByte (MSG_BROADCAST, TE_KNIGHTSPIKE);
        else
                WriteByte (MSG_BROADCAST, TE_SPIKE);
        WriteCoord (MSG_BROADCAST, self.origin_x);
        WriteCoord (MSG_BROADCAST, self.origin_y);
        WriteCoord (MSG_BROADCAST, self.origin_z);

        self.solid = SOLID_NOT;
        self.movetype = MOVETYPE_NONE;

        setorigin (self, self.origin - normalize(self.velocity) * 3);
        self.velocity = '0 0 0';         //add this, it makes the nail stop

      if (other.solid == SOLID_BSP && other != world)
      {
         self.owner = other;
         self.pos1 = self.origin;
         self.pos2 = other.origin;
         self.aflag = time + 10;
         self.think = spike_stuck_think;
         self.nextthink = time;
      }
      else
      {
         self.nextthink = time + 10;     //add this, to prevent packet overflows
         self.think = SUB_Remove;        //add this for same reason as above
      }
};


If the nails lag a frame behind the movers........... play with a higher framerate.
F. A. Špork, an enlightened nobleman and a great patron of art, had a stately Baroque spa complex built on the banks of the River Labe.
Sajt
 
Posts: 1215
Joined: Sat Oct 16, 2004 3:39 am

Postby smd » Sat Sep 29, 2007 8:23 pm

wooow :lol:

now it works perfect!!!


thank u soooooooo much :wink:
smd
 
Posts: 26
Joined: Sun Sep 23, 2007 2:58 pm


Return to QuakeC Programming

Who is online

Users browsing this forum: No registered users and 1 guest