Jump to content

Scripts for boss fight


Recommended Posts

Posted

Needing help to make two scripts for a boss fight. The first is a script for when he is at 50% health, minions spawn. The second script is when he dies, a gate opens for progression. can someone point me towards a tutorial that might specify in this type of scripting.

Posted

Use a Update script to get the health.

The script can run from time to time using RegisterForSingleUpdate to run every second.

 

Use GetActorValue("Helath") to get the current health.

And GetActorValueMax("Health") to get the max value.

Then check if you go (only first time, use a bool) under 50%.

In this case spawn minions (placeatme is a good way to sawn actors)

 

There is the ondeath method you can use, but I do not remember if it is fired correctly. Have a try.

And enable the gate (or open if it is a door)

Posted

You need a map for that first and foremost, what you want to do doesnt work without also having a map you edit

Assuming you have that, place xMarkers around where you want everything to spawn

 

Assuming you got that, I still have 2 Questions:

13 minutes ago, willwhitt56 said:

The first is a script for when he is at 50% health

Does this only happen once? Or every few seconds?

 

13 minutes ago, willwhitt56 said:

The second script is when he dies, a gate opens for progression

Is this a "gate gate" like a locked door that opens itself or one that you want to spawn in? Something like a teleporter?

Posted
5 minutes ago, CPU said:

Use a Update script to get the health.

Dont use an Update Script to get the health thats unnecessarily heavy and needs to be triggered somewhere (= more complicated) :) 

OnHit is the way to go, we only check health when our boss actually loses health and doesnt need a trigger somewhere first

Posted
3 minutes ago, Scrab said:

Dont use an Update Script to get the health thats unnecessarily heavy and needs to be triggered somewhere (= more complicated) :) 

OnHit is the way to go, we only check health when our boss actually loses health and doesnt need a trigger somewhere first

 

We can also give a boss ability with a script-type magic effect that will fire once subjects hp drops below certain percent. :)

Posted
1 hour ago, Scrab said:

You need a map for that first and foremost, what you want to do doesnt work without also having a map you edit

Assuming you have that, place xMarkers around where you want everything to spawn

 

Assuming you got that, I still have 2 Questions:

Does this only happen once? Or every few seconds?

 

Is this a "gate gate" like a locked door that opens itself or one that you want to spawn in? Something like a teleporter?

OK...so here's the thing. I'm still VERY new to scripting, but i'm slowly trying to learn. Here's what im trying to do with this.

 

For the boss room, I have it so that once you activate the trigger box (1.) the gates to the entrance and exit close and the gates in the inner circle open. What i'm trying to do here is once the boss is dead (2.) the gate to the exit will open, allowing exit (3.)

Spoiler

935041535_Screenshot(3).png.babe14130fae744750d71973a1bdf803.png

Spoiler

 

Now as for the summon, What I want to happen is when one of his goon's die (Dremora Soul-Tearer) a number of subjugated souls will spawn. I'm only wanting this to happen once. Once the souls are dead, that's it.

Spoiler

344039998_Screenshot(4).png.9156ea15b57dd960a66d6bb220c93003.png

 

Posted
43 minutes ago, willwhitt56 said:

What i'm trying to do here is once the boss is dead (2.) the gate to the exit will open, allowing exit (3.)

Assuming the boss is a custom actor you created and not some Vanilla asset

You create a new Script. In this new Script you add a new Property which is of type ObjectReference and points at your exit Door

 

As for the actual Code, you want to write an OnDying Event that simply opens the gate, something like this:

 

Event OnDying(Actor akKiller) ; <- This is called when our boss dies
	myDoorProperty.Lock(false) ; <- Unlock the door so the player gets no "lockpick door" option even though the door is already open
	myDoorproperty.SetOpen(true) ; <- We open the door
EndEvent

 

 

51 minutes ago, willwhitt56 said:

Now as for the summon, What I want to happen is when one of his goon's die (Dremora Soul-Tearer) a number of subjugated souls will spawn. I'm only wanting this to happen once. Once the souls are dead, that's it.

You do this pretty much the same way as above. You attach a Script to those Goons with an OnDying() Event

