Daraan on 8/4/2017 at 15:54
So one of the last updates (
https://www.dropbox.com/s/p577b7k265ycno3/DScript0.21.zip?dl=1) v0.21
but it brings lots of functionality, also made it more clear in the first post which global functions you can use in your .nut files.
-----------v0.21--------------
Parameter additions•Scripts now accept multiple On/Off messages via the + operator.
•$MyQVar now a valid parameter which will check for the saved data in the Quest Variable MyQVar
•Added [ScriptName]FailChance. Chance to let a script fail. Can be positive or negative see DBaseTrap.
Script additions•Added a basic DRelayTrap so you can make use of multiple TurnOns and sent multiple messages with the + operator. Stims can be sent as well. See DRelayTrap for more info.
Script changes•DCopyPropertyTrap supports now targeting AND:
--Allows to copy multiple properties with the + operator like: Property="+PhysControl+RenderAlpha"
•DWatchMe accepts TurnOff to remove any!! AiWatchObj links to this object.
•DPortal now works with DPortalTarget and Non -PhysEnter messages. For example you can use DPortalOn="PhysExit"; (leave target blank in this case!)
•When using the + operator with pure object numbers they need a # before them from now on like: +#42+player+#225 else they will be treated as sting "42" which can't point to an object, expect an object is really named "42"
Squirrel changes:--DGetParam removed the single parameter as now everything undergoes a string check handled by DCheckString and returns a single obj,string unless adv=1 is set, then an array is returned.
--All DoOn,DoOff functions will now take the DesignNote as a parameter to save internal extra calls.
--Removed most of the basic functions from the DBaseTrap so you can access them in other .nut files without using extend DBaseTrap.
Quote:
DRelayTrapA relay with all the DBaseTrap features. On TurnOn it will relay the message specified with DRelayTrapTOn. Respectively the on TurnOff to be sent messages can be specified with DRelayTrapTOff. By default these are TurnOn and TurnOff.
With the + operator you can define multiple On, TOn, Off and TOff messages.
With DRelayTrap[On/Off]Target you can specify where to sent the message(s). Default are ControlDeviced linked objects. If DRelayTrap
OnTarget is specified then that will take priority over DRelayTrapTarget.
As a TOn, TOff message you can also send a Stim to do this, first enter the intensity surrounded by square brackets, followed by the stim name. For example: [ScriptName]TOn="[5.00]WaterStim".
There is no Repeat or Delay option.
Design Note exampleNVRelayTrapOn="+TurnOn+BashStim";NVRelayTrapTOn="+TurnOn+[5]FireStim";NVRelayTrapOnTarget="+player+^ZombieTypes"
On TurnOn or when bashed it will send a TurnOn and a FireStim with intensity 5 to the player and the closest Zombie.(relative to the object with the script)
As nothing else is specified on TurnOff will send a TurnOff to all ControlDevice linked objects.
That should be pretty close to Larry's Hub.
LarryG on 8/4/2017 at 20:31
Interesting approach. Not quite what I was asking for, but it certainly looks useful. The DRelayTrap is still on/off focused, which limits its relay to only two sets of response targets. There is no way to send relay three different messages each to a distinct target. But hey, it does allow multiple on/off messages, which is cool.
Daraan on 9/4/2017 at 11:49
Quote Posted by LarryG
Interesting approach. Not quite what I was asking for, but it certainly looks useful. The DRelayTrap is still on/off focused, which limits its relay to only two sets of response targets. There is no way to send relay three different messages each to a distinct target. But hey, it does allow multiple on/off messages, which is cool.
I know it's not exactly what you asked for that's why I said close:cheeky:
I'm building up the framework and DRelayTrap is an intermediate result.
Theoretically the hub script is already in the .nut file but beside parameter grabbing it does nothing.
How it will look like:
For each command you want you write DHubCommand="Parameter1=Value1;Parameter2=Value2;P3=V4..."
Like:
DHubTurnOn="Relay=+TurnOn+FireStim;Target=Player;Count=4";
DHubTurnOff="Relay=[5]WaterStim;Target=[me]";
DHubWhateverCommand="" (do default)
Just had an idea of a different approach, maybe it will be done much faster than I expected, also it should be possible to do something like DHubTurnOn;DHubTurnOn2;DHubTurnOn2321
LarryG on 9/4/2017 at 15:52
I was thinking of something like:
[Scriptname]In1=InputMessage1;
[Scriptname]Out1=OutputMessage1;
[Scriptname]Targ1=OutputTarget1;
[Scriptname]In1Cap=CapacitorValue;
[Scriptname]Count1=Count;
[Scriptname]FailChance1=FailureChance;
[Scriptname]Delay1=Milliseconds;
[Scriptname]DelayMax1=MaximumMilliseconds;
[Scriptname]ExclusiveDelay1=ON/OFF or 1/0 or TRUE/FALSE;
[Scriptname]Repeat=CountValue (-1 = repeat forever once triggered);
[Scriptname]RepeatOff=RepeatOffMessage;
...
[Scriptname]InN=InputMessageN;
[Scriptname]OutN=OutputMessageN;
[Scriptname]TargN=OutputTargetN;
[Scriptname]InNCap=CapacitorValueN;
[Scriptname]CountN=CountN;
...
Daraan on 11/4/2017 at 13:37
Here it comes as you wished Larry and how I answered :)
(
https://www.dropbox.com/s/h66yqvuo5c51w26/DScript0.22.zip?dl=1)
Download
------------v0.22--------------
Parameter addition/fix•[ScriptName]Repeat, Delay, Count, CountOnly are now valid parameters. -> See DBaseTrap
•When responsing to a FrobWorldBegin/End message. [source] will now point to the frobber. Before the script failed.
Script Changes•FIXED: Count and Capacitor was not Savegame compatible, my bad...... now it is.
---NOTE: if you change a value there you need to execute a script_reload before saving the .mis.
•DDrunkPlayer is Save Game compatible now as well.
•DEditorTrap can now be used with DEditorTrapUseIngame=1 to count for example reloads.
ScriptAdditions•DCompileTrap
•DHub
Squirrel changes•DBaseFunction is now the heart of everything. Takes a table and script name to perform stuff. Needed to cut it out of DBaseTrap to made it compatible with DHub. Might get reversed later when I revise the code and see it's not necessary.
•Reloads won't reset counter and capacitor.
-----
Now to the main part of this new version, as Larry said a powerhouse.
Quote:
DHub(not a DBaseTrap script)
will by default send a TurnOn at ControlDeviced linked objects when it receives a valid message. Valid messages are declared in the DesignNote like this: DHub[Message]="Parameter1=Value1;Parameter2=Value2". Even if you want to use the default options a minimal DHub[Message]="==" is necessary! The + operator does not work here.
Multiple actions can be declared for the same Message via DHub[Message]2="Parameter1=Value1;.... The used numbers must be consecutive! If there is a gap all above numbers will be skipped. There is no maximum to different actions a Message can have.
Parameters are basically identically to the ones by DBaseTrap or DRelayTrap beside [T]On/Off.
NOTE:!Parameters require no prefix. String values may not have " " around them!!! And I don't recommend blank spaces anywhere inside the "Parameter=Value;P2=V2" declaration, only if you want to address an object like Target=@false label
The valid parameters - all operators like +,@,$... will work here
Code:
Relay What message(s) should be sent. Like for DRelayTrap there is stim support like [3.7]FireStim.
Target To which object(s)
Delay will delay the message and also defines the time between repeats.
ExclusiveDelay When set to =1 will abort messages from this action which are still waiting to be sent.
Repeat how often should the action be repeated. Repeat=-1 for infinitely.
All Infinite repeats can for now only be stop via a StopInfRepeats message to the Hub, for example via another action with Relay=StopInfRepeats;Target=[me]
Count The maximum number of times a action will be executed. Default =0 infinitely.
All counts can for now be reset via a ResetCount message.
Capacitor The number of times this action will need to receive its triggering before executing. Default = 1 everytime.
CapacitorFalloff The time in seconds after the Capacitor will go down by 1. Default =0
FailChance A chance (from 1 to 100 or -100 to -1) that this action be executed. If the number is negative Capacitor and Counts will still be increased first and then tested if the script will fail or not.
Default Parameter:
By setting DHub[Parameter]="Value". This Parameter will be default for all actions if not specified otherwise.
As an example and as script default DHubRelay="TurnOn";DHubTarget="&ControlDevice".
Design Note exampleInline Image:
https://www.dropbox.com/s/nzwt7tzhxgremuo/DHubExample.jpg?raw=1Quote:
DCompileTrapOn TurnOn tries to compile the Editor Comments.
This script lets you write your own squirrel commands inside the editor.
It uses Editor Comment because the Squirrel line/command end
; also indicates a new Parameter in the Design Note which do interfere, also you are able to use newlines much easier but the moment a newline(made by enter) in the comments is used will be translated to \n and to not destroy your code you need to comment that \n out with a /* at the end of the line and */ at the start of the next
Editor Comment example:Code:
ActReact.Stimulate(Object.Named("player"),"BashStim",20);/* now comes a new line
*/DarkUI.TextMessage("String made by DCompileTrap");/*
*/DarkGame.KillPlayer()
Squirrel additionsDArrayToString(ar,o="+") converts an array to a string with the character defined by o between them.
Quote:
DSetTimerData(name, delay,...[data you want to attach]) returns timer_handle
DSetTimerDataTo(To,name,delay,...) same as above but sent to To instead of self.
DGetTimerData(msgdata,KeyValue=false) returns an Array with your data.
The functions start a timer with multiple data attachments which can be returned later in an array out of the message().data.
This Data is save game compatible!
--------------
But now let me explain why these functions are important/usefull:
If there time gap between 2 actions, there is always the problem how to safely carry over data. The (human) player could save and reload the game in the meantime and all non persistent data will be whipped as new script instances are recreated (that's how I understood it).
The relevant persistent data are script data set with SetData(k,v), QVars and timers.
I don't know it but I think NV came up with something similar so I take an NVRelayTrap as an example: which inverts the message and sends it twice back to the sender (with a delay).
So now we got two objects sending a TurnOn and TurnOff to the Trap and here's the problem a) after the delay how to know which object sent the message? b) What was the message again? and c) how to know if it's first message and needs to be send again?
We would need to save three values. But SetOneShotTimer only has one data slot. The second message would override the first SetData or QVar. Well you could store multiple ScriptData with a prefix and save that prefix in the timer data slot, but I think memory wise that's not the best solution, also it would increase very fast if you need to transfer even more data.
Btw: Squirrel somehow lacks the SetTimedMessage(2) function why?.
--------------
Data can be stored and retrieved in a fixed order (KeyValue=false). For example if you know the first data is always the source the second the repeats left. Returned Array [source Obj ID, Repeats left]
And you can use array[0],array[1] to grab your data.
If there are other data you want to store but for example some are optional or whatever you can store them via key=value,key2=value2,...
now if you use KeyValue=true the array will look like this [key,value,key2,value2] and you can search and find your values like this:
Code:
local array=DGetTimerData(message().data,true)
local key = array.find(param);
loval value =0
if (key!=null)
{value =array[key+1]}
Take a look at the DDrunkPlayerTrap how I made use of that.
LarryG on 11/4/2017 at 23:18
It is going to take a while for me to wrap my mind around your new parameter setting conventions!
Gecko on 12/4/2017 at 12:02
Thank you so much for all this Daraan! I really like the DWatchMe (guards relight every extinguished torches on their patrol path) :thumb: I think i will add this to the HD mods as an optional extra :)
Daraan on 14/4/2017 at 22:17
Quote:
It is going to take a while for me to wrap my mind around your new parameter setting conventions!
In general I tried to keep the readability high, as seen in the screenshot what belongs together should stay together. Same reason all actions use parameters without a prefix.
"TOn" became "Relay" and TDest/Target became "Target".
Well the initial idea came from a small sentence: On="bla";Relay="blub";To=object. Expect Relay the rest disappeared :rolleyes: You would have been happier with TOn, or?
(
https://www.dropbox.com/s/t56f5jij96khgjc/DScript0.23b.zip?dl=1)
--------------Download v0.23------------------- (nut file only on the first post)
Parameter additions/fix•In case of all Frob messages (FrobToolBegin, FrobWorldBegin..) [source] will point to the frobber if it's a real frob else to the sending object of that message.
Script Changes•
DHub:(Just to make clear these are messages not parameters)
-
StopInfRepeats got replaced by StopRepeat!!! - it will still only stop infinite repeats but:
-Single repeats can now stopped via: [Message+number]StopRepeat, this works for non infinite repeats as well.
-Single counts can be reset the same way with [Message+number]ResetCount
--Sending a single reset count message for an action which does not have Count specified is not advised.
-Potential ugly infinite Loop fixed.
•In general tried to improve performance and readability - but for at least DrunkPlayerTrap I destroyed it.
--The performance cut to make the DHub working which affected all scripts is mostly non existent anymore.
It's kinda a hard decision to make: Use more RAM to decrease run time calculations or leave it be. Basically both are minimal but the question is still there.
In case of the DHub every time it receives a valid message it creates a local 20 entry "Design Note" table for that message and actions are performed as the parameters are set. => less persistent memory but more repeated calculations.
Other wise I could calculate these DNs at Sim and save them in a class variable and grab them when needed. => More memory but less calculations.
I think I would prefer the second variant, at the moment it's still the first.
Script AdditionQuote:
DHudCompassUpon receiving FrobInvEnd will clone the current selected object and attach it slightly below the players camera and keep its facing always to north.
By default there is no TurnOff as it is TurnedOff via toggling.
Engine Features -> Frob Info > Inv Action: Script must be set.I suggest scaling down the object to 10-50%.
--------------Download v0.23c-------------------
DHudCompass is now always above the lightgem.
Inline Image:
https://www.dropbox.com/s/dsp0xu1lc367vvs/DHudCompass.gif?raw=1
EnYB0La on 17/4/2017 at 15:00
@Daraan
Shouldn't be a good idea to publish your script on GitHub in order to share it with everyone?
Daraan on 19/4/2017 at 18:59
Quote Posted by EnYB0La
Shouldn't be a good idea to publish your script on GitHub in order to share it with everyone?
Dunno would that be helpful to you guys?
----------------------------------------------
(
https://www.dropbox.com/s/t56an6jm8akmi3c/DScript0.24.zip?dl=1) And 0.24 rolls in (Download)
Quote:
Targeting Operator additions@ and * work now with archetype ids like @-441
'+-' Removes previously added objects via +. For example Target=+@Human+-@bystander
The + operator goes from left to right, so some examples
+-@bystander+@Human would do nothing as Human would be added at the end.
+@Human+-@bystander+@Pagan would be Human excluding servant and aristo (the two other bystander types)
of course Metaproperties can be used as well
+@guard+-@M-FrontGateGuard+-@M-TopFloorGuardScript Addition•DImUndercover + DNotSuspAI
•DGoMissing
--------------------------------------------
The Undercover script serves 2 purposes
A) Bring a bit more logic to guards: Servant walk over marble nothing happens, player touching it slightly whole place goes crazy.
B) The actual purpose being Undercover until an AI gets alerted, Damaged...
Especially the Undercover part can be combined with some other Suspicious scripts to round it up.
For example GoMissing (gen.osm) to notify guards when something was stolen.
Even better with (
http://dromed.whoopdedo.org/tnhscript/highlysuspicious) HighlySuspicious (tnhscript) as it adds lots of control via a suspicious threshold.
Quote:
DGoMissingNearly identical to GoMissing but simulates a caught in the act and the AI instant alerts to level 3. (With my HighlySuspicious settings they would not alert at all)
The normal missingloot type is restored after 2 seconds.
Engine Features -> FrobInfo: World must be Move,
ScriptQuote:
DImUndercoverBy default upon receiving FrobInvEnd (for a general purpose you can use BeginScript or Sim with Count=1) will affected the AIs specified via DImUndercoverTarget - by default @Human -
Use DImUndercoverSelfLit to increase OR decrease the visibility of the player - the default is 5. This can basically used as an On/Off indicator for the (human)player. Else this script gives no feedback on its own if it's on or not.
DImUndercoverMode defines which of the following
bitwise set modes should be used by default the mode is 9 (8 and 1).
Code:
Mode-|------effect-------- | Still alerted when
===Weaker detection Modes===
1: Ignore Footsteps Alerted by other sounds and sight - Use DImUndercoverDeaf=1 to make them completely deaf. Use Deaf=3 if you think the default 2 is to weak.
2: Reduced vision By default will ignore the player until hes 6.5 units in range and than instant aggro. Another value can be set with DImUndercoverSight. DImUndercoverSight=1 or 0 Will make them completely blind. Would have loved to make this better. (basically disables lots of the vision cones)
3: Both above(1+2) (recommended mode)
4: Don't investigate Only when seeing the player will attack him. Alertness cap will still rise.
5: 4+1 (Does not really makes sense)
6: 4+2 (Attacks the player when he comes close. Sounds will rise his alertness and give a bit better vision)
7: 4+1+2 (also recommended)
8: See below.
For your personal design.
16 Adds: "M-DUndercover16"
32 Adds: "M-DUndercover32"
Quote:
====
The Undercover mode 8===========
Used as default with ignore footsteps.
•Settings for use with
(http://dromed.whoopdedo.org/tnhscript/highlysuspicious) HighlySuspicious (Link)) (T2 only)
The player will be made suspicious with the type player.
DImUnderCoverUseDif=1 will append the the current difficulty so player0,1,3 is used.
In the demo (SuspParm.str) I included two presets. - For the second one, if the AI meets the player and knows about 5,4,3 other incidents it will alert.
DImUndercoverForgetMe=1 will delete the AISouspiciousLink to the player when he goes out of range, so he will be checked multiple times by the same AI.
•When activated changes the Team of DImUndercoverTarget to Team
Good and tries to automatically set the
DNotSuspAI script which handles the turning off. This only works if the script 4 slot of the concrete AI is not in use, else a M-DUndercover8 has to be created with the script inside.
End of the effectNote: Mode 1,2,4 won't end automatically only when DImUndercoverAutoOff=1 is set.
DNotSuspAI will be added to them then as well. (they still are hostile)
• By user:
-if the effect was started with FrobInvEnd, a second Frob will end it.
-The script object is dropped.
-The
DImUndercover object receives TurnOff; a single
DNotSuspAI receives EndIgnore
•Automatically
-Messages: On Alertness >= 2 - another alert level can be set with DImUndercoverEnd; the default is 2, you can also use $QVar here.
-AISignal with "alarm" "alert" "EndIgnore" "gong_ring";
-Damage (any source!)
-T2 only: drawn sword or blackjack object, arrow windup (To make this work the second script DT2UndercoverWeapons.nut is used which replaces the standard, sword, blackjack and arrow script.)
-Side effect: An alerted AI will inform others if seen.
When turned off these Properties get removed (regardless of the set mode):
AI-Attributes--Hearing+Vision(mode 1/blind); AI-Core--Vision Description(2); AI-Ability Settings--Investigation(4)
====
Custom Modes===========
Alternatively if you want much more control or my setting interfere with yours you can use DImUndercoverUseMetas=1; this will add (depending on mode) the Metas M-DUndercover1,2,4,8,16,32 to the AIs and M-DUndercoverPlayer(if it exists) to the player.
Their design is up to you.