Reflecting Shield
Moderator: InsideQC Admins
3 posts
• Page 1 of 1
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 :
After I made a new statement for "spike_touch_reflected" the code will compile, but I'm halfway.
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: 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);
}
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.
-

Madfox - Posts: 106
- Joined: Sat Jan 15, 2005 3:13 pm
- Location: Holland
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: Select all
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: Select all
void (entity targ, entity inflictor, entity attacker, float damage) T_Damage =
{
local vector dir;
if (!targ.takedamage)
{
return;
}
if (targ.blocking)
{
return;
}
- r00k
- Posts: 1110
- Joined: Sat Nov 13, 2004 10:39 pm
3 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 1 guest