So, about a day ago, I made a post mentioning that I am not posting my mod until I have fixed a problem with my modified spikes.
For explanations sake, here is how it is currently working in English:
The spikes, when shot, are now a movetype toss, and is a trigger solid (so the player can get damaged by it). Once it touches a solid object (the spikes delete on touch by player), it sticks there, and becomes a movetype none. The think is sub remove, and it thinks after 60 seconds on spawn.
My problem is that the nails can't stick and move with moving map objects, like secret doors and the like. Right now, they just kinda float in mid air. My first attempt did not work at all, and caused the Spikes to do a weird boomerang effect.
Here are the constraints for the think function I need:
1. Needs to still delete after 60 seconds.
2. Needs to still interact with players.
3. Needs to follow moving map objects when stuck to them.
That is essentially what I need to get this working. My only fear is that it will still cause massive lag if enough nails are following an object, even with DP7 protocol. We can always try and see though.
Here is all relating nail code. I would like to note that the nails were the first thing I did, and it's a lot messier than it needed to be. Being naive is fun!
If anyone has a solution to my problem, I will be in your debt, and thanks in advance!
Note: if this was easier than I thought, I'm going to jump off a cliff.
For explanations sake, here is how it is currently working in English:
The spikes, when shot, are now a movetype toss, and is a trigger solid (so the player can get damaged by it). Once it touches a solid object (the spikes delete on touch by player), it sticks there, and becomes a movetype none. The think is sub remove, and it thinks after 60 seconds on spawn.
My problem is that the nails can't stick and move with moving map objects, like secret doors and the like. Right now, they just kinda float in mid air. My first attempt did not work at all, and caused the Spikes to do a weird boomerang effect.
Here are the constraints for the think function I need:
1. Needs to still delete after 60 seconds.
2. Needs to still interact with players.
3. Needs to follow moving map objects when stuck to them.
That is essentially what I need to get this working. My only fear is that it will still cause massive lag if enough nails are following an object, even with DP7 protocol. We can always try and see though.
Here is all relating nail code. I would like to note that the nails were the first thing I did, and it's a lot messier than it needed to be. Being naive is fun!
Code:
void(vector org, vector dir) launch_spike = { newmis = spawn (); newmis.owner = self; newmis.solid = SOLID_TRIGGER; newmis.angles = vectoangles(dir); newmis.weaponmodel = self.weaponmodel; newmis.touch = spike_touch; newmis.classname = "spike"; newmis.think = SUB_Remove; if (!deathmatch) { newmis.movetype = MOVETYPE_FLYMISSILE; newmis.nextthink = time + 6; } else { newmis.movetype = MOVETYPE_TOSS; newmis.nextthink = time + 60; } setmodel (newmis, "progs/spike.mdl"); setsize (newmis, VEC_ORIGIN, VEC_ORIGIN); setorigin (newmis, org); newmis.velocity = dir * 1000; }; void() spike_touch = { if (!deathmatch) { 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); } 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); } remove(self); } else { local float rand; if (other == self.owner && self.velocity) return; if (other.solid == SOLID_TRIGGER) return; // trigger field, do nothing if (pointcontents(self.origin) == CONTENT_SKY) { remove(self); return; } if (other.classname == self.classname) { remove(self); return; } // hit something that bleeds if (other.takedamage) { spawn_touchblood (9); T_Damage (other, self, self.owner, 9); remove(self); } else { self.classname = "stuck_spike"; self.movetype = MOVETYPE_NONE; //setsize (self, VEC_ORIGIN, ' 0 0 4'); self.velocity = '0 0 0'; self.angles = vectoangles(trace_plane_normal); self.angles_x = self.angles_x+(crandom()*30); self.angles_y = self.angles_y+(crandom()*30); self.angles_z = self.angles_z+(crandom()*30); 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); } } };
Note: if this was easier than I thought, I'm going to jump off a cliff.
Comment