Instead of a Door Property you want a "subSouls" ActorBase Property this time which is pointing at your SoulMob and an ObjectReference[] (array) property which contains all the markers you want mobs to spawn on and then you loop "mySpawnPlaces.placeAtMe(subSouls)" through the Array:

 

Event OnDying(Actor akKiller)
	int i = 0
	While(i < mySoulSpawns.length)
		mySoulSpawns[i].PlaceAtMe(subSouls)
		i += 1
	EndWhile
EndEvent           

 

Posted
5 hours ago, Scrab said:

Assuming the boss is a custom actor you created and not some Vanilla asset

You create a new Script. In this new Script you add a new Property which is of type ObjectReference and points at your exit Door

 

As for the actual Code, you want to write an OnDying Event that simply opens the gate, something like this:

 

Event OnDying(Actor akKiller) ; <- This is called when our boss dies
	myDoorProperty.Lock(false) ; <- Unlock the door so the player gets no "lockpick door" option even though the door is already open
	myDoorproperty.SetOpen(true) ; <- We open the door
EndEvent

 

 

You do this pretty much the same way as above. You attach a Script to those Goons with an OnDying() Event

Instead of a Door Property you want a "subSouls" ActorBase Property this time which is pointing at your SoulMob and an ObjectReference[] (array) property which contains all the markers you want mobs to spawn on and then you loop "mySpawnPlaces.placeAtMe(subSouls)" through the Array:

 

Event OnDying(Actor akKiller)
	int i = 0
	While(i < mySoulSpawns.length)
		mySoulSpawns[i].PlaceAtMe(subSouls)
		i += 1
	EndWhile
EndEvent           

 

Seems i did something wrong, I don't really know what to connect the script to. Also, how do I have it connect to the right gate? Here's the script just incase i did something wrong with it

Spoiler

Scriptname CGBossDeathScript extends ObjectReference  
{Scriptname CGBossDeathScript extends ObjectReference

Event OnDying(CGEncDremoraMeleeBoss akKiller)
     myDoorProperty.Lock(false)
     myDoorProperty.SetOpen(true)
EndEvent}
 

One last thing, I don't actually know how to make the souls invisible or connected to the markers until they need to be spawned. like I said, i'm VERY new to this more advanced stuff

Posted
6 hours ago, willwhitt56 said:

Also, how do I have it connect to the right gate? Here's the script just incase i did something wrong with it

 

In this instance, think of the game world as some childs playroom and the actors are 2 lego figures and Papyrus is the Child playing in this world.

When now one Lego figure kills the other, Papyrus will be running at to you with their finger pointing at one of the figures: "There, that one over there killed the other one!". You as the one writing the script can now tell Papyrus to do something else now that its lego figure is ded, in our case, you want to tell Papyrus now that because our figure is no more, it can go open the cool little gate in the corner but if you just tell that to Papyrus, itll be confused "what gate?"

To make sure that Papyrus knows what gate to open, you need to create a Property and have that Property point at the Gate so that when Papyrus walks up to you pointing at the killer, you can tell papyrus to open the gate you are pointing at right now

 

In your Script there are a few issues now:

1) OnDying(Actor akKiller) is a defined expression within Papyrus. You cant change it. Those Events are things that Papyrus does automatically when it sees something happening and when an Actor dies, it will always try to point at an Actor Object not at an "CGEncDremoraMeleeBoss" Object

You need to leave it at "onDying(Actor akKiller)" the only thing youre allowed to change here is the "akKiller" which is just a variable name for you

 

2) The first Line, OnDying is stored inside the Actor Class, not the ObjectReference Class. The ObjectReference Class doesnt know the OnDying() Event

Explaining Class hierarchy and inheritance here would take us much too far, Im going to keep it on what you need to do:

In the Vanilla Game there is no "CGEncDremora,.." mob, so I assume that this Mob is newly crated in your esp (native to your mod) if you dont plan on using the mob anywhere else in your mod, you should create the script in the Actor Tab and have it extend "Actor" instead of "ObjectReference"

Spoiler

