Jump to content

[LE] Problem with Workers :c ! - Help [3]


Recommended Posts

Hey... i have problem xD

and i don't even except answer in this topic cause i need something very hard to do :P

 

well easy in UE or C++ or Java but insane in CK xD

- Maybe cause of my knowledge in CK :P

 

 

ok... now im working on Production building in my Mod and...

Player in one building can Buy Space for Workers for example

House have 3 Loding for 3 Workers

 

and those 3 Spaces for workers can be spend for ppl who do one of possible jobs

for example:

- Guard ( our produciton buildings may be attacked )

( about this i will create new Topic soon cause all i can do is Spawn Enemy unit on XMarker :P )

- Miner ( working in Mine :P )

- Hunter ( worknig in Forest )

- Craftmaster ( making Special Items )

 

And for example we want to have 1 Guard and 2 Miners

Player choice NPC and send them to work...

 

i know i can use AiPackages to do it but normaly i was doing only

Packages to Simulate NPC Living in World

 

Static Packages are not so hard like "Dynamic" Packages :P

 

 

 

Any idea how can i do it ? :P

Link to comment
Share on other sites

Sry 4 Double post but i want answer :tongue:

and im not sure Forum will show evey1 this Topic as Unreaded if i only edit it :tongue:

 

 

cause my ideas are pretty stupid so probably no1 can help me so i was looking all time for help

and i think i can do it by script... woho its gonna be long script xD

 

but i found something like this:

https://www.creationkit.com/index.php?title=MoveToPackageLocation_-_Actor

 

and LOL GJ to sm1 who write those tutorials... they are so useless...

Copy Paste from CK Wiki...

Syntax
Function MoveToPackageLocation() native
Parameters
None.

Return Value
None.

Examples
; Enable JonPaul and move him immediately to the location for his current package.
; Note that the Enable has to come first.
JonPaul.Enable()
JonPaul.MoveToPackageLocation()
Notes
This is mainly intended for use immediately after Enable, in cases where we want an actor to appear at its package location, rather than its editor location.

But WHY i have to Enable NPC first?

im gonna break Game again if i use MoveToPackageLocation without Enable b4?

 

xD

cause i don't wanna break my mod again T_T

most of my mods crash my game from time to time xD

 

cause of my stupid function uses :D

 

btw. im still not sure why should i use Mod Instead of SetValue but ok... im using Mod you Forum told me to use Mod xD

lol xDDDD

 

 

//Edit:

this Creation Kit Wiki is INSANE good... wow

 

6 almost empty lines = good tutorial

 

//Edit2:

this what i paste on top of this post i WHOLE PAGE of Creation Wiki...

w8... that 14 lines of text including Note , Example , Syntax etc.

Edited by TobiaszPL
Link to comment
Share on other sites

The CK wiki pages are not, generally, intended as tutorials; they're meant as reference pages once you've got a handle on things, not to teach you all the bits. Unless they actively say 'tutorial', at least.

 

In your example, the actor needs to be enabled first, because disabled actors don't run packages, and so trying to move it to its package location is referring to a thing that doesn't exist.

 

 

As for the OP, what you'd want could be a Quest or set of Quests with aliases, three for each job type. You can use those aliases to add the appropriate Packages to any actor that fills them, which you would control through scripts, presumably triggered by dialogue.

 

Alternatively, you could just have three aliases, one for each worker, and have the full set of packages added to each one. Then, set up factions for each job you want (Miner, Guard, etc), condition the packages so that they only run if the worker is in the appropriate faction, and control what factions each has by script.

Link to comment
Share on other sites

** Skip to Short Version PLS ! **

or read idc xD

 

 

Nah... im writing Worker Engine :)

 

im not good with Quests and all i can do in quest is

" Go here " " Kill Him " " Find This "

 

but with scripts im much better... lel xD

i just was w8ing too long :P

 

 

 

but here is my other Question... how about Script Attached to NPC with RegisterForSingleUpdateGameTime?

 

