Jump to content

Need a script? Maybe I can help.


fg109

Recommended Posts

I made another topic not long ago and no one posted. Didn't see this topic or I would have just posted here. I'm a noob and I can't figure out fast travel.

 

http://www.creationkit.com/FastTravel_-_Game

 

Example: Game.FastTravel(HomeMarker)

 

What do I use in place of HomeMarker? Is it the map marker ID? Marker name? I tried both and it didn't work but I may have done it wrong.

Link to comment
Share on other sites

  • Replies 272
  • Created
  • Last Reply

Top Posters In This Topic

Thanks for telling me where I have to start for my weightsystem-change-script and telling me about the mod fg109.

 

@gasti and bobby: Gasti should be right. The =! should mean "uneven". So 1+1=2 and 1+2=!2 are both right. I hope you get what I mean. So it checks if the actor was already revived by this script or not.

Link to comment
Share on other sites

So whenever you want to sit, just call the function "SitAt(Game.GetPlayer())" if you want the player to sit at the exact spot he/she is currently standing, or else "SitAt(SomeTarget)" to sit at SomeTarget.

 

I haven't tried it out, so I don't know if the player really does send an "IdleFurnitureExit" event when he/she gets out of a chair.

 

Thanks for going above and beyond what I asked you to do.

 

Your script calls this function "PlaceAtMe(ChairInvisibleSingle)" I'm under the impression that only actors and activators can be moved. (http://www.creationkit.com/Complete_Example_Scripts, Move an Object to a Specific Location Without Fade) I've actually been playing with the "moveto" function, and "ChairinvisibleSingle" is static and can't be moved. I'll be testing "Placeatme" to see if it works better than "moveto".

 

I'm looking forward to testing the script. if anything it has given me some new ideas of how to make it work. Thanks

 

ADDED COMMENT:

CK Wiki had this to say about "Placeatme" "Note: the akFormToPlace can be things such as MiscItem, Actor, ActorBase, etcetera, but it cannot be an ObjectReference" http://www.creationkit.com/PlaceAtMe_-_ObjectReference

Thought I'd look it up before I tested it. It is not meantioned whether or not STATICS can be used.

Edited by leedavis
Link to comment
Share on other sites

@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.

Edited by fg109
Link to comment
Share on other sites

OK, I think I have the script but I can't get it to work because Creation kit is being a (censored). I have looked through your links to Hello World and the other one, but they didn't mention the issue I have.

 

I've been working on a mod, and I'm now at the final stage. I need to find a way to make a perk edit a global variable. I've been looking for it for quite some time, and had given up on it, leaving my mod behind.

 

But then I accidentally found a way.

 

The solution was within one of the perks. The perk pointed to something called "PerksQuest" in the creation kit. I open PerksQuest, and go to scripts. I found the solution, the script was there! Here are the contents of it.

 

 

;BEGIN FRAGMENT CODE - Do not edit anything between this and the end comment

;NEXT FRAGMENT INDEX 18

Scriptname QF_PerksQuest_0005F596 Extends Quest Hidden

 

;BEGIN FRAGMENT Fragment_6

Function Fragment_6()

;BEGIN CODE

; Imperial Luck - racial ability, not perk

 

GlobalImperialLuck.SetValue(0)

;END CODE

EndFunction

;END FRAGMENT

 

;BEGIN FRAGMENT Fragment_13

Function Fragment_13()

;BEGIN CODE

; Persuasion

 

SpeechEasy.SetValue(SpeechEasy.GetValue() * 0.7)

SpeechAverage.SetValue(SpeechAverage.GetValue() * 0.7)

SpeechHard.SetValue(SpeechHard.GetValue() * 0.7)

SpeechVeryHard.SetValue(SpeechVeryHard.GetValue() * 0.7)

;END CODE

EndFunction

;END FRAGMENT

 

;BEGIN FRAGMENT Fragment_8

Function Fragment_8()

;BEGIN CODE

; Treasure Hunter

 

SpecialLootChance.SetValue(85)

;END CODE

EndFunction

;END FRAGMENT

 

;BEGIN FRAGMENT Fragment_0

Function Fragment_0()

;BEGIN CODE

; Daedric Mind

 

GlobalPerkDaedricMind.SetValue(1)

