Help with menu for perk choices for Bobbleheads

Post » Sat May 28, 2011 7:31 am

OK, I want to script all my bobbleheads so that when they are picked up the player can choose from a list of choices for their perk. Just to get started and learn how to do this, I'm just going with medicine bobblehead. I can pick it up and my menu choices are available like they should be. However, none of them add the bonus I have set or display the message like they should. I know it's probably something simple I missed, but I can't figure it out. Here's my script. What am I missing?

scn BucksBobbleheadMEDIScriptshort DoOnceshort Buttonbegin OnActivateif IsActionRef player == 1	if ( DoOnce == 0 )	    Activate	;Allow item pickup		Set BH10.BucksBobbles to ( BH10.BucksBobbles + 1 )	;Add 1 to master count		Set BH10.BucksCarrying to 1	;Tell the script the Player has one or more Bobbleheads (for display case)        ;Disabled 6/30 CES		ModPCMiscStat "Bobbleheads Found", 1		Set BH10.HaveBucksMEDI to 1 ;Set the variable for Display Case		ShowMessage BucksBobbleheadMEDIBuffMessage ;this is my message menu box		Set DoOnce to 1			endif		endifendbegin gamemode;This section of the gamemode block handles all of the button pressesset Button to GetButtonPressed	if ( Button == 0 );use for no perk option	    Showmessage BucksBobbleheadMEDIbonus00 ;message up in left corner	elseif ( Button == 1 );use for plus 2 perk option		Player.modAV medicine 2		Showmessage BucksBobbleheadMEDIbonus01	elseif ( Button == 2 );use for plus 5 perk option		Player.modAV medicine 5		Showmessage BucksBobbleheadMEDIbonus02	elseif ( Button == 3 );use for plus 10 perk option		Player.modAV medicine 10		Showmessage BucksBobbleheadMEDIbonus03	endifend

User avatar
Ally Chimienti
 
Posts: 3409
Joined: Fri Jan 19, 2007 6:53 am

Post » Sat May 28, 2011 5:26 pm

I think I see what it is. I believe I need to change the if blocks "if ( Button == 0 )" to "if ( GetButtonPressed == 0 )"

I'll try that when I get home.
User avatar
Sophie Louise Edge
 
Posts: 3461
Joined: Sat Oct 21, 2006 7:09 pm

Post » Sat May 28, 2011 3:35 pm

I don't see what is wrong with this script. I have compared it to working ones I have, and I can't see anything. But making multiple calls to GetButtonPressed in the same frame is wrong. This is documented in the http://geck.gamesas.com/index.php/GetButtonPressed. The example it shows is just like your example. Have you separately tested the messageboxes in the gamemode block to make sure they appear? Have you entered the modav command at the console to see it is having the effect you want? (I haven't used modav, I use setav, and reading the wiki pages on the two makes me more confused on the difference.)
User avatar
Dina Boudreau
 
Posts: 3410
Joined: Thu Jan 04, 2007 10:59 pm

Post » Sat May 28, 2011 10:19 pm

It'll work if you wait a frame after activating to show the first message. Something like this...

Spoiler
scn BucksBobbleheadMEDIScriptshort DoOnceshort Buttonbegin GameMode	if DoOnce == 1		ShowMessage BucksBobbleheadMEDIBuffMessage ;this is my message menu box		set DoOnce to 2	elseif DoOnce == 2		set Button to GetButtonPressed		if Button >= 0			set DoOnce to 3			if ( Button == 0 );use for no perk option				Showmessage BucksBobbleheadMEDIbonus00 ;message up in left corner			elseif ( Button == 1 );use for plus 2 perk option				Player.modAV medicine 2				Showmessage BucksBobbleheadMEDIbonus01			elseif ( Button == 2 );use for plus 5 perk option				Player.modAV medicine 5				Showmessage BucksBobbleheadMEDIbonus02			elseif ( Button == 3 );use for plus 10 perk option				Player.modAV medicine 10				Showmessage BucksBobbleheadMEDIbonus03			endif		endif	endifendbegin OnActivate	if IsActionRef Player && DoOnce == 0		Activate	;Allow item pickup		Set BH10.BucksBobbles to ( BH10.BucksBobbles + 1 )	;Add 1 to master count		Set BH10.BucksCarrying to 1	;Tell the script the Player has one or more Bobbleheads (for display case)		Set BH10.HaveBucksMEDI to 1 ;Set the variable for Display Case		Set DoOnce to 1	endifend

User avatar
Jordyn Youngman
 
Posts: 3396
Joined: Thu Mar 01, 2007 7:54 am

Post » Sat May 28, 2011 4:14 pm

It looks like it should work, but you could try it like this (do the showmessage in the gamemode block):

