Aller au contenu

Photo

Learning script, I need an explanation


  • Veuillez vous connecter pour répondre
46 réponses à ce sujet

#26
painofdungeoneternal

painofdungeoneternal
  • Members
  • 1 799 messages
I'd look at Resources for scripting for tutorials and things, i tried listing a lot of things, up to you what you use. I would say you need to at some point understand what knightmare is explaining, since it's the basics - no matter how you twist it those things are the things which are what people are going to reply with when you post questions.



My function creates a heartbeat, which runs a script named "TG_EnviroControl.nss" every round. It just has to be run on module load, but it can be run almost anywhere or even more than once, it only allows one heartbeat to be created.



You just add the line to any event really to start it up.



CSLEnviroGetControl( );



I use onmodule loaded, but this allows you to just attach this to whatever script you want. This allows you to add any heartbeat you want without messing up the heartbeat attached to the module. This allows adding features to even a locked module like mysteries of westgate if you can get a single script of your own to run.



No most folks are not modding the OC, unlike most games we can do original things better than the modules that ship with the game. It requires more knowledge as to how things work since you need to modify things from the outside really, you don't really want to redo the actual modules and release those.

#27
Kaldor Silverwand

Kaldor Silverwand
  • Members
  • 1 585 messages

Vaalyah wrote...
From what I've understood, whatever thing in the game has a ht script. Something that simply "counts" the time that pass by. So I can trigger some events with it. ie: I tie a script for "doing something" to the hb script of an item. When the hb script verifies that some conditions have been satisfied (and this check happens every 6 seconds), then my script (the "doing something") starts.
Is it correct?

Yes.

By the way, two questions:
1) from what I am reading, it seems to me that no-one has ever tried to modify the game in this way, is it correct?

I haven't seen a mod that attempts to add additional dialogue except for ones that add to existing dialogue. My own mod - the OC Makeover SoZ Edition - makes many modifications to the OC, but I did not do anything to add additional dialogue at various times using heartbeat scripts.  I did make some changes to companion dialogues though.

2) BG series modders have added thousands of NPCs to the OC... I suppose it is impossible to do the same for NWN2... or not?

I do not think it would be feasible to add new companions into the OC. The OC is heavily dependent on the provided companions and there is code all over the place that assumes who the companions are in the party.  It was a significant effort just to make Shandra act as a full companion all the way through in the Makeover. The Universal Companion mod lets you add in your own companion, and the Makeover adds the SoZ Party Creation feature to the OC, but those aren't really for adding in full-blown companions that interact with other companions in the game.

The NWN2 OC is a lot more restrictive in nature than BG was. You would have an easier time adding NPC's into SoZ than the OC or MotB, because SoZ is less restrictive about companions. SoZ is far more like BG.

What pain's script shows is that you can add a heartbeat script to an object from another script. Something I hinted at but have never done. If you decided to use area heartbeat scripts, then you would be able to have a script like the area onEnter script add your custom area heartbeat script to the area.

If you use the module heartbeat or companion heartbeat scripts then this wouldn't be needed.

Regards

#28
Vaalyah

Vaalyah
  • Members
  • 953 messages
I know I have to learn. And a lot. But of course, being now at the beginning, I can't learn everything in few days. I need a bit more of time to learn and understand. I was wondering if there was a way to do what was in my mind, and knowing that it's possible makes me happy! But your answers are a bit too advanced for me to figure out the subject without problems.

So I would like to thank you very much for all your patience and... well, I would come back after having read some more things around, just to improve and being able to understand a bit more!



Thank you very much! ^^

#29
painofdungeoneternal

painofdungeoneternal
  • Members
  • 1 799 messages
I would advise keeping things simple, keep your projects simple and as your learn more, tackle things which are harder.

Just a side note, the very first thing i wanted to be able to do in script was make fireballs vary by damage type and visual effect, that was probably 3-4 years ago. ( i had only done icons before that )

It was a bit over my head at the beginning, but i focused on doing some other things since i could not figure out how to do that. Since then i've redone a lot of core system, and only in the last year i even implemented elemental substitution into all my spells, but even then i've not added the modes and feats so players can access that, right now only certain monsters take advantage of it. I just don't know how everything works yet, well not enough to make my own modes in a reliable manner.

