Jump to content

Trait which adds temporary effect to player whenever they kill an animal


Auberginuspl

Recommended Posts

Hello, this is my first time posting here. I only recently got into G.E.C.K and I'm struggling to implement a certain feature. I would greatly appreciate any help you guys can give.

 

I want to rework the Animal Friend perk into a trait. Since traits have downsides, I want it to give the player a 5 minute effect that reduces every SPECIAL stat EVERY TIME they kill any creature from the AnimalFriendFaction OR CreatureType 1 and 2.

 

I tried to use the perk menu for this purpose but it looks like there's no function in Entry Points that triggers a customizable actor effect on kill.

 

I'm assuming I'll have to set it up as a quest? Since I'm new to scripting I really have no idea where to start. I tried going through tons of tutorials and topics and I found some functions like GetCreatureType, GetInFaction and CastImmediateOnSelf that maybe could be used here. However, I don't have the slightest idea on how to implement them and how to make the quest repeat infinitely, so that the script executes every time player kills an animal.

 

I would be extremely thankful if someone could tell me if such thing is even possible in the first place. If it is, any tips or suggestions would be helpful. Thanks in advance!

Edited by Auberginuspl
Link to comment
Share on other sites

Thanks for the quick reply, GamerRick, I appreciate it. This might be the function I'm looking for. However, I'm not sure how to use it even after reading the article. I don't know much about scripting.

 

Can you give me the general idea on how I'm supposed to use it for my mod, please? Does it require advanced scripting knowledge?

Link to comment
Share on other sites

Suggest you start from the tutorial on Eventhandlers linked at the bottom in "TIP Do not overlook EventHandlers" under the "Scripting" section of the wiki "Getting started creating mods using GECK" article. You should also see "TIP Block Types Multiple vs Single Frame processing" regarding a separate but related issue. (Eventhandlers and their related UDFs are "single frame" blocks.)

 

It is regarded as an "advanced scripting technique", but like all such it just means it's something you have learn and try out. It is not a technique typically covered in "basic" scripting guides. If you understand what an "event trigger" is, and how a "function call" works (the basics of all GECK commands), then it can be learned quite easily. It simply wasn't present in the "vanilla" game engine until added by NVSE.

 

-Dubious-

Link to comment
Share on other sites

It's complicated. You need the perk to start a quest (already done by some vanilla perks). The quest will have a GameMode block that adds the event handler to a UDF on GetGameLoaded. The UDF will need to detect if it's the type of creature you are looking for and was killed by the player (or maybe one of the player's followers?) and add the effect you want if it isn't already running.

 

I have no idea if this will work or not, as I have never tried anything like it myself.

 

BTW: I was severely handicapped with my first response, because my cat was in my lap at the time, limiting me to only being able to use my mouse and copy/paste functions.

Edited by GamerRick
Link to comment
Share on other sites

Thanks for helping me, GamerRick. I had no idea that it would end up being this challenging. Sounded like a simple idea enough. Right now i'm just trying to understand how event handlers work. This tutorial (linked in wiki page provided by Dubious) helped a little bit.

 

From what I understand event handlers fire whenever and every time X happens? The article mentions, among other things, giving player double vision upon consuming alcohol, so if there was a mod that did something in the same vein without messing with base forms, I could re-purpose it for my script, I think. I'll try looking.

 

You mentioned the GetGameLoaded function. Can you elaborate on its purpose in the context of my mod? Thanks again for your help!

 

PS: I wish my cat liked to sit in my lap, but she won't. Maybe it's because I move my legs too much.

Link to comment
Share on other sites

I don't know if SetJohnnyOnDyingEventHandler will work. It looks like you have to specify a specific NPC or Creature with rActor, but it says "...a handler that will be invoked when a specified Actor (or any Actor) is killed" without elaborating how you would do that for a non specific reference.

 

The only other alternative I know about is adding a script to all creatures in the game that are in the factions you want, that has an OnDeath block in it.

 

To use GetGameLoaded in a quest script:

begin GameMode
     if GetGameLoaded
          SetJohnnyOnDyingEventHandler 1 OnDyingUDF 0 rActor
     endif
end
Edited by GamerRick
Link to comment
Share on other sites

Oh hey, thanks for replying again GamerRick. So I'd like to see if that SetJohnnyOnDying function will work. It says that it can accept form lists so I'm assuming I can just create my own form list with all the animals in it and use in the filter? Other handlers like OnDeath can also apparently use form lists, so if JohnnyOnDying doesn't maybe OnDeath will?

 

I'm not sure what you meant by "adding a script" to all animals, but if it's about selecting a script from the drop down menu in object edit menu (below ID and name) then I think I can't use that because some of the affected animals are already scripted, for example Legion Mongrels.

 

From what little I understand, I'm supposed to start with the event handler, which is an Object script?

scn OnDyingUDF
ref rActor
ref rKiller
begin Function {rActor}
player.CastImmediateOnSelf AnimalFriendDebuff
end

and then the main script, attached to a Start Game Enabled quest? The quest being attached to the perk (trait).

scn OnDyingAnimalRegisterSCRIPT
begin GameMode
if GetGameLoaded
SetJohnnyOnDyingEventHandler 1 OnDyingUDF 0 myAnimalFormList
endif
end

I'll be honest, I don't really know what I'm doing and if any of the above is even remotely close to what I'm trying to accomplish, so sorry if I end up looking like a complete idiot. I'd appreciate any assistance you can provide. Thanks again for spending the time to help me, I'm very grateful!

Edited by Auberginuspl
Link to comment
Share on other sites

  • Recently Browsing   0 members

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