OBJECT_SELF

Moderator: Event DM

Post Reply
User avatar
4x4_Ender
Sage
Posts: 1782
Joined: Wed Jun 04, 2003 11:26 pm
Location: Woodbury, MN (GMT -6)
Contact:

OBJECT_SELF

Post by 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
kombinat
Team Member; Retired with Honors
Posts: 3365
Joined: Fri Jun 13, 2003 12:33 am
DM Avatar: Senath
Location: Sydney, Australia (GMT+10)

Post by 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
User avatar
Lafferty
Scholar
Posts: 1129
Joined: Tue Feb 11, 2003 5:08 pm
Location: look at my hands... they are HUGE. And they cant touch themselves...
Contact:

Post by 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
4x4_Ender
Sage
Posts: 1782
Joined: Wed Jun 04, 2003 11:26 pm
Location: Woodbury, MN (GMT -6)
Contact:

Post by 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)
Contact:

Post by 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
Sindol
Team Member; Retired with Honors
Posts: 6479
Joined: Mon Jan 06, 2003 4:23 pm
Location: Nijmegen - Netherlands (GMT+1)
Contact:

Post by 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
Post Reply