scn BucksBobbleheadMEDIScript  short DoOnce short Button  begin OnActivate  if IsActionRef player == 1         if ( DoOnce == 0 )             Activate    ;Allow item pickup                 Set BH10.BucksBobbles to ( BH10.BucksBobbles + 1 )      ;Add 1 to master count                 Set BH10.BucksCarrying to 1     ;Tell the script the Player has one or more Bobbleheads (for display case)         ;Disabled 6/30 CES              ModPCMiscStat "Bobbleheads Found", 1                 Set BH10.HaveBucksMEDI to 1 ;Set the variable for Display Case                 Set DoOnce to 1                          endif                  endif  end  begin gamemode 			if (DoOnce == 1)                                   ShowMessage BucksBobbleheadMEDIBuffMessage ;this is my message menu box 		                 	Set DoOnce to 2		endif  ;This section of the gamemode block handles all of the button presses  		set Button to GetButtonPressed          if ( Button == 0 );use for no perk option             Showmessage BucksBobbleheadMEDIbonus00 ;message up in left corner         elseif ( Button == 1 );use for plus 2 perk option                 Player.modAV medicine 2                 Showmessage BucksBobbleheadMEDIbonus01         elseif ( Button == 2 );use for plus 5 perk option                 Player.modAV medicine 5                 Showmessage BucksBobbleheadMEDIbonus02         elseif ( Button == 3 );use for plus 10 perk option                 Player.modAV medicine 10                 Showmessage BucksBobbleheadMEDIbonus03         endif 				 end


Edit - Ninja'd ;0
User avatar
KiiSsez jdgaf Benzler
 
Posts: 3546
Joined: Fri Mar 16, 2007 7:10 am

Post » Sat May 28, 2011 5:41 pm

Well, I couldn't find anything wrong with it either, but as you guys probably know by now, I only know enough about this stuff to be VERY dangerous, lol. As for testing it, each button displays like they should and when I press them the message box goes away as it should, it simply does not display my message or add the bonus.

making multiple calls to GetButtonPressed in the same frame is wrong. This is documented in the wiki page.


OK, my mistake.

Have you separately tested the messageboxes in the gamemode block to make sure they appear?


How exactly would I test them? Is there a console command like player.showmessage mymessage or something I should use to test it in game?

Have you entered the modav command at the console to see it is having the effect you want? (I haven't used modav, I use setav, and reading the wiki pages on the two makes me more confused on the difference.)


The vanilla bobbleheads all used modav for the skill bonuses, so I'm just using what they already were using. I could easily be wrong, but I thought modav would add points to a given skill, like player.modav repair 20 would add 20 to your repair skill. But I thought setav would set that skill at whatever number you tell it to. Like player.setav repair 20 would set the players repair skill to 20.

Let me know how you suggest I test this as I don't really know what else to test. Like I said, the buttons are working they just don't display my message or add to the skill.

Thanks David!
User avatar
Catharine Krupinski
 
Posts: 3377
Joined: Sun Aug 12, 2007 3:39 pm

Post » Sat May 28, 2011 9:58 pm

@ pelinor, why is waiting a frame necessary? Is it because the onactivate block also passes activate? In my working scripts, I consume activate rather than passing it. That is the only difference I can see.

@ balok, by "test" I meant temporarily modifying the script so that your showmessage is guaranteed to be called once. Just to check that the showmessage itself is working. But given the suggestion by pelinor this test doesn't seem needed. I find it very hard to predict when an extra frame will be needed, but this seems to be the solution to many different problems. For example, I recently had a problem with moveto and say in the same frame, and then again with placeatme and setpos in the same frame.
User avatar
Czar Kahchi
 
Posts: 3306
Joined: Mon Jul 30, 2007 11:56 am

Post » Sat May 28, 2011 6:11 pm

ModAV is what you want for this.
User avatar
Davorah Katz
 
Posts: 3468
Joined: Fri Dec 22, 2006 12:57 pm

Post » Sat May 28, 2011 9:41 pm

It'll work if you wait a frame after activating to show the first message. Something like this...

Spoiler
scn BucksBobbleheadMEDIScriptshort DoOnceshort Buttonbegin GameMode	if DoOnce == 1		ShowMessage BucksBobbleheadMEDIBuffMessage ;this is my message menu box		set DoOnce to 2	elseif DoOnce == 2		set Button to GetButtonPressed		if Button >= 0			set DoOnce to 3			if ( Button == 0 );use for no perk option				Showmessage BucksBobbleheadMEDIbonus00 ;message up in left corner			elseif ( Button == 1 );use for plus 2 perk option				Player.modAV medicine 2				Showmessage BucksBobbleheadMEDIbonus01			elseif ( Button == 2 );use for plus 5 perk option				Player.modAV medicine 5				Showmessage BucksBobbleheadMEDIbonus02			elseif ( Button == 3 );use for plus 10 perk option				Player.modAV medicine 10				Showmessage BucksBobbleheadMEDIbonus03			endif		endif	endifendbegin OnActivate	if IsActionRef Player && DoOnce == 0		Activate	;Allow item pickup		Set BH10.BucksBobbles to ( BH10.BucksBobbles + 1 )	;Add 1 to master count		Set BH10.BucksCarrying to 1	;Tell the script the Player has one or more Bobbleheads (for display case)		Set BH10.HaveBucksMEDI to 1 ;Set the variable for Display Case		Set DoOnce to 1	endifend



PERFECT! Worked the first try. This is really going to help me a TON! Thank you and everyone else! Have a round on me! :foodndrink:
User avatar
P PoLlo
 
Posts: 3408
Joined: Wed Oct 31, 2007 10:05 am


Return to Fallout: New Vegas