Author Topic: Tutorial: FX System  (Read 3963 times)

0 Members and 1 Guest are viewing this topic.

Bladeghost

  • Jr. Member
  • **
  • Posts: 67
  • Karma: +13/-1
  • idTech4 Mod Artist
    • View Profile
Re: Tutorial: FX System
« Reply #15 on: June 01, 2015, 03:46:10 PM »
I know when I bind to entities, I'll bind to the entity and for a specific bind you'll need to use bindToJoint, as with the right hand that would use that parameter for that specific bone or place binded to.

so from what I see in your script you  can't really use bind (Rhand) alone

so example: use these , the parenthesis are only for example but follow script protocol and try being more specific in your call functions.

bind (entityname)
bindToJoint (RHand)

see if that makes a difference

also this may help?
http://www.3dbuzz.com/training/view/doom-3-modding/series-1/binding-entities
« Last Edit: June 01, 2015, 03:52:50 PM by Bladeghost »

VGames

  • PD3 Beta Testers
  • Hero Member
  • *
  • Posts: 754
  • Karma: +17/-69
    • View Profile
Re: Tutorial: FX System
« Reply #16 on: June 01, 2015, 06:42:13 PM »
This is not working for me at all. Could somebody please make an FX that has lighting, creates a particle effect, makes a sound, and never stops that is also attached to a monsters left and right hands? I would sure appreciate it. It also needs to be created when the monster is initialized via its script file. I'm starting to think this is not possible unless done through the map editor.
Get the latest on Perfected Doom 3 here - http://www.moddb.com/mods/perfected-doom-3-version-500

VGames

  • PD3 Beta Testers
  • Hero Member
  • *
  • Posts: 754
  • Karma: +17/-69
    • View Profile
Re: Tutorial: FX System
« Reply #17 on: June 04, 2015, 12:31:03 PM »
Has anybody tried making a complex FX do what I'm trying to do with it? I'm getting poor results still. Particle effect shows up but is not attached to the joint properly and it doesn't stay forever. And the light stays in place where the demon is spawned. It does not follow him and it stays forever.
Get the latest on Perfected Doom 3 here - http://www.moddb.com/mods/perfected-doom-3-version-500

BielBdeLuna

  • Full Member
  • ***
  • Posts: 242
  • Karma: +8/-20
  • Doom Newbie
    • View Profile
    • my Github repositories
Re: Tutorial: FX System
« Reply #18 on: June 04, 2015, 06:59:36 PM »
one thing is the particle system, another the smoke system, the smoke system isn't as static as the particle system, you need to use a func_smoke entity and link it with your particle effect, you can bind to join the func_smoke, and trigger it whenever you need the smoke

we did this for additional smoke effects for weapons back in d3w times

you can do the same with an fx file, I did use an fx file for a canon that was controlled by the player visual orientation, when the cannon fired, a oarticle happened a flash of light happened and a rocked was launched

IIRC i think there is a func_fx that when triggered starts the FX you have selected.

VGames

  • PD3 Beta Testers
  • Hero Member
  • *
  • Posts: 754
  • Karma: +17/-69
    • View Profile
Re: Tutorial: FX System
« Reply #19 on: June 04, 2015, 08:10:55 PM »
I've got all that. I've done similar things myself. The problem is I cant make an FX spawn and bind itself to a monster like its being said it can be done here. It's not working at all like it should. I know how to add the particle effect to the monsters hands via the def file but you cant add lighting effects along with the particle effect if you do it via the def file. I wanted to use an FX to make the particle effect and the lighting flow form his hands. Try it yourself the way I've shown how I've got it set up. See if you can do it.
Get the latest on Perfected Doom 3 here - http://www.moddb.com/mods/perfected-doom-3-version-500

BielBdeLuna

  • Full Member
  • ***
  • Posts: 242
  • Karma: +8/-20
  • Doom Newbie
    • View Profile
    • my Github repositories
Re: Tutorial: FX System
« Reply #20 on: June 04, 2015, 10:45:39 PM »
because def isn't meant to be used in scripting, def is read depending on what the c++ ask the engine to read in def, all within def is text that gets interpreted, but the way it gets interpreted depends on what the c++ game code asks the engine to read in the def, the rest of text irrelevant to the c++ game code is left behind, that's the reason the def spawnargs are so uneven when it comes to spawnargs, in some defs a spawnargs can do something, and in another def the same spawnarg can do another thing differently than the first

