animating a sprite.
Moderator: InsideQC Admins
14 posts
• Page 1 of 1
animating a sprite.
this is what i did. im pretty sure it should work.
anyone tell me what im doin wrong?
tried this too:
anyone tell me what im doin wrong?
- Code: Select all
void() anim_smoke1 =
{
self.frame = 1;
if (time == time +1)
{
self.frame = self.frame + 1;
}
else if (self.frame == 16)
{
self.frame = 1;
}
};
void() efx_smoke1 =
{
self.movetype = MOVETYPE_NONE;
self.velocity = '0 0 0';
self.touch = SUB_Null;
setmodel (self, "progs/smoke01.spr");
self.solid = SOLID_NOT;
anim_smoke1 ();
};
tried this too:
- Code: Select all
void() anim_smoke1 =
{
self.frame = 1;
if (time == time +1 && self.frame == 1)
{
self.think = self.frame +1;
}
else if (self.frame == 16)
{
self.nextthink = self.frame = 1;
}
};
Last edited by ceriux on Fri Feb 04, 2011 5:15 am, edited 1 time in total.
-

ceriux - Posts: 2223
- Joined: Sat Sep 06, 2008 3:30 pm
- Location: Indiana, USA
i think you have to set a nextthink in there somewhere...
- Code: Select all
void() efx_smoke1 =
{
self.movetype = MOVETYPE_NONE;
self.velocity = '0 0 0';
self.touch = SUB_Null;
setmodel (self, "progs/smoke01.spr");
self.solid = SOLID_NOT;
self.think = anim_smoke1;
self.nextthink = time + 1;
}
Last edited by r00k on Fri Feb 04, 2011 5:16 am, edited 2 times in total.
- r00k
- Posts: 1110
- Joined: Sat Nov 13, 2004 10:39 pm
r00k wrote:i think you have to set a nextthink in there somewhere...
sorry updated my post before i saw you posted. i had that thought.
also tried changing the self.think to self.nextthink. no go.
Last edited by ceriux on Fri Feb 04, 2011 5:16 am, edited 1 time in total.
-

ceriux - Posts: 2223
- Joined: Sat Sep 06, 2008 3:30 pm
- Location: Indiana, USA
think before you nextthink. nextthink needs time. You can not change time in qc. You can only change what you think of time.
- Code: Select all
void() anim_smoke1 =
{
if(self.frame < 16) self.frame = self.frame + 1;
else remove(self);
self.think = anim_smoke1;
self.nextthink = time + 0.1;
};
i should not be here
- leileilol
- Posts: 2783
- Joined: Fri Oct 15, 2004 3:23 am
ceriux wrote:doesnt seem to work leilei. but im going to mess with your code too. (it just removes the sprite on spawn)
My code assumed a explosion animation. If you use a bit of THINK POWER you could change that "else remove(self); " to "else self.frame = 0". WOW IT LOOPS!!!
also try debugging with s_explod.spr instead. trying to help over the internet on a possible malformed sprite file is even more a pain
i should not be here
- leileilol
- Posts: 2783
- Joined: Fri Oct 15, 2004 3:23 am
leileilol wrote:ceriux wrote:doesnt seem to work leilei. but im going to mess with your code too. (it just removes the sprite on spawn)
My code assumed a explosion animation. If you use a bit of THINK POWER you could change that "else remove(self); " to "else self.frame = 0". WOW IT LOOPS!!!
i did use my "think power" and did that right as you were posting =)
it still only seems to play two frames removes it's self then spawns again in a loop. either that or i just cant see it cause the last few frames are working correctly...
- Code: Select all
void() anim_smoke1 =
{
if(self.frame < 15) self.frame = self.frame + 1;
else self.frame =0;
self.think = anim_smoke1;
self.nextthink = time + 0.1;
};
void() efx_smoke1 =
{
self.movetype = MOVETYPE_NONE;
self.velocity = '0 0 0';
self.touch = SUB_Null;
setmodel (self, "progs/smoke01.spr");
self.solid = SOLID_NOT;
self.think = anim_smoke1;
self.nextthink = time + 0.1;
} ;
im recompiling the map with the entity not half way in the chimney see what happens.
edit: it's playing them all from what i can tell. time to try n fix that sprite.
-