;END CODE

EndFunction

;END FRAGMENT

 

;BEGIN FRAGMENT Fragment_4

Function Fragment_4()

;BEGIN CODE

; Golden Touch

 

GlobalPerkGoldenTouch.SetValue(0)

;END CODE

EndFunction

;END FRAGMENT

 

;BEGIN FRAGMENT Fragment_10

Function Fragment_10()

;BEGIN CODE

; Master Trader

 

PerkMasterTrader.SetValue(0)

;END CODE

EndFunction

;END FRAGMENT

 

;END FRAGMENT CODE - Do not edit anything between this and the begin comment

 

globalvariable Property GlobalPerkDaedricMind Auto

GlobalVariable Property GlobalPerkGoldenTouch Auto

GlobalVariable Property GlobalImperialLuck Auto

 

GlobalVariable Property SpecialLootChance Auto

 

GlobalVariable Property PerkMasterTrader Auto

 

GlobalVariable Property SpeechAverage Auto

 

GlobalVariable Property SpeechEasy Auto

 

GlobalVariable Property SpeechHard Auto

 

GlobalVariable Property SpeechVeryHard Auto

 

 

 

I quickly began changing it to what I needed. This is just a test, and just to see if it's going to work I only used one of my Global Variables. It seemed easy enough, and I ended up with this. I saved the script, and tried to compile it. Success.

 

 

Scriptname zHOPerksQuest extends Quest Hidden

 

;BEGIN FRAGMENT CODE - Do not edit anything between this and the end comment

;NEXT FRAGMENT INDEX 18

 

;BEGIN FRAGMENT Fragment_6

Function Fragment_6()

;BEGIN CODE

; Green Thumb

 

GlobalzHOGarlicGlobal.SetValue(100)

;END CODE

EndFunction

;END FRAGMENT

 

;END FRAGMENT CODE - Do not edit anything between this and the begin comment

 

GlobalVariable Property GlobalzHOGarlicGlobal Auto

 

 