normaly i was using UnregisterForUpdateGameTime on Event OnCellDetach

and hope it was stoping this RegisterForSiggoings ....

 

 

but if i left NPC with this Script it will be fine?

 

and other Question... what if any player got perfect idea to make 1000 workers?

we will have 1000 scripts refreshing each hour... it may crash game? :P

 

event better cause i want to add little Sims in Skyrim :)

so NPC will become Hungry Thrist Tired etc. so they will go back to home if needed :P

 

also they will earn gold from player for work so yeee...

 

registerfor 30 sec update may be bad idea :P

but best option xD i can move NPCs without AiPackages and im gonna try it :D !

 

 

this would be INSANE great idea if NPC have to keep his stats in good state even better if he have Family :D wow

and also FINALY WORKING TRADING SYSTEM XD

not only Player Buy / Sell stuff but NPC too :D

 

lel... that only one part of my mod :)

maybe thats why my mods always crash game xD

 

but no1 is hurt cause only 100/200 ppl are allowed to download my mods and then its deleted so i dont care about crashes xD

sometimes even faster admins delete my mods xDDDD

 

 

 

sry 4 my potato english xD

 

 

ok Short version:

1) Register for Update, how about this? safe with 200+ W8ing Updates each 30 sec?

2) Event OnUpdate() will work even if player is not in cell ? or in this same world ?

Link to comment
Share on other sites

You asked: "Event OnUpdate() will work even if player is not in cell ? or in this same world ?"

YES! That makes it complicated to find out, why (the hell) game is sometimes crashing immediately after player is fast travelling.

 

About your first posting, I absolutely agree with foamyesque: "the actor needs to be enabled first, because disabled actors don't run packages, and so trying to move it to its package location is referring to a thing that doesn't exist."

 

next file is part of quest MS11, if you read the code, you'll see there is no enable before, that could be the reason why this quest is so squishy.

MS11CheatStalkTriggerScript

 

Scriptname MS11CheatStalkTriggerScript extends ObjectReference  

Quest Property MS11 auto
Scene Property MS11KillScene auto

ReferenceAlias Property Calixto auto
ReferenceAlias Property Victim auto


Event OnTriggerEnter(ObjectReference akActivator)
    if (akActivator == Game.GetPlayer() && (MS11 as MS11QuestScript).SiegeOfWindhelmTakingPlace == False)
        if (MS11KillScene.IsPlaying())
            Calixto.GetActorReference().MoveToPackageLocation()
            Victim.GetActorReference().MoveToPackageLocation()
        endif
    endif
EndEvent

 

 

 

anothe sample is a Hearthfire script:

BYOHKidsAttendWeddingMarker original

 

Scriptname BYOHKidsAttendWeddingMarker extends ObjectReference
{Script on a marker in the Temple of Mara. Make sure adopted children attend the players wedding and return home safely.}

Quest property BYOHRelationshipAdoption Auto
ReferenceAlias property Child1 Auto
ReferenceAlias property Child2 Auto
Quest property RelationshipMarriageWedding Auto
ReferenceAlias property PlayerWitness01 Auto
ReferenceAlias property PlayerWitness02 Auto
ObjectReference property PlayerWitnessMarker02 Auto
ObjectReference property PlayerWitnessMarker03 Auto
bool kidsMovedForCeremony = False