ceriux - Posts: 2223
- Joined: Sat Sep 06, 2008 3:30 pm
- Location: Indiana, USA
It's been a long time since i messed with sprites, this is old code I had for my flame thrower...
- Code: Select all
.float flametime;
void() flame_touch =
{
if (other.classname == "Torch") return;//no fire-vs-fire
if ((other == self.owner) && ( (self.nextthink - time) > 0.6 ) ) return;
if (other.classname=="player")
{
other.deathtype = "torch";
T_Damage (other, self, self.owner, 20);
}
sound (self, CHAN_WEAPON, "hknight/hit.wav", 1, ATTN_NORM);
BecomeExplosion();
};
void ()
flame_think =
{
local entity t1;
if (pointcontents(self.origin) == CONTENT_WATER)
{
remove (self);
return;
}
if (pointcontents(self.origin) == CONTENT_SLIME)
{
remove (self);
return;
}
// flame has died remove ent.
if (self.frame >= 5)
{
remove(self);
return;
}
//create more fire!
//just for looks
t1 = spawn();
t1.classname = "Torch";
t1.owner = self;
t1.solid = SOLID_NOT;
t1.movetype = self.movetype;
setorigin (t1, self.origin);
setmodel (t1, "progs/s_explod.spr");
t1.velocity = (self.velocity * 0.5);
t1.frame = self.frame;
t1.think = SUB_Remove;
t1.nextthink = time + 0.2;
if ((self.flametime - time) < 0.6)
{
self.frame = self.frame + 0.5;
}
self.think = flame_think;
self.nextthink = time + (sys_ticrate);
};
void() W_FireFlame =
{
local entity flame;
if (self.health<1) return;
//spit out bubbles if underwater
if (self.waterlevel > 1)
{
flame = spawn();
flame.solid = SOLID_BBOX;
flame.movetype = MOVETYPE_FLY;
makevectors (self.v_angle);
flame.velocity = self.velocity;
flame.velocity = aim(self, 10000);
flame.velocity = flame.velocity * 100;
flame.angles = vectoangles(flame.velocity);
flame.flags = FL_ITEM;
flame.frame = 0;
flame.touch = SUB_Null;
flame.think = SUB_Remove;
flame.nextthink = time + 1;
setmodel (flame, "progs/s_bubble.spr");
sound (self, CHAN_WEAPON, "fish/death.wav", 1, ATTN_NORM);
setsize (flame, '0 0 0', '0 0 0');
setorigin(flame, self.origin + (v_forward*16) + '0 0 16');
self.attack_finished = time + 0.8;
return;
}
flame = spawn();
flame.classname = "Torch";
flame.owner = self;
flame.solid = SOLID_BBOX;
flame.movetype = MOVETYPE_FLY;
flame.effects = EF_DIMLIGHT;
flame.frame = 0;
makevectors (self.v_angle);
flame.velocity = self.velocity;
flame.velocity = aim(self, 10000);
flame.velocity = (self.velocity * 0.6) + (flame.velocity * 300);
flame.angles = vectoangles(flame.velocity);
flame.flags = FL_ITEM;
flame.touch = flame_touch;
flame.think = flame_think;
flame.nextthink = time + (sys_ticrate);
flame.flametime = time + (sys_ticrate + 0.05);
sound (self, CHAN_WEAPON, "weapons/ax1.wav", 0.4, ATTN_NORM);
setmodel (flame, "progs/s_explod.spr");
setsize (flame, '0 0 0', '0 0 0');
setorigin(flame, self.origin + (v_forward*16) + '0 0 16');
};
- r00k
- Posts: 1110
- Joined: Sat Nov 13, 2004 10:39 pm
- Code: Select all
// WARNING: UNTESTED, USE AT YOUR OWN RISK!!!!!!11ONE.
Code:
void() anim_smoke1 =
{
self.frame = self.frame + 1;
if (self.frame < 16)
{
self.think = anim_smoke1;
}
else
{
self.think = SUB_Remove;
}
self.nextthink = time + 0.1;
};
// this is kinda weird, because smoke is supposed to
// be spawned by something burning or exploding. As
// is, this smoke sprite will always appears at (0,0,0).
// You may want to fix this.
// Also, may look cool if the smoke goes up a little
// bit while animating, so you may consider adding:
// self.velocity = '0 0 1';
void() efx_smoke1 =
{
precache_model ("progs/smoke01.spr");
setmodel (self, "progs/smoke01.spr");
self.frame = 0;
self.solid = SOLID_NOT;
self.movetype = MOVETYPE_NONE;
self.think = anim_smoke1;
self.nextthink = time + 0.1;
};
I know FrikaC made a cgi-bin version of the quakec interpreter once and wrote part of his website in QuakeC
(LordHavoc)
-

frag.machine - Posts: 2090
- Joined: Sat Nov 25, 2006 1:49 pm
14 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 1 guest