forked from whoopdedo/publicscripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPublicScripts.h
More file actions
1699 lines (1552 loc) · 52.7 KB
/
PublicScripts.h
File metadata and controls
1699 lines (1552 loc) · 52.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/******************************************************************************
* PublicScripts.h
*
* This file is part of Public Scripts
* Copyright (C) 2005-2011 Tom N Harris <telliamed@whoopdedo.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*****************************************************************************/
#ifndef PUBLICSCRIPTS_H
#define PUBLICSCRIPTS_H
#if !SCR_GENSCRIPTS
#include <lg/config.h>
#include <lg/objstd.h>
#include <lg/scrservices.h>
#include <lg/links.h>
#include <lg/tools.h>
#include <darkhook.h>
#include "BaseScript.h"
#include "BaseTrap.h"
#include "CommonScripts.h"
#include "scriptvars.h"
#endif // SCR_GENSCRIPTS
/**
* Script: TrapMetaProp
* Inherits: BaseTrap
* Link: ScriptParams(S??code??) - Link to metaproperty.
* Link: ScriptParams(A@??code??) - Add to linked object. Code matches $$S$$ link.
* Link: ScriptParams(R@??code??) - Remove from object when turned on.
*
* Manipulates metaproperties. When turned on, $$A$$ linked objects have a metaproperty
* added, and $$R$$ linked objects have a metaproperty removed. The metaproperty
* can be named with $$@??code??$$ (the code is any identifier that is convenient for you)
* and a $$S??code??$$ link will point to the metaproperty. Or just name the metaproperty
* directly: ''aFrobInert''. Turning off the trap removes $$A$$ from links and adds to $$R$$ links.
*/
#if !SCR_GENSCRIPTS
class cScr_MPTrap : public cBaseTrap
{
public:
cScr_MPTrap(const char* pszName, int iHostObjId)
: cBaseTrap(pszName, iHostObjId)
{ }
private:
static int LinkIter(ILinkSrv* pLS, ILinkQuery* pLQ, IScript* pScript, void* pData);
protected:
virtual long OnSwitch(bool, sScrMsg*, cMultiParm&);
};
#else // SCR_GENSCRIPTS
GEN_FACTORY("TrapMetaProp","BaseTrap",cScr_MPTrap)
#endif // SCR_GENSCRIPTS
/**
* Script: ToolMP
* Inherits: BaseScript
* Link: ScriptParams(S??code??) - Link to metaproperty.
* Link: ScriptParams(A@??code??) - Add metaproperty when frobbed on linked object.
* Link: ScriptParams(R@??code??) - Remove metaproperty when frobbed.
* Schemas: (Event Activate)
* Parameter: effect(string) - If set to ''source'', the metaproperties are changed on the source of the frob.
* SeeAlso: TrapMetaProp
*
* Manipulates metaproperties on an object when it is frobbed using the script object as a tool.
* The $$A$$ and $$R$$ links can link to an archetype and the script will work with any object
* of that type.
*/
#if !SCR_GENSCRIPTS
class cScr_MPTool : public cBaseScript
{
public:
cScr_MPTool(const char* pszName, int iHostObjId)
: cBaseScript(pszName, iHostObjId)
{ }
private:
static int LinkIter(ILinkSrv* pLS, ILinkQuery* pLQ, IScript* pScript, void* pData);
protected:
virtual long OnFrobToolEnd(sFrobMsg* pFrobMsg, cMultiParm& mpReply);
};
#else // SCR_GENSCRIPTS
GEN_FACTORY("ToolMP","BaseScript",cScr_MPTool)
#endif // SCR_GENSCRIPTS
/**
* Script: TrapScrMsgRelay
* Inherits: BaseTrap
* Link: ScriptParams(??msg??) - Send message in data to the linked object.
* Parameter: status_index(integer) - 1 (default, 2, or 3. Sets data to 1 when turned on, 0 when off.
* Parameter: data(string) - Extra message data. Sets first data not used by $$status_index$$.
* Parameter: data1(string) - First extra data.
* Parameter: data2(string) - Second extra data.
* Parameter: data3(string) - Third extra data.
*
* Trap that sends an arbitrary message when turned on or off. Each ``ScriptParams``
* link names the message to send to the destination of the link. The message is sent
* with the first data argument set to whether the trap was turned on or off. The data
* argument to use can be changed with $$status_index$$. If this is not 1, 2, or 3 then
* no status is sent and the trap only responds to ``TurnOn``.
*
* The message data arguments not being used for status can be set with other parameters.
* The parameter string starts with a letter to tell what type of value is being used.
* ''i'' - An integer.
* ''f'' - A real number.
* ''v'' - A real vector. Enter three numbers separated with commas.
* ''s'' - A string.
* If the first letter doesn't match, the script will guess if the parameter is a number or a string.
*/
#if !SCR_GENSCRIPTS
class cScr_SMRelay : public cBaseTrap
{
public:
cScr_SMRelay(const char* pszName, int iHostObjId)
: cBaseTrap(pszName, iHostObjId)
{ }
private:
static int LinkIter(ILinkSrv* pLS, ILinkQuery* pLQ, IScript* pScript, void* pData);
protected:
virtual long OnSwitch(bool, sScrMsg*, cMultiParm&);
};
#else // SCR_GENSCRIPTS
GEN_FACTORY("TrapScrMsgRelay","BaseTrap",cScr_SMRelay)
#endif // SCR_GENSCRIPTS
/**
* Script: TrapSMTrans
* Inherits: BaseTrap
* Link: ScriptParams(??msg??) - Send ``TurnOn`` to the linked object when ??msg?? is received.
*
* Trigger when any message is received. Each object linked to with ``ScriptParams``
* will get ``TurnOn`` when the message named in the link is received by the script.
*
* Only the ''Invert'' trap control flag can be used. The other flags and the lock
* ignored by this script. The object the script is used on will likely want to use the
* lock and the timing properties.
*/
#if !SCR_GENSCRIPTS
class cScr_SMTrans : public cBaseTrap
{
public:
cScr_SMTrans(const char* pszName, int iHostObjId)
: cBaseTrap(pszName, iHostObjId)
{ }
private:
static int LinkIter(ILinkSrv* pLS, ILinkQuery* pLQ, IScript* pScript, void* pData);
protected:
virtual long OnTurnOn(sScrMsg* pMsg, cMultiParm& mpReply);
virtual long OnTurnOff(sScrMsg* pMsg, cMultiParm& mpReply);
public:
STDMETHOD(ReceiveMessage)(sScrMsg* pMsg, sMultiParm* pReply, eScrTraceAction eTrace);
};
#else // SCR_GENSCRIPTS
GEN_FACTORY("TrapSMTrans","BaseTrap",cScr_SMTrans)
#endif // SCR_GENSCRIPTS
/**
* Script: Forwarder
* Inherits: BaseTrap
* Link: ScriptParams(??msg??)
* SeeAlso: TrapScrMsgRelay, TrapSMTrans
*
* Relays a message to objects that are linked with a ``ScriptParams`` link having
* the name of the message. None of the trap control flags, lock, or timing have
* any meaning to this script.
*
* The data for a ``ScriptParams`` links can only be 15 characters long. Many
* messages will exceed this limit. There are two ways to work around this:
* use an indirect name, or use a shortcut name. An indirect name uses the
* ``Editor\Design Note`` property of an object to provide the full name.
* The link data starts with the character $$#$$ then the name of the other
* object. The entire ``Editor\Design Note`` property is the full name; it is
* not treated as a parameter list.
*
* Message names in a ``ScriptParams`` link can also be given as shortcuts.
* $$.FIB$$ - FrobInvBegin
* $$.FIE$$ - FrobInvEnd
* $$.FTB$$ - FrobToolBegin
* $$.FTE$$ - FrobToolEnd
* $$.FWB$$ - FrobWorldBegin
* $$.FWE$$ - FrobWorldEnd
* $$.IDF$$ - InvDeFocus
* $$.IDS$$ - InvDeSelect
* $$.IF$$ - InvFocus
* $$.IS$$ - InvSelect
* $$.WDF$$ - WorldDeFocus
* $$.WDS$$ - WorldDeSelect
* $$.WF$$ - WorldFocus
* $$.WS$$ - WorldSelect
* $$.CRI$$ - CreatureRoomEnter
* $$.CRO$$ - CreatureRoomExit
* $$.ORI$$ - ObjectRoomEnter
* $$.ORO$$ - ObjectRoomExit
* $$.ORT$$ - ObjectRoomTransit
* $$.PRI$$ - PlayerRoomEnter
* $$.PRO$$ - PlayerRoomExit
* $$.RPRI$$ - RemotePlayerRoomEnter
* $$.RPRO$$ - RemotePlayerRoomExit
* $$.PC$$ - PhysCollision
* $$.PCC$$ - PhysContactCreate
* $$.PCD$$ - PhysContactDestroy
* $$.PI$$ - PhysEnter
* $$.PO$$ - PhysExit
* $$.PFA$$ - PhysFellAsleep
* $$.PMN$$ - PhysMadeNonPhysical
* $$.PMP$$ - PhysMadePhysical
* $$.PWU$$ - PhysWokeUp
* $$.PPA$$ - PressurePlateActivating
* $$.PPD$$ - PressurePlateDeactivating
* $$.PPU$$ - PressurePlateInactive
* $$.PPD$$ - PressurePlateActive
* $$.ME$$ - MotionEnd
* $$.MF$$ - MotionFlagReached
* $$.MS$$ - MotionStart
* $$.MTWP$$ - MovingTerrainWaypoint
* $$.WPR$$ - WaypointReached
* $$.DGMC$$ - DarkGameModeChange
* $$.MT$$ - MediumTransition
* $$.PSC$$ - PickStateChange
* If the message name begins with an exclamation mark ($$!$$) then the
* rest of the name is a stimulus and the word ''Stimulus'' will be added to
* complete the message name.
*/
#if !SCR_GENSCRIPTS
class cScr_Forwarder : public cBaseTrap
{
public:
cScr_Forwarder(const char* pszName, int iHostObjId)
: cBaseTrap(pszName, iHostObjId)
{ }
private:
static int LinkIter(ILinkSrv* pLS, ILinkQuery* pLQ, IScript* pScript, void* pData);
protected:
virtual long OnTurnOn(sScrMsg* pMsg, cMultiParm& mpReply);
virtual long OnTurnOff(sScrMsg* pMsg, cMultiParm& mpReply);
public:
STDMETHOD(ReceiveMessage)(sScrMsg* pMsg, sMultiParm* pReply, eScrTraceAction eTrace);
};
#else // SCR_GENSCRIPTS
GEN_FACTORY("Forwarder","BaseTrap",cScr_Forwarder)
#endif // SCR_GENSCRIPTS
/**
* Script: Validator
* Inherits: BaseTrap
* Message: Validate - Set which link will get the next relay. First data argument is index number.
* Links: ScriptParams(??index??)
* Parameter: order(string) - Set to ''increment'' or ''step'' to have the trap automatically change the relay index after each trigger.
* Parameter: increment(integer) - Value to change the current index when $$order$$ is set to ''increment''.
* Parameter: rollover(integer) - Reset the index to 0 when incremented gets to this value or greater.
*
* Relay ``TurnOn`` and ``TurnOff`` to one of many destinations. ``ScriptParams`` links
* with the data set to an integer index identify the destinations. Initially, the link index 0 is
* triggered. The index can be changed manually by sending a ``Validate`` message. If the
* parameter $$order$$ is set to ''increment'', the index is changed after each relay.
* Parameters $$increment$$ and $$rollover$$ control how the index is incremented.
* Setting the parameter $$order$$ to ''step'' is like ''increment'' except when using $$rollover$$
* and $$increment$$ is greater than 1. When the increment passes the rollover it will continue
* skipping values from 0. For example, 3 links with increment by 2 will go 0,2,0,2,0,2
* when using ''increment'', and 0,2,1,0,2,1 with ''step''.
*/
#if !SCR_GENSCRIPTS
class cScr_Validator : public cBaseTrap
{
public:
cScr_Validator(const char* pszName, int iHostObjId)
: cBaseTrap(pszName, iHostObjId),
SCRIPT_VAROBJ(cScr_Validator, m_iValidateParam, iHostObjId)
{ }
private:
script_int m_iValidateParam;
protected:
virtual long OnSwitch(bool, sScrMsg*, cMultiParm&);
virtual long OnBeginScript(sScrMsg*, cMultiParm&);
virtual long OnMessage(sScrMsg*, cMultiParm&);
};
#else // SCR_GENSCRIPTS
GEN_FACTORY("Validator","BaseTrap",cScr_Validator)
#endif // SCR_GENSCRIPTS
/**
* Script: LinkTemplate
* Inherits: BaseTrap
* Parameter: object(object) - Object that links will be created from.
* Parameter: flavor(string) - Type of link to move.
* Parameter: dest(object) - Destination of the links.
* Parameter: on_create(boolean) - Just make the new links, don't destroy the template links.
* Parameter: off_destroy(boolean) - Only delete links when turned off.
* Parameter: singleton(boolean) - Only allow one of the link type to be made from the object.
*
* Manipulates links. The $$object$$ parameter identifies the source that the links will be
* added to or removed from. Template links are created from the script object to destinations.
* When turned on, identical links will be made using the source object instead of the
* script object. Turning off the trap removes the links and sets them on the script object
* again. $$Flavor$$ and $$dest$$ can be set to restrict which links to use.
*
* When a link is created, the template link is removed. Links that are removed when the
* trap is turned off have a duplicate re-made as a template. The parameter $$on_create$$
* will not delete the template links when a new one is created. $$Off_destroy$$ deletes
* links without creating links on the script object.
*
* Creating multiple links of the same flavor can be avoided by setting the $$singleton$$ parameter.
*/
#if !SCR_GENSCRIPTS
class cScr_LinkTrap : public cBaseTrap
{
public:
cScr_LinkTrap(const char* pszName, int iHostObjId)
: cBaseTrap(pszName, iHostObjId)
{ }
protected:
virtual long OnSwitch(bool, sScrMsg*, cMultiParm&);
};
#else // SCR_GENSCRIPTS
GEN_FACTORY("LinkTemplate","BaseTrap",cScr_LinkTrap)
#endif // SCR_GENSCRIPTS
/**
* Script: TrapTeleportDelta
* Inherits: BaseTrap
* Messages: NetTeleport
* Links: ControlDevice, ScriptParams(dm)
*
* Teleports the object linked with ``ControlDevice`` to somewhere nearby
* this object. The $$dm$$ link identifies a reference object. The new position
* is the same distance and direction from this object as the old position was
* from the reference object. If the reference object is rotated differently than
* the teleport destination, then the controlled object will be rotated to match.
*/
#if !SCR_GENSCRIPTS
class cScr_DeltaTeleport : public cBaseTrap
{
public:
cScr_DeltaTeleport(const char* pszName, int iHostObjId)
: cBaseTrap(pszName, iHostObjId)
{ }
private:
void Teleport(object iObj);
protected:
virtual long OnSwitch(bool, sScrMsg*, cMultiParm&);
#if (_DARKGAME == 3)
virtual long OnMessage(sScrMsg*, cMultiParm&);
#endif
};
#else // SCR_GENSCRIPTS
GEN_FACTORY("TrapTeleportDelta","BaseTrap",cScr_DeltaTeleport)
#endif // SCR_GENSCRIPTS
/**
* Script: RandomRelay
* Inherits: BaseTrap
* Links: ControlDevice, SwitchLink, ScriptParams(??weight??)
* Parameter: reusable(boolean) - Like the trap control flag ''Once''.
* Parameter: preserve(boolean) - Don't remove the link that is used.
* Parameter: weighted(boolean) - Relay along ``ScriptParams`` links where some can be more likely than others.
* Parameter: rechargeable(boolean) - Keep links, but don't reuse a link until all others have been triggered. Requires $$weighted$$ and implies $$preserve$$.
*
* Randomly picks a link and relays the ``TurnOn`` or ``TurnOff`` along it.
*
* A weighted relay lets you use an uneven probability of choosing links. Instead of
* ``ControlDevice`` or ``SwitchLink``, create ``ScriptParams`` links and set
* the data of each to a number greater than zero. Links with higher numbers are
* more likely to be chosen than lower numbers.
*/
#if !SCR_GENSCRIPTS
class cScr_RelayRandom : public cBaseTrap
{
public:
cScr_RelayRandom(const char* pszName, int iHostObjId)
: cBaseTrap(pszName, iHostObjId)
{ }
protected:
virtual long OnSwitch(bool, sScrMsg*, cMultiParm&);
};
#else // SCR_GENSCRIPTS
GEN_FACTORY("RandomRelay","BaseTrap",cScr_RelayRandom)
GEN_ALIAS("RandomRelay1x2","BaseTrap",cScr_RelayRandom,1x2)
#endif // SCR_GENSCRIPTS
/**
* Script: TrigSim
* Inherits: BaseTrap
* Messages: Sim
*
* Generate a trigger when the game starts.
* Since the script has no use after it activates, the object will be destroyed
* to save object ID space. Objects that descend from the ``physical``
* archetype will not be destroyed.
*/
#if !SCR_GENSCRIPTS
class cScr_SimTrigger : public cBaseTrap
{
public:
cScr_SimTrigger(const char* pszName, int iHostObjId)
: cBaseTrap(pszName, iHostObjId)
{ }
protected:
virtual long OnSim(sSimMsg*, cMultiParm&);
virtual long OnTimer(sScrTimerMsg*, cMultiParm&);
};
#else // SCR_GENSCRIPTS
GEN_FACTORY("TrigSim","BaseTrap",cScr_SimTrigger)
#endif // SCR_GENSCRIPTS
/**
* Script: TrapStim
* Inherits: BaseTrap
* Links: ControlDevice
* Stims: ScriptStim
* Parameter: stim(object) - Stimulus to use instead of ``ScriptStim``.
* Parameter: intensity(number) - Stimulus intensity.
*
* Applies a stimulus to linked objects when triggered.
* Turning off the trap sends a negative intensity.
*/
#if !SCR_GENSCRIPTS
class cScr_StimTrap : public cBaseTrap
{
public:
cScr_StimTrap(const char* pszName, int iHostObjId)
: cBaseTrap(pszName, iHostObjId)
{ }
private:
static int LinkIter(ILinkSrv* pLS, ILinkQuery* pLQ, IScript* pScript, void* pData);
protected:
void StimLinks(float fScale, bool bSelf = false);
virtual long OnSwitch(bool, sScrMsg*, cMultiParm&);
};
#else // SCR_GENSCRIPTS
GEN_FACTORY("TrapStim","BaseTrap",cScr_StimTrap)
#endif // SCR_GENSCRIPTS
/**
* Script: TimedStimulator
* Inherits: TrapStim
* Messages: Stage
* Link: ScriptParams(??interval??) - Supported for compatibility. Use parameters instead.
* Parameter: interval(time) - Delay between stims.
* Parameter: stage(integer) - Initial multiplier.
* Parameter: device(boolean) - Only start the timer in response to ``TurnOn``.
*
* Applies a stimulus to ``ControlDevice`` linked object many times until the trap
* is turned off. Each successive stim will multiply the intensity (see ``TrapStim``)
* by an increasing amount.
*
* When turned off, the trap will save the current stage. Turning it on again will
* restart from that value. Send the message ``Stage`` to manually reset the current
* value of the stimulator. The first message data is the new multiplier.
*
* The $$device$$ parameter controls whether the timer can be activated automatically.
* Normally, when an object is created in Dromed, the timer will wait for a ``TurnOn``
* message to activate. If the object is created after the game starts, then the timer
* activates automatically. To make an emitted object wait for ``TurnOn``, you must
* set the $$device$$ parameter to ''true''.
*/
#if !SCR_GENSCRIPTS
class cScr_StimRepeater : public cScr_StimTrap
{
public:
cScr_StimRepeater(const char* pszName, int iHostObjId)
: cScr_StimTrap(pszName, iHostObjId),
SCRIPT_VAROBJ(cScr_StimRepeater, m_hTimer, iHostObjId),
SCRIPT_VAROBJ(cScr_StimRepeater, m_iScale, iHostObjId),
SCRIPT_VAROBJ(cScr_StimRepeater, m_iInterval, iHostObjId)
{ }
private:
script_handle<tScrTimer> m_hTimer;
script_int m_iScale;
script_int m_iInterval;
void GetLinkParams(int* piInterval, int* piInitial);
void StartTimer(void);
protected:
virtual long OnBeginScript(sScrMsg*, cMultiParm&);
virtual long OnTimer(sScrTimerMsg*, cMultiParm&);
virtual long OnMessage(sScrMsg*, cMultiParm&);
virtual long OnSwitch(bool, sScrMsg*, cMultiParm&);
};
#else // SCR_GENSCRIPTS
GEN_FACTORY("TimedStimulator","TrapStim",cScr_StimRepeater)
#endif // SCR_GENSCRIPTS
/**
* Script: TrigOBBSpec
* Inherits: BaseTrap, BasePopulation
* Messages: PhysEnter, PhysExit, Obituary, PMResize
* Links: ScriptParams(arc), ScriptParams(cd), Population, ScriptParams(Population)
* Metaproperties: M-NotifyRegion
* SeeAlso: PhysModelCorrect
*
* Triggers when objects of a specific type enter the bounding box.
* The $$arc$$ link identifies the type of objects that will trigger the trap.
* Every time an object enters or exits the bounding box, the $$cd$$ links
* will be triggered with ``TurnOn`` or ``TurnOff``. ``ControlDevice`` links
* are turned on when the first object enters, and turned off when the last
* object exits.
*
* Objects in the bounding box are tracked with ``Population`` links and the
* metaproperty ``M-NotifyRegion``. Objects that are slain while being tracked
* should send an ``Obituary`` message to the trap. __System Shock 2__ will use
* ``ScriptParams`` links with the data set to ''Population''.
*/
#if !SCR_GENSCRIPTS
class cScr_OBBSpec : public cBaseTrap, protected cTrackPopulation
{
public:
cScr_OBBSpec(const char* pszName, int iHostObjId)
: cBaseTrap(pszName, iHostObjId),
cTrackPopulation(iHostObjId)
{ }
protected:
virtual long OnBeginScript(sScrMsg*, cMultiParm&);
virtual long OnEndScript(sScrMsg*, cMultiParm&);
virtual long OnSim(sSimMsg*, cMultiParm&);
virtual long OnPhysEnter(sPhysMsg*, cMultiParm&);
virtual long OnPhysExit(sPhysMsg*, cMultiParm&);
virtual long OnMessage(sScrMsg*, cMultiParm&);
void SpecTrigger(bool bTurnOn, object iSource);
};
#else // SCR_GENSCRIPTS
GEN_FACTORY("TrigOBBSpec","BaseTrap",cScr_OBBSpec)
#endif // SCR_GENSCRIPTS
/**
* Script: TrigBodyPickup
* Inherits: BaseScript
* Messages: Contained
*
* Turns on when the object is picked up. Turns off when dropped.
*/
#if !SCR_GENSCRIPTS
class cScr_CorpseTrigger : public cBaseScript
{
public:
cScr_CorpseTrigger(const char* pszName, int iHostObjId)
: cBaseScript(pszName, iHostObjId)
{ }
protected:
virtual long OnContained(sContainedScrMsg*, cMultiParm&);
};
#else // SCR_GENSCRIPTS
GEN_FACTORY("TrigBodyPickup","BaseScript",cScr_CorpseTrigger)
#endif // SCR_GENSCRIPTS
/**
* Script: TrigDamageRTC
* Inherits: BaseScript
* Messages: Damage
*
* Triggers the object that caused damage. The first message data argument
* is the amount of damage.
*/
#if !SCR_GENSCRIPTS
class cScr_DamageRTC : public cBaseScript
{
public:
cScr_DamageRTC(const char* pszName, int iHostObjId)
: cBaseScript(pszName, iHostObjId)
{ }
protected:
virtual long OnDamage(sDamageScrMsg*, cMultiParm&);
};
#else // SCR_GENSCRIPTS
GEN_FACTORY("TrigDamageRTC","BaseScript",cScr_DamageRTC)
#endif // SCR_GENSCRIPTS
/**
* Script: TrapHP
* Inherits: BaseTrap
* Parameter: target(object) - Victim.
* Parameter: culprit(object) - What causes the damage. (optional)
* Parameter: damage(object) - Type of damage stimulus. (optional)
* Parameter: hitcount(number) - How much healing or damage to cause.
*
* Increases the hit-points of $$target$$ when turned on. Damages the object by the same amount when turned off.
*/
#if !SCR_GENSCRIPTS
class cScr_HPTrap : public cBaseTrap
{
public:
cScr_HPTrap(const char* pszName, int iHostObjId)
: cBaseTrap(pszName, iHostObjId)
{ }
protected:
virtual long OnSwitch(bool, sScrMsg*, cMultiParm&);
};
#else // SCR_GENSCRIPTS
GEN_FACTORY("TrapHP","BaseTrap",cScr_HPTrap)
#endif // SCR_GENSCRIPTS
/**
* Script: AIItemGiver
* Inherits: BaseScript
* Messages: TransferItem
*
* Takes an item contained by this object and gives it to another object.
* The script can be used in a conversation or response so the AI running
* the pseudo-script will give an item it holds.
*
* The first data argument of the ``TransferItem`` message is the name
* of the object that will become the new container for the item. The second
* argument is the name of the item. If either object can't be found, or the
* AI isn't the current container for the item, then the pseudo-script will abort.
*
* This script may be unstable in __System Shock 2__.
*/
#if !SCR_GENSCRIPTS
class cScr_TransferItem : public cBaseScript
{
public:
cScr_TransferItem(const char* pszName, int iHostObjId)
: cBaseScript(pszName, iHostObjId)
{ }
protected:
virtual long OnMessage(sScrMsg*, cMultiParm&);
};
#else // SCR_GENSCRIPTS
GEN_FACTORY("AIItemGiver","BaseScript",cScr_TransferItem)
#endif // SCR_GENSCRIPTS
/**
* Script: IntrinsicText
* Inherits: BaseTrap
* Properties: Book\Text
* Parameters: text(string), clr(color), clr_red(integer), clr_green(integer), clr_blue(integer), time(time)
*
* Displays text on-screen when turned on. If the ``Book\Text`` property is set,
* the first page of the book file will be shown. Otherwise, the text is given in the
* design note.
*/
#if !SCR_GENSCRIPTS
class cScr_QuickText : public cBaseTrap
{
public:
cScr_QuickText(const char* pszName, int iHostObjId)
: cBaseTrap(pszName, iHostObjId)
{ }
protected:
void ScanText(char* psz);
void DisplayText(void);
protected:
virtual long OnSwitch(bool, sScrMsg*, cMultiParm&);
};
#else // SCR_GENSCRIPTS
GEN_FACTORY("IntrinsicText","BaseTrap",cScr_QuickText)
#endif // SCR_GENSCRIPTS
/**
* Script: IntrinsicPlaque
* Inherits: IntrinsicText
* Messages: FrobWorldEnd
*
* Displays text on-screen when frobbed.
*/
#if !SCR_GENSCRIPTS
class cScr_FrobText : public cScr_QuickText
{
public:
cScr_FrobText(const char* pszName, int iHostObjId)
: cScr_QuickText(pszName, iHostObjId)
{ }
protected:
virtual long OnFrobWorldEnd(sFrobMsg*, cMultiParm&);
virtual long OnSwitch(bool, sScrMsg*, cMultiParm&)
{ return 0; }
};
#else // SCR_GENSCRIPTS
GEN_FACTORY("IntrinsicPlaque","IntrinsicText",cScr_FrobText)
#endif // SCR_GENSCRIPTS
/**
* Script: IntrinsicCover
* Inherits: IntrinsicText
* Messages: WorldFocus
*
* Displays text on-screen when highlighted. The ``WorldAction`` of the property
* ``Engine Features\FrobInfo`` must be set to ``FocusScript``.
*/
#if !SCR_GENSCRIPTS
class cScr_FocusText : public cScr_QuickText
{
public:
cScr_FocusText(const char* pszName, int iHostObjId)
: cScr_QuickText(pszName, iHostObjId)
{ }
protected:
virtual long OnWorldSelect(sScrMsg*, cMultiParm&);
virtual long OnSwitch(bool, sScrMsg*, cMultiParm&)
{ return 0; }
};
#else // SCR_GENSCRIPTS
GEN_FACTORY("IntrinsicCover","IntrinsicText",cScr_FocusText)
#endif // SCR_GENSCRIPTS
/**
* Script: InvSchema
* Inherits: BaseScript
* Messages: FrobInvEnd
* Links: SoundDescription
* Properties: Sound\Object Sound
*
* Play a sound when an inventory object is frobbed. In __Thief__, use a ``SoundDescription``
* link to the schema. In __System Shock 2__, set the ``Sound\Object Sound`` property.
*
* The schema will be played as an ambient sound if it is frobbed by the ``Player``.
*/
#if !SCR_GENSCRIPTS
class cScr_InvSchema : public cBaseScript
{
public:
cScr_InvSchema(const char* pszName, int iHostObjId)
: cBaseScript(pszName, iHostObjId)
{ }
protected:
virtual long OnFrobInvEnd(sFrobMsg*, cMultiParm&);
};
#else // SCR_GENSCRIPTS
GEN_FACTORY("InvSchema","BaseScript",cScr_InvSchema)
#endif // SCR_GENSCRIPTS
/**
* Script: Sippable
* Inherits: BaseScript
* Messages: FrobInvEnd, Contained
* Properties: Inventory\Object Name, Obj\Object name
* Parameter: sips(number) - How many times the object can be frobbed.
*
* The object can be frobbed a limited number of times. After all the sips have
* been used, it is destroyed. Put the string ''%i'' somewhere in the inventory
* name of the object and it will be replaced with the number of sips remaining.
*/
#if !SCR_GENSCRIPTS
class cScr_Sippable : public cBaseScript
{
public:
cScr_Sippable(const char* pszName, int iHostObjId)
: cBaseScript(pszName, iHostObjId)
{ }
private:
void SetSipsLeft(int iSips);
int GetSipsLeft(void);
protected:
virtual long OnFrobInvEnd(sFrobMsg*, cMultiParm&);
virtual long OnContained(sContainedScrMsg*, cMultiParm&);
};
#else // SCR_GENSCRIPTS
GEN_FACTORY("Sippable","BaseScript",cScr_Sippable)
#endif // SCR_GENSCRIPTS
/**
* Script: Zapper
* Inherits: BaseAIScript
* Messages: EndAttack
* Links: AITarget
* Stims: MagicZapStim, Anti-Human
* Schemas: ghmagic, hit_magic, dam_sting, exp_cryopsi
* Parameters: zap_stim(object), zap_strength(number), no_zap_sound(boolean)
*
* Stimulates an object when it is attacked by an AI. Uses a $$MagicZapStim$$ in
* __Thief__ or $$Anti-Human$$ in __System Shock 2__, or the stimulus in the
* $$zap_stim$$ parameter.
*
* Unless $$no_zap_sound$$ is set, a sound is played where the target is. One
* schema is used when the target is the ``Player``, and another for other
* objects. In __Thief__ the sounds are ``ghmagic`` and ``hit_magic``.
* In __System Shock 2__ the sounds are ``dam_sting`` and ``exp_cryopsi``.
*/
#if !SCR_GENSCRIPTS
class cScr_Zapper : public cBaseAIScript
{
public:
cScr_Zapper(const char* pszName, int iHostObjId)
: cBaseAIScript(pszName, iHostObjId)
{ }
protected:
virtual long OnEndAttack(sAttackMsg*, cMultiParm&);
};
#else // SCR_GENSCRIPTS
GEN_FACTORY("Zapper","BaseAIScript",cScr_Zapper)
#endif // SCR_GENSCRIPTS
/**
* Script: PhysModelCorrect
* Inherits: BaseScript
* Messages: Sim, TweqComplete, PMResize
* Properties: Physics\Model, Shape\Scale
*
* Automatically adjusts the physical dimensions of an object to match the
* ``Shape\Scale`` property. Activates when the game starts, when a
* scale tweq completes, and when the ``PMResize`` message is received.
*/
#if !SCR_GENSCRIPTS
class cScr_PhysScale : public cBaseScript
{
public:
cScr_PhysScale(const char* pszName, int iHostObjId)
: cBaseScript(pszName, iHostObjId)
{ }
private:
void DoResize(void);
protected:
virtual long OnSim(sSimMsg*, cMultiParm&);
virtual long OnTweqComplete(sTweqMsg*, cMultiParm&);
virtual long OnMessage(sScrMsg*, cMultiParm&);
};
#else // SCR_GENSCRIPTS
GEN_FACTORY("PhysModelCorrect","BaseScript",cScr_PhysScale)
#endif // SCR_GENSCRIPTS
/**
* Script: TrapPhantom
* Inherits: BaseTrap
* Links: ControlDevice
* Properties: Renderer\Transpncy
* Parameters: alpha_min(number), alpha_max(number), rate(number), fade_time(time), curve(integer)
*
* Gradually changes the ``Renderer\Transpncy`` of an object when turned on or off.
* Turning on the trap will increase the value, turning off decreases it. When the alpha
* reaches $$alpha_max$$ or $$alpha_min$$ the script stops and sends ``TurnOn`` or
* ``TurnOff``. The $$fade_time$$ parameter sets the time it will take to fade from
* $$alpha_min$$ to $$alpha_max$$. Or you can set the speed as alpha-per-second in
* the $$rate$$ parameter.
*
* The $$curve$$ parameter changes the algorithm used to calculate the alpha value.
* The default is to scale linearly to the time. Other options :
* 1 - square
* 2 - square root
* 3 - logarithm
* 4 - exponential (base 10)
* 5 - natural logarithm
* 6 - exponential (base e)
*/
#if !SCR_GENSCRIPTS
class cScr_AlphaTrap : public cBaseTrap
{
public:
cScr_AlphaTrap(const char* pszName, int iHostObjId);
private:
//script_handle<tScrTimer> m_hFadeTimer;
script_int m_bActive;
script_int m_iSign;
script_int m_iStartTime;
static const int sm_iFadeResolution;
float m_fAlphaMin, m_fAlphaMax;
int m_iFadeTime, m_iCurve;
protected:
virtual long OnSwitch(bool, sScrMsg*, cMultiParm&);
virtual long OnBeginScript(sScrMsg*, cMultiParm&);
virtual long OnTimer(sScrTimerMsg*, cMultiParm&);
};
#else // SCR_GENSCRIPTS
GEN_FACTORY("TrapPhantom","BaseTrap",cScr_AlphaTrap)
#endif // SCR_GENSCRIPTS
/**
* Script: TrapMotion
* Inherits: BaseTrap
* Links: ControlDevice
* Parameters: mot(string)
*
* Make an AI play a motion. Link to the AI with ``ControlDevice``.
* The parameter is the name of the motion file (without a ''.mi'' extension),
* not the motion schema. However, only motions that are part of a motion
* schema will be recognized.
*/
#if !SCR_GENSCRIPTS
class cScr_MotionTrap : public cBaseTrap
{
public:
cScr_MotionTrap(const char* pszName, int iHostObjId)
: cBaseTrap(pszName, iHostObjId)
{ }
private:
static int LinkIter(ILinkSrv*, ILinkQuery*, IScript*, void*);
protected:
virtual long OnSwitch(bool, sScrMsg*, cMultiParm&);
};
#else // SCR_GENSCRIPTS
GEN_FACTORY("TrapMotion","BaseTrap",cScr_MotionTrap)
#endif // SCR_GENSCRIPTS
#if (_DARKGAME == 2) || (_DARKGAME == 3)
/**
* Script: TrapCamShift
* Inherits: BaseTrap
*
* Changes the player's viewpoint to this object while the trap is turned on.
* In __System Shock 2__ it is necessary to assign a name to the object.
* This script isn't supported in __Thief 1__.
*
* If the object has a physics model, then the camera view will have a lens-like
* border. Setting the ``Physics\Model\Type`` to ''None'' (which is the same
* as deleting the property) will fill the entire screen with the object view.
*/
#if !SCR_GENSCRIPTS
class cScr_CameraTrap : public cBaseTrap
{
public:
cScr_CameraTrap(const char* pszName, int iHostObjId)
: cBaseTrap(pszName, iHostObjId)
{ }
protected:
virtual long OnSwitch(bool, sScrMsg*, cMultiParm&);
};
#else // SCR_GENSCRIPTS
GEN_FACTORY("TrapCamShift","BaseTrap",cScr_CameraTrap)
#endif // SCR_GENSCRIPTS
#endif // (_DARKGAME == 2) || (_DARKGAME == 3)
/**
* Script: TrigAIAwareShift
* Inherits: BaseScript
* Link: AIAwareness
* Link: ScriptParams(af??code??) - Link to object that can trigger awareness.
* Link: ScriptParams(av??code??) - Relay to these links when the AI can see the object.
* Link: ScriptParams(aa??code??) - Relay to these links when the AI can hear the object.
*
* Triggers when an AI becomes aware of other objects. Create a ``ScriptParams`` link
* to each object to watch for and set the link data to ''af'' plus a code that identifies
* the object. When the AI becomes aware of the object it will send ``TurnOn`` to
* ``ScriptParams`` links that have the same code. If the AI can hear the object, links
* that begin with ''aa'' are used. If it can see the object, links that begin with ''av'' are used.
* ``TurnOff`` will be sent when the AI loses contact with the object.
*
* This script requires the DarkHook library.
*/
#if !SCR_GENSCRIPTS
class cScr_TrackAwareness : public cBaseScript
{
public:
cScr_TrackAwareness(const char* pszName, int iHostObjId);
private:
script_int m_iPrevVis;
script_int m_iPrevAud;
protected:
virtual long OnBeginScript(sScrMsg*, cMultiParm&);
virtual long OnEndScript(sScrMsg*, cMultiParm&);
virtual long OnSim(sSimMsg*, cMultiParm&);
virtual long OnNotify(sDHNotifyMsg*, cMultiParm&);