Jump to content

OnHit script that only registers certain weapon impacts.


antstubell

Recommended Posts

Player needs to break down a blockage, some pieces of wood covering an entrance. I want this only to be possible if the player has/uses/has equipped I guess, a weapon strong enough to do it. At this point in the game player SHOULD only have a pickaxe but for future script re-usability I want to 'filter' what weapons can be used. Most weapons will break it but I need to rule out arrows, bow bash, shield bash, weapon bash and fists. Leaving only the melee weapons sword, mace, war axe, great axe, great sword and warhammer being able to break the blockage. I guess this can be done somehow by weapon types but there are a few IFs I'd need to do to rule out or only allow certain types to do the job. Maybe an easier way? Simple script so far...

 

Actor Property PlayerRef Auto
Message Property MyMSG Auto
String Property Text Auto

Event OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, bool abBashAttack, bool abHitBlocked)

if (akAggressor) == PlayerRef
MyMSG.show()
debug.notification(Text)

endif
EndEvent

 

Link to comment
Share on other sites

This is how I'd tackle the problem. Needs testing. And you didn't mention daggers as allowed or not allowed, so they're currently allowed but you can easily change that.

 

 

Actor Property PlayerRef Auto
Message Property MyMSG Auto
String Property Text Auto

Event OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, bool abBashAttack, bool abHitBlocked)
  Weapon myW = (akSource as Weapon)
  if (akAggressor) == PlayerRef
    If myW  ;rules out ammo, ammo projectiles, spells and spell projectiles
      If myW.IsWarAxe() \
      || myW.IsWarhammer() \
      || myW.IsSword() \
      || myW.IsMace() \
      || myW.IsGreatsword() \
      || myW.IsDagger() \
      || myW.IsBattleAxe()  ;each condition statement requires SKSE
                            ;allows only the above weapon types to continue
        MyMSG.show()
        debug.notification(Text)
      EndIf
    EndIf
  endif
EndEvent 

 

 

Link to comment
Share on other sites

SKSE? Oh man, it's never worked for me after years of trying. I have it installed for using mods that require it but not for modding in CK. Is there, here we go again, a tutorial that will show me how to do this?

I just copied the scripts folder from SKSE into Data folder and above script will not compile.

 

Another attempt.

 

Compiled above script got many errors but said Compile Succeeded. I saved got a warning 'You sure?' went to properties and it said there are none.

Edited by antstubell
Link to comment
Share on other sites

Without SKSE? It is possible...

 

 

Actor Property PlayerRef Auto
Message Property MyMSG Auto
String Property Text Auto
Keyword Property WeapTypeWarhammer Auto
Keyword Property WeapTypeWarAxe Auto
Keyword Property WeapTypeSword Auto
Keyword Property WeapTypeMace Auto
Keyword Property WeapTypeGreatsword Auto
Keyword Property WeapTypeDagger Auto
Keyword Property WeapTypeBattleAxe Auto

Event OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, bool abBashAttack, bool abHitBlocked)
  Weapon myW = (akSource as Weapon)
  if (akAggressor) == PlayerRef
    If myW  ;rules out ammo, ammo projectiles, spells and spell projectiles
      If myW.HasKeyword(WeapTypeWarhammer) \
      || myW.HasKeyword(WeapTypeWarAxe) \
      || myW.HasKeyword(WeapTypeSword) \
      || myW.HasKeyword(WeapTypeMace) \
      || myW.HasKeyword(WeapTypeGreatsword) \
      || myW.HasKeyword(WeapTypeDagger) \
      || myW.HasKeyword(WeapTypeBattleAxe)
                            ;allows only the above weapon types to continue
        MyMSG.show()
        debug.notification(Text)
      EndIf
    EndIf
  endif
EndEvent  

 

 

 

As far as getting scripts to compile properly with SKSE 64 on SSE:

Extract the scripts.rar file found in the Data folder (choose in location as the necessary folder structure is already included)