image.png.6c1006e8b5694dbe076d70c1029576e9.png

 

If you want to use the mob multiple times, you should instead create a Quest and in that Quest create a ReferenceAlias which is filled with your Boss mob and contains the same (corrected) Script but extrends "ReferenceAlias" instead of "ObjectReference"

 

3) As mentioned, Papyrus needs you to tell it what door to actually open

You do that by creating a property which you create by either

  • typing inside your script: "[ObjectType] Property extends [PropertyName] Auto" or
  • by going into the CK again, cdoubleclicking on your script and selecting "add property" on the window that should then pop up (you can also click on your Script once and click on "Property" next to it, or RMB -> "Properties"
Spoiler

image.png.206cda992953884cb715ff718c289256.png

 

because we want to interact with a proper Object inside the World, the Type is "ObjectReference" and the Name can again be whatever you want. In the script I gave you I named this Property simply "myDooPropert". If you name it differently here, you need to change this name in the script appropriately

If you got that far you would have an entry in this Property List, the Value of that Properrty is currently empty though, it points at nothing. To make it point at something you need to click on it and give it a appropriate Value. Depending on what Type the property is this can be something differently. The Value for an Int is a Number, the one for bools true or false

An ObjectRefernce takes a specific Reference in the Game world, you load up your boss room for that and go to the door you want to open. In your Property List, you click on the Door Property and choose "Select from Render Window" which should push the Render Window into your foreground and from there, just click on the Door and save

 

4) Not an Error but the brackets {} are optional for commenting and documenting. You can leave them there or not but there is no necessarity to hvae them there :)

What you did in your case is actuall commenting out the entire Script, so it might have compiled anyway but not because the script was correct, it compiled because the script was basically empty. Other Syntax for commenting would be ";" (for commenting single lines) and ";/ /;" (for comment blocks)

 

Your final Script should something like this:

Scriptname CGBossDeathScript extends Actor ; (or ReferenceAlias if you put the mob in a Quest)

ObjectReference Property myDoorProperty Auto

Event OnDying(Actor akKiller)
     myDoorProperty.Lock(false)
     myDoorProperty.SetOpen(true)
EndEvent
 

 

 

7 hours ago, willwhitt56 said:

One last thing, I don't actually know how to make the souls invisible or connected to the markers until they need to be spawned. like I said, i'm VERY new to this more advanced stuff

 

You dont spawn them in

Like above with the door, you want to do the same here again but this time you want to use a ObjectReference Array (in script you put a [] behind the ObjectReference or if you decline Properties in the CK you tick the Array Checkbox next to the type. This allows you to add multiple ObjectReference into a single name and call  them based on ther index inside this List (array) you create

And you need another Property, this time however an ActorBase Property instead of an ObjectReference one. The Property is this time filled with a dropdown List where you select the soul npc you want to spawn

 

 

Posted
12 hours ago, Scrab said:

 

In this instance, think of the game world as some childs playroom and the actors are 2 lego figures and Papyrus is the Child playing in this world.

When now one Lego figure kills the other, Papyrus will be running at to you with their finger pointing at one of the figures: "There, that one over there killed the other one!". You as the one writing the script can now tell Papyrus to do something else now that its lego figure is ded, in our case, you want to tell Papyrus now that because our figure is no more, it can go open the cool little gate in the corner but if you just tell that to Papyrus, itll be confused "what gate?"

To make sure that Papyrus knows what gate to open, you need to create a Property and have that Property point at the Gate so that when Papyrus walks up to you pointing at the killer, you can tell papyrus to open the gate you are pointing at right now

 

In your Script there are a few issues now:

1) OnDying(Actor akKiller) is a defined expression within Papyrus. You cant change it. Those Events are things that Papyrus does automatically when it sees something happening and when an Actor dies, it will always try to point at an Actor Object not at an "CGEncDremoraMeleeBoss" Object

You need to leave it at "onDying(Actor akKiller)" the only thing youre allowed to change here is the "akKiller" which is just a variable name for you

 

2) The first Line, OnDying is stored inside the Actor Class, not the ObjectReference Class. The ObjectReference Class doesnt know the OnDying() Event

