A weapon you can never put down.

Post » Wed Dec 23, 2009 5:43 am

I've never been good with OnPCEquip, but here's the theory

One of the weapons I have in my mod makes it so that you are unable to unequip it, you must always hold it. On top of this, you will be unable to sleep, your rest will be interrupted. The only way to remove this is to do a quest, upon which the sword turns back to normal, but I've already got that figured.

Anyways, the theory I've had is that it detects if you've got it equipped or not, then if you don't, it removes the copy of the sword you currently have, then adds a new one, and re-equips it. This way the player HAS to hold it even when it breaks.

Problem is I have no idea how this is done. Anyone willing to help?
User avatar
NEGRO
 
Posts: 3398
Joined: Sat Sep 01, 2007 12:14 am

Post » Wed Dec 23, 2009 3:29 pm

This is from the MWSFD's example of a cursed club and it goes on the actual weapon:

Begin cursed_itemshort stateshort OnPCEquipif ( OnPCEquip == 0 ) ; item is not equipped	if ( state == 0 ); if club has never been equipped, don't do anything yet.		return	else		Player->Equip, "cursed_club" ; reequip the item!		MessageBox "The item is cursed, it doesn't leave your hand" ;taunt the player	endif              else	if ( state == 0 ) ;first time equipped. The trap snaps shut		set state to 1	endifendifEnd


To allow the player to drop it, you can change state to 2 once the player has finished the quest. To set it to two, use set cursed_item.state to 2 in another script or add a check in this one:

if ( GetJournalIndex  ==  )     set state to 2endif


Put that code above the OnPCEquip check.
User avatar
Charlie Ramsden
 
Posts: 3434
Joined: Fri Jun 15, 2007 7:53 pm

Post » Wed Dec 23, 2009 2:35 am

Works perfectly, thank you.
User avatar
Adam Kriner
 
Posts: 3448
Joined: Mon Aug 06, 2007 2:30 am

Post » Wed Dec 23, 2009 12:18 pm

You're welcome. Glad I could help. :)
User avatar
Yung Prince
 
Posts: 3373
Joined: Thu Oct 11, 2007 10:45 pm


Return to III - Morrowind