Server Totals
Underdark - (5)
Mikona - (2)
Elysia - (1)
Le'Or - (0)
Ferrell - (0)
M'Chek - (0)
Deglos - (0)
Wilderness - (0)
Visimontium - (0)
Total players: 8
Gallery

Links Menu

OBJECT_SELF

Moderators: Nighthawk4, Dungeon Masters

OBJECT_SELF

PostAuthor: 4x4_Ender » Tue Nov 02, 2004 3:38 am

This might be a dumb question, proving my incredible n00bness in coding using NWNscript. But, what exactly does this command do and when can you use it?? I see it all the time in scripts but never know what its used for.

For example, its used in this script to define the oSourceFactionMember to adjust the reputation of an attacking creature by -35:

Code: Select all
// this function will lower by 35 points how the attackee's
// faction will view the attacker.
main()
{
     object oAttacker = GetLastAttacker();
     if(GetIsObjectValid(oAttacker))
     {
          AdjustReputation(oAttacker, OBJECT_SELF, -35);
     }
}


In order for OBJECT_SELF to work, does it have to be assigned to an object itself somehow, mabye on some event in the object?
"Many make a trade of delusions and false miracles, deceiving the stupid multitude." -Leonardo Da Vinci
User avatar
4x4_Ender
Sage
 
Posts: 1782
Joined: Wed Jun 04, 2003 11:26 pm
Location: Woodbury, MN (GMT -6)

PostAuthor: kombinat » Tue Nov 02, 2004 4:00 am

It's not a command, it's a pre-defined variable which you can use to access the object that the currently executing script is attached to, be it placeable, character, item, creature, whatever, I believe. You should not try to assign anything to it.
Be mindful of the prayers you send
Pray hard but pray with care
For the tears that you are crying now
Are just your answered prayers

kombinat
Team Member; Retired with Honors
 
Posts: 3365
Joined: Fri Jun 13, 2003 12:33 am
Location: Sydney, Australia (GMT+10)
DM Avatar: Senath

PostAuthor: Lafferty » Tue Nov 02, 2004 4:25 am

It's a reference to the calling object. If you for example have a lever that gets pulled and opens a door and deals 5 damage to the user, you hook a script to OnUsed to the lever. That makes the lever the calling object in that moment (the OBJECT_SELF).
In order to access the other 2 objects involved in the example you need to utilize different commands of the nwn scripting engine like GetLastUsedBy() or GetObjectByTag().
Tool for crafters Do you want some human to your salt? nomanisanisland.monolar.de
User avatar
Lafferty
Scholar
 
Posts: 1130
Joined: Tue Feb 11, 2003 5:08 pm
Location: look at my hands... they are HUGE. And they cant touch themselves...

PostAuthor: 4x4_Ender » Tue Nov 02, 2004 4:37 am

Makes sense. Thanks!
"Many make a trade of delusions and false miracles, deceiving the stupid multitude." -Leonardo Da Vinci
User avatar
4x4_Ender
Sage
 
Posts: 1782
Joined: Wed Jun 04, 2003 11:26 pm
Location: Woodbury, MN (GMT -6)

PostAuthor: 4x4_Ender » Tue Nov 02, 2004 6:17 pm

Something i was wondering about this (i know mist told me to cork it, but this wont take long :P ).....

Can you use OBJECT_SELF with GetObject() in a conversation to define an object variable for the NPC that has the conversation applied to them?? Otherwise, you have to use GetObjectByTag() for all the conversation scripts involving the NPC object, which means you need to make a bunch of scripts that are specific to that NPC's tag and cant be used for anything else.
"Many make a trade of delusions and false miracles, deceiving the stupid multitude." -Leonardo Da Vinci
User avatar
4x4_Ender
Sage
 
Posts: 1782
Joined: Wed Jun 04, 2003 11:26 pm
Location: Woodbury, MN (GMT -6)

PostAuthor: Sindol » Tue Nov 02, 2004 7:06 pm

4x4_Ender wrote:Can you use OBJECT_SELF with GetObject() in a conversation to define an object variable for the NPC that has the conversation applied to them?? Otherwise, you have to use GetObjectByTag() for all the conversation scripts involving the NPC object, which means you need to make a bunch of scripts that are specific to that NPC's tag and cant be used for anything else.


In conversation scripts the NPC that has the conversation attached is the caller and will be specified with OBJECT_SELF yes.
So much fun,
yet so little time to enjoy it.
- Sindol
User avatar
Sindol
Team Member; Retired with Honors
 
Posts: 6487
Joined: Mon Jan 06, 2003 4:23 pm
Location: Nijmegen - Netherlands (GMT+1)


Return to NWN Scripting

Who is online

Registered users: Bing [Bot], Google [Bot], Vichan Lyonsen