-
Notifications
You must be signed in to change notification settings - Fork 0
/
ais_ss_incl.nss
632 lines (560 loc) · 24.7 KB
/
ais_ss_incl.nss
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
//Event based spawn system: if no event preselected fire random event
//configs
const int AISS_DEBUG_MESSAGES = 0;
const int AISS_ENABLE_RANDOM_AREA_EVENTS = 0;//uncompleted feature, do not enable
const float fAISS_DELAYED_CLEAN = 60.0;
//configure loot deletion
const string LOOT_TAG = "Bodybag";
//if the loot doesn't destroy automagically, this can handle for you
const int DESTROY_LOOT_OBJECT = FALSE;
//Area events
//fill area with wandering mobs
const int AISS_WANDERING_MOB_EVENT = 3001;
const int AISS_FIXED_MOB_EVENT = 3002;
const int AISS_RANDOM_PLACED_TRAPS = 3003;
const int AISS_FIXED_PLACED_TRAPS = 3004;
const int AISS_RANDOM_PLACEABLES_EVENT = 3005;
const int AISS_FIXED_PLACEABLES_EVENT = 3006;
/*thanks to kesda for writing these two*/
void DebugMessage(string message)
{
if(AISS_DEBUG_MESSAGES)
SendMessageToPC(GetFirstPC(),message);
}
int AISS_TranslateEvent(string sEvent)
{
if(sEvent=="wandering")
return AISS_WANDERING_MOB_EVENT;
else if(sEvent=="fixed")
return AISS_FIXED_MOB_EVENT;
else if(sEvent=="rp_traps")
return AISS_RANDOM_PLACED_TRAPS;
else if(sEvent=="fp_traps")
return AISS_FIXED_PLACED_TRAPS;
else if(sEvent=="rp_plac")
return AISS_RANDOM_PLACEABLES_EVENT;
else if(sEvent=="fp_plac")
return AISS_FIXED_PLACEABLES_EVENT;
else
return AISS_WANDERING_MOB_EVENT;
}
int AISS_GetRandomEvent()
{
return AISS_WANDERING_MOB_EVENT;
}
location RandomLoc(object oArea=OBJECT_SELF, int bFeedback=FALSE)
{
// First, let's get area size
float fAreaH = IntToFloat(GetAreaSize(AREA_HEIGHT, oArea));
float fAreaW = IntToFloat(GetAreaSize(AREA_WIDTH, oArea));
// Then let's get the maximum allowed area size
// which we'll be using to calculate the random location
// using a dice instead of the Random function
float fMaxAreaSizeH = 32.0;
float fMaxAreaSizeW = 32.0;
// Then let's get the scale of the current area for both dimensions,
// compared to the max allowed size
float fScaleAreaH = fMaxAreaSizeH/fAreaH;
float fScaleAreaW = fMaxAreaSizeW/fAreaW;
// Now let's calculate a random location on a virtual 32*32 area.
// The calculation might seem complex, but it is necessary to ensure that
// all values between 1 and 320 have the same chance to be returned
float fXLoc32 = IntToFloat( ((d8()-1)*4 + (d4()-1))*10 + d10() );
float fYLoc32 = IntToFloat( ((d8()-1)*4 + (d4()-1))*10 + d10() );
// Now let's convert the location from the virtual 32*32 area into values that fit
// inside the current area
float fXLoc = fXLoc32/fScaleAreaW;
float fYLoc = fYLoc32/fScaleAreaH;
// alright good so far, let's make it a vector..
vector vPosition = Vector(fXLoc, fYLoc, 0.0f);
// Let's get a random orientation between 0 and 359 degrees
float fOrientation = IntToFloat( ((d6()-1)*6 +(d6()-1))*10 + (d10()-1) );
// some feedback for testing purposes. GetFirstPC() will need to be replaced
// if used in a multiplayer environment
if (bFeedback)
{
DelayCommand(0.1, FloatingTextStringOnCreature("X axis position in the 32*32 virtual area = " + FloatToString(fXLoc32, 5, 2), GetFirstPC()));
DelayCommand(0.1, FloatingTextStringOnCreature("Y axis position in the 32*32 virtual area = " + FloatToString(fYLoc32, 5, 2), GetFirstPC()));
DelayCommand(0.3, FloatingTextStringOnCreature("X axis scale compared to the 32*32 virtual area = " + FloatToString(fScaleAreaW, 5, 2), GetFirstPC()));
DelayCommand(0.3, FloatingTextStringOnCreature("Y axis scale compared to the 32*32 virtual area = " + FloatToString(fScaleAreaH, 5, 2), GetFirstPC()));
DelayCommand(0.5, FloatingTextStringOnCreature("X axis position in the current area = " + FloatToString(fXLoc, 5, 2), GetFirstPC()));
DelayCommand(0.5, FloatingTextStringOnCreature("Y axis position in the current area = " + FloatToString(fYLoc, 5, 2), GetFirstPC()));
DelayCommand(0.7, FloatingTextStringOnCreature("Orientation = " + FloatToString(fOrientation, 5, 2), GetFirstPC()));
}
return Location(oArea, vPosition , fOrientation);
}
//type: acid, acid_splash, electrical, fire, frost, gas, holy,
// negative, sonic, spike, tangle
//level: minor,avarage,strong,deadly,epic
int AISS_TranslateTraps(string trap_type,string trap_level)
{
if(trap_type == "acid")
{
if(trap_level=="minor")
return TRAP_BASE_TYPE_MINOR_ACID;
else if (trap_level=="avarage")
return TRAP_BASE_TYPE_AVERAGE_ACID;
else if (trap_level=="strong")
return TRAP_BASE_TYPE_STRONG_ACID;
else if (trap_level=="deadly")
return TRAP_BASE_TYPE_DEADLY_ACID;
else
return TRAP_BASE_TYPE_MINOR_ACID;
}
else if(trap_type == "acid_splash")
{
if(trap_level=="minor")
return TRAP_BASE_TYPE_MINOR_ACID_SPLASH;
else if (trap_level=="avarage")
return TRAP_BASE_TYPE_AVERAGE_ACID_SPLASH;
else if (trap_level=="strong")
return TRAP_BASE_TYPE_STRONG_ACID_SPLASH;
else if (trap_level=="deadly")
return TRAP_BASE_TYPE_DEADLY_ACID_SPLASH;
else
return TRAP_BASE_TYPE_MINOR_ACID_SPLASH;
}
else if(trap_type == "electrical")
{
if(trap_level=="minor")
return TRAP_BASE_TYPE_MINOR_ELECTRICAL;
else if (trap_level=="avarage")
return TRAP_BASE_TYPE_AVERAGE_ELECTRICAL;
else if (trap_level=="strong")
return TRAP_BASE_TYPE_STRONG_ELECTRICAL;
else if (trap_level=="deadly")
return TRAP_BASE_TYPE_DEADLY_ELECTRICAL;
else if (trap_level=="epic")
return TRAP_BASE_TYPE_EPIC_ELECTRICAL;
else
return TRAP_BASE_TYPE_MINOR_ELECTRICAL;
}
else if(trap_type == "fire")
{
if(trap_level=="minor")
return TRAP_BASE_TYPE_MINOR_FIRE;
else if (trap_level=="avarage")
return TRAP_BASE_TYPE_AVERAGE_FIRE;
else if (trap_level=="strong")
return TRAP_BASE_TYPE_STRONG_FIRE;
else if (trap_level=="deadly")
return TRAP_BASE_TYPE_DEADLY_FIRE;
else if (trap_level=="epic")
return TRAP_BASE_TYPE_EPIC_FIRE;
else
return TRAP_BASE_TYPE_MINOR_FIRE;
}
else if(trap_type == "frost")
{
if(trap_level=="minor")
return TRAP_BASE_TYPE_MINOR_FROST;
else if (trap_level=="avarage")
return TRAP_BASE_TYPE_AVERAGE_FROST;
else if (trap_level=="strong")
return TRAP_BASE_TYPE_STRONG_FROST;
else if (trap_level=="deadly")
return TRAP_BASE_TYPE_DEADLY_FROST;
else if (trap_level=="epic")
return TRAP_BASE_TYPE_EPIC_FROST;
else
return TRAP_BASE_TYPE_MINOR_FROST;
}
else if(trap_type == "gas")
{
if(trap_level=="minor")
return TRAP_BASE_TYPE_MINOR_GAS;
else if (trap_level=="avarage")
return TRAP_BASE_TYPE_AVERAGE_GAS;
else if (trap_level=="strong")
return TRAP_BASE_TYPE_STRONG_GAS;
else if (trap_level=="deadly")
return TRAP_BASE_TYPE_DEADLY_GAS;
else
return TRAP_BASE_TYPE_MINOR_GAS;
}
else if(trap_type == "holy")
{
if(trap_level=="minor")
return TRAP_BASE_TYPE_MINOR_HOLY;
else if (trap_level=="avarage")
return TRAP_BASE_TYPE_AVERAGE_HOLY;
else if (trap_level=="strong")
return TRAP_BASE_TYPE_STRONG_HOLY;
else if (trap_level=="deadly")
return TRAP_BASE_TYPE_DEADLY_HOLY;
else
return TRAP_BASE_TYPE_MINOR_HOLY;
}
else if(trap_type == "negative")
{
if(trap_level=="minor")
return TRAP_BASE_TYPE_MINOR_NEGATIVE;
else if (trap_level=="avarage")
return TRAP_BASE_TYPE_AVERAGE_NEGATIVE;
else if (trap_level=="strong")
return TRAP_BASE_TYPE_STRONG_NEGATIVE;
else if (trap_level=="deadly")
return TRAP_BASE_TYPE_DEADLY_NEGATIVE;
else
return TRAP_BASE_TYPE_MINOR_NEGATIVE;
}
else if(trap_type == "sonic")
{
if(trap_level=="minor")
return TRAP_BASE_TYPE_MINOR_SONIC;
else if (trap_level=="avarage")
return TRAP_BASE_TYPE_AVERAGE_SONIC;
else if (trap_level=="strong")
return TRAP_BASE_TYPE_STRONG_SONIC;
else if (trap_level=="deadly")
return TRAP_BASE_TYPE_DEADLY_SONIC;
else if (trap_level=="epic")
return TRAP_BASE_TYPE_EPIC_SONIC;
else
return TRAP_BASE_TYPE_MINOR_SONIC;
}
else if(trap_type == "spike")
{
if(trap_level=="minor")
return TRAP_BASE_TYPE_MINOR_SPIKE;
else if (trap_level=="avarage")
return TRAP_BASE_TYPE_AVERAGE_SPIKE;
else if (trap_level=="strong")
return TRAP_BASE_TYPE_STRONG_SPIKE;
else if (trap_level=="deadly")
return TRAP_BASE_TYPE_DEADLY_SPIKE;
else
return TRAP_BASE_TYPE_MINOR_SPIKE;
}
else if(trap_type == "tangle")
{
if(trap_level=="minor")
return TRAP_BASE_TYPE_MINOR_TANGLE;
else if (trap_level=="avarage")
return TRAP_BASE_TYPE_AVERAGE_TANGLE;
else if (trap_level=="strong")
return TRAP_BASE_TYPE_STRONG_TANGLE;
else if (trap_level=="deadly")
return TRAP_BASE_TYPE_DEADLY_TANGLE;
else
return TRAP_BASE_TYPE_MINOR_TANGLE;
}
else return TRAP_BASE_TYPE_MINOR_FIRE;
}
//sAISS_resref_group_i = blueprint of i-th spawn group
//iAISS_size_group_i = number of monsters of the i-th blueprint
//bAISS_randomize = randomize monsters group size, from 1 to ais_number_group_i
void AISS_WanderingMonsters(object oArea = OBJECT_SELF)
{
int i = 1, j = 0;
int bRandomize = GetLocalInt(oArea,"bAISS_randomize");
while (GetLocalString(oArea,"sAISS_resref_group_"+IntToString(i))!="")
i++;
int iMobGroups = i-1;
DebugMessage("AISS_WanderingMonsters: found "+IntToString(iMobGroups)+" mob groups");
for(i=1;i<=iMobGroups;i++)
DebugMessage("AISS_WanderingMonsters: Group "+IntToString(i)+" resref: "+
GetLocalString(oArea,"sAISS_resref_group_"+IntToString(i)) + " size: " +
IntToString(GetLocalInt(oArea,"iAISS_size_group_"+IntToString(i))));
object oSpawn;
for(i=1;i<=iMobGroups;i++)
for(j=0;j<(bRandomize>0?Random(GetLocalInt(oArea,"iAISS_size_group_"+IntToString(i)))+1:GetLocalInt(oArea,"iAISS_size_group_"+IntToString(i)));j++)
{
oSpawn = CreateObject(OBJECT_TYPE_CREATURE,GetLocalString(oArea,"sAISS_resref_group_"+IntToString(i)),RandomLoc(oArea));
SetLocalInt(oSpawn,"bAISS_spawned_mob",1);
AssignCommand(oSpawn,ActionRandomWalk());
}
}
//sAISS_plac_resref_group_i
//iAISS_plac_size_group_i
void AISS_RandomPlaceables(object oArea = OBJECT_SELF)
{
int i = 1, j = 0;
int bRandomize = GetLocalInt(oArea,"bAISS_randomize");
while (GetLocalString(oArea,"sAISS_plac_resref_group_"+IntToString(i))!="")
i++;
int iPlacGroups = i-1;
DebugMessage("AISS_RandomPlaceables: found "+IntToString(iPlacGroups)+" placeables groups");
for(i=1;i<=iPlacGroups;i++)
DebugMessage("AISS_RandomPlaceables: Group "+IntToString(i)+" resref: "+
GetLocalString(oArea,"sAISS_plac_resref_group_"+IntToString(i)) + " size: " +
IntToString(GetLocalInt(oArea,"iAISS_plac_size_group_"+IntToString(i))));
object oPlac;
for(i=1;i<=iPlacGroups;i++)
for(j=0;j<(bRandomize>0?Random(GetLocalInt(oArea,"iAISS_plac_size_group_"+IntToString(i)))+1:GetLocalInt(oArea,"iAISS_plac_size_group_"+IntToString(i)));j++)
{
oPlac = CreateObject(OBJECT_TYPE_PLACEABLE,GetLocalString(oArea,"sAISS_plac_resref_group_"+IntToString(i)),RandomLoc(oArea));
SetLocalInt(oPlac,"bAISS_spawned_plac",1);
}
}
void AISS_FixedMonsters(object oArea = OBJECT_SELF)
{
int i = 1, j = 0;
int spawns = 0;
int iMobGroups;
int bRandomize=0;
//let's find area waypoints and populate them
object obj = GetObjectByTag("aiss_spawn_"+GetTag(oArea));
while (GetIsObjectValid(obj))
{
//iAISS_resref_group_i = i-th blueprint
//iAISS_size_group_i = i-th blueprint spawns
//find spawn composition
while (GetLocalString(obj,"sAISS_resref_group_"+IntToString(i))!="")
i++;
iMobGroups = i-1;
object oSpawn;
for(i=1;i<=iMobGroups;i++)
for(j=0;j<(bRandomize>0?Random(GetLocalInt(obj,"iAISS_size_group_"+IntToString(i)))+1:GetLocalInt(obj,"iAISS_size_group_"+IntToString(i)));j++)
{
oSpawn = CreateObject(OBJECT_TYPE_CREATURE,GetLocalString(obj,"sAISS_resref_group_"+IntToString(i)),GetLocation(obj));
SetLocalInt(oSpawn,"bAISS_spawned_mob",1);
AssignCommand(oSpawn,ActionRandomWalk());
}
//reset conunters
iMobGroups = 0;
i=1;
j=0;
obj = GetObjectByTag("aiss_spawn_"+GetTag(oArea),++spawns);
}
}
//iAISS_plac_resref_group_i = i-th blueprint
//iAISS_plac_size_group_i = i-th blueprint spawns
void AISS_FixedPlaceablesGroup(object oArea = OBJECT_SELF)
{
int i = 1, j = 0;
int plac = 0;
int iPlacGroups;
int bRandomize=0;
//let's find area waypoints and populate them
object obj = GetObjectByTag("aiss_plac_spawn_"+GetTag(oArea));
while (GetIsObjectValid(obj))
{
DebugMessage("AISS_FixedPlaceablesGroup: found placeable waypoint");
//find spawn composition
while (GetLocalString(obj,"sAISS_plac_resref_group_"+IntToString(i))!="")
i++;
iPlacGroups = i-1;
DebugMessage("AISS_RandomPlaceables: found "+IntToString(iPlacGroups)+" placeables in waypoint");
object oSpawn;
for(i=1;i<=iPlacGroups;i++)
for(j=0;j<(bRandomize>0?Random(GetLocalInt(obj,"iAISS_plac_size_group_"+IntToString(i)))+1:GetLocalInt(obj,"iAISS_plac_size_group_"+IntToString(i)));j++)
{
oSpawn = CreateObject(OBJECT_TYPE_PLACEABLE,GetLocalString(obj,"sAISS_plac_resref_group_"+IntToString(i)),GetLocation(obj));
SetLocalInt(oSpawn,"bAISS_spawned_plac",1);
}
//reset conunters
iPlacGroups = 0;
i=1;
j=0;
obj = GetObjectByTag("aiss_plac_spawn_"+GetTag(oArea),++plac);
}
}
//sAISS_trap_group_type_i: i-th trap type, and type is one of those specified by TranslateTraps
//sAISS_trap_group_level_i: i-th trap level, and level is one of those specified by TranslateTraps
//iAISS_trap_group_size_i: how many traps of i-th resref to place
//fAISS_trap_group_covered_area_i: how large is trap area of effect
//bAISS_trap_group_not_detectable_i: 1 if trap group is not detectable, default 0;
//iAISS_trap_group_detect_dc_i: if detectable, set detect DC, if 0 default trap DC will be used
//bAISS_trap_group_not_disarmable_i: 1 if trap group is not disarmable, default 0;
//bAISS_trap_group_disarm_dc_i: if disarmable, set disarm DC, if 0 default trap DC will be used
//sAISS_trap_group_keytag_i: if set, key with this tag will disarm i-th trap group
//bAISS_trap_group_not_recoverable_i: if set to 1, i-th group trap will not be recoverable
//sAISS_trap_group_disarm_i: script to be associated onDisarm to i-th trap group
//sAISS_trap_group_triggered_i: script to be associated onTrapTriggered to i-th trap group
void AISS_RandomPlacedTraps(object oArea = OBJECT_SELF)
{
int i = 1, j = 0;
int bRandomize = GetLocalInt(oArea,"bAISS_randomize");
while (GetLocalString(oArea,"sAISS_trap_group_type_"+IntToString(i))!="")
i++;
int iTrapGroups = i-1;
DebugMessage("AISS_RandomPlacedTraps: found "+IntToString(iTrapGroups)+" trap groups");
object oTrap;
int iTrapCostant;
for(i=1;i<=iTrapGroups;i++)
{
iTrapCostant = AISS_TranslateTraps(
GetLocalString(oArea,"sAISS_trap_group_type_"+IntToString(i)),
GetLocalString(oArea,"sAISS_trap_group_level_"+IntToString(i)));
for(j=0;j<(bRandomize>0?Random(GetLocalInt(oArea,"iAISS_trap_group_size_"+IntToString(i)))+1:GetLocalInt(oArea,"iAISS_trap_group_size_"+IntToString(i)));j++)
{
DebugMessage("AISS_RandomPlacedTraps: placing "+
GetLocalString(oArea,"sAISS_trap_group_type_"+IntToString(i))+" "+
GetLocalString(oArea,"sAISS_trap_group_level_"+IntToString(i))+"trap.");
oTrap = CreateTrapAtLocation(iTrapCostant,
RandomLoc(oArea), //where
IntToFloat(Random(5)+1), //physical_size
"ais_rp_trap"+IntToString(i), //tag
STANDARD_FACTION_HOSTILE, //faction
GetLocalString(oArea,"sAISS_trap_group_disarm_"+IntToString(i)),
GetLocalString(oArea,"sAISS_trap_group_triggered_"+IntToString(i)));
SetTrapActive(oTrap);
if(GetLocalInt(oArea,"bAISS_trap_group_not_detectable_"+IntToString(i))>0)
SetTrapDetectable(oTrap,FALSE);
if(GetTrapDetectable(oTrap)&&GetLocalInt(oArea,"iAISS_trap_group_detect_dc_"+IntToString(i))>0)
SetTrapDetectDC(oTrap,GetLocalInt(oArea,"iAISS_trap_group_detect_dc_"+IntToString(i)));
if(GetLocalInt(oArea,"bAISS_trap_group_not_disarmable_"+IntToString(i))>0)
SetTrapDisarmable(oTrap,FALSE);
if(GetTrapDisarmable(oTrap)&&GetLocalInt(oArea,"iAISS_trap_group_disarm_dc_"+IntToString(i))>0)
SetTrapDisarmDC(oTrap,GetLocalInt(oArea,"iAISS_trap_group_disarm_dc_"+IntToString(i)));
if(GetLocalString(oArea,"sAISS_trap_group_keytag_"+IntToString(i))!="")
SetTrapKeyTag(oTrap,GetLocalString(oArea,"sAISS_trap_group_keytag_"+IntToString(i)));
if(GetLocalInt(oArea,"bAISS_trap_group_not_recoverable_"+IntToString(i))>0)
SetTrapRecoverable(oTrap,FALSE);
SetLocalInt(oTrap,"bAISS_spawned_trap",1);
}
}
}
//sAISS_trap_type: i-th trap type, and type is one of those specified by TranslateTraps
//sAISS_trap_level: i-th trap level, and level is one of those specified by TranslateTraps
//fAISS_trap_covered_area: how large is trap area of effect, min 1.0
//bAISS_trap_not_detectable: 1 if trap is not detectable, default 0;
//iAISS_trap_detect_dc: if detectable, set detect DC, if 0 default trap DC will be used
//bAISS_trap_not_disarmable: 1 if trap is not disarmable, default 0;
//bAISS_trap_disarm_dc: if disarmable, set disarm DC, if 0 default trap DC will be used
//sAISS_trap_keytag: if set, key with this tag will disarm i-th trap
//bAISS_trap_not_recoverable: if set to 1, i-th group trap will not be recoverable
//sAISS_trap_disarm: script to be associated onDisarm to i-th trap
//sAISS_trap_triggered: script to be associated onTrapTriggered to i-th trap group
void AISS_FixedPlacedTraps(object oArea = OBJECT_SELF)
{
int i = 1;
int traps = 0;
int bRandomize=0;
//let's find area waypoints and populate them
object oTrap;
int iTrapCostant;
object obj = GetObjectByTag("aiss_trap_spawn_"+GetTag(oArea));
while (GetIsObjectValid(obj))
{
iTrapCostant = AISS_TranslateTraps(
GetLocalString(obj,"sAISS_trap_type"),
GetLocalString(obj,"sAISS_trap_level"));
oTrap = CreateTrapAtLocation(iTrapCostant,
GetLocation(obj), //where
GetLocalFloat(obj,"fAISS_trap_covered_area")>1.0?GetLocalFloat(obj,"fAISS_trap_covered_area"):1.0, //physical_size
"ais_fp_trap"+IntToString(traps), //tag
STANDARD_FACTION_HOSTILE, //faction
GetLocalString(oArea,"sAISS_trap_disarm_"+IntToString(i)),
GetLocalString(oArea,"sAISS_trap_triggered"));
SetTrapActive(oTrap);
if(GetLocalInt(obj,"bAISS_trap_not_detectable")>0)
SetTrapDetectable(oTrap,FALSE);
if(GetTrapDetectable(oTrap)&&GetLocalInt(obj,"iAISS_trap_detect_dc_"+IntToString(i))>0)
SetTrapDetectDC(oTrap,GetLocalInt(obj,"iAISS_trap_detect_dc_"+IntToString(i)));
if(GetLocalInt(obj,"bAISS_trap_not_disarmable_"+IntToString(i))>0)
SetTrapDisarmable(oTrap,FALSE);
if(GetTrapDisarmable(oTrap)&&GetLocalInt(obj,"iAISS_trap_disarm_dc")>0)
SetTrapDisarmDC(oTrap,GetLocalInt(obj,"iAISS_trap_disarm_dc"));
if(GetLocalString(obj,"sAISS_trap_keytag")!="")
SetTrapKeyTag(oTrap,GetLocalString(obj,"sAISS_trap_keytag"));
if(GetLocalInt(obj,"bAISS_trap_not_recoverable")>0)
SetTrapRecoverable(oTrap,FALSE);
SetLocalInt(oTrap,"bAISS_spawned_trap",1);
obj = GetObjectByTag("aiss_trap_spawn_"+GetTag(oArea),++traps);
}
}
void AISS_HandleAreaEvents(object oArea = OBJECT_SELF)
{
switch (GetUserDefinedEventNumber())
{
case AISS_WANDERING_MOB_EVENT:
AISS_WanderingMonsters(oArea);
break;
case AISS_FIXED_MOB_EVENT:
AISS_FixedMonsters(oArea);
break;
case AISS_RANDOM_PLACED_TRAPS:
AISS_RandomPlacedTraps(oArea);
break;
case AISS_FIXED_PLACED_TRAPS:
AISS_FixedPlacedTraps(oArea);
break;
case AISS_RANDOM_PLACEABLES_EVENT:
AISS_RandomPlaceables(oArea);
break;
case AISS_FIXED_PLACEABLES_EVENT:
AISS_FixedPlaceablesGroup(oArea);
break;
}
}
int AISSS_GetAreaCurrentPlayersNumber(object oArea)
{
return GetLocalInt(oArea,"iAISS_PCs_onarea");
}
void AISSS_ClearArea(object oArea = OBJECT_SELF)
{
//how to clean up everything ;-)
DebugMessage("AISSS_ClearArea launched!");
int i = 1, j = 0;
//no clean way to avoid, must cycle through all area objects
object oObj = GetFirstObjectInArea(oArea);
object oLootItem;
while (GetIsObjectValid(oObj))
{
if(GetLocalInt(oObj,"bAISS_spawned_mob") ||
GetLocalInt(oObj,"bAISS_spawned_trap") ||
GetLocalInt(oObj,"bAISS_spawned_plac"))
DestroyObject(oObj);
//NOTE: the loot tag should be different from creature tag!
else if(GetTag(oObj)== LOOT_TAG)
{
oLootItem = GetFirstItemInInventory(oObj);
while (GetIsObjectValid(oLootItem))
{
//safedestroy
DestroyObject(oLootItem);
oLootItem = GetNextItemInInventory();
}
//all inventory destroyed, destroy oLoot if required
if(DESTROY_LOOT_OBJECT)
DestroyObject(oObj);
}
//Here can be added nice things, like deleting items dropped on ground
//by PGs
oObj = GetNextObjectInArea(oArea);
}
SetLocalInt(OBJECT_SELF,"iAISS_area_inited",0);
DebugMessage("AISSS_ClearArea: area reset successfully!");
}
void AISSS_CheckClearArea(object oArea = OBJECT_SELF)
{
if(GetLocalInt(OBJECT_SELF,"iAISS_PCs_onarea")==0 && GetLocalInt(OBJECT_SELF,"bAISS_delayed_clean") && GetLocalInt(OBJECT_SELF,"iAISS_area_inited"))
AISSS_ClearArea();
}
void AISSS_OnAreaEnter(){
object oPC=GetEnteringObject();
if(GetIsPC(oPC)){
SetLocalInt(OBJECT_SELF,"iAISS_PCs_onarea",1 + GetLocalInt(OBJECT_SELF,"iAISS_PCs_onarea"));
SetLocalInt(OBJECT_SELF,"bAISS_delayed_clean",0);
if(GetLocalInt(OBJECT_SELF,"iAISS_PCs_onarea")==1 && GetLocalInt(OBJECT_SELF,"iAISS_area_inited")==0){
SetLocalInt(OBJECT_SELF,"iAISS_area_inited",1);
if(GetLocalInt(OBJECT_SELF,"iAISS_selectedEvent")>0)
{
int i=1;
for(i;i<=GetLocalInt(OBJECT_SELF,"iAISS_selectedEvent");i++)
SignalEvent(OBJECT_SELF, EventUserDefined(AISS_TranslateEvent(GetLocalString(OBJECT_SELF,"sAISS_selectedEvent_"+IntToString(i)))));
}
else if(AISS_ENABLE_RANDOM_AREA_EVENTS)
SignalEvent(OBJECT_SELF, EventUserDefined(AISS_GetRandomEvent()));
else
SignalEvent(OBJECT_SELF, EventUserDefined(AISS_WANDERING_MOB_EVENT));
}
}
}
void AISSS_OnAreaExit(){
object oPC=GetExitingObject();
if(GetIsPC(oPC)){
SetLocalInt(OBJECT_SELF,"iAISS_PCs_onarea",-1+GetLocalInt(OBJECT_SELF,"iAISS_PCs_onarea"));
}
if(GetLocalInt(OBJECT_SELF,"iAISS_PCs_onarea")==0)
{
if(!GetLocalInt(OBJECT_SELF,"bAISS_delayed_clean"))
{
SetLocalInt(OBJECT_SELF,"bAISS_delayed_clean",1);
DelayCommand(fAISS_DELAYED_CLEAN,AISSS_CheckClearArea());
}
}
}
//void main() {}