Aller au contenu

Photo

OnSpawn - create item


  • Veuillez vous connecter pour répondre
8 réponses à ce sujet

#1
Buddywarrior

Buddywarrior
  • Members
  • 256 messages
On the OnSpawn script of the creature, I have a call to a function 
Loot()

I'm trying to have control over what loot drops off of some creatures. Here is what I'm trying to use to spawn loot on the creature during spawn.

string ADROP1 = GetLocalString(OBJECT_SELF, "ADROP1");            string ADROP2 = GetLocalString(OBJECT_SELF, "ADROP2");            string ADROP3 = GetLocalString(OBJECT_SELF, "ADROP3");
            CreateItemOnObject(ADROP1);            CreateItemOnObject(ADROP2);            CreateItemOnObject(ADROP3);

I have the creature death loot set to Leave Lootable Corpse. But no items drop on the creature. What am I doing wrong?

#2
GhostOfGod

GhostOfGod
  • Members
  • 863 messages
Could add some lines to your OnSpawn script kinda like so for testing. See if the problem is somewhere there first:


void main()
{

    string ADROP1 = GetLocalString(OBJECT_SELF, "ADROP1");
    string ADROP2 = GetLocalString(OBJECT_SELF, "ADROP2");
    string ADROP3 = GetLocalString(OBJECT_SELF, "ADROP3");
    object oItem1 = CreateItemOnObject(ADROP1);
    object oItem2 = CreateItemOnObject(ADROP2);
    object oItem3 = CreateItemOnObject(ADROP3);

    SendMessageToPC(GetFirstPC(), "OnSpawn test is running.");
    if (GetIsObjectValid(oItem1))
    SendMessageToPC(GetFirstPC(), "Item1  created successfully.");
    if (GetIsObjectValid(oItem2))
    SendMessageToPC(GetFirstPC(), "Item2  created successfully.");
    if (GetIsObjectValid(oItem3))
    SendMessageToPC(GetFirstPC(), "Item3  created successfully.");

}


If you don't see the first line then your OnSpawn might not be on the creature?

If you don't see the item lines then maybe its the res refs (string variables) set on the creatures?

#3
Shadooow

Shadooow
  • Members
  • 4 474 messages
also consider spawning loot in OnDeath event, creature's AI might use the loot for his own benefits (scrolls, potions...)

#4
Lightfoot8

Lightfoot8
  • Members
  • 2 535 messages
Make sure the droppable flag is set:

SetDroppableFlag(CreateItemOnObject(ADROP1),TRUE);

#5
Shadooow

Shadooow
  • Members
  • 4 474 messages

Lightfoot8 wrote...

Make sure the droppable flag is set:

SetDroppableFlag(CreateItemOnObject(ADROP1),TRUE);

no need to actually, items created by script on NPC are automatically droppable

#6
Buddywarrior

Buddywarrior
  • Members
  • 256 messages
it seams to be working just fine if the treasure model is set to body/pouch, but not as a lootable corpse. hmm..

#7
ffbj

ffbj
  • Members
  • 593 messages
Maybe:
SetLootable(object, int)
Sets whether a creature leaves a lootable corpse upon death

void SetLootable(
object oCreature,
int bLootable
);
Parameters
oCreature

NPC to set as lootable or not

bLootable

TRUE or FALSE



Description
Sets the lootable state of a *living* NPC creature.
This function will *not* work on players or dead creatures.




Remarks
This corresponds to the "leaves lootable corpse" NPC property (under advanced in the NPC's properties).

Only NPCs can be lootable, and their lootable state must be set BEFORE they die.



Known Bugs
Simply calling SetLootable doesn't appear to be sufficient to have the NPC leave a lootable corpse. The corpse left behind isn't selectable. To make a corpse lootable, add the two lines of code below to the end of the NPC's OnSpawn script:



Version
1.61

Example
SetIsDestroyable(TRUE, FALSE, TRUE);
DelayCommand(1.0, SetLootable(OBJECT_SELF, TRUE));

See Also
functions: GetLootable
categories: Inventory Functions

#8
Shadooow

Shadooow
  • Members
  • 4 474 messages

Buddywarrior wrote...

it seams to be working just fine if the treasure model is set to body/pouch, but not as a lootable corpse. hmm..

have you triedd to move spawning items into OnDeath as I suggested? Im doing it like this and while I rarely use lootable corpses (there are few bugs with that) it worked for me.

#9
Buddywarrior

Buddywarrior
  • Members
  • 256 messages
I haven't. I've talked myself into thinking that leaving a little bag of treasure looks better on these rare creatures. Truth is that it's a path of least resistance and the player wont notice and/or care.