Jump to content

how to store player location in script "a" and use it as a mov


tonycubed2

Recommended Posts

Hi,

 

Stuck on something that sounded simple but I can't get the ck commands to do it. I had a primary script that runs after a player fast travels. It is pasted below.

The part that says :

;Disable fast travel

Game.EnableFastTravel(false)

Location TravelTo = PlayerRef.GetLocation()

;travetois where player is being sent to

PlayerRef.MoveTo(Fight)

 

Is where I am stuck. The entire script works great including the move to command that sends the player to a location to fight. This is from a working mod posted several weeks ago that is progressing nicely (thanks to you all). The part NOT working is that Location TravelTo = PlayerRef.GetLocation(). WOn;t compile, and I cannot figure out how to store the players location so that the moveto command can later use it.

 

I need to be able to save the players location so that after he is done fighting at the other world space I can send him back where he came from. But once I move him the script has no more control on the player. There is an activator script on the other side that when he pases the boundary another script will be used to send him back. So the variable stored needs to be usabel on both scripts, passed between the two scripts. I though of global variables bit that did not compile. Any suggestions?

 

thank you all for reading this

 

Tonycubed

 

 

Scriptname FtravelAmbush Extends Quest  

import Game
import Utility
import Debug
import Alias
Quest Property FastTravelAmbushes2012  Auto  
GlobalVariable Property Ftravel Auto
GlobalVariable Property Time0 Auto
GlobalVariable Property Time1 Auto
GlobalVariable Property Time2 Auto
GlobalVariable Property FTravelOdds Auto
;odds of being attacked after fast traveling
ObjectReference Property presentlocal Auto 
int Tock
int attackers
int random
int property travelfast Auto
int myCrimeGold
Keyword Property StormCloaks Auto