Event OnCellAttach()
    ;Is the player about to get married?
    if (RelationshipMarriageWedding.GetStage() >= 10 && RelationshipMarriageWedding.GetStage() < 200)
        ;Debug.Trace("It's your Wedding Day!")
        ;Does the player have children?
        if (BYOHRelationshipAdoption.IsRunning())
            ;Debug.Trace("Your kids are coming to your Wedding! How nice!")
            ;If the player has adopted a child, force them into the PlayerWitness01 alias. Kick the old Witness03 back to their regularly-scheduled behavior.
            Actor oldWitness = PlayerWitness01.GetActorRef()
            PlayerWitness01.ForceRefTo(Child1.GetActorRef())
            PlayerWitness01.GetActorRef().MoveTo(PlayerWitnessMarker02)
            PlayerWitness01.GetActorRef().EvaluatePackage()
            PlayerWitness01.GetActorRef().Disable()
            PlayerWitness01.GetActorRef().MoveToPackageLocation()
            PlayerWitness01.GetActorRef().Enable()
            PlayerWitness01.GetActorRef().EvaluatePackage()
            if (PlayerWitness01.GetActorRef().GetAV("Variable07") > 0)
                if (PlayerWitness01.GetActorRef().GetAV("Variable07") == 6 || PlayerWitness01.GetActorRef().GetAV("Variable07") == 7)
                    (BYOHRelationshipAdoption as BYOHRelationshipAdoptionScript).BreakNameCalling(False, None)
                Else
                    PlayerWitness01.GetActorRef().SetAV("Variable07", 0)
                EndIf
                (BYOHRelationshipAdoption as BYOHRelationshipAdoptionScript).ForcegreetEventReady = False
            EndIf
            if (oldWitness != None)
                ;Debug.Trace("Child1 displaces " + oldWitness)
                oldWitness.MoveToMyEditorLocation()
                oldWitness.MoveToPackageLocation()
                oldWitness.EvaluatePackage()
            EndIf
            ;If the player has adopted two children, force the second child into the PlayerWitness02 alias. Kick the old Witness02 back to their regularly-scheduled behavior.\
            if (Child2.GetActorRef() != None)
                oldWitness = PlayerWitness02.GetActorRef()
                PlayerWitness02.ForceRefTo(Child2.GetActorRef())
                PlayerWitness02.GetActorRef().MoveTo(PlayerWitnessMarker03)
                PlayerWitness02.GetActorRef().EvaluatePackage()
                PlayerWitness02.GetActorRef().Disable()
                PlayerWitness02.GetActorRef().MoveToPackageLocation()
                PlayerWitness02.GetActorRef().Enable()
                PlayerWitness02.GetActorRef().EvaluatePackage()
                if (PlayerWitness02.GetActorRef().GetAV("Variable07") > 0)
                    PlayerWitness02.GetActorRef().SetAV("Variable07", 0)
                EndIf
                if (oldWitness != None)
                    ;Debug.Trace("Child1 displaces " + oldWitness)
                    oldWitness.MoveToMyEditorLocation()
                    oldWitness.MoveToPackageLocation()
                    oldWitness.EvaluatePackage()
                EndIf
            EndIf
            ;Schedule the children to move back home when possible.
            kidsMovedForCeremony = True
        EndIf
    EndIf
EndEvent

Event OnCellDetach()
    if (kidsMovedForCeremony)
        Debug.Trace("Now queuing move to: " + (BYOHRelationshipAdoption as BYOHRelationshipAdoptionScript).newHome)
        (BYOHRelationshipAdoption as BYOHRelationshipAdoptionScript).QueueMoveFamily((BYOHRelationshipAdoption as BYOHRelationshipAdoptionScript).newHome, True)
    EndIf
EndEvent

 

 

 

BYOHKidsAttendWeddingMarker changed a bit

 

Scriptname BYOHKidsAttendWeddingMarker extends ObjectReference
{v1.4a ReDragon 2019}    ; runs on a marker in the Temple of Mara.
; Make sure adopted children attend the players wedding and return home safely.

; https://www.creationkit.com/index.php?title=MoveToPackageLocation_-_Actor

  Quest PROPERTY BYOHRelationshipAdoption    auto
  Quest PROPERTY RelationshipMarriageWedding auto

  ReferenceAlias PROPERTY Child1 auto
  ReferenceAlias PROPERTY Child2 auto
  ReferenceAlias PROPERTY PlayerWitness01 auto
  ReferenceAlias PROPERTY PlayerWitness02 auto

  ObjectReference PROPERTY PlayerWitnessMarker02 auto
  ObjectReference PROPERTY PlayerWitnessMarker03 auto

  Bool kidsMovedForCeremony = False            ; [default=False]