Quite often i see those completely new stating problems they want to tackle which would be a huge challenge if they are even possible to the most skilled scripter. It is just overwhelming to learn how to script, learn the engine, and implement something which the game just not ever made to do at the same time.

So some things you might want to do, you might want to tackle smaller projects until you learn enough to handle them, even volunteer to help a PW or SP module maker get their scripts working. I try to focus on things which i "need to learn" almost all the time. Just the act of learning will actually get what you need done far faster than solely focusing on a single project. Once you "learn" the implementation of something tends to just fall into place very quickly because the issue is more "how" to do it, than doing it. So many have stated they don't have time to learn, when my experience is if you focus on nothing but learning you save far more time in the long run.

Also, in the beginning, if you just read thru the scripts, study how they work, and do minor tweaks, being careful to test them. This is things like changing a damage amount, or perhaps making a spell like drown remove the effects of a spell like combust. You can do many of the same things in the AI or in the campaign scripts, just make sure to comment ( those /* */ things ) what you changed with the original there in case you need to put it back. Then do a lot of testing in game so you can learn how things work.

Note that this is not just the scripts that come with the game, but the scripts by other established scripters as well, you learn a lot by just seeing what people are doing, the scripts that come with the game are not the best examples of the best way to do things.

There is no path to learning scripting, the trick is just keeping at it. After you get some headway, and even if you are getting good, go reread a basic tutorial like knightmares, it's only when the theory and your experience click together that you will really understand how to script. You never are going to stop having ahah moments, nor will you stop learning things from others, even folks who are just starting out. If something seems like its not getting progress, put it down and come back to it after you learn some more, and you really want to come back to your initial projects and redo them once you get more accomplished.

Modifié par painofdungeoneternal, 22 septembre 2010 - 06:43 .


#30
Vaalyah

Vaalyah
  • Members
  • 953 messages
To say the truth, as soon as my gpu would come back from the warranty service, I would try to actually make my toolset run. Last time that my computer was working, the toolset on W7 just freezes as soon as I do whatever click on it.

They have suggested to me to install DirectX9 and .NET. I'll do a try.



Let's suppose the toolset would then work. At that point I would simply have a random try in doing stupid and silly things, like creating an outdoor area, add plants, colouring a path, put an NPC... After a while like that I would try for indoor areas and then with dialogues. No plot, no cause-effect, just random try.



For the point I will feel secure with my basic building abilities, I should have read a lot of things about scripting, so I could be able to start adding extremely basic scripts to my areas. And maybe I'll be able to understand all your suggestions :-D



Then I would like to join somewhat project, because I need to learn and practice a lot. At first with easy things, then I could grow in difficulty. This just to say: "don't worry, I am not totally crazy, I know that I have to start from the base" :-P

#31
Morbane

Morbane
  • Members
  • 1 883 messages
There are heaps of tutorials on the IGN NWNVault . when you're there, look for Lilac Soul's Script Generator, it was designed for NWN1 but for learning purposes it is great for NWN2.

#32
Vaalyah

Vaalyah
  • Members
  • 953 messages
What is it? I've read something about that, but I haven't try to use it (due to computer problems). Is it a sort of collection of scripts?

#33
Morbane

Morbane
  • Members
  • 1 883 messages
It is a very popular site with practically everything NWN1 & NWN2 = mods, scripts, areas, hak packs, modules, etc - it is a community "hub".

My signature leads to a vault page with some content I made - as well in many others' signatures. . .

Modifié par Morbane, 24 septembre 2010 - 03:08 .


#34
Vaalyah

Vaalyah
  • Members
  • 953 messages
Ehm, no, I know what the vault is. I mean, what is "lilac soul's script generator"! :-P

#35
Kaldor Silverwand

Kaldor Silverwand
  • Members
  • 1 585 messages

Vaalyah wrote...

Ehm, no, I know what the vault is. I mean, what is "lilac soul's script generator"! :-P


It is a tool for generating NWN scripts. It is here. I've never used it myself, but others do and the scripts it generates are often NWN2 compatible (although not always).

Regards

#36
Vaalyah

Vaalyah
  • Members
  • 953 messages
Is it worth trying or it is useful just for "common" scripts? Since I would like to learn scripting, of course I can find it useful for more advance feature (plus to see how scripts work) but I would like to do basic things on my own for learning...



By the way, since my computer with NWN2 is still unavailable till my new gpu comes back, is there a place where I can read the scripts that come with the game? Thank you.

