Jump to content

How to add a script to a weapon?


Recommended Posts

Hello everybody

I've never tried modding and scripting.

My first try is to make a weapon that reacts to the events ( congratulates on killing a Deathclaw , mocks for a miss, start a chime when killing a legendary enemy ; this kind of thing)

First thing I created a new weapon making a copy of the 10mm and placed one outside the vault 111.

On the weapon panel I added a new script whit these lines

 

Scriptname prova:pistolaProva3 extends Actor Const

 

Int Property NewProperty Auto Const

 

Event OnKill (Actor akVictim)

if (akVictim != Game.GetPlayer())

Debug.MessageBox("They had a family, you know?")

endIf

endEvent

 

(Basically I just copied and pasted from the CK wiki , cause I don't know what I'm doing)

Compiled OK and saved.

Obviously it doesn't work ; the gun is there, but it does nothing when killing.

 

Am I getting something right?

Is this the correct workflow?

 

Thanks very much to anyone who wants to teach me something.

Link to comment
Share on other sites

Attaching a script which extends ACTOR form to a WEAPON form simply wont work.

 

Scripts attached to a weapon will only have these (two) functions https://www.creationkit.com/fallout4/index.php?title=Weapon_Script

 

You are calling ACTOR functions so you need to attach the script to an ACTOR form (or an ObjectReference instance of an Actor which is probably now confusing the crap outta you).

 

Sorry but I do not know where the basic fundamentals of the class/object hierarchy are explained.

Link to comment
Share on other sites

 

 

Sorry but I do not know where the basic fundamentals of the class/object hierarchy are explained.

Any C++ tutorail on that subject will do ...

Objects and classes are not that different in Papyrus ...

 

Do you have any programming experience?

 

If not, scripting can be a bit weird to get into, especially the whole "classes, objects, methods" concept, but it is not too difficult to understand once you get the general idea of it.

 

 

Also have a look at the Papyrus things in the CK wiki: https://www.creationkit.com/fallout4/index.php?title=Category:Papyrus

 

 

(Basically I just copied and pasted from the CK wiki , cause I don't know what I'm doing)

Compiled OK and saved.

Obviously it doesn't work ; the gun is there, but it does nothing when killing.

 

Am I getting something right?

Is this the correct workflow?

 

Thanks very much to anyone who wants to teach me something.

Maybe start your adventure into scripting with something simple.

Like a push button that displays a message when the player pushes it.

Then maybe try to make a script that displays a different message when the players pushes the button while having low health ...

 

Just to get a feel for how to make scripts that handle different conditions and do different things based on those conditions ...

 

 

But yes, copying examples from the CK wiki is a good thing to do IF YOU UNDERSTAND THEM!

Just blindly copy&pasting will not work (as I have learned the hard way ...).

 

So only copy&paste something that you actually understand.

 

 

The thing you are trying to do is actually a fun little idea for a mod, but not really a "beginner level" - project.

After "messing around" for a bit, yes, something like you described is absolutley possible (I think ...).

 

 

If you have any questions, just ask ...

Link to comment
Share on other sites

You want to put this script on an enchantment which is applied to an explosion.

 

Basically you need to create

 

1. A new projectile

2. A new explosion (Can be tiny)

3. A new enchantment

4. A new magic effect (On which you put the script)

 

and tie them all together. You can use "Override Projectile" on your weapon, so you still use vanilla ammo but it shoots your custom projectile

 

Also I think you want to use Event OnDeath

 

Event OnDeath(Actor akKiller)
if (akKiller == Game.GetPlayer())

...

Endif

EndEvent

 

Link to comment
Share on other sites

Thank you all for the answers.

I see that I'm aiming too high for now, so I'll try with something more basic.

I can't find any Papyrus tutorial in my language ; but I have a "C# for beginning dummies" manual somewhere , I'll build some foundations with that and then back to payrus.

 

Thanks again and see you soon

Link to comment
Share on other sites

I can't find any Papyrus tutorial in my language

Get used to reading A LOT of stuff in english if you want to learn modding ...

Yes, there might be some information out there in your language, but 99% of the little information there is will be in english ...

And forum posts!

 

English isn't my native language either, but I have gotten so used to reading / writing in english that I am actually irritated if I come across something in my native language :laugh:

Link to comment
Share on other sites

  • Recently Browsing   0 members

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