Jump to content

[LE] Scripting Newb needs help (Script inside).


Pyrathas

Recommended Posts

I'm making a player home mod for Evil characters: Thrallmire Keep. The mod starts as a kill Necromancers quest, get Reward, go back, Accept the BYOH quest or refuse the power (fail). There are Prisoners in the Dungeon and a Boss. The Free prisoners are optional but here is the Kicker: Many switches only one frees them the others kill them (failed optional quest) Spawning Undead to swarm your only means of escape (evil laughter). Yes Later on a feature is given where if you killed a unique NPC, you have the option of having their remains brought to the crypt, and you resurrect them as thralls. So you are a Vampire? Great food source. Do you want guards and Servants? Here you go! Now assign them a task. Death is a Release, not a Punishment.

 

Any help with references for coding would be great as I am just learning to code and finally got the Main Mod Questline to work (Aside from the scenes) and the BYOH script to work. I'm trying to set up a scene where you see the Boss reanimate a dead corpse, then he summons undead that is lying on the ground to attack, in one scene, I got the Undead spawn to go on toggle, and the last scene is where the Former Master of the Keep, a Ghost named Micar the Corruptor asks you to rebuild the Keep in exchange for his secrets and the Power of the Keep (BYOH Questline). I can't seem to mirror the Valthume Opening scene...

 

So right now Im trying to make a mod where an NPC when equipping Shackles is restrained and ignores Faction enemies (Player) and when a player flips a switch the NPC is free.

 

Here is what I got so far:

 

I think I fixed it. But I can't compile in CK and yes checked scripts

Link to comment
Share on other sites

  • 2 weeks later...

ack I thought I added it.

 

Scriptname _PyrTKShackleScript extends ObjectReference

ObjectReference property Lever auto
ObjectReference Property BadLever Auto
ObjectReference property Shackle auto
ObjectReference Property Trap Auto
ObjectReference property akactivator auto
Quest Property _PyrTKQuest01 Auto
Actor Property akActor Auto

Int LeverPosition = 1
Int LeverPositionOld

bool property beenActivated auto hidden

 

Function SetRestrained(bool shouldBeRestrained)
Self.SetRestrained(shouldBeRestrained)
EndFunction

 

Function SetDefaultState(ObjectReference Akactivator)

If (LeverPosition == 1)
PlayAnimation("PullUp")
elseif (LeverPosition == -1)
PlayAnimation("PushUp")
endif
LeverPositionOld = LeverPosition
LeverPosition = 0

if Akactivator == Lever
UnlockShackle()
elseif Akactivator == BadLever
ActivateTrap()
endif
EndFunction

Function UnlockShackle()

if akactivator == Lever
If (LeverPosition == -1)
Shackle.SetOpen()
self.SetRestrained(false)
if _PyrTKQuest01.IsRunning()
if (_PyrTKQuest01.GetStageDone(30))
_pyrTKQuest01.SetObjectiveCompleted(55)
endif
endif
endif
endif
EndFunction


Function ActivateTrap()

if (LeverPosition == -1)
trap.enable()
if _PyrTKQuest01.IsRunning()
if (_PyrTKQuest01.GetStageDone(30))
if akActor.IsEssential()
akActor.KillEssential()
_PyrTKQuest01.SetObjectiveFailed(55)
endif
endif
endif
elseif(LeverPosition == 1)
Trap.IsDisabled()
endif

EndFunction

 

Event OnSit(ObjectReference furniture)
Self.SetRestrained(True)
EndEvent
Event OnLoad()
self.SetRestrained(True)
EndEvent

EVENT onActivate(objectReference akActivatingRef)
if akActivatingRef == BadLever
!beenActivated
beenActivated = TRUE
ActivateTrap()
elseif akActivatingRef == Lever
!beenActivated
beenActivated = TRUE
UnlockShackle()
endif
EndEvent

 

 

 

I'm trying to make a quest where the NPC (akactor) stays on the shackle and the Player has to choose which switch (lever) releases him and which switch kills him (badlever), If he dies the objective failed if he lives the objective succeeds.

 

I have more than one hostage and I am trying to use all of them with one switch. But first I want to get the one working, and second I do not know how to reference every NPC in game that activates it. When released they have a package where they "escape" the lair. But I do not know how to do activate an AI package on a script. I've searched the CK wiki for it.

 

I also want to try and make it where the levers are used to release or torture prisoners in the game (I am making it where you can resurrect NPCs you killed to torture but I haven't started that yet) after the quest is complete. That would be easy. just remove the Kill scripts).

Link to comment
Share on other sites

I guess what Im asking is where am I going wrong. It compiles but in my test cell it doesn't work the NPC attacks, and the traps don't kill or release

Link to comment
Share on other sites

Here is one problem:

EVENT onActivate(objectReference akActivatingRef)
              if akActivatingRef == BadLever
                 !beenActivated
                 beenActivated = TRUE
                 ActivateTrap()
             elseif akActivatingRef == Lever
                !beenActivated
                beenActivated = TRUE
               UnlockShackle()
           endif
EndEvent

In the OnActivate event the passed in variable akActivatingRef (akActionRef in stock scripts) is the object reference that activated the object holding the script. In otherwords, you are comparing the player or an NPC to your levers. They obviously don't match and thus halts the script.

Link to comment
Share on other sites

Here is one problem:

EVENT onActivate(objectReference akActivatingRef)
              if akActivatingRef == BadLever
                 !beenActivated
                 beenActivated = TRUE
                 ActivateTrap()
             elseif akActivatingRef == Lever
                !beenActivated
                beenActivated = TRUE
               UnlockShackle()
           endif
EndEvent
In the OnActivate event the passed in variable akActivatingRef (akActionRef in stock scripts) is the object reference that activated the object holding the script. In otherwords, you are comparing the player or an NPC to your levers. They obviously don't match and thus halts the script.

So it should be akActionRef?

Link to comment
Share on other sites

Here is one problem:

EVENT onActivate(objectReference akActivatingRef)
              if akActivatingRef == BadLever
                 !beenActivated
                 beenActivated = TRUE
                 ActivateTrap()
             elseif akActivatingRef == Lever
                !beenActivated
                beenActivated = TRUE
               UnlockShackle()
           endif
EndEvent
In the OnActivate event the passed in variable akActivatingRef (akActionRef in stock scripts) is the object reference that activated the object holding the script. In otherwords, you are comparing the player or an NPC to your levers. They obviously don't match and thus halts the script.
So it should be akActionRef?

Doesn't matter if you call the variable akActionRef, akActivatingRef, or TheGuyWhoYankedTheLever.

 

The problem is that the variable contains the object reference of the actor that activated the activator. To break it down, your script is basically saying this:

If the player character is the same thing as this lever then do this stuff otherwise do nothing.

The result is, your script does nothing.

 

If the script is on the lever(s), try comparing to self instead. i.e.

If self == lever
;do stuff
EndIf
Link to comment
Share on other sites

  • Recently Browsing   0 members

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