Explaining Class hierarchy and inheritance here would take us much too far, Im going to keep it on what you need to do:

In the Vanilla Game there is no "CGEncDremora,.." mob, so I assume that this Mob is newly crated in your esp (native to your mod) if you dont plan on using the mob anywhere else in your mod, you should create the script in the Actor Tab and have it extend "Actor" instead of "ObjectReference"

  Reveal hidden contents

image.png.6c1006e8b5694dbe076d70c1029576e9.png

 

If you want to use the mob multiple times, you should instead create a Quest and in that Quest create a ReferenceAlias which is filled with your Boss mob and contains the same (corrected) Script but extrends "ReferenceAlias" instead of "ObjectReference"

 

3) As mentioned, Papyrus needs you to tell it what door to actually open

You do that by creating a property which you create by either

  • typing inside your script: "[ObjectType] Property extends [PropertyName] Auto" or
  • by going into the CK again, cdoubleclicking on your script and selecting "add property" on the window that should then pop up (you can also click on your Script once and click on "Property" next to it, or RMB -> "Properties"
  Reveal hidden contents

image.png.206cda992953884cb715ff718c289256.png

 

because we want to interact with a proper Object inside the World, the Type is "ObjectReference" and the Name can again be whatever you want. In the script I gave you I named this Property simply "myDooPropert". If you name it differently here, you need to change this name in the script appropriately

If you got that far you would have an entry in this Property List, the Value of that Properrty is currently empty though, it points at nothing. To make it point at something you need to click on it and give it a appropriate Value. Depending on what Type the property is this can be something differently. The Value for an Int is a Number, the one for bools true or false

An ObjectRefernce takes a specific Reference in the Game world, you load up your boss room for that and go to the door you want to open. In your Property List, you click on the Door Property and choose "Select from Render Window" which should push the Render Window into your foreground and from there, just click on the Door and save

 

4) Not an Error but the brackets {} are optional for commenting and documenting. You can leave them there or not but there is no necessarity to hvae them there :)

What you did in your case is actuall commenting out the entire Script, so it might have compiled anyway but not because the script was correct, it compiled because the script was basically empty. Other Syntax for commenting would be ";" (for commenting single lines) and ";/ /;" (for comment blocks)

 

Your final Script should something like this:

Scriptname CGBossDeathScript extends Actor ; (or ReferenceAlias if you put the mob in a Quest)

ObjectReference Property myDoorProperty Auto

Event OnDying(Actor akKiller)
     myDoorProperty.Lock(false)
     myDoorProperty.SetOpen(true)
EndEvent
 

 

 

 

You dont spawn them in

Like above with the door, you want to do the same here again but this time you want to use a ObjectReference Array (in script you put a [] behind the ObjectReference or if you decline Properties in the CK you tick the Array Checkbox next to the type. This allows you to add multiple ObjectReference into a single name and call  them based on ther index inside this List (array) you create

And you need another Property, this time however an ActorBase Property instead of an ObjectReference one. The Property is this time filled with a dropdown List where you select the soul npc you want to spawn

 

 

I got the Boss door script to work. Im having difficulty with the goon one though. Here's what the script looks like:

Spoiler

{Scriptname CGGoonDeathSummonScript extends Actor ;

ObjectReference[] Property NewProperty  Auto  
[ObjectType] Property extends [PropertyName] Auto

ActorBase Property NewProperty  Auto  

Event OnDying(Actor akKiller)
     myDoorProperty.Lock(false)
     myDoorProperty.SetOpen(true)
EndEvent}

 

Posted
23 minutes ago, willwhitt56 said:

I got the Boss door script to work. Im having difficulty with the goon one though. Here's what the script looks like:

 

Youre again commenting out the entire script with the Brackets at beginning and end

 

Then you should name your Properties properly, the name "NewProperty" can only be used once per script (& ideally you dont name a single one NewProperty, poor praxis :^) )

 

[ObjectType] Property extends [PropertyName] Auto <- that line there is invalid and does nothing, you can delete is

And then what is inside your Script isnt actually doing anything, youre just unlocking another door there

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

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