wizardmirth Posted January 30, 2008 Share Posted January 30, 2008 What's the best way to temporarily add a spell effect to an item that has just suddenly been enabled (in my case via OnDeath script). I figure my options are PlayMagicEffect (pme) and PlayMagicShaderVisuals (pms) and then there's AddSpell but I'm not sure if that works on objects or not (haven't tried it yet). So far the best I have been able to do is to get the animation to run EVERY FRAME but that's not what I want. I want something like myobjectref.enable myobjectref.pme effectShockDamage 30to play on enable for a set duration without starting every frame, for maybe 30 seconds. Link to comment Share on other sites More sharing options...
Jumonji Posted January 30, 2008 Share Posted January 30, 2008 I don't know what script you're running this in, but you have a couple of options. You can use a timer or a flag to control this if it's running in a long-term script like a quest. E.g., float fSpellTimershort bSpellUsedref myObject begin ;Use a flag to trigger the spell on enable, assuming it lasts 30 seconds. if bSpellUsed == 0 if myObject.GetEnabled myObject.pme effectShockDamage 30 set bSpellUsed to 1 endifendif ; use a timer to continue running the effect if it must be reset each frame if bSpellUsed == 0 if myObject.GetEnabled set fSpellTimer to 30 set bSpellUsed to 1 endifendif if fSpellTimer > 0 set fSpellTimer to fSpellTimer - GetSecondsPassed myObject.pme effectShockDamageendif -Jumonji Link to comment Share on other sites More sharing options...
Vagrant0 Posted January 30, 2008 Share Posted January 30, 2008 What's the best way to temporarily add a spell effect to an item that has just suddenly been enabled (in my case via OnDeath script). I figure my options are PlayMagicEffect (pme) and PlayMagicShaderVisuals (pms) and then there's AddSpell but I'm not sure if that works on objects or not (haven't tried it yet). So far the best I have been able to do is to get the animation to run EVERY FRAME but that's not what I want. I want something like myobjectref.enable myobjectref.pme effectShockDamage 30to play on enable for a set duration without starting every frame, for maybe 30 seconds. Seems like all you need to do is add a condition so that that portion of the script only runs once when whatever enables the reference gets triggered. short effinit if effinit != 1 myobjectref.enable myobjectref.pme effectShockDamage 30 set effinit to 1 endif Or whatever you're using to cause the enabling of the object. As far as I know "myobjectref.pme effectShockDamage 30" will work once you change the effect to the right thing, and wll only play it 30 seconds. Using a series of timers probably isn't needed in this case. Link to comment Share on other sites More sharing options...
wizardmirth Posted January 31, 2008 Author Share Posted January 31, 2008 Thanks for the replies! This has certainly helped though I had to make adjustments to get what I wanted. This would seem to be because pms (or pme) and enable in the same script don't work--object is enabled but effect does not run. I already tried putting the pms part into my Quest Script but hadn't been able to run it only once until now. This is because the pms must be controled by condition to only run once. scn MyEnemyScript Begin OnDeath MyObjectRef.enable End scn MyQuestScript short effect Begin GameMode if MyObjectRef.GetDisabled == 0 && effect == 0 MyObjectRef.pms effectShockDamage 30 set effect to 1 endif End Link to comment Share on other sites More sharing options...
Vagrant0 Posted January 31, 2008 Share Posted January 31, 2008 Thanks for the replies! This has certainly helped though I had to make adjustments to get what I wanted. This would seem to be because pms (or pme) and enable in the same script don't work--object is enabled but effect does not run. I already tried putting the pms part into my Quest Script but hadn't been able to run it only once until now. This is because the pms must be controled by condition to only run once. scn MyEnemyScript Begin OnDeath MyObjectRef.enable End scn MyQuestScript short effect Begin GameMode if MyObjectRef.GetDisabled == 0 && effect == 0 MyObjectRef.pms effectShockDamage 30 set effect to 1 endif End It should all work within a single Ondeath block. Are you sure you're doing it right? short effinit Begin Ondeath if effinit != 1 myobjectref.enable MyObjectRef.pms effectShockDamage 30 set effinit to 1 endif end Part of your problem before might have been because you were using PME with effectshockdamage instead of either PMS effectshockdamage or PME SHDG. If you have a problem stopping it, you could always add a myobjectref.SME or SMS in another script somewhere to stop the shader once something has happened (like opening the chest). Link to comment Share on other sites More sharing options...
wizardmirth Posted February 1, 2008 Author Share Posted February 1, 2008 What's the difference between [if effinit != 1] and [if effinit == 0] so long as [effinit] is not preset to aything (default is always 0)? I think I tested it at [== 0] because it seemed to me the same thing and it didn't work. I also said it wrong here with the effect code specific to whether you use pms or pme but in the actual script I made sure it was right. Maybe I try again when I get a chance but progress has (finally) been too good. Also not sure if the pme + correct id effect worked at all for me? I think only the pms worked the way I had it set up. Link to comment Share on other sites More sharing options...
Jumonji Posted February 1, 2008 Share Posted February 1, 2008 What's the difference between [if effinit != 1] and [if effinit == 0] so long as [effinit] is not preset to aything (default is always 0)? I think I tested it at [== 0] because it seemed to me the same thing and it didn't work. I also said it wrong here with the effect code specific to whether you use pms or pme but in the actual script I made sure it was right. Maybe I try again when I get a chance but progress has (finally) been too good. Also not sure if the pme + correct id effect worked at all for me? I think only the pms worked the way I had it set up. Script variables default to 0 until you set them, so x != 1 and x == 0 should work the same in your case. Link to comment Share on other sites More sharing options...
Vagrant0 Posted February 1, 2008 Share Posted February 1, 2008 What's the difference between [if effinit != 1] and [if effinit == 0] so long as [effinit] is not preset to aything (default is always 0)? I think I tested it at [== 0] because it seemed to me the same thing and it didn't work. I also said it wrong here with the effect code specific to whether you use pms or pme but in the actual script I made sure it was right. Maybe I try again when I get a chance but progress has (finally) been too good. Also not sure if the pme + correct id effect worked at all for me? I think only the pms worked the way I had it set up. Script variables default to 0 until you set them, so x != 1 and x == 0 should work the same in your case.I prefer to use "!= 1" with most of my true/false logic conditions, it just leaves it as a nice catch all incase something were to interfere with whatever I'm testing for. It really has more use when testing things outside of script variables though, although when paired with a "set xxxxx to 1" forces the variable from whatever it was to whatever you have it at. You just need to make sure that you're planning to use that variable for something else, that you only use the "!= 1" within a section of the script which will only get used durring a very specific period of time where you want this to happen. It's complicated, and probably just my personal preference. Link to comment Share on other sites More sharing options...
wizardmirth Posted February 3, 2008 Author Share Posted February 3, 2008 No I get it. Anyway the first part is up. I have plans to add more story and another quest but this can stand alone as is. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.