By now, I have a compiled script, ready to be attached to my own "PerksQuest". I have created my own quest to avoid any compatibility issues. I them go to scripts and attach my script. I attached it, and edited the properties to point to the global variable - zHOGarlicGlobal. (Ok, I will explain later why this garlic thing is important to my mod. I'll tell you now, the "z" in the name is to put the object to the bottom of the creation kit window, for me easy to sort and find. The HO stands for my mod - Harvest Overhaul.)

 

Having the script attached, I go into the quest Stages and create a blank quest stage 10. I remembered looking at what the original "perksquest" has to make the quest stages work and change the global variables. So I go and drop in this to the "papyrus fragment" bit in the creation kit.

 

 

; Green Thumb

 

GlobalzHOGarlicGlobal.SetValue(100)

 

 

I think I'm done here, as it looks exactly like what the original PerksQuest has. I press OK.

 

Starting 1 compile threads for 1 files...

Compiling "QF_zHOPerksQuest_01009F48"...

c:\games\steam\steamapps\common\skyrim\Data\Scripts\Source\temp\QF_zHOPerksQuest_01009F48.psc(10,0): variable GlobalzHOGarlicGlobal is undefined

c:\games\steam\steamapps\common\skyrim\Data\Scripts\Source\temp\QF_zHOPerksQuest_01009F48.psc(10,22): none is not a known user-defined type

No output generated for QF_zHOPerksQuest_01009F48, compilation failed.

 

Batch compile of 1 files finished. 0 succeeded, 1 failed.

Failed on QF_zHOPerksQuest2_01009F48

 

I'm sorry, what? I already have the script and everything, and I inserted exactly the same thing what the original PerksQuest has.

Example -

; Imperial Luck - racial ability, not perk

 

GlobalImperialLuck.SetValue(0)

 

 

 

I do not want to create a new script or compile it, I already have it. Why can't the Creation kit understand this? I have tried some other things similar to this, including copy/pasting the whole script in the papyrus fragment window, but with the same outcome.

 

What should I do? Am I connecting the script wrong to the quest? Have I written the script wrong? The same script works for the perksquest, it should work for this. Oh, and I tried loading up the original PerksQuest and pressing Compile. It doesn't give any errors. What's going on?

Link to comment
Share on other sites

@ gasti

 

http://www.creationkit.com/Bethesda_Tutorial_Papyrus_Events_and_Properties

 

This could shed some light as the example within states that draugr keep on resurrecting unless debugged.

So I'm guessing the resurrection stops because the number after an even number is uneven ?

__________

 

Please don't forget about me fg109 pretty please :)

 

PS reply system bugged?

Edited by bobbythecamel
Link to comment
Share on other sites

Hi,

 

Is it possible to script a spell so that it adds an effect (say like a disease) to the player,

e.g. the player casts this spell and it does masses of damage to his opponent but adds an incurable (by normal means) disease to the player?

 

I'd like to know this because I'm working on a construct race (e.g. an Android, it'd have to be Dwemer in origin) and I'd like them to be able to sacrifice a little bit of their energy/power/electricity (health) to hurt their enemies and then have to find a specific object to recharge them (most likely a power cell).

 

 

Thanks

 

This is possible, but it will require a scripted ability as well. So when you cast the spell, you add the scripted ability to the player. The scripted ability will keep checking the player to see if he has the disease, if not then it will add the disease to the player. You need the ability because diseases can be dispelled by a Cure Disease potion or a shrine. So as soon as your disease is dispelled, the scripted ability would re-apply it.

 

Your recharging activator should remove the ability and the disease from the player when activated.

Link to comment
Share on other sites

@bobbythecamel

 

You will need two scripts, one for the container and one for the dummy objects.

 

 

Scriptname ExampleObjectScript extends ObjectReference

;;;;;;;;;;;;;;;;
;; Properties ;;
;;;;;;;;;;;;;;;;

Potion Property WhichObject Auto
{Potatoes are potions.  You will need to change the property type to weapons if you're looking for weapons, etc.}

ObjectReference[] Property DummyMarkers Auto
{Array of the dummy potatoes to control potato placement.}

;;;;;;;;;;;;;;;
;; Functions ;;
;;;;;;;;;;;;;;;

;returns the number of markers not 'in use'
Int Function CheckForEmptyMarkers()
int index = 0
int count = 0
while (index < DummyMarkers.Length)
	if DummyMarkers[index].IsDisabled()
		count += 1
	endif
	index += 1
endwhile
Return count
EndFunction

;place object at first 'available' marker, returns true if object is 'placed'
Bool Function PlaceObjectAtEmptyMarker()
int index = 0
while (index < DummyMarkers.Length)
	if DummyMarkers[index].IsDisabled()
		DummyMarkers[index].Enable()
		RemoveItem(WhichObject)
		Return True
	endif
	index += 1
endwhile
Return False
EndFunction

;;;;;;;;;;;;
;; Events ;;
;;;;;;;;;;;;

Event OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer)
if !(akBaseItem == WhichObject)
	Return
endif
int count = CheckForEmptyMarkers()
int index
while (count > 0 && aiItemCount > 0)
	if (PlaceObjectAtEmptyMarker())
		aiItemCount -= 1
		count -= 1
	else
		Debug.Trace(self + " Something went wrong with the potato placement.")
		Return
	endif
endwhile
EndEvent

 

 

 

Scriptname ExampleObjectScript extends ObjectReference

Event OnInit()
BlockActivation()
EndEvent

Event OnActivate(ObjectReference akActionRef)
Disable()
akActionRef.AddItem(Self.GetBaseObject())
EndEvent

 

 

Also, ghasti is right. The "if !Revived" is to check whether or not the actor has been resurrected by the script already.

Link to comment
Share on other sites

I made another topic not long ago and no one posted. Didn't see this topic or I would have just posted here. I'm a noob and I can't figure out fast travel.

 

http://www.creationkit.com/FastTravel_-_Game

 

Example: Game.FastTravel(HomeMarker)

 

What do I use in place of HomeMarker? Is it the map marker ID? Marker name? I tried both and it didn't work but I may have done it wrong.

 

You would have to declare a property for HomeMarker. So a part of your script would look like this:

 

ObjectReference Property HomeMarker Auto

;Some event start
Game.FastTravel(HomeMarker)
;End of some event

 

In my first post I put a link to the wiki page explaining how to set values to the properties.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.

×
×
  • Create New...