; -- EVENTs -- 2

EVENT OnCellAttach()
IF BYOHRelationshipAdoption.IsRunning()
ELSE
    RETURN    ; - STOP -    player does not have children
ENDIF
;---------------------
    int i = RelationshipMarriageWedding.GetCurrentStageID()

IF (i < 10) || (i >= 200)
    RETURN    ; - STOP -    player is not ready to get married /or/ already married
ENDIF
;---------------------
    myF_Action()
    kidsMovedForCeremony = TRUE        ; Schedule the children to move back home when possible.
ENDEVENT


EVENT OnCellDetach()
IF ( kidsMovedForCeremony )
    BYOHRelationshipAdoptionScript ps = BYOHRelationshipAdoption as BYOHRelationshipAdoptionScript
    ps.QueueMoveFamily(ps.newHome, TRUE)
ENDIF
ENDEVENT


; -- FUNCTIONs -- 2

;--------------------
FUNCTION myF_Action()
;--------------------
    actor aRef                                                ;* aRef = oldWitness
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
; If the player has adopted a child, force them into the PlayerWitness01 alias.
; Kick the old Witness01 back to their regularly-scheduled behavior.
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

    aRef = PlayerWitness01.GetActorReference()                ; **  store current Ref of Witness01
    PlayerWitness01.ForceRefTo( Child1.GetReference() )
    myF_Move(PlayerWitness01, PlayerWitnessMarker02, 1)

    IF ( aRef )
        ; instruction order has been changed by ReDragon 2019/04/01
        aRef.MoveToMyEditorLocation()       ; 1
        aRef.EvaluatePackage()              ; 3
        aRef.MoveToPackageLocation()        ; 2
    ENDIF

;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
; If the player has adopted two children, force the second child into the PlayerWitness02 alias.
; Kick the old Witness02 back to their regularly-scheduled behavior.
;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
IF Child2.GetActorReference()
ELSE
    RETURN    ; - STOP -    player does not have a second child adopted
ENDIF
;---------------------
    aRef = PlayerWitness02.GetActorReference()                ; **  store current Ref of Witness02
    PlayerWitness02.ForceRefTo( Child2.GetReference() )
    myF_Move(PlayerWitness02, PlayerWitnessMarker03, 2)

    IF ( aRef )
        ; instruction order has been changed by ReDragon 2019/04/01
        aRef.MoveToMyEditorLocation()       ; 1
        aRef.EvaluatePackage()              ; 3
        aRef.MoveToPackageLocation()        ; 2
    ENDIF
ENDFUNCTION

;----------------------------------------------------------------
FUNCTION myF_Move(ReferenceAlias RA, ObjectReference mRef, Int i)
;----------------------------------------------------------------
    actor aRef = RA.GetActorReference()        ; child1 or child2

; instruction order has been changed by ReDragon 2019/04/01
    aRef.Disable()                           ; 3
    aRef.MoveTo(mRef)                        ; 1
    aRef.Enable()                            ; 5
    aRef.EvaluatePackage()                   ; 2
    aRef.MoveToPackageLocation()             ; 4
    aRef.EvaluatePackage()                   ; 6  maybe this is useless here !?

    float f = aRef.GetActorValue("Variable07")
;---------------------
IF (f <= 0)
    RETURN    ; - STOP -    special actor value of children is already Zero or negative
ENDIF
;---------------------
IF (i == 1)
ELSE
    aRef.SetActorValue("Variable07", 0)
    RETURN    ; - STOP - child02
ENDIF
;--------------------- child01 from here
    IF (f == 6) || (f == 7)
        (BYOHRelationshipAdoption as BYOHRelationshipAdoptionScript).BreakNameCalling(False, None)
    ELSE
        aRef.SetActorValue("Variable07", 0)
    ENDIF
    (BYOHRelationshipAdoption as BYOHRelationshipAdoptionScript).ForcegreetEventReady = False
ENDFUNCTION

 

 

Edited by ReDragon2013
Link to comment
Share on other sites

Quests don't need to be actual quests; they're used to do all sorts of other things.

 

Aliases are by far the most flexible, fastest, and most powerful way to find objects in Skyrim. They're also the safest way to modify things, such as by adding scripts to them or altering the package stack of actors. They're a very potent tool.

Edited by foamyesque
Link to comment
Share on other sites

I don't know how to use Quests...

All i can do with Quests are most simple things like go here kill him etc.

 

 

 

Why my spell activate OnHit Event 2 times in 1 shot ? xD

 

OnHit fires a lot. It will trigger for anything hitting the object (a spell projectile, a weapon hit, etc), and then for each and every magic effect applied as a result. Concentration spells will do this every tick. What you're seeing is one event from the spell hitting, and another from the magic effect hitting.

 

As far as quests go, what I'm saying is: It's something worth learning about because it will let you do a lot of useful things.

Edited by foamyesque
Link to comment
Share on other sites

Bfff...

 

Script:

 

 

State WaitForPlayer
	Event OnHit( ObjectReference QAgr, Form QSrc, Projectile QPro, bool IsPower, bool IsSneak, bool IsBash, bool IsBlock)
		If ( ( QAgr != QPlayer ) || ( QSrc != QSpell ) )
			Return		; Return :: Bad Spell or Caster
		ElseIf ( IsYour )
			ShowMainMenu()
			Return
		Else
			Int QReturn = QBuyMenu.Show( MyCost )
			If( QReturn == 0 )
				QPlayer.RemoveItem( GoldRef , MyCost )
				IsYour = true
			EndIf
		EndIf
	EndEvent
EndState 

 

 

its nooooooooooo ohh w8...

i have idea... but can't test it so il will just ask xD

 

MagicEffect and Spell can be casted at same time???

 

maybe Magic effect cast his OnHit effect

and Spell cast his OnHit effect xD idk

 

So maybe

If ( ( QAgr != QPlayer ) || ( QSrc != QSpell as Spell ) )

will work... but like i said can't test it now xD

 

//Edit:

lel now reading this script i see another misstake xD

what if player don't have enough gold ? :P hehe xD

Edited by TobiaszPL
Link to comment
Share on other sites

Do not think so complicated, make it short and simple.

your sample as follow:

  MiscObject PROPERTY Gold  auto
  Spell   PROPERTY mySpell  auto
  Message PROPERTY QBuyMenu auto

  Int  PROPERTY myCost = 100 auto    ; [default=100]
  Bool IsYour = False


; -- FUNCTION --

;----------------------
FUNCTION ShowMainMenu()
;----------------------
ENDFUNCTION


;=============================
State WaitForPlayer
;==================
EVENT OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, Bool IsPower, Bool IsSneak, Bool IsBash, Bool IsBlock)
;IF (akSource as Spell)
IF (akSource == mySpell as Form)
ELSE
    RETURN    ; - STOP - /1    not affected by this spell (property declaration)
ENDIF
;---------------------
IF (akAggressor == Game.GetPlayer() as ObjectReference)
ELSE
    RETURN    ; - STOP - /2    was not hit by the player
ENDIF
;---------------------
IF ( IsYour )
    ShowMainMenu()
    RETURN    ; - STOP - /3
ENDIF
;---------------------
IF (akAggressor.GetITemCount(Gold) < myCost)
    Debug.Notification("Not enough gold!")
    RETURN    ; - STOP - /4
ENDIF
;---------------------
    IF (QBuyMenu.Show(myCost) == 0)    ; Zero depends on options [Yes/No] or [No/Yes], one has 0 the other has 1 as return value, that you need
        IsYour = TRUE
        akAggressor.RemoveItem(Gold, myCost)
    ENDIF
ENDEVENT             ; /5
;=======
endState
Edited by ReDragon2013
Link to comment
Share on other sites

  • Recently Browsing   0 members

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