wal@Posted: Sat Aug 25, 2007 12:22 pm :
I really need to be able to skin the muzzle flash and smoke so I can hide them but it doesn't seem to be possible. I thought about doing it with an emitter and binding it to the muzzle joint but would that help? I take it a skin wont effect that either, but maybe it could be turned on or off when needed? If this is right, how would it be achieved. Never done anything with emitters before.



Ivan_the_B@Posted: Sat Aug 25, 2007 7:32 pm :
The bad news is that you cannot bind an emitter to the weapon... :?



ajm113@Posted: Sun Aug 26, 2007 8:54 pm :
I don't think the textures area has any thing that would be good for a flash grenade in the first place and it won't kill you to take a look around in the .prt area.

Just make a new .ptr file and just go where the grenade explosion in some other .ptr is and just copy and paste it in your new file and rename the title to something else in the code.

Then create a test map first that will trigger the func_emitter with your effect and play around with it until you get a good effect. That is how I do it when I am trying to create new emitters.

Then when you get a good effect going, just create a mod and copy the gernade.def file place it in your mod's def folder and open the file up and change the explosion effect to your flash. Just look at the comments in the .def area.

Safe, Clean, Fun.



wal@Posted: Mon Jan 07, 2008 10:03 pm :
I made a manual muzzlesmoke thread if anyone wants it. Just give it key:smoke val:whatever.prt. It works well but I'd like to trim it because it's causing an overflow. How do I tell it to just add one every time. I assume it's all the checks that are slowing it down because it's exactly the same as before on screen.
Code:
void weapon_plasmagun::Fire() {
   float currentTime;
   float ammoClip = ammoInClip();
   float number = 1;
   entity owner = getOwner();
   entity weapon_ent = owner.getWeaponEntity();
   entity particle1 = sys.spawn( "func_emitter" );
   entity particle2 = sys.spawn( "func_emitter" );
   entity particle3 = sys.spawn( "func_emitter" );
   entity particle4 = sys.spawn( "func_emitter" );
   entity particle5 = sys.spawn( "func_emitter" );
   entity particle6 = sys.spawn( "func_emitter" );
   entity particle7 = sys.spawn( "func_emitter" );
   entity particle8 = sys.spawn( "func_emitter" );
   string fx = getKey( "smoke" );
   vector org = weapon_ent.getJointPos( weapon_ent.getJointHandle ( "barrel" ) );
   next_attack = sys.getTime() + PLASMAGUN_FIRERATE;
   sys.setSpawnArg( "model", fx );

   if ( ammoClip == PLASMAGUN_LOWAMMO ) {
      startSound( "snd_lowammo", SND_CHANNEL_ITEM, true );
   }
   if ( number == 1 ) {
      particle1.setOrigin( org );
      particle1.setShaderParm( SHADERPARM_TIMEOFFSET, -sys.getTime() );
      number = 2;
   } else if ( number == 2 ) {
      particle2.setOrigin( org );
      particle2.setShaderParm( SHADERPARM_TIMEOFFSET, -sys.getTime() );
      number = 3;
   } else if ( number == 3 ) {
      particle3.setOrigin( org );
      particle3.setShaderParm( SHADERPARM_TIMEOFFSET, -sys.getTime() );
      number = 4;
   } else if ( number == 4 ) {
      particle4.setOrigin( org );
      particle4.setShaderParm( SHADERPARM_TIMEOFFSET, -sys.getTime() );
      number = 5;
   } else if ( number == 5 ) {
      particle5.setOrigin( org );
      particle5.setShaderParm( SHADERPARM_TIMEOFFSET, -sys.getTime() );
      number = 6;
   } else if ( number == 6 ) {
      particle6.setOrigin( org );
      particle6.setShaderParm( SHADERPARM_TIMEOFFSET, -sys.getTime() );
      number = 7;
   } else if ( number == 7 ) {
      particle7.setOrigin( org );
      particle7.setShaderParm( SHADERPARM_TIMEOFFSET, -sys.getTime() );
      number = 8;
   } else if ( number == 8 ) {
      particle8.setOrigin( org );
      particle8.setShaderParm( SHADERPARM_TIMEOFFSET, -sys.getTime() );
      number = 1;
   }
   launchProjectiles( PLASMAGUN_NUMPROJECTILES, spread, 0, 1.0, 1.0 );
   playAnim( ANIMCHANNEL_ALL, "fire" );

   while( !animDone( ANIMCHANNEL_ALL, PLASMAGUN_FIRE_TO_IDLE ) ) {
      currentTime = sys.getTime();
      ammoClip = ammoInClip();
      if ( ( currentTime >= next_attack ) && WEAPON_ATTACK && ( ammoClip > 0 ) ) {
         weaponState( "Fire", 0 );
      }
      waitFrame();
   }
   weaponState( "Idle", PLASMAGUN_FIRE_TO_IDLE );
}