#37
Erithol

Erithol
  • Members
  • 5 messages

Vaalyah wrote...

By the way, since my computer with NWN2 is still unavailable till my new gpu comes back, is there a place where I can read the scripts that come with the game? Thank you.


Between nwnlexicon and nwn2wiki you should be able to find an explanation, and examples of every scripting function that ships with the game until you can access your toolset again.

For the actual scripts themselves, try the community script library, I think it has some if not all of them.  Not positive.

Cheers.

#38
Vaalyah

Vaalyah
  • Members
  • 953 messages
Again, you are far better than me. Where can I find the community script library? (and why are you saying that it is not positive?)

#39
Morbane

Morbane
  • Members
  • 1 883 messages

Erithol wrote...

For the actual scripts themselves, try the community script library, I think it has some if not all of them.  Not positive.

Cheers.


If you are referring to Pain's CSL - it is a custom foundation built with enhanced... well just about everything for PWs.

My suggestion is the NWNLexicon 1.69 - it was redesigned specifically for NWN2 where the 1.68 was really only for NWN1

Lilac Soul's Script generator - IMO is THE best way to learn basic scripting and even a good bit of more advanced stuff as well (like tag based scripting). FYI it actually asks you what you want to do, then generates a script ready to be pasted and compiled in the TS!
:innocent:

Modifié par Morbane, 25 septembre 2010 - 05:25 .


#40
Vaalyah

Vaalyah
  • Members
  • 953 messages
Is there a link to this script generator, please? (I have a really bad internet connection today)

#41
_Knightmare_

_Knightmare_
  • Members
  • 643 messages

Vaalyah wrote...

Is there a link to this script generator, please? (I have a really bad internet connection today)


Lilac Soul's Script Generator.

Works great, but is a bit limited. Don't expect to do anything really complex or build scripted systems and the such. Occasionally it will output a finished script that does not work in NWN2, usually because it calls on an include script that is in NWN1 but not NWN2.

#42
Vaalyah

Vaalyah
  • Members
  • 953 messages
thank you thank you thank you thank you!

I don't want to use it extensively, but just to have some example of scripts! Since I am learning... :-)

#43
Nightwoe

Nightwoe
  • Members
  • 57 messages
Lilac Soul's Scripter. NWN Vault. Download it. Makes scripting cake.

DERP nevermind, someone already said it :pinched:

Modifié par Nightwoe, 26 septembre 2010 - 09:28 .


#44
Vaalyah

Vaalyah
  • Members
  • 953 messages
I want to download it as soon as my computer will be fixed... the problem is, from what I've understood, that it could just help with BASIC scripting. While the things I would like to do is far more complicated. But I don't want to give up. I think it could be an interesting script for many purpose, so, I am going to keep on in this idea! :-)

#45
Nightwoe

Nightwoe
  • Members
  • 57 messages
uhh...I've done a few things I would never have figured out without it...I had a complicated torture- uh, I mean INTERAGATION scene (hehe...>.>;;) that needed multiple animation, movement, tag-to-tag associations, equipment changing, PLUS a huge explosian involving a section of the wall while simultaniously spawning like 15-20 NPCs running through script generated smoke(the smoke never worked, though T_T)

#46
_Knightmare_

_Knightmare_
  • Members
  • 643 messages

Nightwoe wrote...

uhh...I've done a few things I would never have figured out without it...I had a complicated torture- uh, I mean INTERAGATION scene (hehe...>.>;;) that needed multiple animation, movement, tag-to-tag associations, equipment changing, PLUS a huge explosian involving a section of the wall while simultaniously spawning like 15-20 NPCs running through script generated smoke(the smoke never worked, though T_T)


Sure, you can use the Script Gen to have a script do "numerous" things all in the same script, but getting it to do "complicated" things is another matter. Eventually you will find that the program has a limit on what it can do and from there you will need to learn how to do it for yourself. All-in-all though, an excellent tool, its what taught me to script.

#47
Vaalyah

Vaalyah
  • Members
  • 953 messages
I think I will do a long training with it, so I can have a better knowledge of scripting. But then I want absolutely to try writing the script for triggering dialogues following some time-related conditions. I think it could be extremely useful for many purposes!

So, in case someone here has already done something in that direction, please, let me know! I have tons of things to learn!