what you want to do needs to be achieved via scripting, you have to spawn it all with it's due spawnargs (spawn the fx spawner entity with it's spawnarg pointing to the fx file) and bind it to the correct bone, and call it via scripting when the time is due.


so imagine if you want the weapon to have some kind of special smoke that only fires when you reload, when the scriptobject of the weapon is created, you then, from within the script, spawn the fx spawner entity with all prepared, so you can trigger it in the reload animation. so it's there all the time.

motorsep

  • Hero Member
  • *****
  • Posts: 967
  • Karma: +74/-128
  • Artist
    • View Profile
    • Kot in Action Creative Artel
Re: Tutorial: FX System
« Reply #21 on: June 04, 2015, 11:42:55 PM »
@VGames: Have you tried binding you FX to an entity  (target_null for example or some func_static) and that entity to a bone on your character ? (instead of trying to bind FX directly)

solarsplace

  • Jr. Member
  • **
  • Posts: 63
  • Karma: +8/-0
  • Mainly a programmer...
    • View Profile
Re: Tutorial: FX System
« Reply #22 on: June 05, 2015, 06:25:09 AM »
Hi

I here is some code that is working in Arx End Of Sun. It is in the AI script for a Goblin that carries a flaming torch with torch flame particles and a light entity. I decided to do this the old fashioned way with individual script statements rather than a helper function such as startfx so I have greater control to switch the particle off and on when I need to. This will do what you want and it does work.

FYI startfx does work the way you want it to. I know this because I am using it this way elsewhere in my code. It has supporting code in the SDK to automatically bind to joints specified in the .fx file. However, when it does not work, it is hard to debug because there are no discrete steps that you can easily trace through. This is why I am showing you the method below.

What you must always do with things like this, is to break them down into small discrete solvable and provable steps otherwise you have several systems at work and potentially each has a problem and you keep changing things in thing all over the place in the hope of stumbling upon the fix.

#1 find a stock Doom3 particle that runs for a long time. Check this in your map in a func_emitter to prove that it does work and run for a good length of time. Do not proceed until you have proven your test particle works.

#2 Put a light with your light shader you want to use into a map and make sure the light works.  Do not proceed until you have proven your test particle works.

#3 Please open the xyz.md5mesh file for your Barron monster, make absolutely sure you have the joint name 100% correct "rhand" and put it into the "lampBone" variable in the script below. If you got the wrong joint name then it will absolutely not track the AI position.

#4 Put your light shader in the script below in the place of "lights/arx_flame_torch4"

#5 Put the script below into the init() section of your AI before any other commands - just for now. Move it later if you want / need to.

#6 Don't be scared to put in loads of sys.print statements in the scripts to help test your AI

Good luck

Code: [Select]
entity torchFlames;
entity torchLight;

string lampBone = "torch_tip";
vector lightOrigin;

// Flames
sys.setSpawnArg( "model", "arx_fire_torch.prt" );
torchFlames = sys.spawn( "func_emitter" );
torchFlames.setOrigin( self.getJointPos( self.getJointHandle( lampBone ) ) );
torchFlames.bindToJoint( self, lampBone, 0 );

// Light
sys.setSpawnArg( "_color", "1 0.84 0.44" );
sys.setSpawnArg( "falloff", "0" );
sys.setSpawnArg( "light_radius", "146 146 224" );
sys.setSpawnArg( "nodiffuse", "0" );
sys.setSpawnArg( "noshadows", "0" );
sys.setSpawnArg( "nospecular", "0" );
sys.setSpawnArg( "texture", "lights/arx_flame_torch4" );
torchLight = sys.spawn( "light" );
lightOrigin = self.getJointPos( self.getJointHandle( lampBone ) );
lightOrigin_z = lightOrigin_z + 6; // Solarsplace - Need to get the light outside the torch mesh.
torchLight.setOrigin( lightOrigin );
torchLight.bindToJoint( self, lampBone, 0 );

VGames

  • PD3 Beta Testers
  • Hero Member
  • *
  • Posts: 754
  • Karma: +17/-69
    • View Profile
Re: Tutorial: FX System
« Reply #23 on: June 05, 2015, 10:29:03 AM »
I think this is what I'm looking for. I know fx and lighting can't be added to monster body parts in the def files. I was just saying that I couldn't do what I wanted to in the defs for lighting like I did with the particle effects. I needed this done via scripts using FX but I was starting to think lighting could only be bound to monsters using the map editor. U proved me right. I'll try this scripting out as soon as I get home. I think u just saved the day. Thanks.
Get the latest on Perfected Doom 3 here - http://www.moddb.com/mods/perfected-doom-3-version-500

motorsep

  • Hero Member
  • *****
  • Posts: 967
  • Karma: +74/-128
  • Artist
    • View Profile
    • Kot in Action Creative Artel
Re: Tutorial: FX System
« Reply #24 on: June 05, 2015, 10:52:20 AM »
Why couldn't you bind particle emitter and light to the hand right in the Radiant ?

solarsplace

  • Jr. Member
  • **
  • Posts: 63
  • Karma: +8/-0
  • Mainly a programmer...
    • View Profile
Re: Tutorial: FX System
« Reply #25 on: June 05, 2015, 11:09:49 AM »
Why couldn't you bind particle emitter and light to the hand right in the Radiant ?

Hi

You can bind an entity to another entity relative to the parents origin in the map editor, but that will not help VG have a particle effect glued to his monsters hand thoughout the monsters animations.

I am pretty certain thats what VG is after?

Cheers

VGames

  • PD3 Beta Testers
  • Hero Member
  • *
  • Posts: 754
  • Karma: +17/-69
    • View Profile
Re: Tutorial: FX System
« Reply #26 on: June 05, 2015, 11:39:09 AM »
Yeah u see I'm not doing this by mapping. I'm doing this via scripts only. In the def file I was able to add a particle effect that stayed in his hands and lasted forever but there's no way to also add a permanent lighting effect to his hands too via the def or the script file using FX. But the way u just showed me up above in the script file without using an FX seems to be the way to go. But I have to ask does the torch light and particle effects disappear once the goblin that is holding the torch gets killed or is there another command that has to be called when he's killed to remove the bound lighting and particle effects?
Get the latest on Perfected Doom 3 here - http://www.moddb.com/mods/perfected-doom-3-version-500

motorsep

  • Hero Member
  • *****
  • Posts: 967
  • Karma: +74/-128
  • Artist
    • View Profile
    • Kot in Action Creative Artel
Re: Tutorial: FX System
« Reply #27 on: June 05, 2015, 12:20:54 PM »
3dbuzz has a tutorial where light and fire extinguisher are bount to a monster and to his hand bone, without any scripting. I am sure a func_emitter can we bound the same way to the monster's hand.

In script, you would hide whatever you need on spawn, and the show when you need to show the effects. I haven't tried doing exactly that, but I did try binding particles/light to bones in my game and hide/show them via script. It worked fine.

BloodRayne

  • Old Forum Goer
  • Full Member
  • ***
  • Posts: 136
  • Karma: +13/-0
  • Doom Newbie
    • View Profile
    • Grimm Quest for the Gatherer's Key
Re: Tutorial: FX System
« Reply #28 on: June 05, 2015, 06:58:26 PM »
Grimm basically uses FX for everything. For instance, all debris desolves instead of simply dissapearing, the FX spawns smaller debris models, that in turn desolve and fade into a whisp of smoke, including sound and light effects. I've made these effects configurable, so you can go nuts on good rigs, and dial it down on lower specced rigs. I really urge you to check it out. ;)

All entities have the StartFx() command. So you can run that on anything, but the FX will be run from the Origin position. Unless you count monsters, on which you can define smokebones, which are basically FX again, bound to bones by the engine.

If you want to have an effect on a specific bone of a custom animated model, then you need to spawn it (the func_fx, NOT the func_emitter) real time, and bind it to a bone, then trigger it to start, unless (again) it's an AI.

Make sure to set the spawnargs correctly, so that it loops if you want, or if it starts on spawn or when triggered, etc..etc...
« Last Edit: June 05, 2015, 07:01:05 PM by BloodRayne »

VGames

  • PD3 Beta Testers
  • Hero Member
  • *
  • Posts: 754
  • Karma: +17/-69
    • View Profile
Re: Tutorial: FX System
« Reply #29 on: June 05, 2015, 07:37:47 PM »
I used solarsplace's method and the lighting now works. For the particle effect that is attached to his hands I added them via the def file. But the for the lighting I used the above method. My only issue is how do I remove the lighting once the monster is killed? I noticed the bound lighting stays on until the monster burnsaway. For lostsouls I also added lighting to them too using solarplace's method but when they get killed they vanish leaving behind their bound light effect that stays where they were killed until their burnaway moment comes which is when those spooky sound effects stop. So how do I remove these bound lights from killed monsters. Is it done in the ai_monster_base script file or do I need an if statement that allows these bound lights as long as their health is above 0? 
Get the latest on Perfected Doom 3 here - http://www.moddb.com/mods/perfected-doom-3-version-500