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] Making a creature self-destruct?


Matthew_Kaine
 Share

Recommended Posts

As another little experiment of mine, I plan to make a creature or NPC that will approach the player in response to spotting them and explode when close enough to the player, probably leaving nothing but a pile of ash behind. The actor will be capable of being killed before reaching the player, and if the player can successfully take down the actor before reaching the exploding distance, the actor would simply fall down and die like a normal NPC.

I'm assuming this is something that would be handled through scripting, but I'm not sure where to begin. I haven't touched Papyrus, so if you do provide me with code, could you give explanations for the commands that you use? I'd love to learn as I go along. Thanks for any help I receive.

Link to comment
Share on other sites

for a quick update...

GetDistance does NOT work in Skyrim for some odd reason. I asked WillieSea about it and he couldn't get it to work either.

So right now, I'm trying to find some other way to get player distance.

If we cannot find a way to get the distance, I'm not sure how this would work :shrug:

:(

Link to comment
Share on other sites

okay, I somehow got the GetDistance stuff working :shrug:

The script below is for only when the player gets within 512 units from the player, then the actor explodes into the fireball that you asked for:

Scriptname aaMySelfExplodingActor extends ObjectReference  

{Actor explodes when the player is too close.}


Explosion Property FXAtronachFireDeathExplosion Auto ;The explosion that I want to use. This can be changed in the Script Properties

Activator Property DefaultAshPileGhostBlack Auto  ;The explosion that I want to use. This can be changed in the Script Properties



import debug

import game

import utility


int myState


Event OnLoad() ;This will check to see if every item in the current cell has loaded its 3D Data... There might be a better way than this event, but this works.

    While (Self.GetParentCell() == Game.GetPlayer().GetParentCell()) ;If the player is in the same cell as I am, I can start the next if statement.

        if myState == 0 ;If I am Zero, proceed.

            if Game.GetPlayer().GetDistance(Self) < 512 ;If the player gets this close to me, start the script. "SELF" is refering to whatever this is attached to, NPC, player (BAD!!!), Chicken, Dog, etc. Do Not place this on the Player or any object that is NOT an NPC or a main character or anything that you don't want dead! If this is placed on the Player, it can and probably will cause the game to crash when a game is loaded.

                wait(1.0)

                placeAtMe(FXAtronachFireDeathExplosion) ;Creates an Explosion at the Actor

                Wait(0.2) ;wait to delete

                PlaceAtMe(DefaultAshPileGhostBlack, 1) ;Place a Ash Pile at my location.

                Disable() ;Deletes the actor from the game.

                myState = 1 ;Do not run this on me again

            EndIf

        Elseif myState == 1 ;if I'm One, do NOT do anything

            ;Do Nothing

        EndIf

    EndWhile

endEvent


Event OnReset()

    Enable() ;Re-enable for use again.

    myState = 0  ;Sets myState back to zero for use again.

EndEvent

And for a video of it in action (No sound!)


If you don't know much about scripting and how to get to the script properties, I would follow along with these two Classes:

Class #1

Class #2


As far as getting the NPC to run towards the player or to follow, I'm not 100% sure how to do that.

Most likely you will need to setup a AI data package to follow the player, and then once that NPC is close to the player it then explodes.

Someone else should be able to tell you better on this part than I can.

Edited by DsoS
Link to comment
Share on other sites

Alright, so I've added the script with the manager and added it to a mudcarb for testing. I immediately went to see it in-game, but it didn't work. After reloading the CK, I realized it probably needs properties added to it. However, I wasn't sure which to add. I know it's object reference, so I tried to add that type, but it said the script failed to compile. Was there a value I needed to change before plugging it in? I've read over it several times now and don't see any variable that requires a unique ID other than the two animations. What did I do wrong?

Link to comment
Share on other sites

New problem! The script compiles correctly now, but now the crab just disappears upon reaching the distance. No explosion, no pile of ash. The properties automatically defined themselves because of how you worded the script. Was there anything I needed to change in there so that they can find the right files? Not really sure what else it could be.

Link to comment
Share on other sites

make sure that in the script properties on the creatures, that you are selecting "Auto-Fill All" or something worded like that.

even though they are "Auto" defined in the script, they must still be filled in on the properties.

Link to comment
Share on other sites

Auto-FIlling did the trick, thanks! Now, I think the last thing I'd like to figure out is how to make sure the ash pile always appears on the floor. I've tried attaching the script to a Wood Elf and it works wonderfully except that occasionally the ash pile will appear in mid-air instead of on the ground. Is there anyway to tell the ash pile to detect the floor and be placed there? If not, I might have to choose a different effect for after the explosion.

Link to comment
Share on other sites

^Scratch that. What's more important is getting the original idea down. I tried added a new event to the script in order to prevent my actor from blowing up after I've already killed him. The CK sucessfully compiles it, but the actor seems to ignore it in-game. Do you notice anything wrong with this? I've also tried using OnDeath instead of OnDying, but it doesn't seem to make a difference. I have it placed in between the main event and the reset event. Should it be put before the main event? Thanks for any help you can give.



Event OnDying() ;This will check to see when I die.

While (Self.GetParentCell() == Game.GetPlayer().GetParentCell()) ;If the player is in the same cell as I am, I can start the next if statement.

  if myState == 0 ;If I am Zero, proceed.

   myState = 1 ;Do not run this on me again

  EndIf

EndWhile

EndEvent

Nevermind, figured everything out. Thanks again for all the help!

Edited by Matthew_Kaine
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...