Jump to content

DOWNLOAD MODS

Are you looking for something shiny for your load order? We have many exclusive mods and resources you won't find anywhere else. Start your search now...

LEARN MODDING

Ready to try your hand at making your own mod creations? Visit the Enclave, the original ES/FO modding school, and learn the tricks of the trade from veteran modders...

JOIN THE ALLIANCE

Membership is free and registering unlocks image galleries, project hosting, live chat, unlimited downloads, & more...

[SKY] Scripting help concerning Movable Statics and the .PlaceAtMe() Function


TripleSixes
 Share

Recommended Posts

Trying to make a mock version of runescape's fire making skill using scripting.

Scriptname RS_Item_TinderBoxScript Extends ObjectReference
{Script for Tinder Box}

Message Property RS_Message_LogType Auto
MiscObject Property RS_Item_Logs_Logs Auto
ObjectReference Property Campfire01Landburning Auto
Weapon Property RS_Item_TinderBox Auto

Int LogType

Event OnEquipped(Actor akActor)
    If akActor == Game.GetPlayer()
        ExitMenu()
        LogType = RS_Message_LogType.show()
        If LogType == 0;Logs
            Int LogCount = Game.GetPlayer().GetItemCount(RS_Item_Logs_Logs)
            If LogCount >= 1
                Game.GetPlayer().RemoveItem(RS_Item_Logs_Logs, 1, True)
                Game.GetPlayer().PlaceAtMe(Campfire01Landburning)
            EndIf
        ElseIf LogType == 1;Oak
        ElseIf LogType == 2;Willow
        ElseIf LogType == 3;Maple
        ElseIf LogType == 4;Yew
        ElseIf LogType == 5;Magic
        EndIf
    EndIf
    Game.GetPlayer().UnEquipItem(RS_Item_TinderBox, 0)
    Game.GetPlayer().UnEquipItem(RS_Item_TinderBox, 1)
EndEvent

Function ExitMenu()
Game.DisablePlayerControls(false, false, false, false, false, true, false)
utility.wait(0.1)
Game.EnablePlayerControls(false, false, false, false, false, true, false)
EndFunction



The script is firing according to the logs... the Campfire is simply not being placed. Properties are set up correctly, script compiles fine, message executes cleanly alongside the exit menu function. I added some waits to see if it needed more time to place the object, but no dice.

Anybody have a clue about what i'm doing wrong here? I wish moveable statics were form-types, things would be so much simpler than having to have a dumb-reference in a dummy-cell.

 

Link to comment
Share on other sites

I'm still new to scripting, but have you also tried this : 


Campfire01Landburning.moveTo(game.getPlayer() as objectreference, 0.000000, 0.000000, 0.000000, true)
	Campfire01Landburning.setAngle(0.000000, 0.000000, 0.000000)
	Campfire01Landburning.enable(false)
Link to comment
Share on other sites

From the CK Wiki: "Note: the akFormToPlace can be things such as MiscItem, Actor, ActorBase, etcetera, but it cannot be an ObjectReference." You need to cast the ObjectReference as a MiscItem before giving it to PlaceAtMe.

 

Edit: Also, I see you're making a lot of calls to Game.GetPlayer(). I think the script would be more efficient and faster if you made it a property that you can autofill and used that instead of repeated function calls. E.g.:

Actor Property PlayerREF Auto

Or make a variable and do one call to Game.GetPlayer() to fill it, then use the variable.

Edited by BrettM
Link to comment
Share on other sites

The casting of a ObjRef is not possible to a MiscObj sadly, tried casting it to a Static as well, no dice.

Nalfeyn's suggestion worked... but now I have a new problem, the objref I wanted to place has been moved, i need duplicates. Is there a way to make duplicates and still use .moveto?

Link to comment
Share on other sites

You can simply place your campfire in a dummycell, with a xmarker.

So you can send back the campire to the xmarker in the dummy cell, when the event is called a second time. 

For example : 

function sendcamppirebacktodummycall ()
	Campfire01Landburning.moveTo(campfirexmarker)
	Campire01Landburning.setangle(0.000000, 0.000000, 0.000000)
	Campire01Landburning.enable(false)
endFunction

Event OnEquipped(Actor akActor)
    If akActor == Game.GetPlayer()
        ExitMenu()
        LogType = RS_Message_LogType.show()
        If LogType == 0;Logs
            Int LogCount = Game.GetPlayer().GetItemCount(RS_Item_Logs_Logs)
            If LogCount >= 1
                Game.GetPlayer().RemoveItem(RS_Item_Logs_Logs, 1, True)
                sendcampfirebacktodummycell ()
				Campfire01Landburning.moveto(get.player() as objectreference, 0.000000, 0.000000, 0.000000., true)
				Campfire01Landburning.setAngle(0.000000, 0.000000, 0.000000)
				Campfire01Landburning.enable(false)
            EndIf
        ElseIf LogType == 1;Oak
        ElseIf LogType == 2;Willow
        ElseIf LogType == 3;Maple
        ElseIf LogType == 4;Yew
        ElseIf LogType == 5;Magic
        EndIf
    EndIf
    Game.GetPlayer().UnEquipItem(RS_Item_TinderBox, 0)
    Game.GetPlayer().UnEquipItem(RS_Item_TinderBox, 1)
