IKC1108 Posted October 28, 2019 Share Posted October 28, 2019 Hey, I'm trying to create a perk that grants bonus damage to the player for a short time after drawing their weapon. Does anyone know the easiest way to do this? I know there's a function (GetAnimAction) that returns a value based on the animation playing (and drawing a weapon returns 0). I hoped then that I could just have the perk add an ability with the effect I want but with a condition using this function. Basically: [Perk] - Add [Ability] [Ability]Effect: damage +25%Time: 5 secCondition: GetAnimAction == 0 I can't seem to get it working though. I've also tried executing something similar through a script with an if statement but it hasn't done any good. Anyway, I'm totally new to all this so I may be missing something totally obvious. Link to comment Share on other sites More sharing options...
Mktavish Posted October 29, 2019 Share Posted October 29, 2019 GetAnimAction is a bit difficult to get stable results from , for something like this I think.So I would use "HasMagicEffect" or "IsSpellTarget" instead , to add the damage when applicable. With the implement of a timer , it seems you want something like a quick draw damage bonus ??? So that they need spend most of the game time with the weapon holstered to receive the bonus , instead of walking everywhere with a gun drawn ... Is that correct ? So my thoughts on how to do that , would be to use a Perk with an "Entry Point" for adding the damage. But there is a condition on the perk owner of "HasMagicEffect" or "IsSpellTarget"Checking to see if the weapon is out and the spell timer did not expire. Not sure which one will work better ... but either way will require you to make both a "Base Effect" and an "Actor Effect" . So first make a base effect , and use the archetype "Script" in case you need to put a timer in it. But otherwise is just an arbitrary condition to be checked during the entry point.On the base effect flag it ... "Recover , Self , No Magnitude " Now make an actor effect that uses this base effect as the effect item. And on the duration set it to the 5 sec you want it to last. ( hopefully this timer will work , but if not can use a timer in an effect script , or quest script ) Inwhich I would use a quest script for starters to control the effect ... but if that is to process intensive could figure something else out. So for a quest script , with the process delay set to .1 or quicker if possible .The default is 5 sec , so don't be fooled that it is 0.0 for what displays when default is checked. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~SCN MyQuickDrawTimer Int iTimeCheck Begin GameMode If PlayerRef.IsWeaponOut == 1 && iTimeCheck == 0 PlayerRef.CIOS MyQuickDrawActEffect Set iTimeCheck to 1 elseif PlayerRef.IsWeaponOut == 0 Set iTimeCheck to 0 endifEnd~~~~~~~~~~~~~~~~~~~~~~~~~~~ And on your Perk / EntryPoint ... Condition field , Perk Owner tab . Use the condition " IsSpellTarget " "MyQuickDrawActEffect" == 1 Then however you are giving the player the perk , have it start that quest also. Hopefully that works , but if not , can set up a timer in a script to also remove the effect. Link to comment Share on other sites More sharing options...
Mktavish Posted October 30, 2019 Share Posted October 30, 2019 Just realized you are going to need ways to test that it is giving you 25% more damage. What is the print to console for this ? asking into the air ~ Link to comment Share on other sites More sharing options...
IKC1108 Posted November 3, 2019 Author Share Posted November 3, 2019 Hey, thanks for the help. Had a bit more time to work on this and thanks to your advice I'm closer to getting it working using IsWeaponOut. It adds the damage with the weapon drawn and I'm pretty sure removes it when holstered. (The necessary spell effect disappears from the effects list on the pipboy menu anyway). But yeah, it doesn't seem to run out after 5 seconds like it should so I don't think it will work just using the preexisting Ability timer. I'll need to add a script timer instead. I *sort of* understand how to do that using GetSecondsPassed, but one thing I'm not sure about: Does this return the amount of in world time passed or does it return the *real life* seconds passed? Because I don't want the timer to run while the player is in VATS so I'm not sure if that will work.[some context btw if you're curious. I'm trying to mod some of the more terrible perks in the game into something more usable. Mostly that's just meant tweaking some number values but I thought it would be cool to turn "Quick Draw" into a sort of cowboy/western themed deal where you can draw your gun and kill an enemy in one deadly shot.] Link to comment Share on other sites More sharing options...
dubiousintent Posted November 3, 2019 Share Posted November 3, 2019 According to the GECKWiki "GetSecondsPassed":Returns the number of real life seconds that have passed since this function was last called by the calling script. However, note that function only returns the number of elapsed seconds since the last time the function was called. Pay particular attention to the footnotes in that description. This function is unreliable in a ScriptEffect during sleep/wait/fast travel. Use ScriptEffectElapsedSeconds instead. If you take more than 5 seconds between calls, then you do not get to reverse time. So you are going to need to store the timer variable in a "Game Mode" script guarded by a "flag variable" set when you initiate your "spell" and have it checked in the constantly running script every frame. -Dubious- Link to comment Share on other sites More sharing options...
Mktavish Posted November 3, 2019 Share Posted November 3, 2019 To pause a "GetSecondsPassed" while in VATS mode. You would do something like this ...~~~~~~~~~~~~~~~~~~ SCN MyScript Float fTimerInt iDrawInt iWait Begin GameMode ; or Begin ScriptEffectUpdate , if in an effect script If PlayerRef.IsWeaponOut == 1 Set iDraw to 1 If iDraw == 1 && GetVATSMode == 0 && iWait == 0 Set fTimer to fTimer + GetSecondsPassed ; add the bonus damage hereelseif GetVATSMode != 0 || fTimer > 5 Set iWait to 1 If PlayerRef.IsWeaponOut == 0 Set iDraw to 0 Set fTimer to 0 Set iWait to 0 endif endifendifEND ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ I Feel like I am missing something in that script , but maybe it will still help you sort it out.And if I think of something will post back. Add edit : Ah nice ninja dubious ,,, good points too.But I think either one will not pause the VATSmode. Hence a VATSmode check to run the clock. So like dubious says ... it is the result of the line being true above the line that says add to the seconds. Errrmmm .... uh oh ... the internal clock will still tick , then add 2,4,6 seconds that went by while in vats mode. So hmmmm ... need to set up a proxy clock that gets turned on off by Vatsmode. So scratch that script above ... will try thinking up a way to do that , unless someone beats me to it. plz feel free ;) This is quite the intriguing mod puzzle though :) Link to comment Share on other sites More sharing options...
dubiousintent Posted November 3, 2019 Share Posted November 3, 2019 All things considered, why not simply tell the player that entering VATS mods will cancel the effect? Then use "GetVATSMode" in the time section and once it has been entered, just cancel the effect in the script regardless of the timer. Other VATS functions here. -Dubious- Link to comment Share on other sites More sharing options...
Mktavish Posted November 3, 2019 Share Posted November 3, 2019 All things considered, why not simply tell the player that entering VATS mods will cancel the effect? Then use "GetVATSMode" in the time section and once it has been entered, just cancel the effect in the script regardless of the timer. Other VATS functions here. -Dubious- That is an excellent point imo ... since vats already gives bonus. But this is the OP's brain child ... and us as forum helpers , are just that towards their vision. In my view it would be non Vats assisted. But I am already a strict non vats user. And as far as quick draw bonus , if that is the goal ?I think the bonus should be a float from 0 to 5 seconds. Therefore dealing more damage at 1 second than 4 .Just a thought ... :pirate: Link to comment Share on other sites More sharing options...
Mktavish Posted November 3, 2019 Share Posted November 3, 2019 Okies I think I have come up with a way to pause the clock during VatsMode , using a global to store it. And then the way to deliver the adjusted damage. I think is best done with a Perk / EntryPoint. That you conditionalize with the global.Which is simply ... GetGlobalValue : MyGlobal <= 5 And I think the easiest way to attach a script would be still with a quest (process delay set to .1) Here is the script SCN MyScriptFloat fTimerInt iDrawInt iWaitBegin GameMode If PlayerRef.IsWeaponOut == 1 && GetVATSMode == 0 Set iWait to 0 Set iDraw to 1 If iDraw == 1 && GetVATSMode == 0 && iWait == 0 Set fTimer to fTimer + GetSecondsPassed SetGlobalVariable MyGlobal to MyGlobal + fTimer elseif GetVATSMode != 0 Set fTimer to 0 Set iWait to 1 endif If PlayerRef.IsWeaponOut == 0 Set iDraw to 0 Set iWait to 0 Set fTimer to 0 SetGlobalVariable MyGlobal 0 endif endifEND By the way , "SetGlobalVariable" needs to have JIP installed Link to comment Share on other sites More sharing options...
IKC1108 Posted November 10, 2019 Author Share Posted November 10, 2019 (edited) Okay! I wound up doing it slightly differently that you guys suggested but it is definitely working now. The way it works is... The base perk adds an ability that, only when the weapon is not out, runs a script that on start adds a 2nd ability. This 2nd ability is the condition for the damage boost on the base perk and also, only when the weapon is out, runs a script with a timer. When that timer hits 5, the script then dispels the 2nd ability and thus stops itself. Ability 1 of course won't trigger and add ability 2 again until the weapon is not out. This might be a more convoluted but I already had it mostly set up like this and I don't actually know how to use quests. Plus I think it should mean that a script block is only being called:-Once when you first put your weapon away-For the 5 seconds that the bonus is activeIDK if this will make it less process intensive but I figure it can't hurt. Anyway though, your help has been instrumental. Thanks again. All things considered, why not simply tell the player that entering VATS mods will cancel the effect? Then use "GetVATSMode" in the time section and once it has been entered, just cancel the effect in the script regardless of the timer. No, I definitely want it to be more versatile since the point is to make these perks more usable. Anyway, an if condition in the script using GetVATSMode is working so its fine. I think the bonus should be a float from 0 to 5 seconds. Therefore dealing more damage at 1 second than 4 .Just a thought ... :pirate: Actually, I really like this idea. I'm still gonna play around with the actual bonus and/or time (25% damage for 5 seconds is basically just a placeholder while I determined whether I could actually get it to work) so I might just do this. Edited November 10, 2019 by IKC1108 Link to comment Share on other sites More sharing options...
Recommended Posts