Can't Figure out Script

Post » Mon Nov 10, 2014 6:16 pm

I have been tearing my hair out trying to create what appeared to be a simple script for my mod. I have spent 5+ hours researching and trying to figure out what I am doing wrong; tried many different variations of the script.

All I want to do is attach a script on an item. When the player has the item in inventory the players speed will be set to 0. After 10 seconds the item will be dropped out of inventory onto the ground and restore the speed back to the player. Also when dropped the item must have a scale of 2x (when it was initially picked up).

How would you do this?

I am posting one of my many variations of this script. This particular script has an doubling issue and a casting issue. When I, in game, drop the item it works perfectly, before the 10 second time ends. If the script drops the item it won't cast the spell after dropping and won't remove the item from my inventory, just adds a new item to the player's feet.

Begin building_hammer_dropshort OnPCAddshort OnPcDropfloat timer;test to see if player has hammer in inventoryif ( Player -> GetItemCount "building_hammer" == 1 )	set timer to ( timer + GetSecondsPassed )  ;increments counter	MessageBox " timer = %g", timer ;displays timer value for debugging	;if 10 seconds has passed since in inventory drop hammer and reset timer	if ( timer >= 10)		Player -> Drop, "building_hammer", 1 ;drops item from player inventory		set timer to 0 ;resets timer		return	endifendif;if hammer is dropped from inventory restore scale to 2 and remove curseif ( OnPCDrop == 1 )	SetScale 2 ;sets hammer scale to 2	Cast, "remove_curse", Player ;removes curse from player	set OnPCDrop to 0 ;resets flag	set timer to 0 ;resets timerendif;if item is added to inventory for first time then apply speed curse and display messageif ( OnPCAdd == 1 )	Player -> AddSpell, "building_hammer_curse" ;adds curse Drain Speed 100points to player	set OnPcAdd to 0 ;resets flag	MessageBox "Wow, this hammer is heavy", "ok"  ;displays messageendifEnd building_hammer_drop
User avatar
Ricky Meehan
 
Posts: 3364
Joined: Wed Jun 27, 2007 5:42 pm

Post » Mon Nov 10, 2014 6:41 pm

Try using removeitem and placeatpc instead of player->drop. And use getspeed, setspeed instead of spells.

User avatar
Dan Wright
 
Posts: 3308
Joined: Mon Jul 16, 2007 8:40 am


Return to III - Morrowind