EndEvent

Edited by Nalfeyn
Link to comment
Share on other sites

I just went into the game, open the console, and entered player.placeatme 35f47. I got a campfire01landburning right at my feet. The console uses the same functions used in scripts, compiling them on the fly, so I guarantee there is a way to do it with a script if I can do it with the console. Since you already have an ObjectReference property pointing to the campfire, all you need is to get the BaseID for it as a type that PlaceAtMe will accept as an argument.

Form CampfireBase   ; Variable for the ID of the object

CampfireBase = Campfire01LandBurning.GetBaseObject()  ; Should return 35f47 as the base form ID
PlayerRef.PlaceAtMe(CampfireBase)  ; Function should be happy with a Form argument

I think that will do the trick for you.

Link to comment
Share on other sites

That worked out nicely BrettM, I'm on the right track now. The problem is that the campfire is placed a bit too high, so i tried using getPostion and setPosition to fix this, but I can't get the script to compile... any idea what I may be doing wrong?

Scriptname RS_Item_TinderBoxScript Extends ObjectReference
{Script for Tinder Box}
 
Message Property RS_Message_LogType Auto
MiscObject Property RS_Item_Logs_Logs Auto
ObjectReference Property LitLogs Auto
Weapon Property RS_Item_TinderBox Auto
 
Form LitLogs
Int LogType
Actor PlayerRef
 
Event OnEquipped(Actor akActor)
If akActor == Game.GetPlayer()
PlayerRef = Game.GetPlayer()
ExitMenu()
LogType = RS_Message_LogType.show()
If LogType == 0;Logs
Int LogCount = PlayerRef.GetItemCount(RS_Item_Logs_Logs)
If LogCount >= 1
PlayerRef.RemoveItem(RS_Item_Logs_Logs, 1, True)
Form LitLogsBase = LitLogs.GetBaseObject()
PlayerRef.PlaceAtMe(LitLogsBase)
Float X = PlayerRef.GetPositionX()
Float Y = PlayerRef.GetPositionY()
Float Z = PlayerRef.GetPositionZ()
Float ModZ = (Z - 20.0)
LitLogsBase.SetPosition(X,Y,ModZ)
EndIf
ElseIf LogType == 1;Oak
ElseIf LogType == 2;Willow
ElseIf LogType == 3;Maple
ElseIf LogType == 4;Yew
ElseIf LogType == 5;Magic
EndIf
EndIf
PlayerRef.UnEquipItem(RS_Item_TinderBox, 0)
PlayerRef.UnEquipItem(RS_Item_TinderBox, 1)
EndEvent
 
Function ExitMenu()
Game.DisablePlayerControls(false, false, false, false, false, true, false)
utility.wait(0.1)
Game.EnablePlayerControls(false, false, false, false, false, true, false)
EndFunction

Compiler Error:
SetPosition is not a function or does not exist.
Link to comment
Share on other sites

To begin with, you don't want to try setting the position on the BaseID, you want to set the position of the copy that you just spawned using PlaceAtMe. What if you had five fires? The BaseID refers to a form that has no existence. SetPosition is a function of an ObjectReference, not a Form.

 

Lucky for you, the PlaceAtMe will give you the ObjectReference ID of the item it made.

ObjectReference MyLitLogs

MyLitLogs = PlayerRef.PlaceAtMe(LitLogsBase, 1, false, true)  ; Keep the logs disabled (invisible) until they're in position

MyLitLogs.MoveTo(PlayerRef, 0.0, 0.0, PlayerRef.GetHeight() - 35.0)  ; Put the logs on the ground where the player is standing

MyLitLogs.Enable()  ; Use Enable(true) if you want the fire to fade in instead of popping in.

If the player will always be standing on level ground, you might want to give the fire a little X and Y offset instead of 0.0, so he doesn't get a hotfoot. If you like, you can use MyLitLogs.SetPosition(X, Y, ModZ), but using MoveTo means you don't need all the variables and function calls to GetPosition. MoveTo will do the calculations for you.

 

You know, all of this information is in the Papyrus reference material on the CK Wiki, which gives examples and comments on every script and function available. I would recommend that you bookmark this reference. If the compiler doesn't like a function, it may be quicker to look at the function description there and see what you may be overlooking than it is to post a question and wait for an answer.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...