Difference between revisions of "GetIsReactionTypeFriendly"

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

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