Event OnStoryChangeLocation(ObjectReference akActor, Location akOldLocation, Location akNewLocation)
if !((GetPlayer().GetParentCell()).IsInterior())
;Debug.MessageBox("is exterior")
attackers = 1
float Tick = GetCurrentHourofDay()
Tock = Tick as Int
Int check0 = Time0.GetValueInt()
Int check1 = Time1.GetValueInt()
Int check2 = Time2.GetValueInt()
random = Utility.RandomInt(1, 100)
;Debug.MessageBox("Ftravelodds are: "+FTravelOdds.GetValueInt())
if random < FTravelOdds.GetValueInt()
if (tock != check0 && tock != check1 && tock != check2) && ((tock - 1) != check0 && (tock - 1) != check1 && (tock - 1) != check2)
Game.FadeOutGame(false, true, 8.0, 1.0)
ObjectReference PlayerRef = Game.GetPlayer()
myCrimeGold = 0
myCrimeGold = mycrimegold + CrimeFactionEastMarch.GetCrimeGold() as Int
myCrimeGold = mycrimegold + CrimeFactionFalkreath.GetCrimeGold() as Int
myCrimeGold = mycrimegold + CrimeFactionHaafingar.GetCrimeGold() as Int
myCrimeGold = mycrimegold + CrimeFactionHjaalmarch.GetCrimeGold() as Int
myCrimeGold = mycrimegold + CrimeFactionPale.GetCrimeGold() as Int
myCrimeGold = mycrimegold + CrimeFactionReach.GetCrimeGold() as Int
myCrimeGold = mycrimegold + CrimeFactionRift.GetCrimeGold() as Int
myCrimeGold = mycrimegold + CrimeFactionWhiterun.GetCrimeGold() as Int
myCrimeGold = mycrimegold + CrimeFactionWinterhold.GetCrimeGold() as Int
;ambush starts
if RandomInt() < 99
Debug.MessageBox("You are ambushed on the way!")
; Disable fast travel
Game.EnableFastTravel(false)
Location TravelTo = PlayerRef.GetLocation()
;travetois where player is being sent to 
PlayerRef.MoveTo(Fight)
;move player to fight area
PlayerRef = Game.GetPlayer()
PlayerRef.PlaceActorAtMe (Ambushers1, attackers).StartCombat(Game.GetPlayer())
if RandomInt() > 50
PlayerRef.PlaceActorAtMe (Ambushers2, attackers).StartCombat(Game.GetPlayer())
EndIf
if RandomInt() > 50
PlayerRef.PlaceActorAtMe (Ambushers3, attackers).StartCombat(Game.GetPlayer())
EndIf
if RandomInt() > 50
PlayerRef.PlaceActorAtMe (Ambushers4, attackers).StartCombat(Game.GetPlayer())
EndIf
Elseif myCrimeGold > 0
;check for bounty
;do bountry hunters
Debug.MessageBox("Bounty Hunters!")
PlayerRef.PlaceActorAtMe (hunter1, attackers).StartCombat(Game.GetPlayer())
if RandomInt() > 50
PlayerRef.PlaceActorAtMe (hunter2, attackers).StartCombat(Game.GetPlayer())
EndIf
if RandomInt() > 50
PlayerRef.PlaceActorAtMe (hunter3, attackers).StartCombat(Game.GetPlayer())
EndIf
if RandomInt() > 50
PlayerRef.PlaceActorAtMe (hunter4, attackers).StartCombat(Game.GetPlayer())
EndIf
;stormcloak or imeprial and visiting their cities?
ElseIf Game.GetPlayer().GetCurrentLocation().HasKeyword(StormCloaks) == True && (Game.GetPlayer()).IsInFaction(CWImperialFaction)
Debug.MessageBox("The StormCloaks Attack!")
PlayerRef.PlaceActorAtMe (Storm1, attackers).StartCombat(Game.GetPlayer())
if RandomInt() > 50
PlayerRef.PlaceActorAtMe (Storm2, attackers).StartCombat(Game.GetPlayer())
EndIf
if RandomInt() > 50
PlayerRef.PlaceActorAtMe (Storm3, attackers).StartCombat(Game.GetPlayer())
EndIf
if RandomInt() > 50
PlayerRef.PlaceActorAtMe (Storm4, attackers).StartCombat(Game.GetPlayer())
EndIf
ElseIf Game.GetPlayer().GetCurrentLocation().HasKeyword(ImperialLegion) == True && (Game.GetPlayer()).IsInFaction(CWSonsFaction)
Debug.MessageBox("The Imperial Legion Attacks!")
PlayerRef.PlaceActorAtMe (Imperial1, attackers).StartCombat(Game.GetPlayer())
if RandomInt() > 50
PlayerRef.PlaceActorAtMe (Imperial2, attackers).StartCombat(Game.GetPlayer())
EndIf
if RandomInt() > 50
PlayerRef.PlaceActorAtMe (Imperial3, attackers).StartCombat(Game.GetPlayer())
EndIf
if RandomInt() > 50
PlayerRef.PlaceActorAtMe (Imperial4, attackers).StartCombat(Game.GetPlayer())
EndIf
Else
;do bandits
Debug.MessageBox("You have been followed!")
PlayerRef.PlaceActorAtMe (Ambushers1, attackers).StartCombat(Game.GetPlayer())
if RandomInt() > 50
PlayerRef.PlaceActorAtMe (Ambushers2, attackers).StartCombat(Game.GetPlayer())
EndIf
if RandomInt() > 50
PlayerRef.PlaceActorAtMe (Ambushers3, attackers).StartCombat(Game.GetPlayer())
EndIf
if RandomInt() > 50
PlayerRef.PlaceActorAtMe (Ambushers4, attackers).StartCombat(Game.GetPlayer())
EndIf
;ambush ends
EndIf
EndIf
EndIf
EndIf
reset()
Ftravel.SetValueInt(0)
UpdateCurrentInstanceGlobal(Ftravel)
Time0.SetValue(GetCurrentHourOfDay())
UpdateCurrentInstanceGlobal(Time0)
Time1.SetValue(GetCurrentHourofDay())
UpdateCurrentInstanceGlobal(Time1)
Time2.SetValue(GetCurrentHourofDay())
UpdateCurrentInstanceGlobal(Time2)
EndEvent

ActorBase Property Ambushers1  Auto  

ActorBase Property Warlock  Auto  



float Function GetCurrentHourOfDay() 

float Time = Utility.GetCurrentGameTime()
Time -= Math.Floor(Time) ; Remove "previous in-game days passed" bit
Time *= 24 ; Convert from fraction of a day to number of hours
Return Time

EndFunction

