Recent changes Random page
GAMING
Gaming
 
WoWWiki
Halopedia
FFXIclopedia
Age of Conan
Warhammer Online
Grand Theft Wiki
See more...

Racial Hatred script

From NWNWiki

Jump to: navigation, search

[edit] Racial Hatred script

[edit] Note

Ok try this on the "OnUserDefined" event of the NPC's you're using. To test I put it on a Half-Orc NPC blueprint and called them "elf-haters", then created a village of elf haters. They ignored my human PC, but yelled abuse and attacked my elf PC . Just change the RACIAL_TYPE_ELF to whatever race you want, and make sure you comment back in the User Event 1002 in the default OnSpawn script. Further instructions are in the comments.

[edit] The Script

/**
    OnUserDefined which makes an NPC attack all members of a particular race
    when percieved.
    USAGE:
    * place in the OnUserDefined event and make sure you've commented in the
    following line in the OnSpawn event:
        SetSpawnInCondition(NW_FLAG_PERCIEVE_EVENT);         //OPTIONAL BEHAVIOR - Fire User Defined Event 1002
    * Change RACIAL_TYPE_* to whatever race you want to attack.  This example
    makes the NPC attack any elves percieved nearby.  Add "else if" statements if
    you want them to hate more than one race.  For example the below has a commented
    out "else if" which can be used to make this NPC attack dwarves on sight as well.
    Just copy this as many times as needed to add more races - and un-comment it
    Author: sidefx
    Created: 12 Sept 2002
*/
void main()
{
    if ( GetUserDefinedEventNumber () == 1002 )
    {
        object oPerceived;
        if ( GetLastPerceptionSeen () )
        {
            // change the following to change which race to attack
            if ( GetRacialType ( oPerceived = GetLastPerceived () ) == RACIAL_TYPE_ELF )
            {
                ActionSpeakString ( "RARRGH! Stinkin' Elf!" );
                ChangeToStandardFaction ( OBJECT_SELF, STANDARD_FACTION_HOSTILE );
                ActionAttack ( oPerceived );
            }
            // comment in the following to add a second race.  Copy and paste below to
            // add further races.
            /*else if ( GetRacialType ( oPerceived ) == RACIAL_TYPE_DWARF )
            {
                ActionSpeakString ( "GRRR! Die Dwarf scum!" );
                ChangeToStandardFaction ( OBJECT_SELF, STANDARD_FACTION_HOSTILE );
                ActionAttack ( oPerceived );
            }*/
        }
    }
}
Rate this article:
Share this article: