Jump to content

Spawning mob on trigger?


GermainZ

Recommended Posts

Sinderion, tried your script, here's what I got:

IsDead is not a property on script objectreference or one of its parents

Enable is not a property on script objectreference or one of its parents

 

I've also tried defining it first, didn't work:

ObjectReference linkedRef1 = self.GetNthLinkedRef(1)

if linkedRef1.IsDead

self.GetNthLinkedRef(4).Enable

endif

Link to comment
Share on other sites

Ah, that would probably work.

 

Can I do something like this instead (I'm using Enc actors, so I suppose it's fine to place this script on each one of them)

 

Event OnDeath(Actor akKiller)
      IncrementDeathCount()
      ;3 is the number of enemies in this wave
      if DeathCount > 3
            DeathCount = 0
            Debug.Trace("Next wave in 20 seconds; it will not begin until you re-enter")
            Utility.Wait(20)
            ;this will keep checking until the player is positioned in the room (i used random values, but you get the point)
            while not(50<Game.GetPlayer().GetPositionY()<60) and not(50<Game.GetPlayer().GetPositionX()<60)
            endwhile
            XMarker2.Enable
      endif
endEvent

 

 

I probably got the variables wrong, as well as some syntax errors inspired by basic. I'd be grateful for anyone who could fix the script, if it's actually a reasonable way.

Edited by GermainZ
Link to comment
Share on other sites

I decided to just F it and do it up right. I've been working with encounters a lot for my thieves mod I'm gonna be putting out here shortly anyways. I've got a great script going, it works flawlessly to two phases and threw me a curveball for the third. Could be that I set up the objects wrong, I have a feeling it's in my basic math logic though lol. It's probably obvious right in the script we'll see. I've been messing with it longer than I should have already lol I've gotta go for now, here it is if there's something obvious wierd. For some reason my current phase variable ends up 4, when it should be 3 for phase 3, and after the three adds from phase 2 are dead, the phase two portcullis is activated for some reason, as if it's trying to activate phase 2 again. Maybe this is what happens when you call GetNthLinkedRef(4) when there are only three? oooh crap.. I just realized it's cause i was marking phases starting at 1, but the nthlinkedref function starts at 0. Ok I'm a dumbass, but I don't have time to retest it just now, here's the unmodified version. Follow instructions at the top if you want to test it out, I was commenting on the go, hope it's not to vague. Adds are initially disabled as well of course, In step 1 "point to" means set the script property of the helper script attached to an add to point to:

 

 

 


Scriptname DefaultMultiPhaseAddsScript extends ObjectReference  
{ Script for phase control markers on multi phase add based encounter }

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;Simple script for controlling multi phase encounters

;Setup:
; Link a series of xMarkerActivators in a chain. Place this script on each. Activate the first xMarkerActivator in the chain 
; with a trigger or whatever to start the ball rolling.
; 
; For each phase you need to do the following.
; 1. Setup each add to point to the marker that controls it's phase.
; 2. Setup each add to reference an Xmarker as it's enable parent. Set said XMarker as 'Initially disabled'
; 3. Point the phases xMarkerActivator properties to their respective objects. Activator to the door, enablemarker
;     to the enable XMarker, number of adds to the number of adds it has associated.(I may automate this variable later)

; That should do it. When triggered, each xMarkerActivator(Including the starting one) will, in sequence, activate it's activator, enable it's adds, 
;   and move on to the next phase.


Int Property NumberofAdds auto
{
MANDATORY: Set the number of adds this marker should track
}

ObjectReference Property MyEnableMarker auto
{
MANDATORY: Set this property to the enable marker for this phase.
}

ObjectReference Property MyActivateChild auto
{
Optional: Set this to activate this object when the phase is started, like a portcullis or door.
}

ObjectReference Property VictoryActivator auto
{
Optional: Set only for master marker(first in the chain, activated by trigger). Object to activate upon completion of encounter, like a portcullis.
}


Int iDeadAdds              		;For tracking adds that report in dead
Int iNumberofPhases 	 	;Derived number of phases from link chain
Int iCurrentPhase			;Phase tracker Variable
ObjectReference obMasterMarker		;Marker that's in charge
ObjectReference obCurrentPhaseMarker	;Marker who's phase we're currently running only used by master marker


