View unanswered posts | View active topics * FAQ    * Search
* Login 




Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 22 posts ] 
dayfer
 
PostPosted: Fri, Oct 07 2011, 21:14 PM 

User avatar

Player

Joined: 17 Aug 2010
Location: England

Right, well apart from GML coding (Game Maker, fairly simple stuff) I've never actually done anything of the sort, so I was thinking of foraying into the relms of Nwscript, and onto C from there (If I get the hang of Nwscript) However I have absolutly no idea where to start, or how for that matter.

So if anyone could point me in the right direction that would be awesome.


 
      
TeroSNS
 
PostPosted: Fri, Oct 07 2011, 21:35 PM 

User avatar

Player

Joined: 26 Jan 2009

dayfer wrote:
Right, well apart from GML coding (Game Maker, fairly simple stuff) I've never actually done anything of the sort, so I was thinking of foraying into the relms of Nwscript, and onto C from there (If I get the hang of Nwscript) However I have absolutly no idea where to start, or how for that matter.

So if anyone could point me in the right direction that would be awesome.

You're in for a bumpy ride, but as an advice get to known to the language, it's basic functions, and try to do something simple, definately start with "Hello world!" program. after that try something harder like putting integers and string into variables and using them in some way. after that study more of the different methods, learn the coding logic, and after that start making something that actually does something, like creating sorting algorithms.

_________________
My favourite sniper loadout: Huntsman, jarate, bushwacka.
Team Fortress 2 is FREE TO PLAY!
Image


 
      
BlackestAtrocity
 
PostPosted: Fri, Oct 07 2011, 22:00 PM 

User avatar

Player

Joined: 03 Aug 2011

An excellent resource..

NwN Lexicon

_________________
Magister Aurelius Constance


 
      
Gers
 
PostPosted: Fri, Oct 07 2011, 22:10 PM 

User avatar

Player

Joined: 30 Apr 2005
Location: Kentucky, USA

A good basic guide to Object Oriented Programming (OOP) would also probably be a good idea. C and it's associated languages are all OOP, as are many others.

_________________
Image
Named Most Influential Character, Amia Awards 2011


 
      
dayfer
 
PostPosted: Fri, Oct 07 2011, 22:18 PM 

User avatar

Player

Joined: 17 Aug 2010
Location: England

Thanks for all the resources from what I've seen so far looks pretty complex, still should be worth it in the long run.

EDIT: Gers, just found a good guide to OOPs, very helpful.


 
      
dayfer
 
PostPosted: Sat, Oct 08 2011, 8:55 AM 

User avatar

Player

Joined: 17 Aug 2010
Location: England

Hookay, I can't believe I'm asking for help on a Hello World Program...

Code:
void SendMessageToPC
  (
   object oPlayer,
   string szMessage
   "Hello World!"
  )


And when I try save it... I get this message: 08/10/2011 09:55:34: Error. 'helloworldv11' did not compile.
helloworldv11.nss(5): ERROR: UNKNOWN STATE IN COMPILER It then highlights the hello world message and the bracket beneath, any thoughts?

EDIT:

Upon removing the brackets I get end up with this message:

08/10/2011 10:00:04: Error. 'helloworldv14' did not compile.
helloworldv14.nss(2): ERROR: FUNCTION DEFINITION MISSING PARAMETER LIST

Highlighting the Object oPlayer line.

EDIT2: I tried compiling the origonal Send message script they give you on the side, that doesn't work at all either,

Code:
void SendMessageToPC(object oPlayer, string szMessage)


08/10/2011 10:07:36: Error. 'waa1' did not compile.
waa1.nss(2): ERROR: UNKNOWN STATE IN COMPILER

EDIT3: It took literally 20 times, but I did it :D Turns out it was the Object oPlayer that wasn't working afterall!

Code:
void main()
{
    SendMessageToPC
    (GetEnteringObject(),
    "Hello world");
}


After a quick search I found all I needed was (GetEnteringObject() No idea why I needed the semi colon but, it works.


 
      
Selmak
 
PostPosted: Sat, Oct 08 2011, 12:29 PM 

User avatar

Player

Joined: 17 Dec 2004

You don't need to use object and string inside SendMessageToPC(). You just need to use them to initialise oPlayer to GetEnteringObject() and szMessage to whatever your message is. Since GetEnteringObject() is an object, you can use it instead of initialising an object, but obviously there are some good reasons to use object variables or they wouldn't exist. :) Same goes for the message.

Code:
void SendMessageToPC(object oPlayer, string szMessage)


What this does is tell you (and the compiler) the type of each parameter so that you don't supply an int where you need to supply an object, for example. When this does happen it will give you a compiler error. You only need a statement like this if you were defining a function of your own, and then you would need a semicolon on the end, like this:

Code:
void HelloWorld( object oPlayer );


This tells the compiler to expect a function HelloWorld further down the page. Normally, you put these prototypes at the beginning of the script, so that someone glancing at your work sees all your function definitions in one place. Sorry if this is not new ground I'm covering, by the way.