Location Property EastmarchHoldLocation Auto 
Location Property FalkreathHoldLocation Auto 
Location Property HaafingarHoldLocation Auto 
Location Property HjaalmarchHoldLocation Auto 
Location Property PaleHoldLocation Auto 
Location Property ReachHoldLocation Auto 
Location Property RiftHoldLocation Auto 
Location Property WhiterunHoldLocation Auto 
Location Property WinterholdHoldLocation Auto 

Faction Property CrimeFactionEastmarch Auto 
Faction Property CrimeFactionFalkreath Auto 
Faction Property CrimeFactionHaafingar Auto 
Faction Property CrimeFactionHjaalmarch Auto 
Faction Property CrimeFactionPale Auto 
Faction Property CrimeFactionReach Auto 
Faction Property CrimeFactionRift Auto 
Faction Property CrimeFactionWhiterun Auto 
Faction Property CrimeFactionWinterhold Auto







ActorBase Property Ambushers2  Auto  

ActorBase Property Ambushers3  Auto  

ActorBase Property Ambushers4  Auto  

ActorBase Property Hunter1  Auto  

ActorBase Property Hunter2  Auto  

ActorBase Property Hunter3  Auto  

ActorBase Property Hunter4  Auto  

Faction Property CWImperialFaction  Auto  

Keyword Property ImperialLegion  Auto  

Faction Property CWSonsFaction  Auto  

ActorBase Property Imperial1  Auto  
ActorBase Property Imperial2  Auto
ActorBase Property Imperial3  Auto
ActorBase Property Imperial4  Auto
ActorBase Property Storm1  Auto  
ActorBase Property Storm2  Auto  
ActorBase Property Storm3  Auto  
ActorBase Property Storm4  Auto  

Cell Property Encounter1  Auto  

String Property Ambush1 = "Fight" Auto  

ObjectReference Property Fight  Auto  

GlobalVariable Property TravelReturnLoc  Auto  

Link to comment
Share on other sites

You could create an Xmarker (or any small invisible object) in the world somewhere, call it 'MyReturnTravel'.

 

Before you move the player to the fight, move MyReturnTravel to the player.

 

 

BTW, 'Import Alias' is doing nothing.

Import will only allow you to use the global functions in the imported script without the scriptname prefix.

GetLocation is a member function of Alias, and can't be used on an Actor, as the objects are different types.

Edited by tunaisafish
Link to comment
Share on other sites

Then wouldn't it be needed to create many Xmarkers to fit many fast travel possibilities? Plus it would probably required to make lists of possible Xmarkers found in the different Holds and on different itineraries (Whiterun-Falkreath, Whiterun-Solitude...) so the script could select the marker from appropriate lists...

What about seeing if it's not possible then to use the xmarkers already found on Tamriel? (but it would still require lists I guess)

 

Now I'm not a programmer, but I reply at least to propose ideas an up the post as I find this mod project very interesting.

 

Suggestion: add a check that increases the chances of attack if the player has a lot of gold on him! It would be immersive and when someone makes a bank mod at some point, it will make the bank even more interesting. And I'm sure someone will make a bank mod.

Link to comment
Share on other sites

The script worked great with the xmarker! Would never have tried that. Thanks. One more question? The ride back is facilitated by an activator box that has a script with the move command. Working great. But once the player is teleported out of the fighting area the bodies are not being removed, so on future fights they are there breaking immersion. Is there a simple way to delete them on exit or do I have to make custom attackers with scripts to disable and delete on death?

 

Respectfully

 

Tony

Link to comment
Share on other sites

I'd try simple first. In the activator script somewhere...

 

GetParentCell().Reset()

 

I've never tried that before, but from the docs it looks like it just sets a flag for resetting the cell on the next load.

So nothing should change while you're still there.

Link to comment
Share on other sites

Was worth trying, but it had no effect on the dead bodies. :facepalm: Is there a way to assign a script upon spawning a creature? That would be easier that customizing 50 spawns.
Link to comment
Share on other sites

It may sound very naive, but are you using casual Encounter bandits or creatures? I assume their dead bodies should disappear normally after a little time. Or do you use custom creatures?

 

May be a double post . Using the leveled list from the Ckit . Cannot wait for the game to clean bodies up, the area is used frquentky for combat. The bodies need to be gone within 5 minutes.

 

For now I am duplucating the nps and adding death scripts to delete the dead remains within 5 minutes.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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