Jump to content

Recommended Posts

Posted

I'm currently making an item that, when equipped, will return the player's Karma to 0 (neutral) and keep it there.

 

this is currently my code:

 

scn HarmonicRobeEffectSCRIPT

short doOnce


;THIS WILL RESET CURRENT KARMA LEVEL WHEN ITEM IS EQUIPPED

Begin OnEquip Player

ShowMessage HarmonicRobeEquipMessage
if doOnce == 0
	if Player.EquipItem HarmonicRobe
		if Player.getactorvalue Karma >= 1
			modactorvalue Karma 0
		else
			if player.getactorvalue Karma <= -1
				modactorvalue Karma 0
			else
			endif
		endif
	endif
endif

set doOnce to 1

End


;THIS WILL REMOVE ALL KARMA EARNED WHILST ITEM IS EQUIPPED

Begin GameMode

if doOnce == 1
if player.RewardKarma 1
	if Player.getactorvalue Karma >= 1
		modactorvalue Karma 0
	else
		if player.getactorvalue Karma <= -1
			modactorvalue Karma 0
		else
		endif
	endif
endif
endif

End


;THIS WILL REMOVE THE SCRIPT EFFECTS WHEN ITEM IT UNEQUIPPED

Begin OnActorUnequip HarmonicRobe
set doOnce to 0

End

 

 

My problem is that when the item is equipped, it is GIVING karma, infinately. locking it at 1000.

 

I'm sure that it's a basic error but I need help finding the problem.

Posted

You don't need on equip and on unequip for what you're doing.

 

Begin GameMode

if player.GetActorValue Karma != 0
	 player.ForceActorValue Karma 0
endif

end

 

Go read the GECK wiki again on ModAV, RewardKarma, and EquipItem functions. You're not using them correctly.

Posted

thanks for the help. quickly...whats the " != "

 

This scripting language is unfamilliar to me, is that "anything other than"??

Posted
ok...i'm still returningthe same problem, i've made the suggested changes but it's still giving me infinite karma!! and even after i unequip it it doesn't stop
Posted
From the first post I see a problem, ModActorValue do not 'set' values, it 'add' them.
Posted
From the first post I see a problem, ModActorValue do not 'set' values, it 'add' them.

Sorry Laffindude, you already pointed the issue, I saw just now.

Posted

I think I would do something along these lines (I would use a Quest script, myself):

 

scn myQuestScript

short isRobed
short oldkarma
short addkarma

begin GameMode

; just put on the robe
if player.GetEquipped HarmonicRobe == 1 && isRobed == 0
	set isRobed to 1
	set oldkarma to player.getav karma
	set addkarma to (0 - oldkarma)
	rewardkarma addkarma
endif

; just took off the robe
if player.GetEquipped HarmonicRobe == 0 && isRobed == 1
	set isRobed to 0
	rewardkarma oldkarma
endif

end

Posted

If I understand correctly, it should never be a Begin GameMode and do not need to be a quest script. Enough to make an object script attached to the robe with the blocks Begin OnEquip and Begin OnUnequip

 

By the way, if the karma at the equipping instant is to be stored, you can do a bogus quest with only the variable declaration block, the advantage of using quest script variables is they are like globals. The advantage of using the object script with only those two blocks is plain obvious, it runs only when the item is equipped/unequipped

 

Observation: Variables in quest scripts are aways active and retain values between game sessions... EVEN if the quest itself is completed/terminated.

So the bogus quest may simply initiate so to initialize the variables and close afterwards, and can do it silently.

Posted

hmmm using forceAV on karma doesn't seem to want to do anything.

 

short checkme
short doOnce

Begin OnEquip player 
set doOnce to 1
End

Begin GameMode
if doOnce
set checkme to player.GetActorValue Karma

if checkme
	set checkme to (checkme * -1)
	rewardkarma checkme
endif

endif
end


Begin OnUnequip player 
set doOnce to 0
End

 

edited for complete code. Works perfectly for me.

 

 

 

 

If I understand correctly, it should never be a Begin GameMode and do not need to be a quest script. Enough to make an object script attached to the robe with the blocks Begin OnEquip and Begin OnUnequip

 

By the way, if the karma at the equipping instant is to be stored, you can do a bogus quest with only the variable declaration block, the advantage of using quest script variables is they are like globals. The advantage of using the object script with only those two blocks is plain obvious, it runs only when the item is equipped/unequipped

 

Observation: Variables in quest scripts are aways active and retain values between game sessions... EVEN if the quest itself is completed/terminated.

So the bogus quest may simply initiate so to initialize the variables and close afterwards, and can do it silently.

If you want an effect that is constantly updated, then you NEED begin GameMode. He wants to zero the karma whenever it is changed from zero. (look at his original intent with the misused rewardkarma). Using gamemode to constantly monitor karma is the way to do it. If you use gamemode, the script effect can actually keep running even after unequipping. Give it a try with the script above and delete the equip/unequip block and remove the doOnce thing.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...