Event OnActivate(ObjectReference akActor)

	;Count number of phases, so we know when we've won
iNumberofPhases = CountLinkedRefChain(maxExpectedLinkedRefs = 10)
debug.Notification(iNumberofPhases + " phases found.")
	;Start off with our own phase.
iCurrentPhase = 1
ExecutePhase(self)
EndEvent


int function ExecutePhase(ObjectReference obMaster)
;Open my door
obMasterMarker = obMaster
MyActivateChild.Activate(Self)
;Enable my wolves
MyEnableMarker.Enable()
;this then passes control to waiting for enough dead adds to report in
endfunction


;Function for other phasecontrollers to call home.
;Sets up next phasemarker, makes call to execute next phase.

int function ReportPhaseComplete()
		
if iCurrentPhase <= iNumberofPhases
	iCurrentPhase += iCurrentPhase
	Debug.Notification("Phase " + iCurrentPhase + " incomming!")
	;update current phase marker	
	obCurrentPhaseMarker = GetNthLinkedRef(iCurrentPhase)
	(obCurrentPhaseMarker as DefaultMultiPhaseAddsScript).ExecutePhase(self)
else
	debug.notification("You Win! After " + (iCurrentPhase) + "Phases!")
	VictoryActivator.Activate(self)
endif
endfunction

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;Function for adds to report to when they die
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
int function ReportDead()
	iDeadAdds += 1
	debug.Notification("Something reported back! " + iDeadAdds + " adds dead so far!")
	if iDeadAdds >= NumberofAdds ;If that's all dead we need
		;Report to the master marker, cast appropriately
      		(obMasterMarker as DefaultMultiPhaseAddsScript).ReportPhaseComplete()
	endif
endfunction

 

The helper script that goes on the adds:

 


Scriptname MultiPhaseAddHelperScript extends ObjectReference  
{Attached to adds for use with DefaultMultiPhaseAddsScript }

ObjectReference Property PhaseMarker auto
{
MANDATORY: Set this adds phase marker so it knows when to go.
}



Event OnDeath(Actor AkKiller)
(PhaseMarker as DefaultMultiPhaseAddsScript).ReportDead()
EndEvent

 

 

 

Nice and generic and widely usable. Not a quest involved at all. So long as it ends up working I think I like it :D

Link to comment
Share on other sites

Not updating it just now, will later today quite possibly. Will add:

 

- Optional delay, since you seemed to want that

- Error checking.

- Maybe or maybe not, automatically counting adds (so you don't have to set it on the phasemarkers, less chance for configuring to go wrong.)

 

... and unless there's anything else I can think of that should do it for this type of encounter. You can do your next room thing... in the next room...

 

If you wanted the fourth door to close on trigger, just set the 4th door to open by default, and set the main start trigger to it's activate parent too. Obviously set this fourth door as the VictoryActivator of the first PhaseMarker (the one activated by the trigger) since that's what that properties for, the door to leave. Since you're using a nice bethesda defaultactivateself trigger, it will only activate once if you don't change that setting. no worries about it opening and closing the door and stuff.

 

This is making me want to work towards a .esm encounter pack modders resource lol, between this and my pickpockets world encounters thing I'm finishing up. I've got a few things to do before that though lol. This is just a nice exercise/distraction :D

Link to comment
Share on other sites

        if iCurrentPhase <= iNumberofPhases
               iCurrentPhase += iCurrentPhase
               Debug.Notification("Phase " + iCurrentPhase + " incomming!")
               ;update current phase marker    

 

What the hell? just what the hell? Why did I make iCurrentPhase += iCurrentPhase... wth lol. Yeah i was very tired. It's supposed to be iCurrentPhase += 1.

 

That was the entire problem... It may work if you fix that part, or I may need to move that line back out of the if statement where it was. If the debuf notification is to display the correct phase, it needs to have (iCurrentPhase -1) instead of just iCurrentPhase in it, that is how I had it before I started having problems.

Link to comment
Share on other sites

I can't thank you enough.

I've read the script and managed to understand most of it. I will read it again ASAP, although I probably won't be able to test it till Friday.

Thanks again, will reply (either by normal reply or PM, if this post is too deep to bump) once I test it.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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