Ivan_the_B@Posted: Tue Jan 08, 2008 9:49 am :
i don't understand:
1- why do you spawn 8 func_emitters instead of 1... and they are without any SpawnArg
2- why do you do sys.setSpawnArg( "model", fx ); after they are spawned
3- where those entities are removed.

This is the way you should spawn an entity
Code:
sys.setSpawnArg( "origin", v );
          sys.setSpawnArg( "model", "gflamerhand.prt" );
          sys.spawn( "func_emitter" );


you need to remove the old entities or you'll soon hit the limit of 4096 entities



wal@Posted: Tue Jan 08, 2008 5:18 pm :
1-The plasmasmoke.prt lasts for one second and the plasma gun fires 8 times a second, so 8 emitters need to be running at the same time or it will remove the particles after 0.125 seconds. There will never be more than 8 because there's only 1 entity for each. It just updates the origin and restarts the particle.

2-sys.setSpawnArg( "model", fx ); is before they are spawned, not after. particle1.setOrigin( org ); is when one is spawned. entity particle1 = sys.spawn( "func_emitter" ); just tells it what to spawn.

3-They are removed on the Lower thread.

It’s not the amount of entitys that are causing an overflow and it’s not an error that causes it to crash or anything, it just comes up with an overflow warning in the console and it’s messing with the snds because it’s struggling to keep up. I need to tell it to use particle+1 unless over a certain number else { start again. :?



wal@Posted: Thu Jan 10, 2008 9:42 pm :
Oh PISS. It doesn't replace the emitters. I assumed it did because it was removing the particle, so this will go over the limit of entities. I must have miscounted when I tested it before. Never mind, easily fixed:
Code:
void weapon_plasmagun::Fire() {
   float currentTime;
   float ammoClip = ammoInClip();
   float number = 1;
   entity owner = getOwner();
   entity weapon_ent = owner.getWeaponEntity();
   entity particle1;
   entity particle2;
   entity particle3;
   entity particle4;
   entity particle5;
   entity particle6;
   entity particle7;
   entity particle8;
   entity particle9;
   string fx = getKey( "smoke" );
   vector org = weapon_ent.getJointPos( weapon_ent.getJointHandle ( "barrel" ) );
   next_attack = sys.getTime() + PLASMAGUN_FIRERATE;
   sys.setSpawnArg( "model", fx );

   if ( ammoClip == PLASMAGUN_LOWAMMO ) {
      startSound( "snd_lowammo", SND_CHANNEL_ITEM, true );
   }
   if ( number == 1 ) {
      particle1 = sys.spawn( "func_emitter" );
      particle1.setOrigin( org );
      particle1.setShaderParm( SHADERPARM_TIMEOFFSET, -sys.getTime() );
      particle2.remove();
      number = 2;
   } else if ( number == 2 ) {
      particle2 = sys.spawn( "func_emitter" );
      particle2.setOrigin( org );
      particle2.setShaderParm( SHADERPARM_TIMEOFFSET, -sys.getTime() );
      particle3.remove();
      number = 3;
   } else if ( number == 3 ) {
      particle3 = sys.spawn( "func_emitter" );
      particle3.setOrigin( org );
      particle3.setShaderParm( SHADERPARM_TIMEOFFSET, -sys.getTime() );
      particle4.remove();
      number = 4;
   } else if ( number == 4 ) {
      particle4 = sys.spawn( "func_emitter" );
      particle4.setOrigin( org );
      particle4.setShaderParm( SHADERPARM_TIMEOFFSET, -sys.getTime() );
      particle5.remove();
      number = 5;
   } else if ( number == 5 ) {
      particle5 = sys.spawn( "func_emitter" );
      particle5.setOrigin( org );
      particle5.setShaderParm( SHADERPARM_TIMEOFFSET, -sys.getTime() );
      particle6.remove();
      number = 6;
   } else if ( number == 6 ) {
      particle6 = sys.spawn( "func_emitter" );
      particle6.setOrigin( org );
      particle6.setShaderParm( SHADERPARM_TIMEOFFSET, -sys.getTime() );
      particle7.remove();
      number = 7;
   } else if ( number == 7 ) {
      particle7 = sys.spawn( "func_emitter" );
      particle7.setOrigin( org );
      particle7.setShaderParm( SHADERPARM_TIMEOFFSET, -sys.getTime() );
      particle8.remove();
      number = 8;
   } else if ( number == 8 ) {
      particle8 = sys.spawn( "func_emitter" );
      particle8.setOrigin( org );
      particle8.setShaderParm( SHADERPARM_TIMEOFFSET, -sys.getTime() );
      particle9.remove();
      number = 9;
   } else if ( number == 9 ) {
      particle9 = sys.spawn( "func_emitter" );
      particle9.setOrigin( org );
      particle9.setShaderParm( SHADERPARM_TIMEOFFSET, -sys.getTime() );
      particle1.remove();
      number = 1;
   }
   launchProjectiles( PLASMAGUN_NUMPROJECTILES, spread, 0, 1.0, 1.0 );
   playAnim( ANIMCHANNEL_ALL, "fire" );

   while( !animDone( ANIMCHANNEL_ALL, PLASMAGUN_FIRE_TO_IDLE ) ) {
      currentTime = sys.getTime();
      ammoClip = ammoInClip();

      if ( ( currentTime >= next_attack ) && WEAPON_ATTACK && ( ammoClip > 0 ) ) {
         weaponState( "Fire", 0 );
      }
      waitFrame();
   }
   weaponState( "Idle", PLASMAGUN_FIRE_TO_IDLE );
}

I assume then, that is was removing the particle because you can only have one active emitter of a certain name :? Hopefully I'll be able to trim this at some point to make it run better, my poor computer can't cope.



Ivan_the_B@Posted: Fri Jan 11, 2008 2:34 pm :
wal wrote:
2-sys.setSpawnArg( "model", fx ); is before they are spawned, not after. particle1.setOrigin( org ); is when one is spawned. entity particle1 = sys.spawn( "func_emitter" ); just tells it what to spawn.

This is not true.
the entity is spawned when entity particle1 = sys.spawn( "func_emitter" ); is executed.
particle1.setOrigin( org ); only set the entity in the new place (probably '0 0 0' is the default one)

The following examples are equivalent (I've used both in the past)

Code:
sys.setSpawnArg( "model", fx );
particle3 = sys.spawn( "func_emitter" );
particle3.setOrigin( org );

Code:
sys.setSpawnArg( "model", fx );
sys.setSpawnArg( "origin", org );
particle3 = sys.spawn( "func_emitter" );


wal wrote:
1-The plasmasmoke.prt lasts for one second and the plasma gun fires 8 times a second, so 8 emitters need to be running at the same time or it will remove the particles after 0.125 seconds. There will never be more than 8 because there's only 1 entity for each. It just updates the origin and restarts the particle.

Even in the last code you posted new entities are spawned every time so it's not true that you are using again the old ones.

wal wrote:
3-They are removed on the Lower thread.

That is impossible because the entities are declared inside the Fire() thread so cannot be visible from outside of it.
Even the last code you posted have some problems:
- every time the Fire() thread is lauched new variables are instantiated so particleX is null and you are not removing the old ones.
- if you change weapon and than you select the plasma again all the script variables are instantiated again and you've lost the reference to the old ones.

So i suggest you to check carefully you script because right now it can reach the maximum entities limit... and the map will be blocked.
I'd declare particleX variables outside the plasmagun scriptobject so they'll be never lost.

wal wrote:
It’s not the amount of entitys that are causing an overflow and it’s not an error that causes it to crash or anything, it just comes up with an overflow warning in the console and it’s messing with the snds because it’s struggling to keep up.

Don't know what are you talking about but I think a cannot help you :?



wal@Posted: Fri Jan 11, 2008 5:08 pm :
Ivan_the_B wrote:
wal wrote:
2-sys.setSpawnArg( "model", fx ); is before they are spawned, not after. particle1.setOrigin( org ); is when one is spawned. entity particle1 = sys.spawn( "func_emitter" ); just tells it what to spawn.

This is not true.
the entity is spawned when entity particle1 = sys.spawn( "func_emitter" ); is executed.
particle1.setOrigin( org ); only set the entity in the new place (probably '0 0 0' is the default one)

Really. :? That’s not how it reads to me. ( I’m not saying I think your wrong, just that it seems quite illogical to me ). In fact after reading my post again it comes off as quite arrogant. Those answers were meant as my current understanding of the code, not definitive statements. To me it says next time particle1 is written, spawn an emitter with the designation of particle1. As for the placement of the spawn arg line, the first code I posted does work in that it accurately recreates the automatic muzzle smoke, so it must at least respawn the emitter when it gets to the .setOrigin line, right :?:

Ivan_the_B wrote:
wal wrote:
1-The plasmasmoke.prt lasts for one second and the plasma gun fires 8 times a second, so 8 emitters need to be running at the same time or it will remove the particles after 0.125 seconds. There will never be more than 8 because there's only 1 entity for each. It just updates the origin and restarts the particle.

Even in the last code you posted new entities are spawned every time so it's not true that you are using again the old ones.

Yep, in the first one I thought it was reusing them, then I realised it wasn’t so I wrote the second one.

Ivan_the_B wrote:
wal wrote:
3-They are removed on the Lower thread.

That is impossible because the entities are declared inside the Fire() thread so cannot be visible from outside of it.
Even the last code you posted have some problems:
- every time the Fire() thread is lauched new variables are instantiated so particleX is null and you are not removing the old ones.
- if you change weapon and than you select the plasma again all the script variables are instantiated again and you've lost the reference to the old ones.
So i suggest you to check carefully you script because right now it can reach the maximum entities limit... and the map will be blocked.
I'd declare particleX variables outside the plasmagun scriptobject so they'll be never lost.

Yea, it’s done a bit differently in my script, I condensed it into one thread so as to not take up loads of space on the board until it’s final. I have the entity particle1; ect lines in the object weapon_plasmagun : weapon_base { section. Will they still not get removed :?:

Ivan_the_B wrote:
wal wrote:
It’s not the amount of entitys that are causing an overflow and it’s not an error that causes it to crash or anything, it just comes up with an overflow warning in the console and it’s messing with the snds because it’s struggling to keep up.

Don't know what are you talking about but I think a cannot help you :?

It’s just causing it to miss the snd_fire most of the time as far as I can tell. Very annoying. It says
Code:
IDRENDERWORLDLOCAL::RESIZEINTERACTIONTABLE: OVERFLOWED INTERACTIONTABLEWIDTH, DUMPING



Ivan_the_B@Posted: Fri Jan 11, 2008 6:17 pm :
The particles are probably spawned in '0 0 0' and then moved to the location specified with setOrigin( org );

from doom_events
Code:
// Sets the current position of this entity (relative to it's bind parent if any).
scriptEvent   void    setOrigin( vector origin );

// Creates an entity of the specified classname and returns a reference to the entity.
scriptEvent   entity   spawn( string classname );

// Sets a key/value pair to be used when a new entity is spawned.
scriptEvent   void    setSpawnArg( string key, string value );


setOrigin simply update the position. you can even use it on the player and he'll be "teleported".
Quote:
I have the entity particle1; ect lines in the object weapon_plasmagun : weapon_base { section. Will they still not get removed :?:

If you remove them on weapon lowering they should be ok.

Oh well... i'll write what i'd do. But I fear I'll finish your mod before the mine :mrgreen::mrgreen:
Just joking lol :D

Code:
entity particle1; //global variable
entity particle2; //global variable

object weapon_plasmagun : weapon_base {

//...


void weapon_plasmagun::spawn_emitters_if_needed() {
   if(!particle1){
     sys.setSpawnArg( "model", fx );
     sys.setSpawnArg( "origin", '0 0 0' ); //somewhere far from the map
     particle1 = sys.spawn( "func_emitter" );
   }
   if(!particle2){
     sys.setSpawnArg( "model", fx );
     sys.setSpawnArg( "origin", '0 0 0' ); //somewhere far from the map
     particle2 = sys.spawn( "func_emitter" );
   }
}

void weapon_plasmagun::init() { //executed every time the plasma is selected
  //...
  spawn_emitters_if_needed();
}


void weapon_plasmagun::Fire() {
   //...
   if ( number == 1 ) {
      particle1.setOrigin( org );
      particle1.setShaderParm( SHADERPARM_TIMEOFFSET, -sys.getTime() );
   } else if ( number == 2 ) {
      particle2.setOrigin( org );
      particle2.setShaderParm( SHADERPARM_TIMEOFFSET, -sys.getTime() );
   }
}

}//end object


So...
- spawn the emitters only the first time the plasma is selected
- store their reference in global variables (never lose their values )
- never remove them... simply reuse.
- simple and working without side effects :mrgreen:

Do the same for all the 8 emitters.

Quote:
IDRENDERWORLDLOCAL::RESIZEINTERACTIONTABLE: OVERFLOWED INTERACTIONTABLEWIDTH, DUMPING

You are lucky! I know something about it.
I had this problem in my mod time ago... so I searched everywhere (intenet and souce code) but nothing useful found. Then i did a lot of tests to understand the problem... and the result is that there is sort of table allocated (for interactions) when a map is loaded.
The lenght of this table is about the number of entities that have collisions + about 100.
The "100" is an extra probably used for entities dinamically spawned during the game like gibs and the ones spawned by scripts.
If you exceed the limits of this table that warning will be shown and the game will go much slower. Expecially in big areas with lots of objects.
If you reload the map this time the table will be larger (don't know why) so it was initially hard to reproduce the error. :mrgreen:

Conclusions:
- it may happen because you script is spawing too many entities ( like i said before )
- yes, emitters seems having something to do with collisions.
- other than always make sure your scripts are removing what you don't need anymore, you could "trick" the game: create an empty box in the space and fill it with about 100 exploding_barrels. At the beginning of the map remove them all --> now you have some more free space in that damn table.

I know you are thinking "I'll put there 500 barrels instead of 100 so I'll have more space". The bad news is that it seems like it doesn't work in this way and after that about 100 entities removed you always gain the same amount of space in the table.

This idea saved me :-]



wal@Posted: Fri Jan 11, 2008 8:49 pm :
Ivan_the_B wrote:
The particles are probably spawned in '0 0 0' and then moved to the location specified with setOrigin( org );

But on the first code I posted, sys.setSpawnArg( "model", fx ); is after the sys.spawn lines like you said. So if they’re spawning on the entity particle1 = sys.spawn( "func_emitter" ); lines why do they have the right particle model assigned :?:

Ivan_the_B wrote:
setOrigin simply update the position. you can even use it on the player and he'll be "teleported".

:D I know, that part of the mod is already done :D

Ivan_the_B wrote:
Oh well... i'll write what i'd do.

Cheers for the code and help, as always. 8)

Ivan_the_B wrote:
- it may happen because you script is spawing too many entities ( like i said before )

Are you saying that even if removed, the entities are staying on that table and causing the overflow :?:

Ivan_the_B wrote:
- yes, emitters seems having something to do with collisions.

Particles interacting with each other maybe :?:



Ivan_the_B@Posted: Fri Jan 11, 2008 9:17 pm :
Quote:
But on the first code I posted, sys.setSpawnArg( "model", fx ); is after the sys.spawn lines like you said. So if they’re spawning on the entity particle1 = sys.spawn( "func_emitter" ); lines why do they have the right particle model assigned

I think that the first ones have no model so you shouldn't see them... and that sys.setSpawnArg( "model", fx ); is used from the sequent call to sys.spawn( "func_emitter" ); and so on...
Not sure, but it makes sense.
I'd like to do some more tests on this...

Quote:
Are you saying that even if removed, the entities are staying on that table and causing the overflow