Urban Wars
December 17, 2018, 01:24:49 am
Welcome, Guest. Please login or register.

Login with username, password and session length
News: Welcome, here you will find all the information on Urban Wars
 
  Home Help Search Staff List Login Register  

Randomly spawning a different sprite

Pages: 1 [2]
  Print  
Author Topic: Randomly spawning a different sprite  (Read 116 times)
DukeInstinct
Administrator
Lieutenant
*****
Posts: 120


The ArchDuke


View Profile WWW
« Reply #15 on: April 24, 2010, 12:52:02 am »

Either way takes about the same amount of memory. You might save a couple bytes in your dat file with the loop method.

If you want to use a loop then the second piece of code I posted should go into your create explosion function while the first piece of code I posted should go into your spawn debris function.
Report Spam   Logged



Urban Wars Coder/3d Modeler/Animator

Mexicouger
Lieutenant
*
Posts: 111


View Profile
« Reply #16 on: April 24, 2010, 01:00:59 am »

NEXT QUESTION. Is there a distinct surface for a player. A distinct vector? Say you shoot a gun and you have  arichochet sound effecta You don`t want it to play whne you hit the player. So how woul dyou setup that if statement?
Report Spam   Logged
DukeInstinct
Administrator
Lieutenant
*****
Posts: 120


The ArchDuke


View Profile WWW
« Reply #17 on: April 24, 2010, 01:56:29 am »

If you're using a traceline to detect what your weapon hit then you'd use:
Code:
if (trace_ent.takedamage)
To check whether it's a player/monster.

If you're using a entity that acts as a projectile then in that projectile's touch function you'd add:
Code:
if (other.takedamage)
Report Spam   Logged



Urban Wars Coder/3d Modeler/Animator

Mexicouger
Lieutenant
*
Posts: 111


View Profile
« Reply #18 on: April 24, 2010, 02:04:04 am »

OK i think I get it now. I added richochet sounds and I don`t want it to play on a player. Also, sorry bout so many questions and bad spelling. My phone is retarded and blends letters. I also wa sjust messing with th erandom code and added a random func to a .nextthink function, an dnow the debris randomly disapears between 1-8 seconds. I think coding is fooking awesome. Now I did something a bit offtopic a while ago. I created a solid sprite that .thinks about shooting a weapon. he .nextthinks in 3 seconds but never nextthinks. Any help? like he will shoot the weapon when I load the map in 3 seconds, But he won`t shoot it again. I added the think funcstions and all. i put his .think = W_FirePistol  and he does the whole pistol action, but he won`t do it again.
Report Spam   Logged
DukeInstinct
Administrator
Lieutenant
*****
Posts: 120


The ArchDuke


View Profile WWW
« Reply #19 on: April 24, 2010, 09:35:28 pm »

There should also be an assignment to nextthink in the actual think function. So basically add:
Code:
self.nextthink=time+3;
to your think function.
Report Spam   Logged



Urban Wars Coder/3d Modeler/Animator

Mexicouger
Lieutenant
*
Posts: 111


View Profile
« Reply #20 on: April 26, 2010, 08:42:40 am »

I had  a nextthink already. And time counts as 1 second right? self.nextthink = time + 5; that is 6 seconds right?
Report Spam   Logged
DukeInstinct
Administrator
Lieutenant
*****
Posts: 120


The ArchDuke


View Profile WWW
« Reply #21 on: April 26, 2010, 06:12:25 pm »

Nope. It's 5 seconds.
Report Spam   Logged



Urban Wars Coder/3d Modeler/Animator

Mexicouger
Lieutenant
*
Posts: 111


View Profile
« Reply #22 on: April 26, 2010, 07:45:18 pm »

So why must we put time + 5; then?
Report Spam   Logged
DukeInstinct
Administrator
Lieutenant
*****
Posts: 120


The ArchDuke


View Profile WWW
« Reply #23 on: April 26, 2010, 10:01:58 pm »

time is the amount of seconds that has elapsed since the game began.

If you just put nextthink=5; then that would mean 5 seconds after the game began. You'd most likely be past that time every call to that function so your think function would never be triggered. However, if you put nextthink=time+5; then that would mean 5 seconds after you assigned nextthink.
Report Spam   Logged



Urban Wars Coder/3d Modeler/Animator

Mexicouger
Lieutenant
*
Posts: 111


View Profile
« Reply #24 on: April 26, 2010, 10:23:26 pm »

Oh wow! That`s a big difference! Thanks!
Report Spam   Logged
Pages: 1 [2]
  Print  
 
Jump to:  


Get your own Chat Box! Go Large!
Bookmark this site! | Upgrade This Forum
SMF For Free - Create your own Forum | Buy traffic for your forum/website

Powered by SMF | SMF © 2016, Simple Machines
Privacy Policy