allow dynlight to track owner
git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@2890 e016b1c5-ed68-44aa-a2f7-31cac88cffde
This commit is contained in:
@@ -368,10 +368,12 @@ struct playerent : dynent, playerstate
|
||||
{
|
||||
extern void removebounceents(playerent *owner);
|
||||
extern void detachsounds(playerent *owner);
|
||||
extern void removedynlights(physent *owner);
|
||||
extern physent *camera1;
|
||||
extern void togglespect();
|
||||
removebounceents(this);
|
||||
detachsounds(this);
|
||||
removedynlights(this);
|
||||
if(this==camera1) togglespect();
|
||||
}
|
||||
|
||||
|
||||
+2
-1
@@ -385,10 +385,11 @@ extern int lastcalclight;
|
||||
|
||||
extern void fullbrightlight(int level);
|
||||
extern void calclight();
|
||||
extern void adddynlight(const vec &o, int reach, int expire, int fade, uchar r, uchar g = 0, uchar b = 0);
|
||||
extern void adddynlight(physent *owner, const vec &o, int reach, int expire, int fade, uchar r, uchar g = 0, uchar b = 0);
|
||||
extern void dodynlights();
|
||||
extern void undodynlights();
|
||||
extern void cleardynlights();
|
||||
extern void removedynlights(physent *owner);
|
||||
extern block *blockcopy(const block &b);
|
||||
extern void blockpaste(const block &b);
|
||||
extern void freeblock(block *&b);
|
||||
|
||||
@@ -619,8 +619,8 @@ void grenadeent::splash()
|
||||
particle_splash(0, 50, 300, o);
|
||||
particle_fireball(5, o);
|
||||
addscorchmark(o);
|
||||
adddynlight(o, 16, 200, 100, 255, 255, 224);
|
||||
adddynlight(o, 16, 600, 600, 192, 160, 128);
|
||||
adddynlight(NULL, o, 16, 200, 100, 255, 255, 224);
|
||||
adddynlight(NULL, o, 16, 600, 600, 192, 160, 128);
|
||||
if(owner != player1) return;
|
||||
int damage = guns[GUN_GRENADE].damage;
|
||||
radialeffect(owner, o, damage, owner, GUN_GRENADE);
|
||||
@@ -874,7 +874,7 @@ void gun::attackfx(const vec &from, const vec &to, int millis)
|
||||
addbullethole(owner, from, to);
|
||||
addshotline(owner, from, to);
|
||||
particle_splash(0, 5, 250, to);
|
||||
adddynlight(from, 4, 100, 50, 96, 80, 64);
|
||||
adddynlight(owner, from, 4, 100, 50, 96, 80, 64);
|
||||
attacksound();
|
||||
}
|
||||
|
||||
@@ -902,7 +902,7 @@ void shotgun::attackfx(const vec &from, const vec &to, int millis)
|
||||
int holes = 3+rnd(5);
|
||||
loopi(holes) addbullethole(owner, from, sg[i], 0, false);
|
||||
}
|
||||
adddynlight(from, 4, 100, 50, 96, 80, 64);
|
||||
adddynlight(owner, from, 4, 100, 50, 96, 80, 64);
|
||||
attacksound();
|
||||
}
|
||||
|
||||
@@ -925,7 +925,7 @@ void sniperrifle::attackfx(const vec &from, const vec &to, int millis)
|
||||
addshotline(owner, from, to);
|
||||
particle_splash(0, 50, 200, to);
|
||||
particle_trail(1, 500, from, to);
|
||||
adddynlight(from, 4, 100, 50, 96, 80, 64);
|
||||
adddynlight(owner, from, 4, 100, 50, 96, 80, 64);
|
||||
attacksound();
|
||||
}
|
||||
|
||||
|
||||
@@ -174,7 +174,8 @@ void calclight()
|
||||
|
||||
struct dlight
|
||||
{
|
||||
vec o;
|
||||
physent *owner;
|
||||
vec offset, o;
|
||||
block *area;
|
||||
int reach, fade, expire;
|
||||
uchar r, g, b;
|
||||
@@ -190,12 +191,19 @@ vector<dlight> dlights;
|
||||
|
||||
VAR(dynlight, 0, 1, 1);
|
||||
|
||||
void adddynlight(const vec &o, int reach, int expire, int fade, uchar r, uchar g, uchar b)
|
||||
void adddynlight(physent *owner, const vec &o, int reach, int expire, int fade, uchar r, uchar g, uchar b)
|
||||
{
|
||||
if(!dynlight) return;
|
||||
|
||||
dlight &d = dlights.add();
|
||||
d.owner = owner;
|
||||
d.o = o;
|
||||
if(d.owner)
|
||||
{
|
||||
d.offset = d.o;
|
||||
d.offset.sub(d.owner->o);
|
||||
}
|
||||
else d.offset = vec(0, 0, 0);
|
||||
d.reach = reach;
|
||||
d.fade = fade;
|
||||
d.expire = lastmillis + expire;
|
||||
@@ -219,6 +227,15 @@ void cleardynlights()
|
||||
dlights.setsize(0);
|
||||
}
|
||||
|
||||
void removedynlights(physent *owner)
|
||||
{
|
||||
loopv(dlights) if(dlights[i].owner==owner)
|
||||
{
|
||||
freeblock(dlights[i].area);
|
||||
dlights.remove(i--);
|
||||
}
|
||||
}
|
||||
|
||||
static inline bool insidearea(const block &a, const block &b)
|
||||
{
|
||||
return b.x >= a.x && b.y >= a.y && b.x+b.xs <= a.x+a.xs && b.y+b.ys <= a.y+a.ys;
|
||||
@@ -237,6 +254,11 @@ void dodynlights()
|
||||
dlights.remove(i--);
|
||||
continue;
|
||||
}
|
||||
if(d.owner)
|
||||
{
|
||||
d.o = d.owner->o;
|
||||
d.o.add(d.offset);
|
||||
}
|
||||
persistent_entity l((int)d.o.x, (int)d.o.y, (int)d.o.z, LIGHT, d.reach, d.r, d.g, d.b);
|
||||
calclightsource(l, d.calcintensity(), false);
|
||||
if(area)
|
||||
|
||||
Reference in New Issue
Block a user