A semicolon is necessary in order to end the statement. You'll be using it a lot from now on. ;)

Code:
//Example function
void HelloWorld( object oPlayer ){

    SendMessageToPC( oPlayer, "Hello World!" );

}


 
      
dayfer
 
PostPosted: Sat, Oct 08 2011, 15:43 PM 

User avatar

Player

Joined: 17 Aug 2010
Location: England

Thanks, that's helped alot, the old basic scripting I did was just for my own plat formers, which I'd done all the sprites for etc, and as auto compiled etc.

I'm still learning good programming practices as we speak :)

I'm going to go ahead and try make a simple NPC that lets you do a bunch of stuff in a convorsation, such as I don't know, blow him up or something, try get more complex than sending a Hello World message. Still, so far so good.

EDIT: Does anyone know of a website or program that lists the resource names of different visual effects and spell visuals. For example, I'm trying to have the NPC be struck by lightning when the option is picked so...


 
      
Selmak
 
PostPosted: Sat, Oct 08 2011, 19:20 PM 

User avatar

Player

Joined: 17 Dec 2004

See the constants list at the lexicon.


 
      
dayfer
 
PostPosted: Sat, Oct 08 2011, 20:28 PM 

User avatar

Player

Joined: 17 Aug 2010
Location: England

Thanks!


 
      
dayfer
 
PostPosted: Mon, Oct 10 2011, 15:04 PM 

User avatar

Player

Joined: 17 Aug 2010
Location: England

Who wants more noobtastic scripting errors? Me neither.

Anywho, trying to keep things simple and have the showcase NPC to fire a curse at the Player, here's what I have so far...

Code:
void Main()
{
object oTarget = GetObjectByTag("oPC")
ActionCastSpellAtObject(SPELL_BESTOW_CURSE,oTarget,1);
}


And I get this error: 10/10/2011 16:03:14: Error. 'curse1' did not compile.
curse1.nss(4): ERROR: PARSING VARIABLE LIST

Confused!

EDIT: Nevermind I fixed it, just needed to define nSpell.

Code:
void Main()
{
nSpell= SPELL_BESTOW_CURSE;
object oTarget = GetObjectByTag("OPC");
ActionCastSpellAtObject(nSpell,oTarget,1);
}


 
      
PaladinOfSune
 
PostPosted: Mon, Oct 10 2011, 15:18 PM 

User avatar

Player

Joined: 15 Dec 2004
Location: England, UK

That isn't going to work as GetObjectByTag("oPC") won't do anything. That function is for getting placeables, monsters and such using the tag defined in the toolset... player characters don't have tags. This is part of a conversation, yeah? There's a specific function for getting the PC in a conversation. It's GetPCSpeaker().

_________________
Image
"Let's unwrite these pages and replace them with our own words."


 
      
dayfer
 
PostPosted: Mon, Oct 10 2011, 15:25 PM 

User avatar

Player

Joined: 17 Aug 2010
Location: England

Was literately about to say it wasn't working, thanks, I'll use that.

EDIT: And it still does nothing... hrm.

EDIT2: Forgot to set the bCheat to True :oops:

EDIT3: And it still fails to do anything... Here's what I'm using:

Code:
void Main()
{
nSpell= SPELL_BESTOW_CURSE;
object oTarget = GetPCSpeaker();
bCheat=TRUE;
ActionCastSpellAtObject(nSpell,oTarget,1);
}


 
      
PaladinOfSune
 
PostPosted: Mon, Oct 10 2011, 15:36 PM 

User avatar

Player

Joined: 15 Dec 2004
Location: England, UK

The problem there is that nobody is actually casting the spell. Nothing is saying who should be doing that action. You have a spell and a target, sure, but no caster.

There is a function for that! AssignCommand().

You'll want it to look as:

Code:
AssignCommand( OBJECT_SELF, ActionCastSpellAtObject( nSpell, oTarget, 1 ) );


Generally, all the functions in NWscript that begin with 'Action' require it to be assigned to a target for them to work.

_________________
Image
"Let's unwrite these pages and replace them with our own words."


 
      
dayfer
 
PostPosted: Mon, Oct 10 2011, 15:54 PM 

User avatar

Player

Joined: 17 Aug 2010
Location: England

Attempted to do so, and its still doing nothing... Tried both:

Code:
void Main()
{
nSpell = SPELL_BESTOW_CURSE;
object oTarget = GetPCSpeaker();
bCheat=TRUE;
AssignCommand( OBJECT_SELF, ActionCastSpellAtObject( nSpell, oTarget, 1 ) );
}

And:
Code:
void Main()
{
nSpell = SPELL_BESTOW_CURSE;
object oTarget = GetPCSpeaker();
bCheat=TRUE;
AssignCommand(GetBbjectByTag("Scriptshowcaser"), ActionCastSpellAtObject( nSpell, oTarget, 1 ) );
}


