Aller au contenu

Photo

Kill+destroy & put loot in inventory


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

#1
psiiijay

psiiijay
  • Members
  • 258 messages

Is there a way to script a script (spell for the sake of it) that kills and destroys a target and then puts all it's loot in the casters inventory?

I can script a killing/destroying script easily enough but I can't seem to find the "inventory" or loot of a target before it turns into a corps..

 

My theory was using GetFirstItemInInventory & then get next item all before the creature dies (as after it dies it turns into a container and is no longer the oTarget of the spell) and then use ActionTakeItem for all items but it seems that the loot is "there" only after the creature dies - so I'll have to use a new script to target the loot as it's gonna be in the new container and not the target of the spell..

 

Is there a way you can think of to achieve the desired result?    



#2
Lugaid of the Red Stripes

Lugaid of the Red Stripes
  • Members
  • 955 messages

Loot bags are new objects created at the time of death, with the death script adding copies of the dead creature's items and creating new random loot on the loot bag object.  All loot bags have the same tag, though I forget what it is exactly.  You could fire a script on delay that looks for a loot bag nearby to where the creature died, but timing could be tricky. 

 

A more complicated solution would be to hijack the death script itself, with code to deposit the loot directly into the killer's inventory, and then destroy the dying creature. 

 

Another idea might be to have a custom summoned creature that retrieves all the loot for the caster, moving from corpse to corpse, with a conversation that allows the caster to pick through their inventory.



#3
psiiijay

psiiijay
  • Members
  • 258 messages

What about lootable corpses - I didn't find a way to do that but I think that might work - I can keep the bodies after death, but I don't think that they have anything in there.. Maybe if all objects moved to the corps I could fire a takeItem before destruction.. You know how I can get a corps lootable? (for some reason the toolset says setlooable only works on living creature..) 



#4
Lugaid of the Red Stripes

Lugaid of the Red Stripes
  • Members
  • 955 messages

Lootable corpses are just loot bags with a different graphic attached, you can get them using the same tag. 

 

Your spell script could SetLootable or move items around before it kills the creature, it's just the random loot drops created in the on-death script you have to worry about.  Take a look at the regular on-death script, and see what you have to copy-in-paste to replicate the random loot drop.



#5
psiiijay

psiiijay
  • Members
  • 258 messages

What? no - Corpses are corpses - If you set IsDestroyable in death script to (FALSE, TRUE, TRUE) You have a corp that can be resurrected - But for some reason not looted.. If I can get it to be looted - Id have no problem doing what I want I think.. 



#6
Dann-J

Dann-J
  • Members
  • 3 161 messages

One approach may be to have the spell script stun and freeze the target for a second, before killing it via a delayed death effect. That should give the inventory loop enough time to transfer all of the target's items before they get killed. You could use parts of the 'flesh to stone' spell script (without applying the stoneskin effect to the target). You'd have to make them temporarily immortal while frozen to prevent players from killing them prematurely.

 

The include file 'x0_i0_corpses' contains a useful function called LootInventory(), which will move any non-equipped items in the target's inventory to a second object (such as the caster). There's also a LootInventorySlots() function. You'll want to set bDecay and bDropWielded to FALSE if you use it.



#7
psiiijay

psiiijay
  • Members
  • 258 messages

Cool, I'll try looking at the files -  The weird thing is that - I used the "stunning method before,  If I kill the creature and then destroy it (I'm using a none decaying corps system) the corps is gone and no loot even appears, sometimes I'll just see a VFX on the ground of a glowing light where a loot bag should have been - this happens even if I set a delay for the destruction (something I didn't want to really do).. BUT if I kill a creature, and then use destroy script on it - the corps turns to loot just fine.. This makes me wonder how the system works.. I don't wanna use random loot but the creatures original as if it were carrying a plot item it would also be destroyed.. I'll check the lootinventory :)     



#8
psiiijay

psiiijay
  • Members
  • 258 messages

Wow - there are a lot of cool functions there..



#9
Dann-J

Dann-J
  • Members
  • 3 161 messages

Cool, I'll try looking at the files -  The weird thing is that - I used the "stunning method before,  If I kill the creature and then destroy it (I'm using a none decaying corps system) the corps is gone and no loot even appears, sometimes I'll just see a VFX on the ground of a glowing light where a loot bag should have been - this happens even if I set a delay for the destruction (something I didn't want to really do).. BUT if I kill a creature, and then use destroy script on it - the corps turns to loot just fine.. This makes me wonder how the system works.. I don't wanna use random loot but the creatures original as if it were carrying a plot item it would also be destroyed.. I'll check the lootinventory :)     

 

DestroyObject() will do its job too well - destroying everything about the creature (including droppable items). Your character probably won't get any experience for 'killing' them either.

 

Applying EffectDeath() will trigger the creature's standard OnDeath event, which I suspect is needed to drop loot bags or create a lootable corpse. If you assign the effect to the caster (but apply it to the target), then the caster will get the XP for killing them - AssignCommand(oCaster, ApplyEffectToObject(...etc...)).

 

To use the functions in x0_i0_corpses, add the following line at the very top of your script/s:

 

#include "x0_i0_corpses"



#10
psiiijay

psiiijay
  • Members
  • 258 messages

IT WORKS!! tnx a bunch!:)