DMH-Online

Dungeon Masters Helper · Est. 2005

Items Scripts

NWN Script: random_magic.htm

Author Sticky: Post Working Scripts Here
Ben WH Posted: Tuesday, 30 July 04:01PM
Ben W-Husey

script: randomitemplus1

Just a quick script which generates a random +1 weapon on the ground. Uses a generic trigger to place the item based on a PC being with x distance (at present 20). Placed in the OnHeartBeat, but adapt away. Really just saves you doing a random +1 weapon script!

NWScript:
//:://////////////////////////////////////////////
//::
//:: Edited  By:   Ben W-Husey
//::               July 29, 2002
//:://////////////////////////////////////////////
void main()
{
   object oCreature = GetNearestCreature(CREATURE_TYPE_PLAYER_CHAR, PLAYER_CHAR_IS_PC);
   if (GetIsObjectValid(oCreature) == TRUE && GetDistanceToObject(oCreature) < 20.0)
   {
    effect eMind = EffectVisualEffect(VFX_IMP_DISPEL);
    string sItem = "nw_wswmdg002";
    int rnd;
    rnd = Random(110); // Calculate _one_ random number
    if (rnd < 15)
    {
        sItem = "nw_wswmdg002";            //dagger
    } else if (rnd < 20)
    {
        sItem = "nw_wblmhl002";    //light hammer
    } else if (rnd < 30)
    {
        sItem = "nw_wdbmqs002";           //quarterstaff
    } else if (rnd < 33)
    {
        sItem = "nw_waxmhn002";          //hand axe
    } else if (rnd < 38)
    {
        sItem = "nw_waxmbt002";            //battleaxe
    } else if (rnd < 44)
    {
        sItem = "nw_wblmml002";           //light mace
    } else if (rnd < 48)
    {
        sItem = "nw_wblmfl002";       //light flail
    } else if (rnd < 52)
    {
        sItem = "nw_wblmms002";       //morning star
    } else if (rnd < 60)
    {
        sItem = "nw_wswmss002";       //short sword
    } else if (rnd < 70)
    {
        sItem = "nw_wswmls002";       //long sword
    } else if (rnd < 73)
    {
        sItem = "nw_wswmbs002";       //bastard sword
    } else if (rnd < 75)
    {
        sItem = "nw_wswmgs002";       //greatsword
    } else if (rnd < 77)
    {
        sItem = "nw_waxmgr002";       //greataxe
    } else if (rnd < 81)
    {
        sItem = "nw_wplmss002";       //spear
    } else if (rnd < 83)
    {
        sItem = "nw_wplmhb002";       //halberd
    } else if (rnd < 84)
    {
        sItem = "nw_wplmsc002";       //scythe
    } else if (rnd < 85)
    {
        sItem = "nw_wswmka002";       //katana
    } else if (rnd < 86)
    {
        sItem = "nw_wspmku002";       //kukri
    } else if (rnd < 88)
    {
        sItem = "nw_wspmka002";       //kama
    } else if (rnd < 91)
    {
        sItem = "nw_wbwmsh002";       //short bow
     } else if (rnd < 93)
    {
        sItem = "nw_wbwmln002";       //long bow
    } else if (rnd < 96)
    {
        sItem = "nw_wbwmxl002";       //light crossbow
    } else if (rnd < 97)
    {
        sItem = "nw_wbwmxh002";       //heavy crossbow
    } else if (rnd < 99)
    {
        sItem = "nw_wbwmsl001";       //sling
    } else if (rnd < 100)
    {
        sItem = "nw_wblmfh002";       //heavy flail
    } else if (rnd < 101)
    {
        sItem = "nw_wblmhw002";       //warhammer
    } else if (rnd < 102)
    {
        sItem = "nw_wdbmma002";       //Dire Mace
    } else if (rnd < 103)
    {
        sItem = "nw_wdbmax002";       //double axe
        } else if (rnd < 104)
    {
        sItem = "nw_wdbmsw002";       //double sword
        } else if (rnd < 105)
    {
        sItem = "nw_wspmnn002";       //Nunchaku
        } else if (rnd < 106)
    {
        sItem = "nw_wspmsc002";       //sickle
    }
else if (rnd < 108)
    {
        sItem = "nw_wswmrp002";       //rapier
    }
    else if (rnd < 110)
    {
        sItem = "nw_wswmsc002";       //scimitar
    }
    object oMonster = CreateObject(OBJECT_TYPE_ITEM, sItem, GetLocation(OBJECT_SELF));
   ApplyEffectToObject(DURATION_TYPE_INSTANT, eMind, oMonster);
    SetPlotFlag(OBJECT_SELF, FALSE);
    DestroyObject(OBJECT_SELF, 0.5);
   }
}
⌂ All Scripts ← PreviousNext → 👁 Category List

All Items Scripts

📄 aquire_time 📄 bead_of_force 📄 book_of_inf_spells 📄 clear_inventory 📄 clear_inventory_002 📄 clear_inventory_003 📄 clear_inventory_004 📄 cursed_items 📄 cursed_items_002 📄 cursed_potion 📄 give_xp 📄 glow_when_mob 📄 healing_belt 📄 helm 📄 hurled_weapons 📄 item_weight 📄 key_rental 📄 lore_items 📄 npc_owners 📄 random_magic 📄 retrieve_ammo 📄 scimitar_of_dancing 📄 scroll_creation 📄 spawn_item 📄 spawn_item_002 📄 spawn_item_004 📄 stone_of_recall 📄 stone_of_recall_002 📄 summon_creature 📄 teleport_item 📄 torch 📄 weapon_upgrade