Author Topic: Problem with treasure creation  (Read 412 times)

Legacy_DM-Chemosh

  • Newbie
  • *
  • Posts: 42
  • Karma: +0/-0
Problem with treasure creation
« on: September 30, 2010, 12:49:37 am »


               I encoutered a weird problem with one of my other bosses. In the
OnSpawnScript I use the CTG CreateTreasure stuff, which works with all
bosses I did fine. Now, for the one I am talking about, there's never
treasure created on her for some reason? The script is the SAME as for
the boss before her and those DO get treasure when they get spawned in
the level. So treasure chest for the area is fine (Unique). Question
is: Could that be because she has an OnDmg script or could it even be
because of her appearance that I chose? I'm really out of thoughts what
causes it and it's annoying me quite a bit!

As 420 already told me:
Two possible causes right off the top of my head. Either the creature's
OnSpawn script has a SetIsDestroyable() command making the creature
unselectable when dead or the X2_L_NOTREASURE local int may be set in
the creature's variables (Edit Creature>Advanced>Variables).

I use the normal OnSpawnScript Template with the CTG treasure creation.

The following script (done by one of our other DMs) is on the "ondamaged" of her, though: (the only variable on her is "nStage" = 0 from the spawn) but I am asking myself it the GetPlotFlag actually screws the treasure creation up, since she is NOT "plot" by default onspawn in the creature properties and I don't see any reason why this script is actually making her? 


void main()
{
    //--------------------------------------------------------------------------
    // GZ: 2003-10-16
    // Make Plot Creatures Ignore Attacks
    //--------------------------------------------------------------------------
    if (GetPlotFlag(OBJECT_SELF))
    {
        return;
    }
    object oPC = GetFirstPC();
    object oTarget = GetNearestCreature(CREATURE_TYPE_PLAYER_CHAR, PLAYER_CHAR_IS_PC);
    float fHP = IntToFloat(GetCurrentHitPoints());
    float fMaxHP = IntToFloat(GetMaxHitPoints());
    float fPercent = fHP/fMaxHP;
    float fDist = GetDistanceBetween(oTarget, OBJECT_SELF);
    int nStage = GetLocalInt(OBJECT_SELF, "nStage");


    if (fPercent<=0.30 && nStage == 0) {
        ClearAllActions(TRUE);
        ActionSpeakString("Now - you shall see my true form!");
        ApplyEffectToObject(DURATION_TYPE_INSTANT,EffectVisualEffect(VFX_DUR_DEATH_ARMOR),  OBJECT_SELF);
        ApplyEffectToObject(DURATION_TYPE_INSTANT,EffectVisualEffect(246),  OBJECT_SELF);
        SetCreatureAppearanceType(OBJECT_SELF, APPEARANCE_TYPE_WRAITH);
        SetLocalInt(OBJECT_SELF, "nStage", 1);
    }
    else if (fPercent <= 0.10 && nStage ==1) {
        ClearAllActions(TRUE);
        ActionSpeakString("If I'm going down, I'm taking one of you with me!");
        ActionForceMoveToObject(oTarget, TRUE);
        SetLocalInt(OBJECT_SELF, "nStage", 3);
    }
    else if (nStage == 3) {
        if (fDist < 5.0) {
            if (TouchAttackMelee(oTarget) == 1 || TouchAttackMelee(oTarget) == 2) {
                ActionSpeakString(GetName(oTarget) + ", you shall die with me!");
                effect eDeath = EffectDeath(TRUE);
                ApplyEffectToObject(DURATION_TYPE_INSTANT, eDeath, oTarget);
            }
        }
        else {
            ClearAllActions(TRUE);
            ActionForceMoveToObject(oTarget, TRUE);
        }
    }
    else{
    //--------------------------------------------------------------------------
    // Execute old NWN default AI code
    //--------------------------------------------------------------------------
    ExecuteScript("nw_c2_default6", OBJECT_SELF);
    }
}


Anyone has a Solution for this weird problem? Sorry for bothering you guys, just working hard to make get the dungeon done. Thankful for any help you people can provide.
               
               

               
            

Legacy_DM-Chemosh

  • Newbie
  • *
  • Posts: 42
  • Karma: +0/-0
Problem with treasure creation
« Reply #1 on: September 30, 2010, 03:33:32 pm »


               I...

...changed the appearance = still no loot

.. deleted and created a new treasure container = still no loot

.. copied the OnSpawnScript from another boss (same dungeon) = still no loot



Any ideas?!
               
               

               
            

Legacy_Mudeye

  • Full Member
  • ***
  • Posts: 238
  • Karma: +0/-0
Problem with treasure creation
« Reply #2 on: September 30, 2010, 04:53:46 pm »


               

Is the "Leaves Lootable Corpse" flag set on the creature?

Try just putting an object in the inventory of the creature to see if it gets dropped.

If the creature speaks any of the lines in the script then the Plot Flag is not set.



Make sure that the tags for creating the treasure chest are unique and the script uses them. If they are out of sync it could be trying to create treasure on the wrong chest.
               
               

               
            

Legacy_DM-Chemosh

  • Newbie
  • *
  • Posts: 42
  • Karma: +0/-0
Problem with treasure creation
« Reply #3 on: September 30, 2010, 11:32:43 pm »


               Hello Mudeye,



Flag "LeavesLootableCorpse" is set on the Creature.



Treasure should be spawned on HER, not on a chest (using the Default CTG Treasure thing)



She does speak those lines, transforms and also tries the touch attack (which sometimes seems to kill ALL PCs that are next to her?). Script is working fine, just the treasure generation on that monster doesn't.



She has a certain plot item in her inventory (like all the other bosses in that dungeon as well) which drops fine from her. But all other bosses additionally get treasure created on (as it should be) just not her.





Important to note here is, that any other boss draws correctly treasure out of the area Unique chest, only this particular one doesn't.
               
               

               
            

Legacy_kalbaern

  • Hero Member
  • *****
  • Posts: 1531
  • Karma: +0/-0
Problem with treasure creation
« Reply #4 on: October 01, 2010, 02:39:16 am »


               Try changing your bosses appearance to something else. Certain appearances are disabled from dropping loot in the Bioware System.
               
               

               
            

Legacy_Mudeye

  • Full Member
  • ***
  • Posts: 238
  • Karma: +0/-0
Problem with treasure creation
« Reply #5 on: October 01, 2010, 04:51:21 pm »


               Can you post the script that is supposed to be generating the items on the Boss then?  



This sounds like an identifier problem. Something like you don't have the tags right for the chest or boss or item or something.



One thing to do might be to have the Boss drop the items as soon as it gets them to see if they are ever there at all.  void ActionPutDownItem( object oItem ); should be the function.
               
               

               
            

Legacy_420

  • Sr. Member
  • ****
  • Posts: 370
  • Karma: +0/-0
Problem with treasure creation
« Reply #6 on: October 01, 2010, 08:16:06 pm »


               

DM-Chemosh wrote...

She does speak those lines, transforms and also tries the touch attack (which sometimes seems to kill ALL PCs that are next to her?). Script is working fine, just the treasure generation on that monster doesn't.

I don't have any new insight on the treasure spawning problem, it may help to see the script that spawns the additional loot like Mudeye suggests.

However, the problem with all PCs getting killed probably has to do with the fact that the OnDamaged event triggers whenever a PC damages the creature and if they meet the conditions they will all get the death touch.

