Difference between revisions of "GetIsReactionTypeFriendly"

From NWN Lexicon
Jump to: navigation, search
(Created page with " =GetIsReactionTypeFriendly(object, object)= Determine whether a creature has a friendly reaction towards another given creature. int  GetIsReactionTy...")
 
m (Remarks: typo fix)
 
(3 intermediate revisions by 2 users not shown)
Line 7: Line 7:
 
Determine whether a creature has a friendly reaction towards another given creature.
 
Determine whether a creature has a friendly reaction towards another given creature.
  
[[int | int ]] GetIsReactionTypeFriendly(
+
<nwscript>
    [[object | object ]] oTarget,
+
int GetIsReactionTypeFriendly(
    [[object | object ]] oSource = OBJECT_SELF
+
    object oTarget,
);
+
    object oSource = OBJECT_SELF
 +
);
 +
</nwscript>
  
 
====Parameters====
 
====Parameters====
Line 32: Line 34:
 
====Remarks====
 
====Remarks====
  
If you just want to know how two objects feel about each other in terms of faction and personal reputation, use GetIsFriend() instead. <br /><br /> This is used mainly for an automatic check of difficulty settings, different factions, an area (or module in general) PvP settings, and like/dislike settings for individuals. <br /><br /> An easy to understand example is outlined in the code example. <br /><br /> You use either GetIsReactionTypeFriendly() or GetIsReactionTypeHostile() in *all* spells which will cause a harmful effect - even if they do not allow saves, spell resistance, or are special monster abilities. <br /><br /> Why? Well, you must make sure that a PC isn't going to start killing other players while, for example, in a no-PvP starting area. Without these checks (basically for "are we meant to damage them"), they could damage the enemy, and the enemy do nothing in return (and it breaks the area rules).
+
If you just want to know how two objects feel about each other in terms of faction and personal reputation, use [[GetIsFriend]]() instead. <br /><br /> This is used mainly for an automatic check of difficulty settings, different factions, an area (or module in general) PvP settings, and like/dislike settings for individuals. <br /><br /> An easy to understand example is outlined in the code example. <br /><br /> You use either [[GetIsReactionTypeFriendly]]() or [[GetIsReactionTypeHostile]]() in *all* spells which will cause a harmful effect - even if they do not allow saves, spell resistance, or are special monster abilities. <br /><br /> Why? Well, you must make sure that a PC isn't going to start killing other players while, for example, in a no-PvP starting area. Without these checks (basically for "are we meant to damage them"), they could damage the enemy, and the enemy do nothing in return (and it breaks the area rules).
  
 
<br />
 
<br />
Line 42: Line 44:
 
====Example====
 
====Example====
  
<font color="#007f00">// This is basically a single check for a target.
+
<nwscript>
</font>
+
// This is basically a single check for a target.
<font color="#007f00">// GetIsReactionTypeFriendly() is used for all spells which normally
+
 
</font><font color="#007f00">// affect anyone inside the blast, or any single-target hostile spell,  
+
// GetIsReactionTypeFriendly() is used for all spells which normally
</font><font color="#007f00">// where you can choose the target yourself.
+
// affect anyone inside the blast, or any single-target hostile spell,  
</font>
+
// where you can choose the target yourself.
<font color="#007f00">// Basically, if a fireball were to be fired in a room, several things
+
 
</font><font color="#007f00">// would stop it - from this one function check (and this is why it  
+
// Basically, if a fireball were to be fired in a room, several things
</font><font color="#007f00">// is so important).
+
// would stop it - from this one function check (and this is why it  
</font>
+
// is so important).
<font color="#007f00">// 1. If the caster is allied with the target, and the difficulty is  
+
 
</font><font color="#007f00">//    not Hardcore or Difficult, then the spell will not damage
+
// 1. If the caster is allied with the target, and the difficulty is  
</font><font color="#007f00">//    friendly people, by this function returning TRUE
+
//    not Hardcore or Difficult, then the spell will not damage
</font><font color="#007f00">// 2. Depending on the PvP settings, Party PvP means you will
+
//    friendly people, by this function returning TRUE
</font><font color="#007f00">//    not damage any party members (allies), and this returns TRUE
+
// 2. Depending on the PvP settings, Party PvP means you will
</font><font color="#007f00">// 3. If you aim to try and attack sombody in a no PvP area, this
+
//    not damage any party members (allies), and this returns TRUE
</font><font color="#007f00">//    will always return TRUE.
+
// 3. If you aim to try and attack somebody in a no PvP area, this
</font><font color="#007f00">// 4. Likewise (but difficulty overrules) if you are in a Full PvP area,
+
//    will always return TRUE.
</font><font color="#007f00">//    this will return FALSE, allowing everything to be damaged.
+
// 4. Likewise (but difficulty overrules) if you are in a Full PvP area,
</font>
+
//    this will return FALSE, allowing everything to be damaged.
<font color="#007f00">// Without these basic checks, as well as, of course, Like/Dislike
+
 
