This repository has been archived by the owner on Oct 6, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathScripting_AllDocs.txt
1535 lines (1285 loc) · 65.2 KB
/
Scripting_AllDocs.txt
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
Parameter Info:
¯¯¯¯¯¯¯¯¯¯¯¯¯¯
[thothie][/thothie] = Entry added by Thothie based on working script or code
<command> - Means the parameter is required
[command] - Means the parameter is optional
(target) - indicates origin is to be used instead of entity id
_idx - indicates client model index rather than entity id
(r,g,b) is a color in the format "(red,green,blue)". Each value ranges from 0-255 //thothie - with the exception of some client side effects, including beams, which are 0-1.0
$rand(<low>,<high>)
$randf(<low>,<high>)
Returns a random number bewtween <low> and <high>. Floating point uses $randf()
$vec(x,y,z)
Returns (x,y,z), with all parameters resolved (you can use constants or variables for x, y and z)
$vec.<x/y/z/pitch/yaw/roll>(<vector>)
Returns the x, y, z, pitch, yaw or roll value of the specified vector
pitch, yaw and roll correspond to x, y and z respectively, but are named for clarity
$anglediff(<destang>,<srcang>)
Returns the difference between two angles. Accounts for 360 degree wrap-around
$relpos(r,f,u)
Is a relative position in the format "$relPos(units Right,units Forward,units Up)"
For example, $relpos(-1,10,0) Means 1 unit to the left (negative), 10 units forward,
and 0 units up from the origin of the item or NPC that is running the script command.
$relpos($vec(pitch,yaw,roll),$vec(r,f,u))
Returns a relative position, same as the above command, except you specify the source
angles instead of using the entity's angles. A string such as,
"$relpos((0,90,0),(60,60,10))"
will *not* work. You must use $vec(), such as "$relpos($vec(0,90,0),$vec(60,60,10))"
Or use variables, such as "$relpos(ANGLES_VAR,OFFSET_VAR)"
$relvel(r,f,u)
Is a relative velocity in a similar format to $relpos()
For example, $relvel(-1,10,0) Means 1 unit to the left (negative), 10 units forward,
and 0 units up based on the direction the item or NPC is facing
$relvel($vec(pitch,yaw,roll),$vec(r,f,u))
Returns a relative velocity, same as the above command, except the source angles
are specified instead of using the entity's angles. Syntax rules are similar to $relpos
$cansee(<enttype>,[distance])
Returns 1 if the monster can see <enttype> or 0 if not. When [distance]
is specified, the target must be within this distance to be successful.
<enttype> may be "enemy", "ally", "player", or a monster or player name.
//note $cansee(enemy) doesn't conform to relations used by $get(ent_lastheard,relation,ent_me) etc.
$dist(<start origin>,<end origin>)
Returns a float indicating the distance between the two points
$veclen(<vector>)
Returns the length of a vector
$veclen2D(<vector>)
Returns the length of a vector, excluding the z component
$dir(<start origin>,<end origin>)
Returns a normalized vector indicating the direction from <start origin> to <end origin>
$within_cone(<point origin>,<cone origin>,<cone angles>,<cone apex angle>)
$within_cone2D(<point origin>,<cone origin>,<cone angles>,<cone apex angle>)
Returns 1 if the point is within the defined infinite cone
$cone_dot(<point origin>,<cone origin>,<cone angles>)
$cone_dot2D(<point origin>,<cone origin>,<cone angles>)
Returns -1 to 1 indicating how far off the point is from straight forward in the view cone
$anim_exists(<name>)
Checks if anim <name> exists within the scripted monster or player.
$get_sky_height(<origin>)
Returns the sky height at <origin>. Returns "none" if sky not found or if <origin>
is above the sky
$get_ground_height(<origin>)
Returns the ground height at <origin>. Returns "none" if ground not found or if <origin>
is below the ground
$get_skill_ratio(<ratio(0-1)>,<Min Amt>,<Max Amt>)
Returns a number between Min and Max based on the ratio. If the ratio is .5, this returns
a number halfway between Min and Max. If .1, the number is 10% of the way towards Max.
$int(<number>)
Returns <number> as an integer
$float(<precision>,<number>)
Returns <number> as a float with <precision> decimal places
$stradd(<string1>,<string2>,<string3>,etc.)
Adds strings together //Thothie - never seen this work, but the code looks fine :\
$get_token(<token string>,<idx>)
Retrieves one token from a token string.
A token string is an array of strings separated by semi-colons (ex: "string;string2;etc")
$get_token_amt(<token string>)
Determines the number of tokens (a.k.a array elements) in a token string.
$get(<target>,<value>,[extra])
$get_by_idx(<target idx>,<value>,[extra])
Returns a value of the <target> entity ($get_by_idx uses an entity index for <Target>)
<value> may be:
Entities:
========
"name" - returns the name of <target>
"name.full" - returns the full name of <target> (an Orc, 2 fire arrows, the Gaurd, etc.)
"name.full.capital" - returns the full name of <target>, but starting with a capital letter
"id" - returns an id that can be used as a <target>
"index" - returns an entity index that can be sent to the client and used in $getcl()
"exists" - returns 1 if the entity still exists
"alive" - returns 1 if the entity is alive
"speed","speed2D" - returns the current total speed or ground speed (speed2D)
"onground" - returns 1 if the entity is currently on the ground
"gravity" - returns the entity's current gravity (0 is the same as 1.0)
"height" - returns distance from top to bottom of the bounding box
"origin" - returns the origin in (x,y,z) format
"origin_center" - returns the entity bbox center in (x,y,z) format
"velocity" - returns the current velocity in (x,y,z) format
"angles" - returns the current angles in (x,y,z) format
"range" - returns the distance to the entity (from bounding box to bounding box)
"range2D" - returns the distance to the entity, excluding height
"relationship" - returns "ally", "enemy" or "neutral"
"isplayer" - returns 1 if <target> is a player
Scripted:
========
"scriptvar" - Returns the value of the Variable named [extra] in scripted entity <target>
//Thothie - there maybe an issue with this, if the script calling for the scriptvar has a matching scriptvar set
//- place variable name in single quotes to prevent this, eg. $get(MY_MASTER,scriptvar,'NPCATK_TARGET')
NPCs:
====
"race" - returns the race
"movedest.origin" - returns the current move destination
"movedest.prox" - returns the current move destination proximity //Thothie-seems to actually return a 1 until rest reached - use $dist(game.monster.origin,<origin>) or $get(<target_ent>,range)
"moveprox" - returns the monster's default move proximity, based on bbox size
Player Only:
===========
"target" - returns a player's current target in entity format
"gender" - returns "male" or "female"
"eyepos" - returns the position of the player's eye (camera)
"jumping" - returns 1 if the player is jumping
"ducking" - returns 1 if the player is ducking
<stat.<name>[.max/.ratio] - returns a player's Natural stat (Concentration, Awareness, Fitness, etc.)
Ex: stat.concentration or stat.strength.ratio
<skill.<name>[.prof/.balance/.power][.max/.ratio]>
Returns the current skill amount (Ex: skill.spellcasting or skill.smallarms.power)
If [.max] is added, it returns the max amount possible of that skill
If [.ratio] is added, it returns a ratio of the current amount to the max
"canattack" - returns 1 if can attack //Thothie AUG2007a
$getcl(<target idx>,<value>,[value2])
Returns a value of the <target idx> entity on the client.
<target idx> is the entity index, which is usually sent from the server
"exists" - returns 1 if the entity still exists
"visible" - returns 1 if the entity is visible
"isplayer" - returns 1 if the entity is a player
"gravity" - returns the entity's current gravity (0 is the same as 1.0)
"origin" - returns the origin in (x,y,z) format
"center" - returns the center in (x,y,z) format
"velocity" - returns the current velocity in (x,y,z) format
"angles" - returns the current angles in (x,y,z) format
"scale" - returns the current scale
"bonepos" - returns the last rendered position of bone #[value2]
"model" - returns the name of the model, or "0" if none
"modelidx" - returns model index number
"anim" - returns the current animation index
"frame" - returns the current animation frame
"framerate" - returns the current animation framerate
$get_by_name(<name>)
Returns the id of an entity that is named <name>
game.x.x
Returns the current state of something
Examples: game.time | game.monster.isalive
game
.time
.map
.name - Name of the map
.skyname - Prefix for the current sky
.players - Number of players
.clientside - Whether the script is currently running on the client
.serverside - Whether the script is currently running on the server
.sound - Game constants / Sound channels and volumes
.weapon
.voice
.item
.body
.stream
.static
.maxvol
.silentvol
.monster - A value from the current monster (that the script is running on)
.name
.origin
.....etc, etc, etc <same as $get()>
.tempent - A value from the current temp entity (Only valid during a callback function)
.origin
.angles
.velocity
.scale
.deathtime
.bouncefactor
.script - Values returned by a command
.last_sent_id - ID of last script send to a client
.last_light_id - ID of last dynamic light
.iteration - Current iteration when called in a loop
.localplayer - Client-side values associated with the local player
.index - Local player index
.thirdperson - Whether the player is in thirdperson
.viewmodel.left.id - Left view model entity index
.viewmodel.right.id - Right view model entity index
.viewmodel.active.id - Active view model (left or right) entity index (-1 if none)
//Thothie new
.pvp - returns ms_pklevel var
.revision - returns version
.central - returns ms_central_enabled var
Targets:
ent_lastseen: The entity the monster last saw
ent_lastheard: The entity the monster last heard
ent_lastspoke: The entity the monster last heard text from
ent_lastoffered: The entity the monster last game somthing to //Thothie - defunct
ent_lastgave: The entity the monster recieved something from //Thothie - defunct
ent_laststole: The entity the monster last noticed trying to steal from him //Thothie - defunct
ent_lastused: The entity the monster by last used by
ent_laststruck: The entity the monster was last hit by
ent_laststruckbyme: The npc I last hit
ent_lastprojectile: Last projectile created (via tossprojectile)
ent_lastcreated: Last entity created (via createnpc/createitem)
ent_me: Myself
ent_owner: My owner (items only)
ent_creationowner: The entity that created me (via createnpc/createitem)
ent_target: My current target (player only)
ent_expowner: The player that will receive credit for my damage and kills (projectiles)
Compares:
strings:
a equals b If a is alphabetically equal to b //Thothie - use also for comparing vectors or entity ID's
a isnot b If a is not alphabetically equal to b
a contains b True if a occurs anywhere in b (case sensitive, new JUN2007)
a startswith b True if a starts with b (case sensitive, new JUN2007), you can use $lcase() to convert case
numberical:
a == b If a is numerically equal to b
a != b If a is not numerically equal to b
a > b If a is numerically more than b
a < b If a is numerically less than b
a >= b If a is numerically more than or equal to b
a <= b If a is numerically less than or equal to b
(math compares are order sensitive, meaning: "=>" isnot ">=", etc.)
All vars are effectively strings, so you can do string comparisons of numbers, and the like.
Use string compares when comparing target id's.
Commands
¯¯¯¯¯¯¯¯
{ [[scope]] [event name]
Starts an event. Commands can only be executed within an event.
[[scope]] == [server] - Event is server-side only
[[scope]] == [client] - Event is client-side only
[[scope]] == nothing or [shared] - Event is used on the client and server
}
Closes an event.
Thothie: remember if an event is both on client and server, the variables and available properties may not match up
dbg <text1> <text2...>
Prints text to the console (dev mode 1). The parameters can be variables.
//Thothie: Only appears in alpha builds
hp <#>
Sets the monster's current and max hit points.
fov <0-360>
Sets the monster's field of vision (range in front of it that it can see)
Thothie: DON'T USE THIS - it eventually leads to all monsters on the map "going blind"
gold <#>
Sets the ammount of gold a monster currently has
width <#>
Monster's clipping box width (the rectangle's width)
height <#>
Monster's clipping box height
stepsize <#>
Highest stair height the monster can walk up
Thothie: base_monster_shared will make this half the monster's height by default
maxslope <0-90>
Max slope angle the monster can walk up.
race <racename>
Monster's alignment
Thothie: see \races.script
skilllevel <#>
Sets how much exp is gained from from killing this monster
setbbox [mins] [maxs]
Sets an entity's clipping box size (Example: "setbox (-1,-1,-1) (1,1,1)" )
setbbox <animsize/npcsize>
npcsize: Sets an NPC's clipping box to it's normal size (-Width/2,-Width/2,0) (Width/2,Width/2,Height)
animsize: Sets an NPC's clipping box to the bbox extracted from the anim
setsolid <none/box/slidebox/trigger>
Sets the solidity of the object. Default is box for monsters
"none" - Not solid
"box" - Use the entity's bounding box (width x width x height)
"slidebox" - Similar to box, but for objects that move without AI
"trigger" - Non-blocking, but responds to a touch
setalive <0/1>
Marks the creature as alive or dead
Thothie: playing with this will fool monster spawners and may cause issues
setprop <target> <property> <value>
Sets a core value of an entity. These values are used directly by the engine. Useful for direct
control over an entity or brush. No validation checks are done. Erroneous values for the
particular entity type will cause undefined behavior and crashing.
<property> may be:
"speed" float
"skin" int
"modelindex" int
"model" string
"solid" int
"movetype" int [see movetype entries at end - thothie]
"classname" string
"basevelocity" vector
"avelocity" vector
"velocity" vector
"movedir" vector
"ltime" float
"nextthink" float
"friction" float
"frame" float
"animtime" float
"sequence" int
"playerclass" int (used for glass brushes - not related to MS player)
"target" string
"targetname" string
"netname" string
"view_ofs" vector
"deadflag" int
"health" float
"controller0" byte
"controller1" byte
"controller2" byte
"controller3" byte
"blending0" byte
"blending1" byte
//thoithie added DEC2007
"rendermode" 1-5 (see hammer)
"renderamt" 0-255
setcallback <think/touch/blocked/render> <enable/disable>
Sets whether the game calls script functions on these events. Calling script
events slows down the game, so only enable the callbacks you use.
"think" - Calls game_think every frame. Enabled by default
"touch" - Calls game_touch every frame that the enity is touching something.
PARAM1 is the other entity. Disabled by default
"blocked" - Calls game_blocked when movement is blocked by anther entity.
PARAM1 is the other entity. Disabled by default
"render" - Calls game_prerender every frame on the client.
Calls game_render every frame on the client.
Default off
name <name>
Monster's name as shown when looking at it, or when it's speaking
Also sets the unique name to <name>
name_prefix <name>
Sets the prefix to the name (Ex. "a","the","a pair of")
Thothie: this can be sent in name (above) with a file pipe, eg. an|Orc, a pair of|Gauntlets, etc.
name_unique <name>
Sets a unique name, for reference with $get_by_name()
Thothie: subsequent spawns of script with idenitcal name_unique will be ignored
roam <0|1>
Turns on/off monsters ability to freely move around
blood <type>
Sets the blood type. <type> can be "red", "green", or "none"
movespeed <multiplier>
Multiplies the npc's speed by <multiplier>
drop_to_floor [target]
Drops the entity to the floor. If no [target], the entity running the script is used
setmodel <modelpath>
Sets the monster's current model
setmoveanim <animation name>
Sets the monster's current movement animation
setidleanim <animation name>
Sets the monster's current idle animation
setmonsterclip <1|0>
Enables or Disables adheres to monsterclip (Default: Enabled)
setangle <angle> <value>
When <angle> == "velocity", <value> is not used. The model angle is set forward based on the object's velocity.
When <angle> == "view.<pitch/yaw/roll>", The view angle is set to <value>
When <angle> == "add_view.<pitch/yaw/roll>", <value> is added to the current view angle
When <angle> == "view", <value> can be a <ent_target> or a (pitch,yaw,roll) value
The view angles are set to either face a target or to the specified value
When <angle> == "view_origin", <value> can be a (x,y,z) value
The view angles are set to face the location
When <angle> == "face", <value> can be a <ent_target> or a (pitch,yaw,roll) value
The model and view angles are set to either face a target or to the specified value
When <angle> == "face_origin", <value> can be a (x,y,z) value
The model and view angles are set to face the location
*setorigin <target> <(x,y,z)>
sets <target> location to the specified value
setvelocity <target> <(x,y,z)>
Sets the velocity on <target> to the specified value
addvelocity <target> <(x,y,z)>
Adds a velocity to <targeT>
catchspeech <eventname> <text to catch>
Allows the monster to listen to players and respond to what they say
repeatdelay <#>
Sets the function to repeat every <#> seconds
setmovedest <target/(origin)> <stopdistance>
Causes the monster to move towards <target> or (origin) until <stopdistance> close.
//careful! setting setmovedest to invalid location formats can cause crash! (must be ID's or $relpos)
//sometiems setting an origin location inside the stopdistance will cause crash
//too many setmovedests set at the same time will cause crash
setmovedest none
Removes the monster's current destination
volume <#>
Sets the volume at which the monster's sounds are played. Value must be between 0 and 10
playsound <channel #> <volume> [sound1]
Plays a sound on <channel #> at <volume> (1-10)
playrandomsound <channel #> <volume> [sound1] [sound2] [sound3] [none] etc..
Plays a random sound between sound1, sound2, sound3... (Any may be ommited, or replaced with 'none').
# sets the channel the sound plays on.
sound.play3d <sound> <volume> <origin> [attenuation (default: 0.8)]
Plays a sound at a location
sound.pm_play <sound> <volume> <channel>
** Only available from physics event: game_playermove
Plays a sound for the current player on whom physics is being run
(Always the local player, if run on client)
On client: Plays for the local player
On Server: Sound sent to everyone *except* the current player (his sound plays clientside)
sound.setvolume <channel #> <sound> <volume>
Changes the volume of an already playing sound
say <sound>[length] [sound][length] [sound][length] etc..
Example: say chitchat[.5]
This would play sound/npc/chitchat.wav and open the NPC's mouth for .5 seconds
Example: say iam[.5] [.5] fine[.7]
This would play sound/npc/iam.wav and open the NPC's mouth for .5 seconds. After .5 seconds, the
NPC would open his mouth again for another .5 seconds (Assuming the wav file contained the words
"I am", this would simulate the NPC mouthing the words). Then the sound sound/npc/fine.wav is played
and the mouth opened for .7 seconds.
callevent [delay] <eventname> [PARAM1] [PARAM2] etc...
Executes the named event after [delay] seconds (optional)
Can pass parameters to the event
[thothie]Note: you cannot use PARAMs if you use a delay, pass with setvard instead
Also note you cannot pass PARAMs or keywords directly from one scriptevent to another
for instance:
callevent do_stuff PARAM1 PARAM2 ent_me
is invalid, the event will recieve the literal strings ("PARAM1", "ent_me", etc.) instead of a variable
instead use:
local OUT_PARAM1 PARAM1
local OUT_PARAM2 PARAM2
callevent do_stuff OUT_PARAM1 OUT_PARAM2 $get(ent_me,id)
this applys whenever you send a param or substution to another script or event
be it via callevent, callexternal, applyeffect, createnpc, or what not
[/thothie]
callexternal <target> [delay] <eventname> [PARAM1] [PARAM2] etc...
Executes the script event <eventname> on <target> after [delay] seconds (server side only)
callexternal all <eventname> [PARAM1] [PARAM2] etc...
Calls the script event on every existing player, npc, and item in the game.
//thothie - you can use "players" in place of all, to only call the script event on players
calleventloop <loops> <eventname> [PARAM1] [PARAM2] etc...
Executes the script event <eventname> <loops> times in a row
Can pass parameters to the event
Recieving event gets game.script.iteration to count loops (count starts at 0)
dodamage <target> <range> <dmg> <cth> [type]
Causes monster to attack <target> up to a distance of <range> for damage <dmg> at
a chance to hit of <cth> (in %)
dodamage <target> "direct" <dmg> <cth> <dmg source> [type]
Causes direct damage to be dealt, without range checking. <dmg source> is the attacker
dodamage <position> <range> <dmg> <cth> <attn> <flags> [type]
Does radius damage at <position> with <range>, <cth> and falloff <attn>.
<attn> == 1.0 Means linear falloff | 0.0 is no damage falloff with ranage.
Higher <attn> values make damage falloff faster
Flags:
"reflective": Can damage yourself
"normal": Cannot damage self
[type] = damage type (eg. slash, pierce, blunt, fire, lightning, cold, poison, etc.) - defaults to "generic" //New as of JAN2007
[Thothie]
AOE damage (the third type) seems to have some sort of bug where it needs to be near (or maybe LOS) of the calling script
Using xdodamage may prevent this issue (see ms.stx)
related events (called whithin the attacking monsters script when he does damage to a target):
{ game_dodamage //1:AttackHit(1/0) 2:EntityHit 3:StartOrigin 4:EndOrigin
{ game_damaged_other //PARAM1=ent hit PARAM2=damage
{ game_struck //PARAM1=incoming damage
{ game_damaged //PARAM1=attacker PARAM2=Damage PARAM3=DamageType
[/Thothie]
tossprojectile <dir> <speed> <dmg> <cof> <projectile scriptname> [start offset]
Causes monster to launch <projectile scriptname> in <dir> at <speed> for <dmg> starting from
[start offset] with cone of fire <cof>
If <dir> == "view": Use current view angles for direction
If <dir> == (origin): Aim directly at (origin)
If <dir> == (target): Aim directly at (target)
createnpc <scriptname> <position> [PARAM1] [PARAM2] etc...
Creates an NPC with <scriptname> at <position>
The entity's script will have have "game_dynamically_created" called, and at that time
PARAM1, PARAM2, etc. will be defined with the specified parameters.
(Note: These aren't defined yet at "game_spawn")
createitem <itemname> <position> [PARAM1] [PARAM2] etc...
Creates an item with <itemname> at <position>
The item's script will have have "game_dynamically_created" called, and at that time
PARAM1, PARAM2, etc. will be defined with the specified parameters.
(Note: These aren't defined yet at "game_spawn")
companion <add/remove> <target companion> <target player>
Associates the NPC <target companion> with the player. The NPC will spawn with the player across
transitions. The npc's ent_owner is set to the player.
'remove' - removes the companion from the player.
//Thothie - Defunct, companions use quest data for better dependability / less character corruption
emitsound <source entity> <origin> <volume> <duration> <type> [danger radius (only for "danger")]
Creates a sound that monsters can respond to.
<type> Can be:
"danger": Monsters should avoid <origin> up to [danger radius] units
"combat": A combat action has been initiated by <source entity>
"move": <source entity> is moving
<volume> Acts as the radius for the sound. However this radius will be multiplied
for npcs that have hearingsensitivity set higher than 1. They will hear further.
When an NPC hears a sound (hearingsensitivity taken into account), the event
game_hearsound is called with:
ent_lastheard: Source Entity
PARAM1 - Sound type
PARAM2 - Sound Origin
PARAM3 - Danger Radius (If danger sound)
helptip <target> <tipname> <title> <text>
Displays a help tip on the player's screen, if it hasn't already been displayed.
Use a bar (|) as a carriage return.
//Thothie - tipname 'generic' is repeatable
quest set <target> <questname> <questdata>
Sets the data of a quest for <target> player. This is saved to the player's file.
quest unset <target> <questname>
Removes the data of a quest for <target> player. This is saved to the player's file.
usetrigger <trigger1> [trigger2] [trigger3] etc..
Fires map triggers named <trigger1>, [trigger2], etc..
saytext <speech>
Causes the monster to say <speech>
saytextrange "default"/<range>
Changes the range of <saytext>. "Default" sets it back to the game default (300)
givehp <amount>
givemp <amount>
Gives <amount> HP/MP to npc.
storage
<openaccount> <storagename> <target> <callback>
Opens a storage account in storage <storagename> for <target>
Calls "<callback>_exists" if account already exists
Calls "<callback>_success" if successful
<checkaccount> <storagename> <target> <callback>
Checks if <target> owns an account in storage <storagename>
Calls "<callback>_success" if successful
Calls "<callback>_failed" if failed
<trade> <storagename> <target> <feeratio> <displayname> <callback>
Gives <target> access to storage <storagename>
Retrieval will cost the item price times <feeratio>
Calls "<callback>_noaccount" if player has no account
Calls "<callback>_success" if successful
//Thothie - all "storage" commands are defunct- this method of banking corrupts characters
VAR TYPES:
const <var> <val>
Replaces all subsequent instances of <var> with <val>
const is only executed at loadtime
A const can only be defined once. All subsequent definitions are ignored
[Thothie]
Use this for any static value
Only subsequent "const" definitions are ignored - setvar and setvard's are not
Redefining a const as a setvar/d causes strange and unpredictable behavior
[/Thohie]
local <var> <val>
Sets an event variable <var> to now be equal to <val>
These variables are local to the event, and deleted at the end of the event
[thothie]
Use this whenever the var is not needed outside of an event, such as with one-time calculations and adjustments
These may static in calleventloop's - I've not tested
[/thothie]
setvar <var> <val>
Sets a script variable <var> to now be equal to <val>
setvar is executed at loadtime and runtime
[thothie]
This should ONLY be used if the var MUST be defined pre-spawn AND is adjusted later (ie. almost never)
if the setvar is defined ANYWHERE else in the script, it will pick up the subsequent definition prior to script processing
since such behavior is difficult to predict, it is best to avoid use of these when possible
[/thothie]
setvarg <var> <val>
Sets a global variable <var> to now be equal to <val>
setvarg is only executed at runtime.
[thothie]
These stay after map transitions, but not server crashes - they are not always 100% dependable
Convention says all setvarg's should start with "G_"
You can *usually* use these whenever a bunch of different npcs need to share a count
You cannot use this to pass var from server to client or visa versa (setvarg's are server side)
[/thothie]
setvard <var> <val>
Sets a script variable <var> to now be equal to <val>
setvard is only executed at runtime.
[thothie]
Most variables should use this function
Do not use this to change a setvar or const or strange things will happen
[/thothie]
//Thothie
- Try not to mix and match var types - especially via #include - I've not yet discovered the paticulars, but it can result in unpredictable behavior
- such as vars not getting set, or even swapping positions with other vars
- suspect something in the code needs to be fixed in this regards
- Note that anything in game_spawn or npc_spawn is pre-loaded
- thus vars used to define things there (such as setanimidle or setmodel) must be setvar or const
- to avoid confusion, define as little as possible there (just the model) and use use npc_post_spawn to define the rest
- script specific:
- ANIM_IDLE should always be a setvar (often loaded in game_spawn, thus is preload))
- ANIM_RUN should always be a setvar (often loaded in game_spawn, thus is preload))
- ANIM_WALK should always be a setvar (often loaded in game_spawn, thus is preload)
- All other vars used by base_monster_xxx should be always setvard instead (ATTACK_RANGE, MOVE_RANGE, etc.)
CONDITIONALS:
if ( <var> <compare> <val> ) <command>
else <else_command>
If the <compare> between <var> and <val> is true, execute <command>
otherwise, optionally execute <else_command>
Example: if( MY_VARIABLE > 1 ) callevent my_event
if ( <var> <compare> <val> )
{
<commands>
<commands>
}
else
{
<else_command>
<else_command>
}
If the <compare> between <var> and <val> is true, execute <commands>
otherwise, optionally execute <else_commands>
add <var> <val>
subtract <var> <val>
multiply <var> <val>
divide <var> <val>
mod <var> <val>
Adds, subtracts, multiplies, divides, or does modulus on <var> by <val>
capvar <var> <minvalue> <maxvalue>
Caps a variable, numerically, between <minvalue> and <maxvalue>
vectoradd <result> <vector1> <vector2>
vectormultiply <result> <vector1> <vector2>
Adds/multiplies <vector1> to <vector2> and places the resulting vector in <result>
vectoradd <result> <vector1>
vectormultiply <result> <vector1>
Adds/multiplies <vector1> to <result> and places the resulting vector back into <result>
vectoradd <result> <x/y/z> <value>
vectormultiply <result> <x/y/z> <value>
Adds/multiplies <value> to x, y, or z of <result> and places the resulting vector back into <result>
vectormultiply <result> <value>
Multiplies x, y and z of <result> by <value> and places the resulting vector back into <result>
vectorset <sourcevec> <x/y/z> <value>
Sets x, y, or z of <sourcevec> to <value>
=========== String Parsing ===========
stradd <result> <string1> <string2>
Concatenates <string1> to <string2> and places the resulting string in <result>
stradd <result> <string>
Concatenates <string> to <result> and places the resulting string back into <result>
token.add <token string> <new token>
Adds a token to <token string>. Basically it adds new text separated by a semi-colon.
token.del <token string> <idx>
Deletes a token from <token string>
========== Entity Parsing ============
storeentity <type> <target>
Stores an entity in the npc's local storage.
<type> can be any valid ent type. Manually storing some types (such as ent_owner, ent_lastheard)
may interfere what the game expects to be stored in that slot and cause a crash
deleteent <target> ["fade"]
Deletes the target entity
If "fade" is specified, the entity will fade away and be deleted after a delay
traceline <startpos> <endpos> <flags> [ignoreent]
//Thothie - this does not work, use $get_traceline([vec],[vec],[flag]) (see entry)
Does a traceline and stores the result in variables.
<flags> can be:
"normal" Hit entites and world
"worldonly" Only hit the world
"ignoreglass" Goes through glass (Can be combined with other flags)
"simplebox" Uses bounding boxes instead of hitboxes (Can be combined with other flags)
The result is stored in the following variables:
game.trace.hit [0/1] Whether the trace hit anything.
game.trace.fraction [0-1] Ratio of how far the trace traveled before a collision
game.trace.hitent Server: id of entity hit. | Client: index of entity hit | or "none" if hit wall
game.trace.endpos Ending position of trace
[Thothie]This does not work - use $get_traceline(<start>,<end>,[type]) - see ms.stx[/Thothie]
#include [scope][casual] <file> ["allowduplicate"]
Includes another script file at this point in the current script file.
A script file can only be included once within another script, unless you specify "allowduplicate"
[scope] == Optional scope. Can be [client] or [server]
[casual] == Doesn't error if file not found
#scope <scope>
Sets the default event scope [server/client/shared]
Events found after this line will use this scope if one isn't explicitly set
//Thothie - this does not always seem to work
precache <model/sprite/sound>
Precaches the model, sprite or sound
Executed at loadtime
precachefile <scriptname>
Precaches the models, sprites and sounds used in the specified script
Executed at runtime
//Thothie - This only works inside the { game_precache event
Scripting effects
====================================================
registereffect
Registers a scripted effect. An effect is meant to temporarily modify an entity's behavior.
This command accepts parameters from the following variables values:
EFFECT.NAME - Name
EFFECT.TYPE - normal: Effect is applied from the applyeffect command
player_action: Effect is automatically applied to players on their initial spawn
EFFECT.SCRIPT - The effect's scriptfile
====================================================
applyeffect <target> <effect name> [Param1] [Param2]...
Applies an effect to <target>. The affect is applied server-side
====================================================
clientevent new <target> <scriptname> [param1] [param2] etc..
Sends an effect to a client. The effect will always attach to the local player.
<target> may be:
"all" - All clients on the server
"all_in_sight" - All clients in the potientially visible area
<target> - A player entity
====================================================
clientevent update <target> <ID> <Eventname> [param1] [param2] etc..
Updates a client-side effect. When the effect is created with "new",
store game.script.last_sent_id in a variable. Then use it here for <ID>
clientevent remove <target> <ID>
Removes a client-side effect
//Thothie - not always reliable, better to update and use "removescript" command client side
====================================================
effect
Initiates a server-side special effect:
beam point <spritename> <width> <startpos> <endpos> <(r,g,b)> <brightness> <noise> <duration>
beam end <spritename> <width> <startpos> <target> <attachment index> <(r,g,b)> <brightness> <noise> <duration>
beam ents <spritename> <width> <target> <attachment index> <(r,g,b)> <brightness> <noise> <duration>
//thoth variant:
beam ents <spritename> <width> <target1> <attach#> <target2> <attach#> <(r,g,b)> <brightness> <noise> <duration>
beam vector <spritename> <width> <startpos> <endpos> <(r,g,b)> <brightness> <noise> <duration>
//beam ents under the thoth variant are stored in ent_lastcreated and G_LAST_BEAM,
//they can be modified via:
effect beam update <beam_id> <property> <value> [option]
- properties include:
- color <(r,g,b)>
- start_target <entity> [attachment_index]
- end_target <entity> [attachment_index]
- end_origin <origin> //untested
- start_origin <origin> //untested
- vector <start_origin> <end_origin> //may only work with beams created with vector, not sure
- brightness <value>
- noise <value>
- remove (no params) - removes beam on next think
tempent gibs <modelname/spritename> <position> <size> <velocity> <randomness> <amount> <duration>
tempent spray <modelname/spritename> <position> <direction> <count> <speed> <noise>
tempent trail <modelname/spritename> <start> <dest> <count> <life> <scale> <speed> <randomness>
glow <target> <(r,g,b)> <amount> <duration> <fadeduration>
screenshake <position> <amplitude> <frequency> <duration> <radius>
screenfade <target/"all"> <duration> <holdtime> <(r,g,b)> <alpha> <fadin|fadeout|noblend|perm>
====================================================
cleffect
Initiates a client-side special effect
tempent sprite <spritename> <position> <creation event> <update event>
tempent model <modelname> <position> <creation event> <update event>
Creates a sprite or model on the client
<creation event> is called when the sprite is created
<update event> is called each frame that the sprite needs to be updated
tempent set_current_prop <property> <value>
Sets the properties of the current client-side ent being updated
Can only be used from <callback event> or from "game_update_tempent"
<property> can be:
origin - Set the origin
velocity - Set the Velovity
model - Set a new sprite/model
death_delay - [tempent] Die after delay (Default is 1 second)
bouncefactor - Amount of bounce from hitting something
gravity - Gravity
frame - Current frame
frames - Number of frames in a sprite or animation (if a model vanishes, set frames to 9999)
framerate - Framerate //for models this is a ratio, for sprites it is FPS
scale - Sprite/model scale
collide - "world" - Collide with World only
"all" - Collide with entities and World
"die" - Die on collision. Must be combined with one of the above
"none" - Turn off collisions
update - Sets whether the callback event is called
rendermode - The render mode
"normal" - For models or non-transparant sprites
"color" - Render sprite transparency by color
"texture" - Render sprite transparency by texture
"glow" - Always display sprite on top
"alpha" - Render transparency by renderamt
"add" - Render sprite transparency by color & renderamt
renderfx - A render special effect
"normal" - No effect
"glow" - A shell around the object using rendercolor and renderamt
"player" - Object is not a player but should be rendered as one
renderamt - Amount of effect applied by rendermode and/or renderfx
rendercolor - (r,g,b) color
iuser[1-4] - Custom integer data
fuser[1-4] - Custom floating point data
inwater - "1" if bottom of model is underwater | "0" if not
waterorigin - Origin of the water surface, if in water | "none" if not found
timer <dl> <cb> - [tempent] Calls event named <cb> after <dl> delay
fadeout <dl> - [tempent] Fades out the sprite over <dl> time, or use 'lifetime' in place of <dl>
cb_hitwater <cb> - [tempent] Calls event named <cb> if the tempent enters water
cb_die <cb> - [tempent] Calls event named <cb> if the tempent dies from collision
//Thothie - some not mentioned
angles (PITCH,YAW,ROLL)
body [index] - model body index (raw)
frameent <model/sprite> <resourcename> <position> <creation event>
Creates a sprite or model entity on the client that lasts one frame
<creation event> is called when the entity is created
frameent set_current_prop <property> <value>
Sets the properties of the current client-side one-frame ent being updated
Can only be used from <callback event> or from "game_update_tempent"
<property> - Same propties as the tempent set_current_prop command
setprop <ent index> <property> <value>
Sets the properties of a client-side ent
<property> - Same propties as the tempent set_current_prop command
light <"new"/id> <origin> <radius> <(color)> <death delay> <flags>
Creates a dynamic light.
The id of this new light is stored in game.script.last_light_id
This can be stored and used later to modify the same light.
<flags> Can include:
entity - Lights entities only
dark - Creates darkness instead of light
beam_points <startpos> <endpos> <modelname/spritename> <life> <width> <amplitude> <brightness> <speed> <framerate> <(r,g,b)>
Create a type of beam on the client
====================================================
wearable <slots taken> <position name;position name;position name>
Specifies a position that an item takes up when worn. Can take up multiple positions.
The position names match with names used in "setwearpos" in the player script.
====================================================
wearable 0
Removes wearable status from the item.
====================================================
registerattack
--------------
Adds a new attack to an item.
This command accepts parameters from the following variables:
reg.attack.type - The type of attack
"strike-land" - Standard melee attack. Do damage to closest target in front of player
"target" - Does callbacks on closest target in front, but doesn't auto-aim or do damage
"charge-throw-projectile" - Does a ranged attack using player origin and straight forward as start points
"hold-strike" - Holds the attack while attack button is held.
reg.attack.range - Range
reg.attack.dmg - Damage
reg.attack.dmg.range - Damage will randomly be +/- this range (ex: dmg=40 & dmgrng=10 == 50-30 dmg)
reg.attack.dmg.type - Custom attack type. Corresponds to monster "takedmg" command
reg.attack.aoe.range - Splash damage range
reg.attack.aoe.falloff - Splash damage falloff - 0: no falloff | 1: linear falloff | 2+: high falloff
reg.attack.energydrain - Stamina consumed
reg.attack.mpdrain - MP drained and required for attack
reg.attack.stat - Player stat associated with this attack. Sets prof., balance and power to use this stat
reg.attack.stat.prof - Stat used for proficiency. Used to determine if you're high enough skill to use an attack
reg.attack.stat.balance - Stat used for accuracy
reg.attack.stat.power - Stat used for power
reg.attack.stat.exp - Stat that gains exp from a kill using this attack
reg.attack.noise - World noise made by player (higher = monsters further away can hear you)
reg.attack.callback - Prefix for callback events (<callback>_start, <callback>_strike, <callback>_toss, <callback>_end)
reg.attack.ofs.startpos - Attack start, Offset (r,f,u) from player origin
reg.attack.ofs.aimang - Attack direction, Offset (pitch,yaw,roll) from straight forward
reg.attack.priority - When selecting attacks to perform, this ranks attacks (higer=more priority)
reg.attack.keys - Indicates the last x keys that must have been pressed in a short time frame
+ This key must have been pressed
- This key must have been released
~ This key must have been pressed, then released
attack1 - The key that activates the item (default could be mouse1 or mouse2)
forward, back, moveleft, moveright, use, jump - Game keys
reg.attack.dmg.ignore - Call the callbacks, but don't do damage
Melee Attacks
-------------
reg.attack.hitchance - % chance attack will hit
reg.attack.delay.end - Duration of entire attack.
reg.attack.delay.strike - Time until damage is done and <reg.attack.callback>_strike is called
reg.attack.dmg.noautoaim - Uses traceline for detection instead of vicinity/FOV aiming (Auto-aim)
Ranged Attacks
--------------
reg.attack.ammodrain - Ammo used up this attack (defaults to 1 if not specified) (ranged attacks only)
reg.attack.hold_min&max - <min>;<max> - Min seconds until the attack goes off; Max seconds the attack can be usefully charged
reg.attack.projectile - Name of the ammo. An itemname substring search is done through player inventory for ammo
reg.attack.COF - <wide>;<narrow> - Starting COF (uncharged attack); Narrow COF (when charged fully)
reg.attack.delay.end - Duration of the attack after the attack button is released.
====================================================
registerspell
-------------
Treats the item like a spell.
The item will only last in the player hands for a limited time. It can't be worn, and if dropped
it disappears.
This command accepts parameters from the following variables:
reg.spell.reqskill - Skill required to learn the spell from a scroll
reg.spell.fizzletime - Duration the spell will last in the player hands
reg.spell.castsuccess - % Chance that the spell will immediately fizzle
reg.spell.preparetime - Delay until the spell is usable
====================================================
learnspell <spell scriptname>
Causes the player holding this item to attempt to learn <spell scriptname>
If successful, "game_learnspell_success" will be called
If not, "game_learnspell_failed" will be called
====================================================
==================================================
Most NPC commands can be used with players as well
==================================================
playanim <once/hold/critical/break> <animname>
Plays the animation <animname>
<once> - Plays the animation once. Won't stop a once or hold anim currently playing
<hold> - Plays the animation once, then holds the last frame until a critical or
break animation is called
<critical> - Plays the animation once. Breaks out of any currently playing anim
<break> - Breaks out of any currently playing anim. You should follow this with a line
that sets a new animation to play
giveitem <itemname> [amount]