block a service under certain condition?

Post » Mon Jun 18, 2012 11:15 pm

Hi how can I do to block the service of forges unless you talk to the forge owner and contract something?
User avatar
Donald Richards
 
Posts: 3378
Joined: Sat Jun 30, 2007 3:59 am

Post » Tue Jun 19, 2012 4:35 am

How can I do this?
User avatar
Cathrine Jack
 
Posts: 3329
Joined: Sat Dec 02, 2006 1:29 am

Post » Tue Jun 19, 2012 3:55 am

Depends on what you want to do, if you just want to lock the forge of one NPC set a global variable in dialogue and test for it in the forge's script

EVENT onActivate ( objectReference triggerRef )	if (triggerRef != Game.GetPlayer()) || (PlayerGotPermission.GetValue() == 1)			playAnimation("activate")	endifendEvent

In dialogue you set the global variable PlayerGotPermission to 1. When you want to use this for more forges you'd need a global variable for each of them, or make a local variable, add the forge as parent reference to the NPC and set the forge's local variable in the dialogue.
User avatar
ONLY ME!!!!
 
Posts: 3479
Joined: Tue Aug 28, 2007 12:16 pm

Post » Mon Jun 18, 2012 8:46 pm

What I want to do is to allow the use of the Forge only if the player Pays for it ..... I woudl also like to add a timed period like he canuse the forge for x hours or eventually per "item creation" ... this I think paired with the tree I am developing woudl make much more realisti cthe crafting ...
User avatar
Reven Lord
 
Posts: 3452
Joined: Mon May 21, 2007 9:56 pm

Post » Tue Jun 19, 2012 5:25 am

ok so basicvally is a new script to place in the furnaces ? or in all the smithing stuff? shodul I have a link between objects? or a script that is endependant from each , may be use this or that can I refine this or that may be refining mole shoudl cost less than the forge? how to add the timer? and how can I do to add time of development to weapons and stuff so that it take a certain amount of time to develope something according to the item? like if I make a sword and it shoudl take two hors how can I do make pass in the game 2 hours?
User avatar
Albert Wesker
 
Posts: 3499
Joined: Fri May 11, 2007 11:17 pm

Post » Tue Jun 19, 2012 1:06 am

Do I need to start programming to achieve this result?
User avatar
Taylah Illies
 
Posts: 3369
Joined: Fri Feb 09, 2007 7:13 am

Post » Mon Jun 18, 2012 9:00 pm

Why don't you look at the existing forges?

CraftingBlacksmithForgeSTATIC is an activator it has two scripts BlacksmithForge01 is the one you want to have a closer look at (doubleclick on it)

scriptName  BlacksmithForge01 extends ObjectReferenceimport Debugspell property FlameDamage AutoEVENT onActivate ( objectReference triggerRef )	playAnimation("activate")endEventEvent OnTriggerEnter ( objectReference triggerRef )	if (triggerRef == Game.GetPlayer())		FlameDamage.Cast(triggerRef, triggerRef)	endIfendEvent

That's no rocket science is it? one event starts when anyone activates the forge, the other when the player stands upon it.

The second script is a bit trickier:
event onActivate(objectReference akActivator);  debug.Trace(self + " has been activated by " + akActivator);Actor is attempting to mineif akActivator as actor  ;if the actor is the player  if akActivator == game.getPlayer()   ;if this is not depleted and the player has the right item   if requiresTool && playerHasTools() == false	FailureMessage.Show()   ;enter the furniture   else;	 debug.Trace(self + " should cause " + akActivator + " to activate " + getLinkedRef())	if getLinkedRef()	 getLinkedRef().activate(akActivator)	 AchievementsQuest.incHardworker(2)	Else;	  debug.Trace(self + ": error this ore does not have a linkedRef")	endif   endif  Else   if getLinkedRef()	getLinkedRef().activate(akActivator)   Else;	 debug.Trace(self + ": error this ore does not have a linkedRef")   endif  EndIf;Something unexpected has activated the oreElse;   debug.Trace(self + "has been activated by: " + akActivator + " why?")endifendEvent

Here you replace if akActivator == game.getPlayer() with
if akActivator == game.getPlayer() && PlayerGotPermission.GetValue() == 1

Seems like gamesas originally intended that wee need to carry tools to use the forge, you could also use this for your needs by hijacking the code and replacing if requiresTool && playerHasTools() == false with if PlayerGotPermission.GetValue() != 1 and then modify the message. Or you could add a new if-block with your condition that displays a different message when the player has no permission.

Nobody's going to make your mod for you, my new onactivate event above starts the event only if the user isn't the player or when the global variable is set, the changed line for the second scripts adds the new condition that the variable has to be set when the player uses the forge. Your task now is to improve on those scriplets and adapt them to your needs.

Start here to learn scripting: http://www.creationkit.com/Bethesda_Tutorial_Papyrus_Hello_World
User avatar
Georgia Fullalove
 
Posts: 3390
Joined: Mon Nov 06, 2006 11:48 pm

Post » Mon Jun 18, 2012 11:41 pm

Thanks but how can I do to add a timing to the crafting? for eaxample if I want to take 1 hour pass in the game when creating a sword or 1 day when making an armor or stuff like that?
User avatar
josie treuberg
 
Posts: 3572
Joined: Wed Feb 07, 2007 7:56 am

Post » Mon Jun 18, 2012 11:56 pm

I'd use something like this (untested):

int hour = GameHour.GetValueInt()if hour < 23   GameHour.SetValueInt(hour+1)else	   GameHour.SetValueInt(0)   int day = GameDay.GetValueInt()   if day < 30	  GameDay.SetValueInt(day+1)   else	  GameDay.SetValueInt(1)	  int month = GameMonth.GetValueInt()	  if month < 12		 GameMonth.SetValueInt(month+1)	  else		 GameMonth.SetValueInt(1)		 Gameyear.SetvalueInt(Gameyear.GetvalueInt() + 1)	  endif   endifendif

The forum breaks comments, but it should be obvious that midnight is a special case: the hour is reset to 0 and you advance to the next day, and maybe even month or year. If you prevent the player from smithing after 11 pm (haunted forge, grumpy neighbors) the scriplet can be reduced to "GameHour.SetValueInt(GameHour.GetValueInt()+1)"

Finding the script where to add this and finding a way to differentiate between weapons and armor is your exercise for this week.
User avatar
Nitol Ahmed
 
Posts: 3321
Joined: Thu May 03, 2007 7:35 am

Post » Tue Jun 19, 2012 9:18 am

I was thinking to implement the crafting time according to 2 factors : weapon cost and weight ? make sense? like if a weapon costs let's say 300 gold , then weights 4 gold , then It coudl be 300 x 4 / 24 = 50 hours means that the forge will be busy like 2 days , but how can I do to preplan how much time he needs to pay for use may be is better not let the player pay per time but on crafting use ... like you can pay once endependantly of what you craft ... couse there is a rsk the player runs out of money and still be using the forge for lieka week or so ... is it possible to make pass time for more than 24 h?

As for the time there is no one to ask for renting the forge after a certain hour so I guess is not a problem the player will be able to craft only in day hours , unless has his own forge ... makes sense to me ...

do I need to create new scripts or I shoudl edit the ones in the forges already?
User avatar
Poetic Vice
 
Posts: 3440
Joined: Wed Oct 31, 2007 8:19 pm


Return to V - Skyrim