Jump to content

Need help with Scripting


TheMan21

Recommended Posts

Ok, hello at all!

 

I will try to explain it short:

I want to use the function isRunning (just because I want to test something). In this script, the camera should shake.

But I dont know which event I should use.

 

Scriptname newscript1 extends ObjectReference  

EVENT <eventname>
if Game.GetPlayer().IsRunning()
	Game.ShakeCamera(Game.GetPlayer(), 0.8, 0.6)
endif
endEVENT

 

So, which event should I use? maybe OnLoad? Can this script work?

Link to comment
Share on other sites

The event you use will depend on what you wish to be the "cause" of the effect. For example, does the camera shake when the player is running if (s)he is wearing a particular ring? After they cast a spell? If they have a specific follower? There are many events for each situation.

 

If it's a spell, you can add an ability with Event OnEffectStart(). If it's a ring, item of clothing or weapon, you can use Event OnEquipped. There is an event for when an NPC sees the player, if the player puts something in a chest, and so on. What are the circumstances under which you want your script to run?

Link to comment
Share on other sites

Ok, I used the Event OnEquipped and created a new Ring. The Script is attached to the Ring.

It works only when I'm running, then open the inventory and equipping the Ring. The camera is shaking short after closing the inventory. How can I make it like an effect? I equip the Ring and I have this as an effect?

 

EVENT OnEquipped(Actor Game.GetPlayer)
if Game.GetPlayer().IsRunning()
	Game.ShakeCamera(Game.GetPlayer(), 0.8, 0.6)
endif
endEVENT

Link to comment
Share on other sites

To have to always active, you need to make a constant effect ability with an attached magic effect. It would be type: Script -> Constant Effect -> Self. You can attach your script to it as above, except you use the event OnEffectStart().

 

Scriptname RunningScript extends activemagiceffect

Event OnEffectStart(Target, Caster)
       if (Game.GetPlayer().IsRunning())
               Game.ShakeCamera(Game.GetPlayer(), 0.8, 0.6)
       endif
EndEvent

And on the ring:

 

Scriptname AddRingAbilityScript extends objectreference

Spell Property YourAbilityName auto

Event OnEquipped(Wearer)
       if (Wearer = Game.GetPlayer())
               Game.GetPlayer().AddSpell(YourAbilityName, false) ; False suppresses any notification from appearing on-screen
       endif
EndEvent

Link to comment
Share on other sites

Guys, that won't work.

 

It will only check if the player is running when the ring is first worn (when the effect first starts), so no different from the previous script.

 

What you need to do is use a Condition Function to test "IsRunning" on the player in the Magic Effect, then have a script to shake the camera whenever the condition is true. The effect will now start and stop every time the player starts/stops running.

 

Scriptname RunningScript extends activemagiceffect

Event OnEffectStart(Target, Caster)
If Caster == Game.GetPlayer()
	Game.ShakeCamera(Caster, 0.8, 0.6)
EndIf
EndEvent

Edited by steve40
Link to comment
Share on other sites

One last question:

 

I know how to add the condition, but where is the option for adding a condition to an object? It's not on the wiki page I think

 

PS: Where should I attach the script? To the Ring? Sorry for this questions :D

Edited by TheMan21
Link to comment
Share on other sites

You would put KingsGambit's "AddRingAbilityScript" on the ring. Then you would need to make an Ability and a MagicEffect for that ability. The MagicEffect must be archetype SCRIPT. Then you would put my "RunningScript" script on the MagicEffect. The Condition Function should be put on the Ability (it might also work if you add it to the MagicEffect). You would configure the condition to test "IsRunning" == 1 on the PlayerRef. Oh, and you would have to set the script property "YourAbilityName" on the ring to point to your custom Ability. Edited by steve40
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...