PowerQuest 0.18.12
|
PowerQuest scripts are just c# but with super easy ways to do adventure game things!
Access those things with a simple letter or word, then a dot/period. eg. Type C.
to get a list of characters, then C.Dave.
will give a list of things you can do with that character.
You can type:
C.
for Characters - C.Barney.WalkTo( C.Dave );
E.
for Engine - "Game" level functions. Eg. E.FadeOut(1);
, E.Wait();
R.
for Rooms - R.Kitchen.FirstTimeVisited
P
. for Props - P.Door.PlayAnimation("Open");
H.
for Hotspots - H.Tree.Description = "Strudy Tree";
Regions.
for Regions - Regions.River.Walkable = false;
Points.
for Room Points - Plr.Walkto( Points.CaveEntry );
I.
for Inventory Items - I.Screwdriver.Add();
D.
for Dialog Trees - D.Shopkeeper.Start();
O.
for Dialog Options - O.BuyFish.Show()
G.
for Guis - G.Keypad.Show()
. See also Control. and Button. for accessing gui controls.Globals.
for Globals Script - Your own global script with your own functions. Globals.MyFunction();
Audio.
for Audio - Audio.Play("Bang");
Cursor.
for Cursor - Cursor.Hide();
Camera.
for Camera - Camera.Shake(10);
Settings.
for Settings - Settings.VolumeMusic = 0.5f;
All the regular c# things work too. You don't need to know any c# to start, but when you want to learn more, try this W3 schools interactive tute thing!
Here's the full list with more examples:
E.FadeOut(1); E.Wait(3); if ( E.FirstOccurance("AteBadPie") ) E.ChangeRoom(R.Vomitorium); E.Save(1);
C.Barney.Room = R.Current; C.Player.WalkTo( P.Tree ); if ( C.Player.Talking == false ) C.Player.PlayAnimation("EatPizza"); C.Bill.Position = Points.UnderTree; C.Barney.SayBG("What's all this then?"); Dave: Ah... Nothing! C.Player.AnimWalk = "Run"; C.Barney.Description = "A strange looking fellow with a rat-tail";
if ( R.Current.FirstTimeVisited ) R.Kitchen.ActiveWalkableArea = 2;
I.RubberChicken.Add(); I.Active.Description = "A rubber chicken with a pulley in the middle" if ( I.Sword.Active ) Display: You can't use a sword on that if ( I.HeavyRock.EverCollected ) Dave: I'm not lugging any more of those around
D.SayHi.Start(); D.TalkToFred.OptionOn("AskAboutPies");
O.AskAboutTrees.On(); O.Tree.Description = "That tree's bad news."; O.AskForSandwich.OffForever();
G.Keypad.Show(); G.Inventory.Hide(); Label.KeypadReadout.Text = "ENTER PASSWORD";
Camera.Shake(3); Camera.SetCharacterToFollow( C.Barney ); Camera.SetPositionOverride( Points.InterestingPoint, 1.2f ); Camera.SetZoom( 1.5f );
Settings.VolumeSFX = 0.5f; Settings.Language = "DE"; Settings.DialogDisplay = eDialogDisplay.TextAndSpeech ;
Audio.Play("Explosion"); Audio.PlayMusic("AwesomeMusic"); Audio.Stop("Alarm", 0.5f);
Globals.m_myVariable = 69; Globals.MyFunction(); E.WaitFor( Globals.MyBlockingFunction );The hotspots, props, regions and points in the current room are accessed like this:
P.GoldKey.Hide(); P.Ball.MoveTo(10,20,5); P.Door.PlayAnimation("SlamShut"); P.Door.Animation = "Closed";
H.BlueCup.Cursor = "Drink"; if ( H.Tree.UseCount > 0 ) H.Tree.Description = "Someone's cut it down";
if ( Regions.DiscoFloor.GetCharacterOnRegion( C.Dave ) ) Regions.DiscoFloor.Tint = Color.blue; Regions.Chasm.Walkable = false;
C.Plr.WalkTo( Points.UnderTree );
Quest Scripts you create and edit will be in a few different files. The functions are created automatically for you, but here's a list of them:
Adding Variables
You can add member variables to any of your quest scripts. They'll be automatically saved/restored in-game if they're simple types.
In the quest script editor, just add variables to the "header" section. (Or anywhere in the script's .cs file). Eg:
public bool m_doorOpened = false;
Accessing variables
In the same script that the variable is declared, it can be accessed in any function, like so: m_doorOpened = true;
If you need to access a variable/function from multiple scripts, the best place for it is in the GlobalScript (GlobalScript.cs). This is like the other scripts, but it's easier to access from anywhere, and has some extra global functions too.
Access the global script like this:
Globals.m_doorOpened = true;
You can also access variables and functions from your other scripts, for example a room script or character script:
R.Kitchen.Script.m_doorOpened = true; C.Dave.Script.m_wearingPants = false;
To add a function to a script file, open it in your IDE (VS/Monodevelop) first. Then add your function to the script class as you normally would in c#.
Calling regular functions you've made is no different than accessing variables
OpenDoor();
if in the same script, otherwise:
R.Kitchen.Script.OpenDoor();
Dave: Hello
or Plr.WalkTo( P.Door );
=>
. => R.Kitchen.Script.OpenDoorSlowly => Globals.Explosion(5);
yield return E.Wait(()=> Globals.Explosion(5));
. So much easier in the Quest Script Editor ;)Note that references to GameObjects, Components, and other unity objects WON'T be saved/restored.
If you need that you'll have to use the OnPostRestore() functions to re-initialize these and hook references back up.
PowerQuest is very flexible. If you're brave, you can edit everything about how it works. Avoid directly editing the PowerQuest classes themselves though (The ones in the PowerQuest or Plugins folder). Since when you update PQ you'll lose your changes.
But most functionality can be added by editing things in the Game folder.
GlobalScript is the best place to add simple functionality. For example, GlobalScript.OnMouseClick() has all the logic for what happens when you click the mouse in the game. This can be changed to support different types of adventure game interface. And functions added to GlobalScript are easy to access from your interaction scripts too.
Advanced customisation
Most quest object classes have are "Partial" classes, so you can extend them by adding your own variables and functions.
The easy place to add these is in the file /Game/PowerQuestExtensions.cs
There's also callbacks for various game events that you can hook into to get things working the way you want.
This gets a bit hairy and hard to document, and there may be hooks that you need that aren't there. So hit me up on the forums/discord if you need help.