Modme Forums

trigger to activate fx? (fire, water, smoke)

Game Modding | Call of Duty: Black Ops 3 | Scripting


ModmeBot:

Thread By: KillJoyYT
is it possible to create a trigger use or damage that will activate fx?

for example you buy or shoot an object and smoke or fire appears.

any help is appreciated thank you


ModmeBot:

Reply By: modric

function fxtrigger()
{


trigger = ("fx_trigger", "targetname");



while ( 1 )
	{
		trigger waittill( "trigger", player );
	
	}
	playFX( level._effect["powerup_grabbed"], self.origin );

}


ModmeBot:

Reply By: Harry Bo21

modric
function fxtrigger() { trigger = ("fx_trigger", "targetname"); while ( 1 ) { trigger waittill( "trigger", player ); } playFX( level._effect["powerup_grabbed"], self.origin ); }

that will do exactly nothing because the waittill is in a loop - the fx is outside the loop... check your code, how many times now...


ModmeBot:

Reply By: modric
i thought adding a break will make it only able to play once? also yea i meant to have the fx in the brackets


ModmeBot:

Reply By: KillJoyYT
ok do I have to change the powerup_grabbed

also theres no targetname for fx do I just add a kvp?


ModmeBot:

Reply By: mathfag

Zone

fx,fx/path.efx



Top of script
#precache( "fx", "fx/path");



Bottom of script
function fxtrigger()
{
trig = GetEnt("fx_trigger","targetname");
trig waittill( "damage");
PlayFX( "entire/fx/path/you/precached/above", trig.origin );
trig Delete();
}

OR if you want to reuse the trig
function fxtrigger()
{
trig = GetEnt("fx_trigger","targetname");
while(1)
	{
	trig waittill( "damage" );
	PlayFX( "entire/fx/path/you/precached/above", trig.origin );
	}
}


NOTE:
If the effect you spawn is a looping effect it will play forever


ModmeBot:

Reply By: Harry Bo21
trigger.origin will be in the middle of the air...

a triggers origin is the centre of the brush

and i realised that - but he didnt say he wanted it to work more than once, and regardless was broken

so my point stands, check your code or stop answering, every single time you do i spot major problems, you are CONFUSING these noobies


ModmeBot:

Reply By: mathfag

Harry Bo21
trigger.origin will be in the middle of the air... a triggers origin is the centre of the brush and i realised that - but he didnt say he wanted it to work more than once, and regardless was broken so my point stands, check your code or stop answering, every single time you do i spot major problems, you are CONFUSING these noobies

If you have a small ass trigger damage around a teddy or something does it really matter if it's on the trigs origin?


ModmeBot:

Reply By: Harry Bo21
firstly how do you know thats what he wants?

secondly why have a trigger around it, when you can just "enable damage" on the model itself so its actually "accurate" and not some random box "around" the actual mesh of a model? if anything its simpler too

thirdly the use of the code is irrelevent, you are posting broken code after broken code - CHECK it works, you are making life HARDER for people already seeking help

Its not rocket science


ModmeBot:

Reply By: Abnormal202

Harry Bo21
firstly how do you know thats what he wants? secondly why have a trigger around it, when you can just "enable damage" on the model itself so its actually "accurate" and not some random box "around" the actual mesh of a model? if anything its simpler too thirdly the use of the code is irrelevent, you are posting broken code after broken code - CHECK it works, you are making life HARDER for people already seeking help Its not rocket science

we all love our triggers very much,
but sometimes they can be a crutch.

Try the "enable damage" way,
you learn something new everyday.

thank you very much



p.s. Rocket science is easy


ModmeBot:

Reply By: mathfag

Harry Bo21
firstly how do you know thats what he wants? secondly why have a trigger around it, when you can just "enable damage" on the model itself so its actually "accurate" and not some random box "around" the actual mesh of a model? if anything its simpler too thirdly the use of the code is irrelevent, you are posting broken code after broken code - CHECK it works, you are making life HARDER for people already seeking help Its not rocket science

1: Yes I do. He said trigger damage.
2: He said trigger.
3: You're right.
4: Stop saying everything is wrong and actually post a solution.
5: Delete the gun pack link in your signature because it doesn't lead anywhere.


ModmeBot:

Reply By: Harry Bo21
arguing semantics now

check your code works in future

simple


ModmeBot:

Reply By: KillJoyYT
I'm sorry for the confusion guys. I would rather have trig damage.

I put the code in my gsc and
idk

im confused with what kvps I need and what variables I have to change


ModmeBot:

Reply By: mathfag

KillJoyYT
I'm sorry for the confusion guys. I would rather have trig damage. I put the code in my gsc and idk im confused with what kvps I need and what variables I have to change

In function main:
thread damage_trig();


at the bottom:
function damage_trig()
{
trig = GetEnt("d_trig","targetname");
trig waittill( "damage" );
PlayFX( level._effect["powerup_on_solo"], trig.origin );
trig Delete();
}


Radiant:

I tested this and it works 100%


ModmeBot:

Reply By: Harry Bo21
much better


ModmeBot:

Reply By: KillJoyYT
wow you guys are awesome thank you


one more question!

I change "powerup_on_solo" to another fx thats in my fx browser?


so for fire would it be this?


function damage_trig()
{
trig = GetEnt("d_trig","targetname");
trig waittill( "damage" );
PlayFX( level._effect["fire_barrel_factory_zmb"], trig.origin );
trig Delete();
}


ModmeBot:

Reply By: mathfag

KillJoyYT
wow you guys are awesome thank you one more question! I change "powerup_on_solo" to another fx thats in my fx browser? so for fire would it be this? function damage_trig() { trig = GetEnt("d_trig","targetname"); trig waittill( "damage" ); PlayFX( level._effect["fire_barrel_factory_zmb"], trig.origin ); trig Delete(); }

Level._effect effects are effects that are defined somewhere like in _zm.gsc

For radiant effects you need to do the following:
In your case

in the zone file:
fx,fire/fx_fire_barrel_factory_zmb.efx

at the top of the script:
#precache("fx" "fire/fx_fire_barrel_factory_zmb");


and in your script
PlayFX("fire/fx_fire_barrel_factory_zmb", trig.origin );

<hr>
A hint:
instead of
#precache("fx" "fire/fx_fire_barrel_factory_zmb");
it's better do do
#define FIRE_SPAWN_FX "fire/fx_fire_barrel_factory_zmb"
#precache("fx", FIRE_SPAWN_FX);

PlayFX(FIRE_SPAWN_FX, trig.origin);

so if you change the effect you don't need to change the code all the time.


ModmeBot:

Reply By: Harry Bo21

Level._effect effects are effects that are defined somewhere like in _zm.gsc


wrong


the array is "created" in _zm yes, you can "add to" it whereever


ModmeBot:

Reply By: Abnormal202

Harry Bo21
Level._effect effects are effects that are defined somewhere like in _zm.gsc wrong the array is "created" in _zm yes, you can "add to" it whereever

only lameos use level effects


ModmeBot:

Reply By: Harry Bo21

Abnormal202
Harry Bo21 Level._effect effects are effects that are defined somewhere like in _zm.gsc wrong the array is "created" in _zm yes, you can "add to" it whereever only lameos use level effects

they use the array to track how many are precached...

and access them from other scripts without redefining them yet again

you should only precache an fx one time - not in every script you use it