You can do something like this to avoid having it trigger multiple times:

    else if (nStage == 3) {
        if (fDist < 5.0) {
            if (TouchAttackMelee(oTarget) == 1 || TouchAttackMelee(oTarget) == 2) {
                ActionSpeakString(GetName(oTarget) + ", you shall die with me!");
                effect eDeath = EffectDeath(TRUE);
                ApplyEffectToObject(DURATION_TYPE_INSTANT, eDeath, oTarget);
                SetLocalInt(OBJECT_SELF, "nStage", 4);
            }



-420
               
               

               
            

Legacy_DM-Chemosh

  • Newbie
  • *
  • Posts: 42
  • Karma: +0/-0
Problem with treasure creation
« Reply #7 on: October 03, 2010, 03:37:45 am »


               First of all - thanks 420 for fixing THAT certain problem with the kiling people over and over again. Could've thought of that particual thing by myself actually, lol.



Anyways, here's the OnSpawnScript with the treasurecreation on the bottom:



//:://////////////////////////////////////////////////

//:: CUSTOM OnSpawn handler.

/*

* Default OnSpawn handler with XP1 revisions.

*

* This can be used to customize creature behavior in three main ways:

*

* - Uncomment the existing lines of code to activate certain

*   common desired behaviors from the moment when the creature

*   spawns in.

*

* - Uncomment the user-defined event signals to cause the

*   creature to fire events that you can then handle with

*   a custom OnUserDefined event handler script.

*

* - Add new code _at the end_ to alter the initial

*   behavior in a more customized way.

*/

//:://////////////////////////////////////////////////

//:: Copyright © 2002 Floodgate Entertainment

//:: Created By: Naomi Novik

//:: Created On: 12/11/2002

//:://////////////////////////////////////////////////



#include "x0_i0_anims"

//#include "x0_i0_walkway"

#include "x0_i0_treasure"



void main()

{

   // ***** Spawn-In Conditions ***** //



   // * REMOVE COMMENTS (// ) before the "Set..." functions to activate

   // * them. Do NOT touch lines commented out with // *, those are

   // * real comments for information.



   // * This causes the creature to say a one-line greeting in their

   // * conversation file upon perceiving the player. Put [NW_D2_GenCheck]

   // * in the "Text Seen When" field of the greeting in the conversation

   // * file. Don't attach any player responses.

   // *

   // SetSpawnInCondition(NW_FLAG_SPECIAL_CONVERSATION);



   // * Same as above, but for hostile creatures to make them say

   // * a line before attacking.

   // *

   // SetSpawnInCondition(NW_FLAG_SPECIAL_COMBAT_CONVERSATION);



   // * This NPC will attack when its allies call for help

   // *

   // SetSpawnInCondition(NW_FLAG_SHOUT_ATTACK_MY_TARGET);



   // * If the NPC has the Hide skill they will go into stealth mode

   // * while doing WalkWayPoints().

   // *

   // SetSpawnInCondition(NW_FLAG_STEALTH);



   // * Same, but for Search mode

   // *

   // SetSpawnInCondition(NW_FLAG_SEARCH);



   // * This will set the NPC to give a warning to non-enemies

   // * before attacking.

   // * NN -- no clue what this really does yet

   // *

   // SetSpawnInCondition(NW_FLAG_SET_WARNINGS);



   // * Separate the NPC's waypoints into day & night.

   // * See comment on WalkWayPoints() for use.

   // *

   // SetSpawnInCondition(NW_FLAG_DAY_NIGHT_POSTING);



   // * If this is set, the NPC will appear using the "EffectAppear"

   // * animation instead of fading in, *IF* SetListeningPatterns()

   // * is called below.

   // *

   // SetSpawnInCondition(NW_FLAG_APPEAR_SPAWN_IN_ANIMATION);



   // * This will cause an NPC to use common animations it possesses,

   // * and use social ones to any other nearby friendly NPCs.

   // *

   // SetSpawnInCondition(NW_FLAG_IMMOBILE_AMBIENT_ANIMATIONS);



   // * Same as above, except NPC will wander randomly around the

   // * area.

   // *

   // SetSpawnInCondition(NW_FLAG_AMBIENT_ANIMATIONS);



   // **** Animation Conditions **** //

   // * These are extra conditions you can put on creatures with ambient

   // * animations.



   // * Civilized creatures interact with placeables in

   // * their area that have the tag "NW_INTERACTIVE"

   // * and "talk" to each other.

   // *

   // * Humanoid races are civilized by default, so only

   // * set this flag for monster races that you want to

   // * behave the same way.

   // SetAnimationCondition(NW_ANIM_FLAG_IS_CIVILIZED);



   // * If this flag is set, this creature will constantly

   // * be acting. Otherwise, creatures will only start

   // * performing their ambient animations when they

   // * first perceive a player, and they will stop when

   // * the player leaves the area.

   // SetAnimationCondition(NW_ANIM_FLAG_CONSTANT);



   // * Civilized creatures with this flag set will

   // * randomly use a few voicechats. It's a good

   // * idea to avoid putting this on multiple

   // * creatures using the same voiceset.

   // SetAnimationCondition(NW_ANIM_FLAG_CHATTER);



   // * Creatures with _immobile_ ambient animations

   // * can have this flag set to make them mobile in a

   // * close range. They will never leave their immediate

   // * area, but will move around in it, frequently

   // * returning to their starting point.

   // *

   // * Note that creatures spawned inside interior areas

   // * that contain a waypoint with one of the tags

   // * "NW_HOME", "NW_TAVERN", "NW_SHOP" will automatically

   // * have this condition set.

   SetAnimationCondition(NW_ANIM_FLAG_IS_MOBILE_CLOSE_RANGE);





   // **** Special Combat Tactics *****//

   // * These are special flags that can be set on creatures to

   // * make them follow certain specialized combat tactics.

   // * NOTE: ONLY ONE OF THESE SHOULD BE SET ON A SINGLE CREATURE.



   // * Ranged attacker

   // * Will attempt to stay at ranged distance from their

   // * target.

   // SetCombatCondition(X0_COMBAT_FLAG_RANGED);



   // * Defensive attacker

   // * Will use defensive combat feats and parry

   // SetCombatCondition(X0_COMBAT_FLAG_DEFENSIVE);



   // * Ambusher

   // * Will go stealthy/invisible and attack, then

   // * run away and try to go stealthy again before

   // * attacking anew.

   // * This is not yet working fully!

   // SetCombatCondition(X0_COMBAT_FLAG_AMBUSHER);



   // * Cowardly

   // * Cowardly creatures will attempt to flee

   // * attackers.

   // SetCombatCondition(X0_COMBAT_FLAG_COWARDLY);





   // **** Escape Commands ***** //

   // * NOTE: ONLY ONE OF THE FOLLOWING SHOULD EVER BE SET AT ONE TIME.

   // * NOTE2: Not clear that these actually work. -- NN



   // * Flee to a way point and return a short time later.

   // *

   // SetSpawnInCondition(NW_FLAG_ESCAPE_RETURN);



   // * Flee to a way point and do not return.

   // *

   // SetSpawnInCondition(NW_FLAG_ESCAPE_LEAVE);



   // * Teleport to safety and do not return.

   // *

   // SetSpawnInCondition(NW_FLAG_TELEPORT_LEAVE);



   // * Teleport to safety and return a short time later.

   // *

   // SetSpawnInCondition(NW_FLAG_TELEPORT_RETURN);







   // ***** CUSTOM USER DEFINED EVENTS ***** /





   /*

     If you uncomment any of these conditions, the creature will fire

     a specific user-defined event number on each event. That will then

     allow you to write custom code in the "OnUserDefinedEvent" handler

     script to go on top of the default NPC behaviors for that event.



     Example: I want to add some custom behavior to my NPC when they

     are damaged. I uncomment the "NW_FLAG_DAMAGED_EVENT", then create

     a new user-defined script that has something like this in it:



     if (GetUserDefinedEventNumber() == 1006) {

         // Custom code for my NPC to execute when it's damaged

     }



     These user-defined events are in the range 1001-1007.



     The OnDeath user defined event does not work reliably because

     the creature dies and the user-defined event handler script

     does not always run as a result. For OnDeath events, you will

     need to create a custom OnDeath script.

   */



   // * Fire User Defined Event 1001 in the OnHeartbeat

   // *

   // SetSpawnInCondition(NW_FLAG_HEARTBEAT_EVENT);



   // * Fire User Defined Event 1002

   // *

   // SetSpawnInCondition(NW_FLAG_PERCIEVE_EVENT);



   // * Fire User Defined Event 1005

   // *

   // SetSpawnInCondition(NW_FLAG_ATTACK_EVENT);



   // * Fire User Defined Event 1006

   // *

   SetSpawnInCondition(NW_FLAG_DAMAGED_EVENT);



   // * Fire User Defined Event 1008

   // *

   // SetSpawnInCondition(NW_FLAG_DISTURBED_EVENT);



   // * Fire User Defined Event 1003

   // *

   // SetSpawnInCondition(NW_FLAG_END_COMBAT_ROUND_EVENT);



   // * Fire User Defined Event 1004

   // *

   // SetSpawnInCondition(NW_FLAG_ON_DIALOGUE_EVENT);







   // ***** DEFAULT GENERIC BEHAVIOR (DO NOT TOUCH) ***** //



   // * Goes through and sets up which shouts the NPC will listen to.

   // *

   SetListeningPatterns();



   // * Walk among a set of waypoints.

   // * 1. Find waypoints with the tag "WP_" + NPC TAG + "_##" and walk

   // *    among them in order.

   // * 2. If the tag of the Way Point is "POST_" + NPC TAG, stay there

   // *    and return to it after combat.

   //

   // * Optional Parameters:

   // * void WalkWayPoints(int nRun = FALSE, float fPause = 1.0)

   //

   // * If "NW_FLAG_DAY_NIGHT_POSTING" is set above, you can also

   // * create waypoints with the tags "WN_" + NPC Tag + "_##"

   // * and those will be walked at night. (The standard waypoints

   // * will be walked during the day.)

   // * The night "posting" waypoint tag is simply "NIGHT_" + NPC tag.

   WalkWayPoints();





   //* Create a small amount of treasure on the creature

   CTG_GenerateNPCTreasure(TREASURE_TYPE_UNIQUE, OBJECT_SELF);





   // ***** ADD ANY SPECIAL ON-SPAWN CODE HERE ***** //



}

               
               

               
            

Legacy_DM-Chemosh

  • Newbie
  • *
  • Posts: 42
  • Karma: +0/-0
Problem with treasure creation
« Reply #8 on: October 03, 2010, 03:40:12 am »


               

kalbaern wrote...

Try changing your bosses appearance to something else. Certain appearances are disabled from dropping loot in the Bioware System.


Thanks, kalbaern! Do you know if the "Drow, Matron" is one of them by chance? Because I'm pretty sure that I had her dropping stuff before but for some reason, she doesn't anymore. I could send you the boss to check on her as an erf if anyone wants to get a closer look into it. Just drop me a note here.
               
               

               
            

Legacy_kalbaern

  • Hero Member
  • *****
  • Posts: 1531
  • Karma: +0/-0
Problem with treasure creation
« Reply #9 on: October 03, 2010, 07:42:24 am »


               I see the issue, its the treasure call used is all.
CTG_GenerateNPCTreasure(TREASURE_TYPE_UNIQUE, OBJECT_SELF);

This has a chance to fail if you didn't realise it.

the treasure include holds the key. NPC treasure has a chance of not being generated based on the result in
const int BK_CHANCE_OF_N0_MONSTERTREASURE = 40; found in #include "x0_i0_treasure".

So avoid it.

Substitute this in your Boss OnSpawn Events only instead.
CTG_CreateTreasure(TREASURE_TYPE_UNIQUE, OBJECT_SELF);

That should ensure loot despite appearances or racial types. The NPC loot call is never certain unless you set
const int BK_CHANCE_OF_N0_MONSTERTREASURE = 40; to zero instead of whatever it is currently. This is the setting for all NPCs though and you'd be affecting drops from every single creature in your module.

I bet all or most of your Bosses have the same issue. I'd bet if you tested this one enough, it'd drop loot at some point as well. Anyhow, change your OnSpawn as I suggested and it'll work everytime.
               
               

               
            

Legacy_DM-Chemosh

  • Newbie
  • *
  • Posts: 42
  • Karma: +0/-0
Problem with treasure creation
« Reply #10 on: October 04, 2010, 07:43:55 am »


               Nope. That's the weird thing here:



My bosses in that dungeon use all the same OnSpawn script (only varying from their behavioral settings!) - so the fun part is:



I spawn another boss from one of the other levels before (same treasure call there!) = IT DOES GET TREASURE



I spawn that boss for that level => she doesn't



I don't think it's that CTG_CreateTreasure(TREASURE_TYPE_UNIQUE, OBJECT_SELF); call therefore, since it does work with all the other bosses that have the same call. I can basically exchange all the bosses within the levels from 2-5 - they all work on any of those levels, only that certain one we talk about here, doesn't get treasure on ANY level.



I'm at the point to copy/paste her, give her another tag, appearance, attach the scripts again and try again since maybe the BP is just buggy?!
               
               

               
            

Legacy_kalbaern

  • Hero Member
  • *****
  • Posts: 1531
  • Karma: +0/-0
Problem with treasure creation
« Reply #11 on: October 04, 2010, 04:08:07 pm »


               Change the treasure call and it should work. I've had similar issues when using the same type scripts when utilising the CEP invisible and invisible no glow appearances and this was the fix.



You could also switch her to a dynamic elven female and give her dark skin and custom clothing/armor as a test.
               
               

               
            

Legacy_GhostOfGod

  • Hero Member
  • *****
  • Posts: 1490
  • Karma: +0/-0
Problem with treasure creation
« Reply #12 on: October 04, 2010, 05:08:19 pm »


               Actually, if I'm looking at this right, it is the Racial type, not the appearance type that matters. This is the part of the script that determines if it is a invalid racial type:

// Now we determine whether we put treasure on the NPC
   int nRacialType = GetRacialType(oNPC);
   switch (nRacialType) {
   case RACIAL_TYPE_ANIMAL:
   case RACIAL_TYPE_BEAST:
   case RACIAL_TYPE_MAGICAL_BEAST:
   case RACIAL_TYPE_VERMIN:
       // No treasure, sorry.
       return;

Try double checking the racial type of the boss or do as Kalbaern suggests and use the other treasure function.

Hope it helps. Good luck.
               
               

               


                     Modifié par GhostOfGod, 04 octobre 2010 - 04:11 .
                     
                  


            

Legacy_DM-Chemosh

  • Newbie
  • *
  • Posts: 42
  • Karma: +0/-0
Problem with treasure creation
« Reply #13 on: October 05, 2010, 11:24:43 am »


               

GhostOfGod wrote...

Actually, if I'm looking at this right, it is the Racial type, not the appearance type that matters. This is the part of the script that determines if it is a invalid racial type:

// Now we determine whether we put treasure on the NPC
   int nRacialType = GetRacialType(oNPC);
   switch (nRacialType) {
   case RACIAL_TYPE_ANIMAL:
   case RACIAL_TYPE_BEAST:
   case RACIAL_TYPE_MAGICAL_BEAST:
   case RACIAL_TYPE_VERMIN:
       // No treasure, sorry.
       return;

Try double checking the racial type of the boss or do as Kalbaern suggests and use the other treasure function.

Hope it helps. Good luck.


Weird! I have some bosses that are BEAST and they get treasure. I'll try the hint that kalbaern suggested and let you know later, guys!
               
               

               
            

Legacy_Mudeye

  • Full Member
  • ***
  • Posts: 238
  • Karma: +0/-0
Problem with treasure creation
« Reply #14 on: October 05, 2010, 04:36:25 pm »


               There could be some setting on the boss that your are unaware of or that got set by accident.  You might try recreating the boss from scratch.  Or else creating it by copying one that already gets treasure and modifying it.  That way you are sure you  have a clean start.