Need help on some Scripts for near-finished Project

Post » Wed Jun 29, 2016 8:50 pm

Evening everyone!, hope everyone is well.



I'm writing this at 3:00am, in the morning where I'm at so please bear with me, been having a hard time with the Creation kit finishing my project, which is because I'm a total noob at scripting :cryvaultboy:


I wanted to at least figure out one of these problems on my own before asking for help, but after three days of frustration I gotta try something different. All I need to do is compile these scripts and my Quest mod will be pretty much finished and it will truly complete this project.



Basically I'm trying to create a Teleport Script and a Event Script, I'll explain what I'm trying to do below:



Teleport Script



This one I've had some progress with but to no avail. Fortunately I've seen this work before in other mods so I know its possible, and what I'm trying to do is basically have a script attached to my spell that allows me to teleport to a Xmarkerheading located in a custom worldspace and if used again recall me back to my previous location. (Example: if I use the spell in Whiterun inn to teleport to the worldspace then use the spell again in the worldspace it will teleport me back to whiterun inn)



I've add some success teleporting to the worldspace with this basic script which works great, but I'm not able to teleport back to my previous location.



Scriptname Teleport_Spell_Script extends activemagiceffect

ObjectReference property teleDest auto

Event OnEffectFinish(Actor Target, Actor Caster)
target.MoveTo(TeleDest)
EndEvent

I've also tried this one I found, which teleported me to the worldspace but needed a marker in the skyrim to recall to.



ScriptName CDC_TeleportScript extends ActiveMagicEffect

ObjectReference Property HomeMarker Auto
{A marker where the caster will be moved to when teleport is cast.}

ObjectReference Property ReturnMarker Auto
{A second marker originally placed at the same location as the home marker.}

Event OnEffectStart(Actor akTarget, Actor akCaster)
if akCaster.GetDistance(HomeMarker) < 5000 ; if already at home (i.e. near the home marker)
akCaster.MoveTo(ReturnMarker) ; go to return marker
else ; if not at home
ReturnMarker.MoveTo(akCaster) ; set return marker
akCaster.MoveTo(HomeMarker) ; then go home
endif
EndEvent


Event Script



Unfortunately for this one, I have no scripts to post, because this one is very specific, and didn't really find anything really close to what I needed, and I don't know if I really need scripts for this one but I think I do. This one is really important because it's part of the quest, basically I need a script that spawns creatures on certain days. For example I have it that Draugrs,Bandits and creatures attack this village on weekends at specific times, these enemies all have packages so they will do their job, and I already have their spawnpoints ready, I just want them to spawn on their own at these times- everytime. I Have the amount of npc's placed already, and I'm assuming I need a script attached to them? I tried to have them "initially disabled" hoping they will spawn to complete their packages but that failed horribly. But this is my goal:




(Fredas) Friday: 8:00pm : Creature Attack


(Loredas)Saturday: 8:00pm : Draugrs Attack


(Sundas)Sunday 8:00pm : Bandits Attack


and so on.



I have about 20 of each placed, so when they all die they don't respawn till the following week.





So that's basically it, I hope someone can help me out. I really want to get this mod finished for Skyrim remastered and after looking at it, these are the last two missing pieces I need to finish this project. Thank you all for your time and I apologize if I didn't explain something clearly. I tried to do this without the use of scripts, but after hours of messing around in the CK I realize this is simply not possible.



Once again, Thanks for time



User avatar
CHANONE
 
Posts: 3377
Joined: Fri Mar 30, 2007 10:04 am

Post » Wed Jun 29, 2016 6:24 pm

For Teleport:


