Scripting Chem Limit

Post » Sat May 28, 2011 10:33 pm

Hello, I'm trying to script the limit of chem use depending on player's Endurance, but I've never touched Timer before.

I wanted to set the global variable to +1 each time the chem is used, but I wanted it to get back after 10 secs.

scn ChemOverdoseJetScriptfloat TimerBegin ScriptEffectStart	Set ChemLimit to ChemLimit + 1EndBegin ScriptEffectUpdateSet Timer to ScriptEffectElapsedSecondsif Timer >= 10	Set ChemLimit to ChemLimit - 1endifEnd


This script adds perk if global variable is higher than 2 and removes it if it's lower than 3.

Scn ChemsAll1ScriptBegin GameModeif ChemLimit > 2	player.AddPerk PerkChemOverdose1endifif ChemLimit < 3	player.RemovePerk PerkChemOverdose1End

User avatar
Taylor Tifany
 
Posts: 3555
Joined: Sun Jun 25, 2006 7:22 am

Post » Sat May 28, 2011 2:06 pm

Hello, I'm trying to script the limit of chem use depending on player's Endurance, but I've never touched Timer before.

I wanted to set the global variable to +1 each time the chem is used, but I wanted it to get back after 10 secs.


According to my understanding of ScriptEffectElapsedSeconds, that part should work.

This script adds perk if global variable is higher than 2 and removes it if it's lower than 3.


This is the same as saying the player must have the perk if the global >= 3, right?

The script is missing an endif, but I would also guard the addperk/removeperk functions so it is not continually adding/removing the perk

Scn ChemsAll1Script  Begin GameMode   if ChemLimit >= 3 	if player.HasPerk PerkChemOverdose1 == 0        player.AddPerk PerkChemOverdose1	endifelse	if player.HasPerk PerkChemOverdose1 == 1		player.RemovePerk PerkChemOverdose1	endifendifEnd


Edit - You need a way to stop the timer part and remove the spell:

scn ChemOverdoseJetScript  float Timer short iDone Begin ScriptEffectStart          Set ChemLimit to ChemLimit + 1  End  Begin ScriptEffectUpdate if iDone == 0 	Set Timer to ScriptEffectElapsedSeconds 	if Timer >= 10 			Set ChemLimit to ChemLimit - 1 			Set iDone to 1			RemoveSpell ChemOverdoseJetSpell ;whatever your spell name is	endif	 endif  End

User avatar
Becky Cox
 
Posts: 3389
Joined: Thu Jun 22, 2006 8:38 am

Post » Sat May 28, 2011 2:53 pm

Thanks, but the thing is I added this script to the Effect in Jet. Remove Spell works for abilities, but it's consumable and I don't want to whole Jet stop working after that time.
User avatar
Steve Bates
 
Posts: 3447
Joined: Sun Aug 26, 2007 2:51 pm


Return to Fallout: New Vegas