No coding areas, but no casting either.


 
      
PaladinOfSune
 
PostPosted: Mon, Oct 10 2011, 16:03 PM 

User avatar

Player

Joined: 15 Dec 2004
Location: England, UK

Well, for starters, it's void main, not void Main. :D You'll find it'll actually try to compile after renaming that, at least.

Secondly, you missed out defining nSpell as an integer.

It should look like...

Code:
void main()
{
    object oTarget = GetPCSpeaker();
    int nSpell = SPELL_BESTOW_CURSE;

    AssignCommand( OBJECT_SELF, ActionCastSpellAtObject( nSpell, oTarget, METAMAGIC_ANY, TRUE ) );
}

_________________
Image
"Let's unwrite these pages and replace them with our own words."


 
      
dayfer
 
PostPosted: Mon, Oct 10 2011, 16:06 PM 

User avatar

Player

Joined: 17 Aug 2010
Location: England

*Facepalm*

Man I feel like a noob at this, thanks again, lemme try that.

EDIT: And it works! Thanks Pally, I'll try move onto another... thing.


 
      
dayfer
 
PostPosted: Mon, Oct 10 2011, 16:44 PM 

User avatar

Player

Joined: 17 Aug 2010
Location: England

dayfer wrote:
*Facepalm*

Man I feel like a noob at this, thanks again, lemme try that.

EDIT: And it works! Thanks Pally, I'll try move onto another... thing.


EDIT2: Now, for the next one, how exactly will I go about making variables, e.g. old GML code:

Code:
// isalive is the variable in question

If isalive = 1


That would be in a text appears if... As once the showcaser has killed the beggar, he can hardly do it again.


 
      
Selmak
 
PostPosted: Mon, Oct 10 2011, 17:38 PM 

User avatar

Player

Joined: 17 Dec 2004

Something worth pointing out is that when the function definition specifies a value for a certain parameter e.g. int bCheat=FALSE, that is a default value.

When there is a default for a parameter, you do not have to supply it unless you want to supply a different value for that parameter, though you still need to put a comma in if there are more parameters after it.


 
      
Selmak
 
PostPosted: Mon, Oct 10 2011, 18:00 PM 

User avatar

Player

Joined: 17 Dec 2004

dayfer wrote:
dayfer wrote:
*Facepalm*

Man I feel like a noob at this, thanks again, lemme try that.

EDIT: And it works! Thanks Pally, I'll try move onto another... thing.


EDIT2: Now, for the next one, how exactly will I go about making variables, e.g. old GML code:

Code:
// isalive is the variable in question

If isalive = 1


That would be in a text appears if... As once the showcaser has killed the beggar, he can hardly do it again.


Okay. First thing to note is that text appears in conversation if the conditional script returns TRUE. So in that script there is no void main(), by default when you edit a script for that, it opens with an int StartingConditional() function instead.

Then, you have to return a TRUE or FALSE value.

There is a GetIsDead() function for determining whether something is dead. However you first need to get an object for it to work with. Depends on how you have your target NPC's death set up, if the body does not fade away after death then you could use GetObjectByTag.

A more common approach though with quests is to set a particular variable on the PC to indicate that they have completed some stage of the quest. You can use SetLocalInt() and GetLocalInt() for those purposes.

SetLocalInt() sets an integer on an object. You must supply a name for the integer, and an object to set it on, and obviously the value you want to set.

So if the PC kills an NPC to complete a job, you need an OnDeath script for when the NPC dies.

That script sets the variable on the PC, who will be the result of GetLastKiller() in the NPC's OnDeath script.

It's a bit of a runaround, but anyway coming back to the conversation, you can then get that variable from the PC. If it has been set to the right value (because you killed the NPC) then you can return FALSE, hiding that conversation option. Or you can return TRUE, showing that conversation option.

Note that by default, if there is not a conditional script attached to an NPC response, it will be as if there were a conditional script always returning TRUE. Since an NPC can only speak one particular line in response to one of your lines, the first one that has a condition of TRUE will be used. So make sure that your drag the lines around to suit the particular logic you have in mind. :)

Whew! Sorry if I went on for a bit there.


 
      
dayfer
 
PostPosted: Mon, Oct 10 2011, 18:21 PM 

User avatar

Player

Joined: 17 Aug 2010
Location: England

Selmak wrote:
Whew! Sorry if I went on for a bit there.

Never a problem in my books, thanks a bunch, I'll get to it :)


 
      
Scimiter
 
PostPosted: Mon, Oct 10 2011, 18:28 PM 

User avatar

Player

Joined: 25 Apr 2009
Location: Canada

Heh. At this rate you should just host a webinar on NWN script basics Selmak. :wink:

_________________
Guys I play:
Finng Meras
Joshua Steel
Daniel Makie
Celub Elubmiire
Tristan
Len'ionel

Image


 
      
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 22 posts ] 


Who is online

Users browsing this forum: No registered users and 86 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group