Page 1 of 2
effects on demand
Posted: August 11th, 2010, 2:10 pm
by <LT>YosemiteSam[NL]
How can I play an effect on demand (when triggered I mean, not loop in one place) ?
I tried something with oneshot effect but can't make it work.

Re: effects on demand
Posted: August 11th, 2010, 4:28 pm
by waywaaaard
precache the effect:
rest
playfx ( <effect id >, <position of effect>, <forward vector>, <up vector> )
Module
Effects
Summary
Play this effect.
Example
fx = playfx (enginesmoke, engine.origin);
Minimum Number of arguments: 2
1 : <effect id> The effect id returned by loadfx
2 : <position of effect> The world position of the effect
Number of optional arguments: 2
1 : <forward vector> The forward vector of the effect
2 : <up vector> The up vector of the effect
Re: effects on demand
Posted: August 11th, 2010, 4:39 pm
by <LT>YosemiteSam[NL]
Ok so I have a trigger which triggers the efect...so it would be like this;
Code: Select all
trigger waittill ("trigger");
playfx ( "teleport_light", (400,300,200))
I want it to be a oneshotfx....just make it playoneshotfx ( "teleport_light", (400,300,200),60); ?
If this is right?...didn't know it was this simple

Re: effects on demand
Posted: August 11th, 2010, 5:02 pm
by Rezil
The way I do effects:
Code: Select all
ship_smoke()
{
o1 = getent("cruise_exhaust_1","targetname");
fx = loadfx("fx/rezil/cruise_exhaust_black_smoke.efx");
while(1)
{
playfx(fx, o1.origin);
wait 0.5;
}
}
This is for a looping effect. For a single one just don't loop it(so no while(1)).
Re: effects on demand
Posted: August 11th, 2010, 7:08 pm
by <LT>YosemiteSam[NL]
Thx guys, I went with this one;
Code: Select all
main()
{
level thread precacheFX();
thread ppsh_spawn();
}
precacheFX()
{
level._effect["teleport_light"] = loadfx ("fx/fire/teleport_light.efx");
}
ppsh_spawn()
{
trigger = getent("weapon_pickup_ppsh_mp","targetname");
{
trigger waittill ("trigger");
maps\mp\_fx::loopfx("teleport_light", (-664,1432,248), 10);
}
}
Have to tweak it a bit more before it is to my liking.
Re: effects on demand
Posted: August 11th, 2010, 7:24 pm
by Rezil
Same thing, you only make it a level array and load it seperately. The loopfx function is basically a loop with a wait command.

Re: effects on demand
Posted: August 12th, 2010, 11:56 pm
by <LT>YosemiteSam[NL]
Now I want to remove the effect (play effect...pick up weapon....remove effect), checked mods online and made this script now but it doesn't work;
Code: Select all
main()
{
thread ppsh_spawn();
}
ppsh_spawn()
{
trigger = getent("weapon_pickup_ppsh_mp","targetname");
fx = loadfx("fx/fire/spawn_light.efx");
while (1)
{
playfx(fx, (-664,1432,248));
trigger waittill("trigger");
thread effect_delete();
wait 0.05;
}
}
effect_delete()
{
self.playfx = true;
while(self.playFX)
{
efx = PlayFX( level._effect["fx"], ( -664, 1432, 248 ));
wait 0.05;
}
efx Delete();
}
Any ideas ?
Re: effects on demand
Posted: August 13th, 2010, 4:45 pm
by <LT>YosemiteSam[NL]
Is the delete(); command even possible (been trying for over 2 hours now

).
It's the last thing I need for my deck16 map. Can I post the final version in the "post your complete maps here" forum, or is that just for jumpmaps ?
Re: effects on demand
Posted: August 13th, 2010, 7:04 pm
by Drofder2004
Code: Select all
loopfxDeletion (ent)
{
self endon ("death");
ent waittill ("effect deleted");
self delete();
}
This is the code used in CoD4, but I cannot find it referenced by any other code...
If it doesn't work, it should produce an error, run the map with /developer 1
Re: effects on demand
Posted: August 13th, 2010, 7:21 pm
by <LT>YosemiteSam[NL]
this is the code now;
Code: Select all
main()
{
thread ppsh_spawn();
}
ppsh_spawn()
{
trigger = getent("weapon_pickup_ppsh_mp","targetname");
fx = loadfx("fx/fire/spawn_light.efx");
while (1)
{
playfx(fx, (-664,1432,248));
trigger waittill("trigger");
thread loopfxDeletion (ent);
wait 0.05;
}
}
loopfxDeletion (ent)
{
self endon ("death");
ent waittill ("effect deleted");
self delete();
}
Running it with the compiler (or just start a devmap) I get this error;
Code: Select all
uninitialised variable 'ent': (file 'maps/mp/call_spawn_effect.gsc', line 16)
thread loopfxDeletion (ent);
I also added the following line, but that doesn't work;
Code: Select all
ent = playfx(fx, (-664,1432,248));
Re: effects on demand
Posted: August 13th, 2010, 9:07 pm
by Drofder2004
You havent defined what "ent" is...
---
I am confused as to what exactly you are needing to delete?
You are playing FX, to remove the FX, just stop the loop.
If you are using an entity to play the FX on, then you can delete the entity... but in this case, there is no entity involved...
Re: effects on demand
Posted: August 13th, 2010, 9:29 pm
by <LT>YosemiteSam[NL]
You are playing FX, to remove the FX, just stop the loop.
This is what I want....when triggered the loop should stop and start again after 60 seconds. But I don't know how to stop the loop to remove the FX.
Re: effects on demand
Posted: August 14th, 2010, 7:14 pm
by <LT>YosemiteSam[NL]
I have this code now but it doesn't recognize the "stopfx" command (cause it is not correct

) ;
Code: Select all
main()
{
thread ppsh_spawn();
}
ppsh_spawn()
{
trigger = getent("weapon_pickup_ppsh_mp","targetname");
fx = loadfx("fx/fire/spawn_light.efx");
while (1)
{
playfx(fx, (-664,1432,248));
trigger waittill("trigger");
stopfx(fx, (-664,1432,248));
wait 60;
}
}
How do I stop it ?
Re: effects on demand
Posted: August 15th, 2010, 4:02 pm
by <LT>YosemiteSam[NL]
Ok, still working on it but to no avail...this code I'm working with now but how do I get the entity to reappear ?;
Code: Select all
main()
{
thread ppsh_spawn(getent("ppsh_fxorigin","targetname"));
thread deletefx(getent("weapon_pickup_ppsh_mp","targetname"),
getent("ppsh_fxorigin","targetname"));
}
ppsh_spawn(o1)
{
//o1 = spawn("script_origin",(-664,1432,248));
//trigger = getent("weapon_pickup_ppsh_mp","targetname");
fx = loadfx("fx/fire/spawn_light.efx");
while(1)
{
playfx(fx,o1.origin);
wait 0.5;
}
}
deletefx(trigger,o1)
{
trigger waittill("trigger");
o1 delete();
}
Re: effects on demand
Posted: August 15th, 2010, 4:23 pm
by Rezil
What exactly do you want? The effect to stop when you trigger it and then to restart after a certain period of time?