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...

Can someone explain in English what this script actually does?


Cydonian_Knight
 Share

Recommended Posts

Hey everyone! So for my mod, I'm using this script to detect if a weapon made a kill, but I don't actually understand what makes it work. Here's the script:

Scn aaBanishment

Ref Target

Short DoOnce

Short Dead

Begin ScriptEffectStart

Set DoOnce to 0

Set Target to GetSelf

End

Begin GameMode

If DoOnce == 0

If Target.GetDead == 1

Set Dead to 1

Set aaDBBanishCount to (aaDBBanishCount + Dead)

Set DoOnce to 1

Endif

Endif

Endif

End

aaDBBanishmentCount is a global variable I've set. I've adopted this script from one on the CSWiki and I've tested it and it works, so I know it's doing something right lol. But what does GetSelf actually do? And what does a "ref" variable do compared to a "short"? Sorry if these are basic questions but I couldn't find enough information on the CSWiki. If someone could explain in English exactly what is going on here I would be most grateful XD

Thanks!!

CK

Edit: Hmm and for some reason the formatting isn't showing up correctly in the post. It won't let me indent at all so the script doesn't look like it should or how it looks in the CS. Any idea why?

Link to comment
Share on other sites

The Ref varibale is used for specifically References, it tells the game you are going to be using a reference for an Object, creature, NPC ect.

Short is an integer format that uses 16 bit for data, this is something you would use then you are dealing with numbers.

GetSelf returns the calling object itself as a reference

Also for this Set aaDBBanishCount to (aaDBBanishCount + Dead) you could actually do away with the dead variable and do this Set aaDBBanishCount to aaDBBanishCount + 1

Edit: Another thing I noticed was you haev a ScriptEffectStart block there which leads me to believe this script is attached to an enchantment, is it?

If so I would change the GameMode block to a ScriptEffectUpdate block.

Link to comment
Share on other sites

Also for this Set aaDBBanishCount to (aaDBBanishCount + Dead) you could actually do away with the dead variable and do this Set aaDBBanishCount to aaDBBanishCount + 1

Edit: Another thing I noticed was you haev a ScriptEffectStart block there which leads me to believe this script is attached to an enchantment, is it?

If so I would change the GameMode block to a ScriptEffectUpdate block.

Thank you so much! I don't know how I missed that part about GetSelf. For some reason, I had it in my head that it referred to the player character for some reason. Thanks for clearing that up.

And yes, it is an enchantment. I used your suggestions, does this look better now?

Scn aaBanishment


Ref Target

Short DoOnce


Begin ScriptEffectStart

	Set DoOnce to 0

	Set Target to GetSelf

End


Begin ScriptEffectUpdate

     If DoOnce == 0

		If Target.GetDead == 1

			Set aaDBBanishCount to (aaDBBanishCount + 1)

			Set DoOnce to 1			

		Endif

	Endif

End


Link to comment
Share on other sites

Your script formatting is not showing up because you have not enclosed the script in -code- tags.

One thing to note about your final script.

:rolleyes: Smarty Says: You do not need to set DoOnce to 0 in your ScriptEffectStart block of code. All variables are initialized to 0 at script start. An enchantment starts new for each and every enchantment and does NOT keep any values from one enchantment script execution to the next. That is also why you have to use a global variable to store the resulting value of your kills.

Link to comment
Share on other sites

Your script formatting is not showing up because you have not enclosed the script in -code- tags.

One thing to note about your final script.

:rolleyes:Smarty Says: You do not need to set DoOnce to 0 in your ScriptEffectStart block of code. All variables are initialized to 0 at script start. An enchantment starts new for each and every enchantment and does NOT keep any values from one enchantment script execution to the next. That is also why you have to use a global variable to store the resulting value of your kills.

Ah ok, that makes sense. Thanks WillieSea!

So in this script is for my mod here, and I also need to set a faction requirement and a random chance to instantly kill anything belonging in those specific factions. So here's the script I wrote. Will this do what I want it to do? It seemed to work alright ingame. For the particular script I want there to be a 5% chance of instantly killing a Daedra or Dremora. Will the script do this correctly and how does it look overall? I'm brand new at this so any feedback or criticism is very much appreciated :lmao:

Scn aaBanishment


Ref Target

Short DoOnce

short randomvar


Begin ScriptEffectStart

	Set Target to GetSelf

	set randomvar to getrandompercent

End


Begin ScriptEffectUpdate

	If Target.getInFaction daedraFaction || getInFaction DremoraFaction

		If (randomvar < 5)

			kill

		endif

	endif

End


Begin ScriptEffectUpdate

	If DoOnce == 0

		If Target.getInFaction daedraFaction || getInFaction DremoraFaction

			If Target.GetDead == 1

				Set aaDBBanishCount to (aaDBBanishCount + 1)

				Set DoOnce to 1			

			Endif

		endif

	Endif

End

Link to comment
Share on other sites

Scn aaBanishment

Ref Target
Short DoOnce
short randomvar

Begin ScriptEffectStart
Set Target to GetSelf
set randomvar to getrandompercent
If ((Target.getInFaction daedraFaction) || (Target.getInFaction DremoraFaction))
If (randomvar < 5)
kill
endif
endif
End

Begin ScriptEffectUpdate
If DoOnce == 0
If ((Target.getInFaction daedraFaction) || (Target.getInFaction DremoraFaction))
If Target.GetDead == 1
Set aaDBBanishCount to (aaDBBanishCount + 1)
Set DoOnce to 1
Endif
endif
Endif
End[/code]

Some notes:

1. You never want to put two of the same block in your scripts (ScriptEffectUpdate in this case). You can just put it all in one block.

2. Your first 'ScriptEffectUpdate' block could easily go into your 'ScriptEffectStart' block since that code only needs to run once at the start.

3. Your second 'GetInFaction' was missing the 'Target.' reference name. Although it may work anyway since the effect would be running on the target anyway. You might not even need the target, but it does make it clearer code.

4. I added parenthesis around your if conditions. They may not need it but it makes it clearer code. (to me at least) :pints:

Link to comment
Share on other sites

Thanks for your help WillieSea! I'll be sure to keep that all in mind. And thank you for showing me the adjusted script, that makes much more sense than the one I had written. I just got lazy but you're right, I should always try to make it as clean as possible. And I knew that it probably wasn't a good idea to have 2 of the same blocks in one script, but I wasn't sure how to merge the two. So the script will now correctly give a 5% chance of killing a Daedra or Dremora every hit? Thanks for helping me out with this XD

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...