Index | FAQ | Search | Memberlist | Usergroups | Profile | Log in to check your private messages | Log in | Register

Reflecting Shield

| Inside3d Forums Forum Index -> QuakeC Programming

View previous topic :: View next topic
Author | Message
--- | ---
Madfox Joined: 15 Jan 2005 Posts: 36 Location: Holland |

Posted: Wed Mar 10, 2010 10:33 pm Post subject: Reflecting Shield |

Well, I have a model with 12 frames, in which there are four to block the player's attack. I really have no idea where to start. So I took the part of a single spike to reflect, in the spike_touch function. Later I can see for other weapons, if I understand how it works.
I divide the shielding in two parts, because I think blocking is another thing than reflecting.
As I said earlier, I'm a carrot when it comes to coding.
So to start I searched in Weapons.qc line 694 :

Code:
.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);
}
if(other.classname == "monster_ogre_melee")
{
// all of our new reflection code goes here
local vector I,N;
I = self.velocity;
N = normalize(self.origin - other.origin);
self.velocity = 2*(N*I)*N - I;
self.owner = other;
self.touch = spike_touch_reflected;
return;
// all of our new reflection code end here
}
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);
};

After I made a new statement for "spike_touch_reflected" the code will compile, but I'm halfway.

Back to top |

Madfox Joined: 15 Jan 2005 Posts: 36 Location: Holland |

Posted: Tue Mar 30, 2010 3:48 am Post subject: |

Can some one at least give me a simple blocking code advice?

Back to top |

r00k Joined: 13 Nov 2004 Posts: 483 |

Posted: Tue Mar 30, 2010 7:26 am Post subject: |

You could have a global variable such as .float blocking so on certain frames it's set 1, then in combat.qc just make entities (target) not take damage if self.blocking == 1.

Code:
void () player_block1 = [ 8, player_block2 ] { self.blocking = 1; if (!(self.health)) self.blocking = 0;
};
void () player_block2 = [ 9, player_block1 ]
{
if (!(self.health))
self.blocking = 0;
};

Code:
void (entity targ, entity inflictor, entity attacker, float damage) T_Damage = { local vector dir; if (!targ.takedamage) {
return;
}
if (targ.blocking)
{
return;
}

Back to top |

Display posts from previous:

| Inside3d Forums Forum Index -> QuakeC Programming | All times are GMT
Page 1 of 1

Jump to:

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

Powered by phpBB © 2004 phpBB Group