Create a new Interior Cell, and drop an Actor in there (might work with Markers, but since the days of Oblivion I've always used Actors since they can change places without issue); when you first Teleport out of Tamriel, just before you do somove the actor to the Player's location. Then just use the Return to target them instead. If they're disabled, they won't appear in the world and shouldn't move. You might need a flag to indicate which way to go. :



ObjectReference Property DestinationMarker Auto
Actor Property ReturnMarker Auto
GlobalVariable Property WhichWay Auto

Event OnEffectStart(Actor Target, Actor Caster)
If ( WhichWay.GetValue() == 0 )
WhichWay.SetValue(1)
ReturnMarker.MoveTo(Target)
Target.MoveTo(DestinationMarker)
ElseIf ( WhichWay.GetValue() == 1 )
WhichWay.SetValue(0)
Target.MoveTo(ReturnMarker)
EndIf
EndEvent
User avatar
u gone see
 
Posts: 3388
Joined: Tue Oct 02, 2007 2:53 pm

Post » Wed Jun 29, 2016 10:10 pm




Heya CDM_, thanks for the response! and thanks for the script! it complied perfectly.



It teleports me fine - I made a new Interior, New NPC marked it as "disabled" and I can get to my world just fine, however casting it again I can't recall back to my original spot. Tried going to Windhelm, and other places to test it and they all teleport me fine but No recall back to the previous location.



I'm assuming that I have to create a new Global Variable , which was the only part in the script I didn't fill out cause I have no idea what to do there. I know I can make a New Global Variable but going by the link in the Creation kit Wiki page , I'm not sure where to go from there.




I wish I wasn't a complete noob at this stuff. :wallbash:

User avatar
sam smith
 
Posts: 3386
Joined: Sun Aug 05, 2007 3:55 am

Post » Wed Jun 29, 2016 11:55 pm

There's a global variable tab. Right click, new. Iirc, you can then point to it like any other object.


Global Property YapsGlobal Auto

User avatar
Prue
 
Posts: 3425
Joined: Sun Feb 11, 2007 4:27 am

Post » Wed Jun 29, 2016 2:04 pm

Use an actual marker not an NPC. Using an NPC wastes a huge amount of resources and markers work just fine in Skyrim. You also don't need a global variable.



My script you listed above will do what you want if you just place two xheader markers at the same location in your world space and link both of them to that script. You may want to change that GetDistance check to a value greater than 5000 though. (One of the markers gets moved around as the spell is cast and the other one always stays in its original spot.)





For the spawning script I'm not sure. I've never really written anything like that. But I'll think about it and let you know if I come up with something.

User avatar
Lynne Hinton
 
Posts: 3388
Joined: Wed Nov 15, 2006 4:24 am

Post » Thu Jun 30, 2016 2:10 am





Hello again Elias555! and thanks for responding Cdcooley , had no idea you would actually show up but I'm glad you did.



Jeez I feel so stupid and I'm incredibly embarrassed right now. I spend hours into the night trying to figure out how to get that script working, and I actually only made One Xmarkerheading and link the script to that heading twice when I should've made 2 of them, not to mention the Global variable, I was clearly overthinking it. I'm happy to announce that not only did I learn quite abit from this experience, but the spell is working! :shocking:



Seriously thank you guys very much for your help, it's just a great feeling to see something come together like this and I'm grateful that there are people out there who are MUCH better at scripting than I am!



To cdcooley, as far as the final script, I feel I could've written that better. I did find a script from that was posted back in 2012 that is the closest to what I needed for the event packages



scriptname myGuySpawner extends Quest

Actor property myGuy auto
GlobalVariable property GameHour auto
Static property myGuyMarker auto

Event OnInit()
RegisterForSingleUpdateGameTime(1) ;Updates once per hour in-game. NEVER USE RegisterForUpdate or RegisterForUpdateGameTime. Ever.
endEvent

Event OnUpdateGameTime()
if GameHour.GetValue() >= 19.0 || GameHour.GetValue() <= 7.0 ;Between 7PM and 7AM
myGuyMarker.PlaceActorAtMe(myGuy)
else
RegisterForSingleUpdateGameTime(1) ;Check again in another hour if not the right time
endif
endEvent

The original poster wanted to script a event that makes a npc spawn in solitude when nightime comes, and this script was posted which "checks once an hour , and if the time is right spawns the NPC. The script is attached to a quest and linked to global variable Gamehour. So going by from this script, if the spawn I need will spawn On certain days, I'm think it will depend on global variables, time, though I'm not sure you can pick out specific days like that in the CK.



I did think about adding a "Arena script" which spawned monsters at a trigger but it didn't feel natural. I also tried messing around with trigger boxes, with making enemies spawn on Load, like in vanilla but I had absolutely no luck with that, honestly if I could figure out how the vanilla game does it, then I would be more than satisfied with that considering that was my first choice, but I decided to try scripts since I couldn't figure it out.



All in All I feel I asked enough out of you guys, I'm extremely grateful for all your help.

User avatar
Blaine
 
Posts: 3456
Joined: Wed May 16, 2007 4:24 pm

Post » Wed Jun 29, 2016 2:41 pm

OK, I've foraged through some of my old scripts and might have something to get you started. I can help with the timing part but honestly have no idea what would be the best way to actually use it. Maybe PlaceAtMe commands to put appropriate creatures a the right spots. Maybe disable, enable, and resurrect commands?



Anyway, if you figure out the other parts about how to spawn them here's a script that will trigger at the right times and check to make sure the player is nearby based on Location and raw distance. The location checks are handy if you are attacking a village and the critters are supposed to attack even if the player is sitting in the inn. If you wanted to require the player to be outside you can remove the part checking the child location.



ScriptName DailyEventWhenPlayerNearby Extends ObjectReference

float Property EventTargetTime = 20.0 Auto
{The target game hour for the event. Default is 8:00 pm}
float Property EventMaxDelay = 2.0 Auto
{How many hours after the target the event could fire. Default is 2 hours.}

Actor Property playerRef Auto


Event OnInit()
OnUpdateGameTime() ; fake event call just to get things started
EndEvent


Event OnUpdateGameTime()
float currentTime = Utility.GetCurrentGameTime() ; really game days past here
float timeLeft = (currentTime - (currentTime as int)) * 24.0 ; chop off the days and scale into current game hour
timeLeft = EventTargetTime - timeLeft ; finally it is the time left until event should happen today
if timeLeft >= 0.0 ; still too early, try again later today
RegisterForSingleUpdateGameTime(timeLeft)
;Debug.Notification("Registering " + timeLeft)
else ; not too early, will need to check again tomorrow
RegisterForSingleUpdateGameTime(timeLeft + 24.0)
;Debug.Notification("Registering " + (timeLeft + 24.0))
if timeLeft + EventMaxDelay >= 0.0 ; within the target time window
int dayOfWeek = (currentTime as int) % 7 ; Sundas is 0, Morndas is 1, etc.
;Debug.Notification("IT IS TIME!")
Location myLoc = GetCurrentLocation()
Location playerLoc = playerRef.GetCurrentLocation()
if playerLoc == myLoc || myLoc.IsChild(playerLoc) || GetDistance(playerRef) < 5000 ; player is nearby
if dayOfWeek == 0 ; Sundas - bandit day
;Debug.Notification("Bandit day!")
; code to spawn bandits

elseif dayOfWeek == 6 ; Loredas - draugr day
;Debug.Notification("Draugr day!")
; code to spawn bandits

elseif dayOfWeek == 5 ; Fredas - creature day
;Debug.Notification("Creature day!")
; code to spawn creatures

endif
endif
endif
endif
EndEvent

Note I haven't actually run that code so you might want to uncomment the Notification lines and make sure you get messages at the appropriate times.

User avatar
Clea Jamerson
 
Posts: 3376
Joined: Tue Jun 20, 2006 3:23 pm

Post » Wed Jun 29, 2016 11:53 am

Hello again!


And thanks for the script cdcooley, it complied fine but as you mentioned I myself, cannot figure out a way to make this work. I've been up since yesterday trying to get this thing to work and I'm just stressed out and very tired. I've tried alot of things but can't figure out how to get certain npc's to spawn at the right times.



At this point, I think if I can just get at least one NPC to spawn I'll just make it a boss character of sorts, and call it a wrap. I'm not going to give up yet though, if somehow I manage to do it then that's great. I feel really bad that you did all this and I can't even get this thing to work, but at least I got the teleport script working and to me that was a big deal, it really put my project together.



Not gonna go to bed though yet, gonna spend today trying alternatives and messing around with scripting some more.



Hopefully I don't pass out ! :user:

User avatar
Rudy Paint fingers
 
Posts: 3416
Joined: Sun Nov 11, 2007 1:52 am

Post » Wed Jun 29, 2016 9:10 pm

Hello! Me Again.



I didn't want to make a new topic for this, but it is Script related so I figured this is appropriate. I have a question about the FXcameraAttachEffectsACT script. I've been experimenting with diffrent effects and what not but something happened that has me worrying.


The first thing, I put a trigger box around an object and the effects work great except if I put another in a another area that's suppose to be different, it inherits the previous triggerbox, even if its a interior! I couldn't figure out how to make them unique which brings us to the issue that has me sweating.



Since the triggerboxes weren't cooperating I was worried they did anything in the vanilla game, and apparently they did. Now everything is using the same triggerbox FX, and I'm worried that I did something really bad by accident. I'd like to have fogs in certain areas and fallen leaves, not fallen leaves everywhere, even at the top of skyrim mountains which takes place in a entirely different worldspace.



Did I screw up? I'm pretty stumped right now :meh:

User avatar
NO suckers In Here
 
Posts: 3449
Joined: Thu Jul 13, 2006 2:05 am


Return to V - Skyrim