Install SKSE 64 for normal game play usage (i.e. specific files in the main folder and the PEX files in the Data > Scripts folder)

If you never changed the INI setting where the CK looks for source files, then copy the SKSE 64 PSC files to Data > Source > Scripts.

If you do it correctly, you will be asked if you want to overwrite some of the PSC files that you've already extracted from the scripts.rar file.

 

Alternatively, copy the SKSE 64 PSC files to a different folder (mine are at Data > Scripts > Source - SKSE)

Download Sublime Text or other third party utility from the External Text Editors list on the right hand side: https://www.creationkit.com/index.php?title=Category:Papyrus

If using Sublime Text when you get to the step about creating a SublimePapyrus.ini you can use mine and make adjustments to the file paths as needed

 

 

[Skyrim]
# The path to the folder containing the vanilla Skyrim .psc files.
scripts=x:\SteamLibrary\steamapps\common\skyrim special edition\Data\Source\Scripts

# The path to PapyrusCompiler.exe
compiler=x:\SteamLibrary\steamapps\common\skyrim special edition\Papyrus Compiler\PapyrusCompiler.exe

# The folder you wish to output the .pex files to. If commented out, then .pex files are placed in the folder one level above the .psc file.
output=x:\SteamLibrary\steamapps\common\skyrim special edition\Data\Scripts

# The name of the file containing Papyrus' flags. The file has to be among the folders that are imported, which includes the scripts folder defined above and the folder containing the .psc file(s) to be compiled.
flags=TESV_Papyrus_Flags.flg

[Import]
# Additional folders that contain .psc you wish to import when compiling.
# The order in which .psc files are processed is:
# - the path containing the .psc file to compile provided that this path is not the same as the path containing the vanilla Skyrim .psc files
# - path1
# .
# .
# .
# - pathN
# - the path containing the vanilla Skyrim .psc files
#
# Template
# pathN=DriveName:\FolderName\SubfolderName\
# path1 contains SKSE scripts
# path2 contains SKYUI SDK scripts
# path3 contains base game and DLC scripts
path1=x:\SteamLibrary\steamapps\common\skyrim special edition\Data\Scripts\Source - SKSE
path2=x:\SteamLibrary\steamapps\common\skyrim special edition\Data\Scripts\Source
path3=x:\SteamLibrary\steamapps\common\skyrim special edition\Data\Source\Scripts
 

 

Note that the SublimePapyrus.ini goes in your Documents folder.

Link to comment
Share on other sites

Thanks for your help, script works.

Regarding SKSE. These are the instructions I have followed repeatedly for years to install SKSE for CK and every time it hasn't worked. These are the instructions that come with the SKSE download.

If you create mods, copy the .psc files in Data\Scripts\Source\ into the Data\Scripts\Source\ folder of your installation. The .psc files are only needed if you have the CreationKit installed and intend to create or compile Papyrus scripts. Make sure to add them to your include path. (The part in italics I'm not sure what it means)

What did you refer to when you said "Extract the scripts.rar file found in the Data folder " The .rar folder that the game already has?

If it is a simple copy and paste why after 8 years of modding has it never worked for me?

Link to comment
Share on other sites

When SSE came out Bethesda changed the location of the source scripts folder. Some authors saw this as a "bug" and changed "sScriptSourceFolder=" in their CreationKitCustom.ini file to point to the old location. Other authors just went with the change. The SKSE team is one that maintained use of the old folder structure. Thus if you left everything at default or changed the INI entry to point somewhere else, you would need to copy / paste the PSC files into the correct folder for your setup.

 

As far as the scripts.rar file, that is the one that comes with the Creation Kit and needs to be extracted before you can compile scripts. You have probably already extracted it, but the step is there in order to be all inclusive.

 

I don't know what they mean by "include path". Just make sure that if you only compile with the CK that ALL you PSC files are in the same folder.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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