TTLG|Thief|Bioshock|System Shock|Deus Ex|Mobile
Results 1 to 2 of 2

Thread: New Squirrel script: Set multiple qvars

  1. #1
    Member
    Registered: Jan 2001
    Location: Formby, NW England

    New Squirrel script: Set multiple qvars

    Download:
    http://www.mediafire.com/file/6kilpa.../multQVars.nut

    This is similar to a normal QuestVarTrap, but you can set multiple qvars/objectives with one object, and display a custom on-screen text message.

    Reasoning:
    Let's say you have a mission in which completing a goal, e.g. read a book, or go to meet someone, causes another goal will be revealed. You have to make the new goal visible before completing the first one, otherwise the mission could become completed prematurely. Solving that problem causes another one: the "Objective Complete" message will be the last thing shown on screen, and the player may not realise there are new goals.

    The purpose of my SetMultQVars script is to allow multiple goals to be set from one object, along with a 'new goal' message to override whatever the game is trying to display.

    Example:
    Mission starts with goal_0 only. Upon completion, goal_1 becomes visible. goal_0 must be completed last to allow the mission to keep going.

    Add the SetMultQVars script to any object.
    Trap > Quest Var:
    =1:goal_visible_0; =1:goal_state_1
    (standard quest var trap syntax, but multiple statments separated by ; )

    There is no known limit to the number of qvars that can be set. Arithmetic is also supported, so you can add, subtract etc.

    The goals will be set in that order. By default it'll get the value of "NewGoal" as found in strings\playhint.str (no need to extract it from the crf) and will display it on screen.

    You can override the message in a number of ways.
    1) Put a custom version of playhint.str in your strings folder, define a new value, e.g.
    NewMessage = "Check your goals you taffer"

    Add a Design Note to your object will the following value:
    GoalString = "NewMessage"
    (this won't interfere with other custom script parameters)

    2) Set up a book with the text in page_0, e.g
    books\english\gText.str:
    page_0: "Check your goals!"

    Book > Text prop on the object:
    gText

    Code:
    Code:
    class QVarArithmetic extends SqRootScript
    {
    	function setNewValue(qvarCommand) //e.g =1:goal_state_3
    	{
    		local parts = split(qvarCommand, ":"); //returns array of =1 and goal_state_3
    		local lhs = strip(parts[0]); //remove spaces, user might write property like this: =1:goal_state_3; =3:goal_state_4
    		local rhs = parts[1];
    		
    		local qValue = Quest.Get(rhs);
    		local userInt = lhs[1].tointeger()-48; //Number entered after the =, + etc
    		
    		switch(lhs[0])
    		{
    			case 61:
    				qValue = userInt; break;
    			case 43:
    				qValue += userInt; break;
    			case 45:
    				qValue -= userInt; break;
    			case 42:
    				qValue *= userInt; break;
    			case 47:
    				qValue /= userInt; break;
    			case 37:
    				qValue %= userInt; break;
    			case 33: //!
    				qValue = qValue | userInt; break;
    			case 124: //|
    				qValue = qValue | userInt; break;
    			case 123: //{
    				qValue = qValue << userInt; break;
    			case 125: //}
    				qValue = qValue >> userInt; break;
    			case 63: //?
    				qValue += Data.RandInt(0, userInt); break;
    			case 100: //d
    				qValue += Data.RandInt(1, userInt); break;
    			default:
    				print("WARNING: Operator not supported: " + lhs[0].tochar()); 
    				DarkUI.TextMessage("Operator not supported: " + lhs[0].tochar(), 0)
    				break;
    		}
    		Quest.Set(rhs, qValue);
    	}
    }
    
    //Sets a load of qvars specified in the QuestVar propery. Appears instant to the player. Goal text can be overwritten.
    class SetMultQVars extends QVarArithmetic
    {
    	function OnTurnOn()
    	{
    		local qvProp = Property.Get(self, "TrapQvar");
    		local qvList = split(qvProp, ";");
    		
    		//qvCommands are like =1:goal_state_3
    		foreach(qvCommand in qvList)
    		{
    			setNewValue(qvCommand);
    		}
    				
    		ShowText();
    	}
    	
    	//Gets the specified entry from playhint.str, or shows the value from the specified book, or shows "New Objectives" by default.
    	function ShowText()
    	{
    		local popup;
    		if(HasProperty("DesignNote") && "GoalString" in userparams())
    		{
    			popup = Data.GetString("PLAYHINT", userparams().GoalString);
    		}
    		else if ( HasProperty("book") )
    		{
    			local bookname = GetProperty("book");
    			popup = Data.GetString(bookname, "Page_0", "", "Books");
    		}
    		else
    		{
    			popup = Data.GetString("PLAYHINT", "NewGoal");
    		}
    
    		DarkUI.TextMessage(popup);
    	}
    }

  2. #2
    Desperately dodgy geezer
    Registered: Nov 2001
    Location: The Wailing Keep
    Thank you Robin! I've been wanting this for some time now. There were situations in Godbreaker where I triggered 6 or 7 QVarTraps at one time and had to put a tiny delay before the last one to make sure it was last.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •