eschaeon Posted April 17, 2012 Share Posted April 17, 2012 Could you help with mine? Its a script that will be tied to constant effect spell that returns 33% of all damage taken into Magicka restore. The Damage would still be delivered 100%, just 33% of whatever that is = magicka gain. Its very similar to how http://skyrim.nexusmods.com/downloads/file.php?id=8547 works. I pulled apart the script that came with it to learn how to do mine but couldn't get it to work. Scriptname PPDamagetoMagickaEffect extends activemagiceffect {Script for Paladin's Damage into Magicka Restore effect.} float pPrevHealth float Property MagickaRstPercentage = 0.33 auto {Percentage of taken damage to restore} Event OnHit() Actor target = GetCasterActor() float CurMagicka = target.GetAV("Magicka") if dmgAmount > 0 float rstMagicka = dmgamount * MagickaRstPercentage endif endEvent Link to comment Share on other sites More sharing options...
hydralisk77 Posted April 17, 2012 Share Posted April 17, 2012 @hydralisk77 Have you tried experimenting with the Hold type AI packages? If you are sure you want to use scripting, I can think of a couple ways to do it. The easiest way to do it would be to disable the gladiators' AI until the fight starts, but I am not sure you want that, since that also disables any animation or movement. You can also place a collision cube around the gates and change the collision layer to L_Navcut. This will disable any navmesh that it intersects, which should prevent the navmesh jumping you're seeing. So this collision cube should be enabled while the gates are closed, and disabled when the gates are opened. (Just keep increasing the size until the NPCs can't get past it.) I don't know if it'll actually work though since from my experience, NPCs in combat has no need of navmesh to move around. Scriptname ExampleLeverScript extends ObjectReference {Adapted from the norlever01script} ;;;;;;;;;;;;;;;; ;; Properties ;; ;;;;;;;;;;;;;;;; bool property isInPullPosition = True Auto {Used to determine lever's default position.} Actor[] Property GroupA Auto {Gladiators from group A.} Actor[] Property GroupB Auto {Gladiators from group B.} ObjectReference[] Property EnableObjects Auto {Objects to toggle enable/disable upon.} Bool Property GatesOpened Auto {Used to track if the gates are opened or closed.} Bool Property AIMode Auto {True = enable/disable AI, False = enable/disable objects.} Bool Property AIDisabled Auto {Used to track if the gladiators have AI enabled.} ;;;;;;;;;;;;;;; ;; Functions ;; ;;;;;;;;;;;;;;; ;This has to be handled as a function, since OnLoad and OnReset can fire in either order, and we can't handle competing animation calls. Function SetDefaultState() if (isInPullPosition) playAnimation("FullPull") gotoState("pulledPosition") Else playAnimation("FullPush") gotoState("pushedPosition") EndIf EndFunction Function HandleActivation() ;if one group of actors are dead if CheckReset() ;if the gates are opened if GatesOpened ;toggle the gates (so they close) BlockActivation(False) Activate(Self) BlockActivation() endif ;reset the actors, and if in AIMode then disable AI if AIMode MassSetAI(False, True) else MassSetAI(True, True) endif else ;not all actors in a group are dead ;if in AIMode, and AI is disabled if (AIMode && AIDisabled) ;enables AI MassSetAI(True, False) endif ;toggle the gates opened/closed BlockActivation(False) Activate(Self) BlockActivation() endif EndFunction ;Returns true if at least one group is all dead, otherwise false Bool Function CheckReset() int deadcount = 0 int index = 0 while (index < GroupA.Length) if (GroupA[index].IsDead()) deadcount += 1 endif index += 1 endwhile if (deadcount == GroupA.Length) Return True endif deadcount = 0 index = 0 while (index < GroupB.Length) if (GroupB[index].IsDead()) deadcount += 1 endif index += 1 endwhile if (deadcount == GroupB.Length) Return True endif Return False EndFunction ;Enables/Disables AI of actors, optionally reset the actors Function MassSetAI(Bool bEnableAI = True, Bool bReset = False) int index = 0 while (index < GroupA.Length) if (bReset) GroupA[index].Reset() endif GroupA[index].EnableAI(bEnableAI) index += 1 endwhile index = 0 while (index < GroupB.Length) if (bReset) GroupB[index].Reset() endif GroupB[index].EnableAI(bEnableAI) index += 1 endwhile AIDisabled = !bEnableAI EndFunction ;;;;;;;;;;;;;;;;;;; ;; Events/States ;; ;;;;;;;;;;;;;;;;;;; Event OnInit() BlockActivation() if AIMode MassSetAI(False, False) endif EndEvent EVENT OnLoad() BlockActivation() SetDefaultState() endEVENT Event OnReset() BlockActivation() SetDefaultState() EndEvent Auto STATE pulledPosition EVENT onActivate (objectReference triggerRef) gotoState ("busy") HandleActivation() isInPullPosition = False playAnimationandWait("FullPush","FullPushedUp") gotoState("pushedPosition") endEVENT endState STATE pushedPosition EVENT onActivate (objectReference triggerRef) gotoState ("busy") HandleActivation() isInPullPosition = True playAnimationandWait("FullPull","FullPulledDown") gotoState("pulledPosition") endEVENT endState STATE busy ; This is the state when I'm busy animating EVENT onActivate (objectReference triggerRef) GatesOpened = !GatesOpened if !AIMode int index = 0 while (index < EnableObjects.Length) if (EnableObjects[index].IsDisabled()) EnableObjects[index].Enable() else EnableObjects[index].Disable() endif index += 1 endwhile endif endEVENT endSTATE So if you want to go with enabling/disabling the actors' AI, set AIMode to true, otherwise if you want to go with using collision cubes, set AIMode to False. Fill the GroupA and GroupB arrays with the gladiators from each team. If you're using collision cubes, then fill the EnableObjects array with the collision cubes. As for your second request with the execution, I would have to take a look at the main quest to see how it's done. I suspect that they use a scene though, and I haven't done anything with that before. EDIT: Forgot to mention that I'm assuming the gates you're using are actually the PortGatePole01 activators, and that you have a lever set up as their activate parent. Hi fg, Thanks so much for uploading a working script for me! It worked great after I selected the AI toggle mode. I hide the gladiators in a room so they won't look weird before the fight. Sometimes reseting the fight after one team won will crash the game but it's a small price to pay for a good working script. I used the same script on the chopping block and got it to work somehow too. It just won't reset the dead victim like it did for the arena. I am now doing a beta test of the mod with your script. Sometimes the script working perfectly on my pc doesnt work at all on other peeps'. Anyways, just want to thank you for the help and you are added to the credit list of my mod. I know you didn't do it for thist, but I think you deserve to have your work credited. H. Link to comment Share on other sites More sharing options...
fg109 Posted April 18, 2012 Author Share Posted April 18, 2012 (edited) @Armornv I don't know whether it's the right idle or not: Scriptname Example extends Actor Idle property DragonFlightIdle auto Event OnLoad() EnableAI() PlayIdle(DragonFlightIdle) Utility.Wait(0.1) EnableAI(False) EndEvent @screamingabdab You need to add a keyword property for "ArmorHelmet" to the script, then change line 122 from if (akBaseItem as Armor) to if (akBaseItem as Armor) && (akBaseItem.HasKeyword(ArmorHelmet) @eschaon I haven't taken a look at the mod you linked to, but if you change your script to this, it should work pretty well: Scriptname PPDamagetoMagickaEffect extends activemagiceffect {Script for Paladin's Damage into Magicka Restore effect.} actor target float pPrevHealth float Property MagickaRstPercentage = 0.33 auto {Percentage of taken damage to restore} Event OnEffectStart(Actor akTarget, Actor akCaster) target = akCaster pPrevHealth = target.GetAV("Health") RegisterForUpdate(0.25) EndEvent Event OnUpdate() pPrevHealth = target.GetAV("Health") EndEvent Event OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, bool abBashAttack, bool abHitBlocked) float dmgAmount = pPrevHealth - target.GetAV("Health") pPrevHealth = target.GetAV("Health") if dmgAmount > 0 float rstMagicka = dmgamount * MagickaRstPercentage target.RestoreAV("Magicka", rstMagicka) endif endEvent Event OnEffectFinish(Actor akTarget, Actor akCaster) UnregisterForUpdate() EndEvent Edited April 18, 2012 by fg109 Link to comment Share on other sites More sharing options...
Armornv Posted April 18, 2012 Share Posted April 18, 2012 Thanks for that fg! The script compiles fine, but alas, he still has the standing on the ground pose. Getting closer, but I didn't see anything else related to an idle flight. :( Also for some reason, if there is a coc marker heading in the room, he goes to that now instead of the x marker heading he used to go two. No biggie, Just there while im building the room. Link to comment Share on other sites More sharing options...
entropiachrome Posted April 18, 2012 Share Posted April 18, 2012 fg109... is... AWESOME!!! Tx so much for your help with my coffin script, tonight I will be sending a message to you about followers. :thumbsup: Link to comment Share on other sites More sharing options...
eschaeon Posted April 18, 2012 Share Posted April 18, 2012 Wow, thanks! You knocked that out easy! And it does work great. This is much better than I could have hoped for, you have no idea. Once I release this mod I'll credit you for Scripting! Link to comment Share on other sites More sharing options...
Xenon32 Posted April 18, 2012 Share Posted April 18, 2012 I don't know it this has already been asked, but would you be willing to put together a script that takes control of the first-person camera (I'd assume it's the 1stPCam object in the editor) for use in creating a cinematic camera for cutscenes and the like? Link to comment Share on other sites More sharing options...
Fury945 Posted April 18, 2012 Share Posted April 18, 2012 Thanks for your help Fg109I couldn't even think of where to begin without it. Link to comment Share on other sites More sharing options...
fg109 Posted April 18, 2012 Author Share Posted April 18, 2012 @Xenon32 I'm sorry, but that's beyond my abilities. I've looked but there are almost no scripting commands related to cameras, and I can't think of any way to use the ones that are there to do what you describe. Link to comment Share on other sites More sharing options...
scrivener07 Posted April 18, 2012 Share Posted April 18, 2012 Ive got one. Do you know how to force the player to activate furniture? I ask because there is no function for showing a crafting menu. Ive tried everything from packages, quests, scenes, and moving crafting benches directly to the player and doing Game.GetPlayer().Activate(CellBench). Heres what I got going on now. I have a MiscObject with the below script attached. Im trying to set it up so when the player drops the MiscObject from their inventory the script catches that and moves an alchemy lab from an empty cell I made to the player and then force the player to activate the table which should pull up the crafting menu. All debug scripts play at the correct times. If I ever get that portion working Im gonna fix it up so when you drop the item it is instantly added back to inventory ready to be "triggered" again. Scriptname AlchemistkitScript extends ObjectReference Event OnContainerChanged(ObjectReference akNewContainer, ObjectReference akOldContainer) If akNewContainer == Game.GetPlayer() ;Saving this for later Debug.Notification("Kit is entering player") if (Game.GetPlayer().GetItemCount(Self) == 1) Debug.Notification("I have 1 Kit") endif Endif If akOldContainer == Game.GetPlayer() Debug.Notification("Kit is leaving player") CellBench.MoveTo(Game.GetPlayer()) ;Nothing happens Game.GetPlayer().PlaceAtMe(AFK_Bench) ;I can move the base object just fine like this. Still no activate. Game.GetPlayer().Activate(CellBench); Seems to do nothing if (Game.GetPlayer().GetItemCount(Self) <= 0) Debug.Notification("I have no Kits") endif Endif if (Game.GetPlayer().GetItemCount(Self) > 1) ;Saving this for later Debug.Notification("I have more than 1 Kit") Debug.Notification("Write code here to Get# of kits = x. Then x-x+1") ;Game.GetPlayer().RemoveItem(Self) ;something like that ::shrugs:: endif EndEvent MiscObject Property AlchemistKit Auto Furniture Property AFK_Bench Auto ;Base object ObjectReference Property CellBench Auto ;Reference hangin out in an empty cell Link to comment Share on other sites More sharing options...
Recommended Posts