1. Script Name
Lootable, destroyabe, 'non-naked' corpse, ver 2.0
*NEW*: Does not allow access to No-Drop objects!
No-Drop are objects on which the 'Dropable' checkbox hasn't been set.
(Thanks to Raith Veldrin's suggestion)
2. What it does:
Monster does not vanish on death but collapse on the ground. This is an
exact representation of the dead monster (with all its visible equipment
such as armor, weapons, etc.), not a generic corpse.
The dead monster can be looted by 'using' it.
Corpse can also be destroyed if enough damage is done to it.
Upon destruction, all 'Dropable' objects are directly available for
collection.
3. Notes:
This is an updated version of the scripts to prevent No-Drop objects
from falling into the greedy hands of the players.
Also, looting animation has been improved. I love the animation when the
monster equipped weapon gets looted
There is no 'on heartbeat' scripts, which is a good thing.
You will have to create two templates, one for a placeable, one for a
creature (more on that below)
Changes to a monster scripts are minimal:
To setup your monster to leave its nice lootable corpse behind,
1) you may need to modify it's 'onSpawn' script so that the line with
NW_FLAG_DEATH is un-commented.
(rename it to anything you like after modifying it)
2) create / modify its on-user defined scripts with these few lines:
NWScript:
void main()
{
int nUser = GetUserDefinedEventNumber();
if ( nUser == 1007 )
{
object oCorpse = CreateObject(OBJECT_TYPE_PLACEABLE, "corpsetoloot", GetLocation(OBJECT_SELF), FALSE);
SetLocalObject(oCorpse, "el_corpse_owner", OBJECT_SELF);
SetLocalObject(OBJECT_SELF, "el_corpse_corpse", oCorpse);
SetIsDestroyable(FALSE, TRUE, FALSE);
ActionDoCommand(ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectDeath(), OBJECT_SELF));
}
return;
}
Note : The important part in the script above is the "corpsetoloot" name
in the CreatObject call, which is the blueprint resref of the placeable
(see later). If your placeable ends-up with a different resref (Advanced
tab), use it here instead
And that's pretty much it!
As mentioned, you will have to create two templates, one for a
placeable, one for a creature (more on that below)
There are two scripts for the placeable, and two scripts for the
creature.
Placeable:
---------
First, you need to create it. Here is how to do that:
NWScript: --------------
THIS IS NOT A SCRIPT, BUT INSTRUCTIONS ON HOW TO CREATE THE PLACEABLE
Experienced users can skip this :)
--------------
. in the editor, click on the little table icon on the right (it is called'paint placeable objects')
. select custom
. select containers&switches
. right-click, 'new', 'next'
. replace the name with "corpsetoloot" select 'launch properties dialog', 'finish'
. change the name to 'corpse' and the tag to, er..., whatever you want, such as 'corpse_tag'
. change hitpoint, hardness , etc. to whatever you want a corpse to be (the default are fine)
. select 'usable' (but not 'has inventory')
. change the Appearance type to 'invisible object'
. go to Advanced, and check that the blueprint resref is indeed "corpsetoloot"
. go to Scripts, press the 'Edit' on the 'on-death' line
. copy and past from the 'on-death' script below, save the script under some name (such as el_loot_ondth)
. do the same for 'on-used' line, with the 'on-used' script below
. make sure all the other script lines are empty
. press the OK at the bottom.
--------------
And the on-death script for it is:
NWScript:
void main()
{
object oCorpseOwner;
object oInvItem;
oCorpseOwner = GetLocalObject(OBJECT_SELF, "el_corpse_owner");
SetPlotFlag(oCorpseOwner, FALSE);
ApplyEffectToObject(DURATION_TYPE_INSTANT,EffectVisualEffect(VFX_COM_CHUNK_RED_SMALL),oCorpseOwner);
AssignCommand(oCorpseOwner, SetIsDestroyable(TRUE, FALSE, FALSE));
}
And the on-used script for it is:
NWScript:
void main()
{
object oCorpseOwner;
object oInvItem;
object oLootedBy;
oCorpseOwner = GetLocalObject(OBJECT_SELF, "el_corpse_owner");
oLootedBy = GetLastUsedBy();
SetLocalObject(OBJECT_SELF, "el_corpse_looter", oLootedBy);
object oSuperTaker = CreateObject(OBJECT_TYPE_CREATURE, "el_actionloot", GetLocation(oLootedBy), FALSE);
SetLocalObject(oSuperTaker, "el_corpse_to_loot", oCorpseOwner);
SignalEvent(oSuperTaker, EventUserDefined(2000));
AssignCommand(oLootedBy, ActionPlayAnimation(ANIMATION_LOOPING_GET_LOW, 1.0, 4.0));
return;
}
Creature:
---------
You also need to create it. Here is how to do that:
NWScript: --------------
THIS IS NOT A SCRIPT, BUT INSTRUCTIONS ON HOW TO CREATE THE CREATURE
Experienced users can skip this :)
--------------
. in the editor, click on the little red monster head icon on the left (it is called'paint creatures')
. select custom
. select Custom 1
. right-click, NEW , NEXT
. select Human, click NEXT
. {Class and level}, this is fine, select NEXT
. {Appearance and portrait}:
click 'select portrait'
select 'Placeable objects and door'
scroll all the way down, pick the all black square (one before last)
(PLC_P04_, or if you want something 100% black, PLC_W02_)
click OK and NEXT
. {Faction}:
pick-up 'Defender'
. {Name}:
replace the Name with el_actionloot
delete the Last Name (use backspace key if needed)
click NEXT
. {Select Palette Category}:
select Custom 1
click NEXT
click NEXT
. {Finish}:
select Launch Creature Property, and FINISH
The Creature Properties window opens...
Under [Basic]:
delete the First Name (either delete it, or change it to 'Looting')
change the Tag to el_ActionLoot (note the capitals)
change the Appearance to Null Human
press the Inventory... (bottom left) and drag all equipment from the paper doll to the trashcan
Under [Advanced]:
check that the Blueprint ResRef is 'el_actionloot'. If it is not, you may either start again or change the 'on-used' script above in the placeable accordingly.
delete the sound set. (use backspace key if needed)
Under [Script]:
you need to delete OnBlocked, OnCombatRoundEnd, OnDeath, OnHeartBeat, OnPerception, OnRested, and OnSpawn
you need to copy and paste the onUserDefined with the creature onuserdef script given below (save as el_take_usdf)
you need to copy and paste the OnConversation, OnDamaged, OnDisturbed, OnPhysicalAttacked, OnSpellCast all with the same creature 'misc' script given below (save as el_take_misc)
That's it!
. press the OK at the bottom.
--------------
Here is the onUserDef script for the creature:
NWScript:
void LootStuff(int nInventorySlot, object oToLoot)
{
ActionTakeItem(GetItemInSlot(nInventorySlot,oToLoot), oToLoot);
}
void main()
{
int nUser = GetUserDefinedEventNumber();
if ( nUser == 2000 )
{
object oTargeToLoot = GetLocalObject(OBJECT_SELF, "el_corpse_to_loot");
LootStuff(INVENTORY_SLOT_LEFTHAND, oTargeToLoot);
LootStuff(INVENTORY_SLOT_RIGHTHAND, oTargeToLoot);
LootStuff(INVENTORY_SLOT_HEAD, oTargeToLoot);
LootStuff(INVENTORY_SLOT_CHEST, oTargeToLoot);
int nAmtGold = GetGold(oTargeToLoot);
if(nAmtGold)
{
TakeGoldFromCreature(nAmtGold,oTargeToLoot,FALSE);
}
object oInvItem = GetFirstItemInInventory(oTargeToLoot);
while (oInvItem != OBJECT_INVALID)
{
ActionTakeItem(oInvItem, oTargeToLoot);
oInvItem = GetNextItemInInventory(oTargeToLoot);
}
LootStuff(INVENTORY_SLOT_ARMS, oTargeToLoot);
LootStuff(INVENTORY_SLOT_ARROWS, oTargeToLoot);
LootStuff(INVENTORY_SLOT_BELT, oTargeToLoot);
LootStuff(INVENTORY_SLOT_BOLTS, oTargeToLoot);
LootStuff(INVENTORY_SLOT_BOOTS, oTargeToLoot);
LootStuff(INVENTORY_SLOT_BULLETS, oTargeToLoot);
LootStuff(INVENTORY_SLOT_CLOAK, oTargeToLoot);
LootStuff(INVENTORY_SLOT_LEFTRING, oTargeToLoot);
LootStuff(INVENTORY_SLOT_NECK, oTargeToLoot);
LootStuff(INVENTORY_SLOT_RIGHTRING, oTargeToLoot);
ActionDoCommand( ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectDamage(2000), OBJECT_SELF) );
}
return;
}
Here is the script used for OnConversation, OnDamaged, OnDisturbed,
OnPhysicalAttacked, OnSpellCast, for the creature
NWScript:
void main()
{
ActionDoCommand( ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectDamage(2000), OBJECT_SELF) );
}
Well, that's it!
Tell me what you think. Suggestions always welcome.
--
Cheers,
Emmanuel / Sentur
|