Need help placing inventory items on the ground.

Post » Fri Jul 08, 2011 5:13 pm

Here is the script that I'm wanting to altar:

Begin LycanthropeFeeding		; Script originally written by Yacoby		; Edited by Wolvman	Float Temp	Float Endu	Float Str		Float HRatio ;health ratio	Short Rnd100 ;Random 100	Float Remove ;remove %	Short WaitForAnswer	long invitem  ;inventory stuff	long invcount	long invref	float npcx ;npc place	float npcy	float npcz	short NotStartUpFrame	If ( MenuMode == 1 )		Return	Endif 		;-------------------------------------------------------------------------------------		;Removing/Stopping		;-------------------------------------------------------------------------------------	If ( GetDisabled )		StopScript, "LycanthropeFeeding"		Set NotStartUpFrame to 0		SetDelete, 1		Return	Endif	If ( NotStartUpFrame )		If ( YAC_WC_FeedState == -1 )			Set NotStartUpFrame to 0			StopScript, "LycanthropeFeeding"			Return		Endif	Endif	Set NotStartUpFrame to 1		;-------------------------------------------------------------------------------------		;Waiting		;-------------------------------------------------------------------------------------	If ( LycanthropeFeed < 1 ) ;not do anything		Return	Endif		;-------------------------------------------------------------------------------------		;Modding health/Getting remove chance		;-------------------------------------------------------------------------------------		;( ( Strength + Endurance ) / 2 ) + Endurance * ( Level - 1 ) / 10		;Get a rough aprox of the health, we can't use the usal methord, as it always return 0	Set Endu to ( GetEndurance )	Set Str to ( GetStrength )	Set Temp to ( ( Str + Endu ) / 2 )	Set Temp to ( Temp + Endu * ( ( GetLevel ) - 1 ) / 10 )	Set Temp to ( temp / 3 )	Set HRatio to ( Player->GetHealthGetRatio )	Set Remove to ( 5 / HRatio )	Player->ModCurrentHealth, Temp	Set InfectionFeedAmount to Temp ;set the feed amount, so then YAC_WC_FeederScript will change the NPCs health		;-------------------------------------------------------------------------------------		;Scattering NPCs items, and removing them		;-------------------------------------------------------------------------------------	setx invitem,invcount,invref to xInventory	whilex ( invcount )		Set Rnd100 to ( ( Random, 100 ) + 1 ) ;make the random number		if ( invcount < 0 )			set invcount to invcount * ( -1 )		endif		if ( Rnd100 > Remove )			set Temp to 1		else			set Temp to 0		endif		xRemoveitem, invitem, invcount		ifx ( Temp )			set npcx to GetPos, x			set npcy to GetPos, y			set npcz to GetPos, z			set temp to ( Random, 101 ) ;randomize the area the item falls			set temp to ( Temp - 50 )			set NPCX to ( NPCx + Temp )			set temp to ( Random, 101 ) ;random 100 is more random than random 50			set temp to ( Temp - 50 )			set NPCy to ( NPCy + Temp )			xPlace, invitem		endif		setx invitem,invcount,invref to xInventory	endwhile		;-------------------------------------------------------------------------------------		;Removing NPC, and Setting Victims Count Up		;-------------------------------------------------------------------------------------	Disable	Player->Playsound, "Swallow" ; Placeholder	Set LycanthropeVictims to ( LycanthropeVictims + 1 )	If ( Player->GetSpell, "LycanthropeHunger1" == 1 )		Player->RemoveSpell, "LycanthropeHunger1"	Endif	Messagebox, "You devour the corpse and cure your bloodlust."	Set YAC_WC_FeedState to -1 ;END ALLend


So this script basically allows the player to simulate eating a corpse as a werewolf. A separate script triggers this one when the player targets a dead NPC and pushes an assigned keyboard key. It causes the screen to fade out, plays some feeding sound effects, disables the NPC's body and sets all of the inventory items in a stack on the floor at a random nearby location. It also heals your character a certain amount based on the NPC's stats.

What I am wanting to change is the "Scattering Item" portion. Currently it takes all of the NPC's inventory items and stacks them one by one on top of one another perfectly when placing them on the floor. I want to change it to look messy, with each item scattered about the floor in a small radius around the player's position in there own special locations (no stacking). I would also like to place a static blood pool under the player as well as some random bones scattered about.

I've already given it more than a few shots but I keep breaking the script, so I've forced myself to stop and see if anyone else has the right idea about pulling this off before I snap :biggrin: .
User avatar
Racheal Robertson
 
Posts: 3370
Joined: Thu Aug 16, 2007 6:03 pm

Post » Fri Jul 08, 2011 10:35 am

It seems the only way you'd be able to pull this off is to follow a process like this:

1. Record the item's base ID
2. Drop it
3. Loop through the cell using xFirstItem and xNextRef and find the newest reference with that ID (ie the very last one found before xNextRef returns a 0)
4. Move that item to some other location
5. Rinse and repeat
User avatar
Lyd
 
Posts: 3335
Joined: Sat Aug 26, 2006 2:56 pm


Return to III - Morrowind