</font><font color="#007f00">// flags, personal reputations and so on, the spell could really break
+
// Without these basic checks, as well as, of course, Like/Dislike
</font><font color="#007f00">// the game.
+
// flags, personal reputations and so on, the spell could really break
</font>
+
// the game.
<font color="#0000ff">void</font> main()
+
 
{
+
void main()
    <font color="#007f00">// Get spell target
+
{
</font>    <font color="#0000ff">object</font> oTarget = GetSpellTargetObject();
+
    // Get spell target
+
    object oTarget = GetSpellTargetObject();
    <font color="#007f00">// They cannot be allied (or can be, in cirtain environments),
+
 
</font>    <font color="#007f00">// nor break the internal PvP rules, so we can do the
+
    // They cannot be allied (or can be, in certain environments),
</font>    <font color="#007f00">// damage to them
+
    // nor break the internal PvP rules, so we can do the
</font>    <font color="#0000ff">if</font>(!GetIsReactionTypeFriendly(oTarget))
+
    // damage to them
    {
+
    if(!GetIsReactionTypeFriendly(oTarget))
        <font color="#007f00">// Do 5 damage to them, if we don't break PvP and so on
+
    {
</font>        <font color="#0000ff">effect</font> eDam = EffectDamage(<font color="#7f007f">5</font>);
+
        // Do 5 damage to them, if we don't break PvP and so on
        ApplyEffectToObject(DURATION_TYPE_INSTANT, eDam, oTarget);
+
        effect eDam = EffectDamage(5);
    }
+
        ApplyEffectToObject(DURATION_TYPE_INSTANT, eDam, oTarget);
}
+
    }
 +
}
 +
</nwscript>
  
 
====See Also====
 
====See Also====

Latest revision as of 03:36, 24 June 2019



GetIsReactionTypeFriendly(object, object)

Determine whether a creature has a friendly reaction towards another given creature.

int GetIsReactionTypeFriendly(
    object oTarget,
    object oSource = OBJECT_SELF
);

Parameters

oTarget

The target creature to test.

oSource

The source creature to test the feelings of. (Default: OBJECT_SELF)


Description

Returns TRUE if oSource has a friendly reaction towards oTarget, depending on the reputation, PVP setting and (if both oSource and oTarget are PCs), oSource's Like/Dislike setting for oTarget.



Remarks

If you just want to know how two objects feel about each other in terms of faction and personal reputation, use GetIsFriend() instead.

This is used mainly for an automatic check of difficulty settings, different factions, an area (or module in general) PvP settings, and like/dislike settings for individuals.

An easy to understand example is outlined in the code example.

You use either GetIsReactionTypeFriendly() or GetIsReactionTypeHostile() in *all* spells which will cause a harmful effect - even if they do not allow saves, spell resistance, or are special monster abilities.

Why? Well, you must make sure that a PC isn't going to start killing other players while, for example, in a no-PvP starting area. Without these checks (basically for "are we meant to damage them"), they could damage the enemy, and the enemy do nothing in return (and it breaks the area rules).


Version

1.62

Example

// This is basically a single check for a target.
 
// GetIsReactionTypeFriendly() is used for all spells which normally
// affect anyone inside the blast, or any single-target hostile spell, 
// where you can choose the target yourself.
 
// Basically, if a fireball were to be fired in a room, several things
// would stop it - from this one function check (and this is why it 
// is so important).
 
// 1. If the caster is allied with the target, and the difficulty is 
//     not Hardcore or Difficult, then the spell will not damage
//     friendly people, by this function returning TRUE
// 2. Depending on the PvP settings, Party PvP means you will
//     not damage any party members (allies), and this returns TRUE
// 3. If you aim to try and attack somebody in a no PvP area, this
//     will always return TRUE.
// 4. Likewise (but difficulty overrules) if you are in a Full PvP area,
//     this will return FALSE, allowing everything to be damaged.
 
// Without these basic checks, as well as, of course, Like/Dislike
// flags, personal reputations and so on, the spell could really break
// the game.
 
void main()
{
    // Get spell target
    object oTarget = GetSpellTargetObject();
 
    // They cannot be allied (or can be, in certain environments),
    // nor break the internal PvP rules, so we can do the
    // damage to them
    if(!GetIsReactionTypeFriendly(oTarget))
    {
        // Do 5 damage to them, if we don't break PvP and so on
        effect eDam = EffectDamage(5);
        ApplyEffectToObject(DURATION_TYPE_INSTANT, eDam, oTarget);
    }
}

See Also

functions: 

GetIsFriend



 author: Jason Harris, editor: Jasperre, additional contributor(s): Kristian Markon, Jasperre