· 8 years ago · Dec 02, 2017, 11:28 PM
1#include "dw_psi_inc"
2#include "d1_cards_jinc"
3
4const string RETURN_WAYPOINT = "wp_dw_return";
5const int POLYMORPH_SLITHER = 152;
6const int N_TILE_SOURCE_LIGHT_BLACK_NO_REALLY = 255;
7
8const string DW_STAT_TREASURESFOUND = "DW_STAT_TREASURESFOUND";
9
10// custom talktable base
11const int DW_CUSTOM_TALK_TABLE_OFFSET = 0x1000000;
12
13// Add companion to party
14void AddNPCToParty(object oNPC);
15
16// Start a henchman conversation
17void ActionStartHenchmanConversation(object oNPC, string sDialog);
18
19// Turn on power for an area
20void ActionTurnOnPower(object oArea);
21
22
23// Changes PC to look like Conley
24void ChangeToConley(object oPC, int nArmored = FALSE);
25
26// Changes PC back from Conley
27void ChangeFromConley(object oPC);
28
29// do the alignment change when breaking a vow
30void DoBreakVow(object oPC, string sVow, int nAmount = 5, string sJournal = "", int nJournal = 0);
31
32// do the alignment change when keeping a vow
33void DoKeepVow(object oPC, string sVow, int nAmount = 5, string sJournal = "", int nJournal = 0);
34
35
36// Causes the creature to speak a string from the custom talk table associated
37// with the module. Note: use the nRef value as it appears in the custom talk
38// table (i.e. without the offset)
39// - nRef: string reference number
40// - nVolume: TALKVOLUME_* constant
41void DW_ActionSpeakStringByStrRef(int nRef, int nVolume = TALKVOLUME_TALK);
42
43// change alignment only once for sCause
44void DW_AdjustAlignment(object oNPC, int nAlignment, int nShift, string sCause);
45
46// adjust a stat
47int DW_ChangeStat(string sStat, int nAmount = 1);
48
49// get the numeric value of a character
50int DW_CharVal(string sString);
51
52// triggers cutscene using module-specific cutscene module
53// A waypoint is dropped at the current location as a return point.
54void DW_CutsceneTransitionAway(string sWaypoint);
55
56// return to the previous module
57void DW_CutsceneTransitionReturn();
58
59// Display floaty text above the specified creature.
60// The text will also appear in the chat buffer of each player that receives the
61// floaty text.
62// - nStrRefToDisplay: String ref (therefore text is translated)
63// - oCreatureToFloatAbove
64// - bBroadcastToFaction: If this is TRUE then only creatures in the same faction
65// as oCreatureToFloatAbove
66// will see the floaty text, and only if they are within range (30 metres).
67void DW_FloatingTextStrRefOnCreature(int nStrRefToDisplay, object oCreatureToFloatAbove, int bBroadcastToFaction=TRUE);
68
69// returns player object (First Person Only)
70object DW_GetPlayer();
71
72// get a particular stat
73int DW_GetStat(string sStat);
74
75// return if creature has item
76int DW_HasItem(object oCreature, string s);
77
78// see if PC is wanted in area
79int DW_IsWanted(string sRegion);
80
81// Changes the reputation of how a companion feels about the PC
82// sToken - a unique token to ensure that reputation cannot change multiple times
83void DW_ChangeReputation(object oNPC, int nAmount, string sToken, int nRomance = FALSE);
84
85// gets the act # of the module based on the module tag
86int DW_GetAct();
87
88// gets the bounty for a region
89int DW_GetBounty(string sRegion);
90
91// gets owner for effect - can later remove all effects by that owner
92// using DW_RemoveEffectByOwner
93object DW_GetEffectCreator(string sOwnerTag);
94
95// Get total number of items on person
96int DW_GetItemCount(object oNPC, string sTag);
97
98// return random ability
99int DW_GetRandomAbility();
100
101// gets the region of an area - used for crime scripts
102string DW_GetRegion(object oArea);
103
104// Checks to see how a companion feels about the PC
105int DW_GetReputation(object oNPC, int nRomance = FALSE);
106
107// makes everyone in area peaceful
108void DW_PacifyArea(object oArea);
109
110// Checks if any party member has item
111int DW_PartyHasItem(object oPC, string sItem);
112
113// removes stacked items from inventory
114void DW_RemoveStackedItem(object oPC, string sTag, int iAmount);
115
116// remove all companions
117void DW_RemoveAllCompanions();
118
119// remove effect by owner tag
120void DW_RemoveEffectByOwner(object oCreature, string sOwnerTag);
121
122// remove effect by type
123void DW_RemoveEffectByType(object oPC, int nEffectType);
124
125// Reward party & ensure it's a one-time reward
126void DW_RewardXP(int nXP, string sReward);
127
128// Speak the sound associated with a reference in the talk table
129// - nRef: string reference number
130void DW_PlaySoundByStrRef(int nRef);
131
132// Causes the creature to instantly speak a string from the custom talk table
133// associated with the module. Note: use the nRef value as it appears in the
134// custom talk table (i.e. without the offset)
135// - nRef: string reference number
136// - nVoice: if TRUE, play associated voice file
137// - nVolume: TALKVOLUME_* constant
138void DW_SpeakStringByStrRef(int nRef, int nVoice = FALSE, int nVolume=TALKVOLUME_TALK);
139
140// Send a server message (szMessage) to the oPlayer. Note: use the nRef value as
141// it appears in the custom talk table (i.e. without the offset)
142// - nRef: string reference number
143void DW_SendMessageToPCByStrRef(object oPC, int nStrRef);
144
145// Gets a string from the talk table
146string DW_GetStringByStrRef(int nRef, int nGender=GENDER_MALE);
147
148// Sets the bounty for a region
149void DW_SetBounty(string sRegion, int nAmount);
150
151// Show achievements for DW1
152void DW1_ShowAchievements(object oPC, string GUI_ACHIEVEMENTS);
153
154// Show achievements for DW2
155void DW2_ShowAchievements(object oPC, string GUI_ACHIEVEMENTS);
156
157// Show achievements for DW3
158void DW3_ShowAchievements(object oPC, string GUI_ACHIEVEMENTS);
159
160// See if player has vowed
161int GetHasVowed(object oPC, string sVow);
162
163// Determines if something is a weapon
164int GetIsMeleeWeapon(object oWeapon);
165
166// Removes all effects from target
167void DW_RemoveAllEffects(object oTarget);
168
169// Removes creature's helmet, mostly for cutscenes and such
170void RemoveGear(object oCreature);
171
172// Sends a debug message to the player
173void SendDebugMessage(string sMessage);
174
175// Makes creature transparent, mostly for cutscenes
176void SetTransparent(object oCreature);
177
178// Set a vow
179void SetVow(object oPC, string sVow, string sJournal = "", int nJournal = 0);
180
181// Remove helm, weapons, and shields
182void UnequipGear(object oNPC);
183
184void ActionStartHenchmanConversation(object oNPC, string sDialog)
185{
186 object oPC = DW_GetPlayer();
187 SetLocalString(oNPC, "Dialog", sDialog);
188
189 if(GetIsInCombat(oPC) || GetIsInCombat(oNPC))
190 return;
191 AssignCommand(oNPC, JumpToObject(oPC));
192 AssignCommand(oNPC, ActionStartConversation(oPC, sDialog, FALSE, FALSE));
193
194}
195
196// Turn on power for an area
197void ActionTurnOnPower(object oArea)
198{
199 SendMessageToPC(DW_GetPlayer(), "Turning on power for " + GetName(oArea));
200
201 // indicate power is on for area (used for door controls)
202 SetLocalInt(oArea, "power", 1);
203
204
205 // turn on electric lights
206 int nNth;
207 object oLight = GetObjectByTag("ElectricLight");
208 while(oLight != OBJECT_INVALID)
209 {
210 SendDebugMessage("Found " + GetTag(oLight) + " at " + GetTag(oArea));
211 if(GetArea(oLight) == oArea)
212 {
213 object oNewLight = CreateObject(OBJECT_TYPE_PLACEABLE, "dw1_litlight", GetLocation(oLight));
214 vector vLight = GetPosition(oLight);
215 vLight = Vector(vLight.x, vLight.y, 1.5);
216 location lLight = Location(oArea, vLight, GetFacing(oLight));
217 object oLightObject = CreateObject(OBJECT_TYPE_LIGHT, "lt_dw_electric", lLight);
218 SendDebugMessage("Created " + GetTag(oNewLight) + " with light object " + GetTag(oLightObject));
219 DestroyObject(oLight);
220 }
221 oLight = GetObjectByTag("ElectricLight", nNth++);
222 }
223}
224
225void AddNPCToParty(object oNPC)
226{
227 AssignCommand(oNPC, SetAssociateListenPatterns());
228 SetLocalInt(oNPC,"NW_COM_MODE_COMBAT",ASSOCIATE_COMMAND_ATTACKNEAREST);
229 SetLocalInt(oNPC,"NW_COM_MODE_MOVEMENT",ASSOCIATE_COMMAND_FOLLOWMASTER);
230
231
232 object oPC = DW_GetPlayer();
233
234 string sTag = GetTag(oNPC);
235 AddRosterMemberByCharacter(sTag, oNPC);
236 AddRosterMemberToParty(sTag, oPC);
237
238 // For main companions, always give them the player's XP
239 if((sTag == "Heather") || (sTag == "Daniel"))
240 {
241 SetXP(oNPC, GetXP(oPC));
242 }
243}
244
245void ChangeToConley(object oPC, int nArmored = FALSE)
246{
247 if(nArmored)
248 {
249 ApplyEffectToObject(DURATION_TYPE_PERMANENT, EffectPolymorph(151, TRUE), oPC);
250 }else{
251 ApplyEffectToObject(DURATION_TYPE_PERMANENT, EffectPolymorph(150, TRUE), oPC);
252 }
253}
254
255void ChangeFromConley(object oPC)
256{
257 DW_RemoveAllEffects(oPC);
258}
259
260void DoBreakVow(object oPC, string sVow, int nAmount = 5, string sJournal = "", int nJournal = 0)
261{
262 if(!GetHasVowed(oPC, sVow))
263 return;
264
265 if(GetLocalInt(oPC, sVow) == 2)
266 return;
267
268 // can only break vow once
269 SetLocalInt(oPC, sVow, 2);
270
271 AdjustAlignment(oPC, ALIGNMENT_CHAOTIC, nAmount);
272
273 string sMessage = DW_GetStringByStrRef(154, GetGender(oPC));
274 FloatingTextStringOnCreature(sMessage, oPC, TRUE);
275
276 if(GetStringLength(sJournal) > 0)
277 {
278 AddJournalQuestEntry(sJournal, nJournal, oPC);
279 }
280}
281
282
283void DoKeepVow(object oPC, string sVow, int nAmount = 5, string sJournal = "", int nJournal = 0)
284{
285 if(!GetHasVowed(oPC, sVow))
286 return;
287
288 AdjustAlignment(oPC, ALIGNMENT_LAWFUL, nAmount);
289
290 string sMessage = DW_GetStringByStrRef(153, GetGender(oPC));
291 FloatingTextStringOnCreature(sMessage, oPC, TRUE);
292
293 if(GetStringLength(sJournal) > 0)
294 {
295 AddJournalQuestEntry(sJournal, nJournal, oPC);
296 }
297
298}
299
300int DW_HasItem(object oCreature, string s)
301{
302 return GetIsObjectValid(GetItemPossessedBy(oCreature, s));
303}
304
305int DW_IsWanted(string sRegion)
306{
307 if(DW_GetBounty(sRegion) > 0)
308 return TRUE;
309
310 if(GetGlobalInt(sRegion + "_Murder") > 0)
311 return TRUE;
312
313 return FALSE;
314}
315
316void DW_ChangeReputation(object oNPC, int nAmount, string sToken, int nRomance = FALSE)
317{
318 object oPC = DW_GetPlayer();
319 // get either the normal or romance reputation
320 string sReputation = "DW_Reputation";
321 if(nRomance)
322 sReputation = "DW_Reputation_Romance";
323 // add the tag of the NPC
324 sReputation = sReputation + GetTag(oNPC);
325
326 // check if sToken has already been set. If so, don't allow change.
327 if(GetStringLength(sToken) > 0)
328 {
329 string sFlag = "REP_" + sToken + "_SET";
330 if(GetLocalInt(oNPC, sFlag) > 0)
331 return;
332 SetLocalInt(oNPC, sFlag, 1);
333 }
334
335 int nReputation = GetLocalInt(oNPC, sReputation);
336 nReputation = nReputation + nAmount;
337 SetLocalInt(oNPC, sReputation, nReputation);
338 SetGlobalInt(sReputation, nReputation);
339 if(nRomance) {
340 SendDebugMessage("Changing romance reputation on " + GetName(oNPC) + " by " + IntToString(nAmount) + ". Now set to " + IntToString(nReputation) + ".");
341 SendMessageToPC(oPC, "Romance increased.");
342 }else{
343 SendDebugMessage("Changing normal reputation on " + GetName(oNPC) + " by " + IntToString(nAmount) + ". Now set to " + IntToString(nReputation) + ".");
344 SendMessageToPC(oPC, "Influence increased.");
345 }
346}
347
348int DW_ChangeStat(string sStat, int nAmount = 1)
349{
350 int nStat = GetGlobalInt(sStat);
351 nStat = nStat + nAmount;
352 SetGlobalInt(sStat, nStat);
353 return nStat;
354}
355
356
357int DW_CharVal(string sString)
358{
359 sString = GetStringLowerCase(sString);
360 return FindSubString("abcdefghijklmnopqrstuvwxyz", sString);
361}
362
363object DW_GetPlayer()
364{
365 return GetFirstPC(TRUE);
366}
367
368int DW_GetBounty(string sRegion)
369{
370 return GetGlobalInt(sRegion + "_Bounty");
371}
372
373
374int DW_GetStat(string sStat)
375{
376 int nStat = GetGlobalInt(sStat);
377 return nStat;
378}
379
380string DW_GetStringByStrRef(int nRef, int nGender=GENDER_MALE)
381{
382 nRef += DW_CUSTOM_TALK_TABLE_OFFSET;
383// return GetStringByStrRef(nRef, nGender);
384// Gender male only for now
385 return GetStringByStrRef(nRef);
386}
387
388
389object DW_GetEffectCreator(string sOwnerTag)
390{
391 object oCreator = GetObjectByTag(sOwnerTag);
392 if(oCreator == OBJECT_INVALID)
393 {
394 oCreator = CreateObject(OBJECT_TYPE_PLACEABLE, "plc_invisobj", GetLocation(OBJECT_SELF), FALSE, sOwnerTag);
395 if(oCreator == OBJECT_INVALID)
396 SendDebugMessage("Unable to create creator object with tag: " + sOwnerTag);
397 SendDebugMessage("Created new creator object with tag: " + GetTag(oCreator));
398 }
399 return oCreator;
400}
401
402int DW_GetItemCount(object oNPC, string sTag)
403{
404 object oItem = GetFirstItemInInventory (oNPC);
405 int nTotal = 0;
406 while (oItem != OBJECT_INVALID)
407 {
408 string sItem = GetTag(oItem);
409 if (sItem == sTag)
410 nTotal = nTotal + GetItemStackSize(oItem);
411 oItem = GetNextItemInInventory (oNPC);
412 }
413 return nTotal;
414}
415
416int DW_GetRandomAbility()
417{
418 switch (d6())
419 {
420 case 1:
421 return ABILITY_CHARISMA;
422 case 2:
423 return ABILITY_CONSTITUTION;
424 case 3:
425 return ABILITY_DEXTERITY;
426 case 4:
427 return ABILITY_INTELLIGENCE;
428 case 5:
429 return ABILITY_STRENGTH;
430 case 6:
431 return ABILITY_WISDOM;
432 }
433 return 0;
434}
435
436string DW_GetRegion(object oArea)
437{
438 string sRegion = GetLocalString(OBJECT_SELF, "Region");
439 // set region for area if not already set
440 if(sRegion == "")
441 {
442 string sArea = GetName(oArea);
443 int nDash = FindSubString(sArea, "-");
444 if(nDash > 1)
445 sArea = GetStringLeft(sArea, nDash - 1);
446
447 sRegion = sArea;
448 SetLocalString(oArea, "Region", sRegion);
449 }
450 return sRegion;
451}
452
453
454void DW_PacifyArea(object oArea)
455{
456 object oPC = GetFirstPC();
457 object oObject = GetFirstObjectInArea(oArea);
458 while(oObject != OBJECT_INVALID)
459 {
460 if(GetObjectType(oObject) == OBJECT_TYPE_CREATURE)
461 {
462 ClearPersonalReputation(oPC, oObject);
463 AssignCommand(oObject, ClearAllActions(TRUE));
464 }
465 oObject = GetNextObjectInArea(oArea);
466 }
467 SetStandardFactionReputation(STANDARD_FACTION_COMMONER, 80, oPC);
468 SetStandardFactionReputation(STANDARD_FACTION_MERCHANT, 80, oPC);
469 SetStandardFactionReputation(STANDARD_FACTION_DEFENDER, 80, oPC);
470}
471
472int DW_GetReputation(object oNPC, int nRomance = FALSE)
473{
474 string sReputation = "DW_Reputation";
475 if(nRomance)
476 sReputation = "DW_Reputation_Romance";
477
478 sReputation = sReputation + GetTag(oNPC);
479
480 int nReputation = GetLocalInt(oNPC, sReputation);
481 if(nRomance) {
482 SendDebugMessage("Checking romance reputation on " + GetName(oNPC) + ". Now set to " + IntToString(nReputation) + ".");
483 }else{
484 SendDebugMessage("Checking normal reputation on " + GetName(oNPC) + ". Now set to " + IntToString(nReputation) + ".");
485 }
486 return nReputation;
487}
488
489void DW_ActionSpeakStringByStrRef(int nRef, int nVolume=TALKVOLUME_TALK)
490{
491 // add the custom talk table offset to correct the base StrRef
492 nRef += DW_CUSTOM_TALK_TABLE_OFFSET;
493 ActionSpeakStringByStrRef(nRef, nVolume);
494}
495
496void DW_AdjustAlignment(object oNPC, int nAlignment, int nShift, string sCause)
497{
498 if(GetLocalInt(GetModule(), sCause) == 1)
499 return;
500 AdjustAlignment(oNPC, nAlignment, nShift);
501
502 SetLocalInt(GetModule(), sCause, 1);
503}
504
505void DW_CutsceneTransitionAway(string sWaypoint)
506{
507 string sAct = IntToString(DW_GetAct());
508 string sModule = "dw" + sAct + "cutscene";
509 // get rid of existing waypoint
510 DestroyObject(GetObjectByTag(RETURN_WAYPOINT));
511 object oPC = DW_GetPlayer();
512
513 object oWaypoint = CreateObject(OBJECT_TYPE_WAYPOINT, RETURN_WAYPOINT, GetLocation(oPC));
514 SetGlobalString("ReturnModule", GetTag(GetModule()));
515
516 DelayCommand(1.0, LoadNewModule(sModule, sWaypoint));
517}
518
519void DW_CutsceneTransitionReturn()
520{
521 string sModule = GetGlobalString("ReturnModule");
522 DelayCommand(1.0, LoadNewModule(sModule, RETURN_WAYPOINT));
523}
524
525void DW_FloatingTextStrRefOnCreature(int nStrRefToDisplay, object oCreatureToFloatAbove, int bBroadcastToFaction=TRUE)
526{
527 // add the custom talk table offset to correct the base StrRef
528 nStrRefToDisplay += DW_CUSTOM_TALK_TABLE_OFFSET;
529 FloatingTextStrRefOnCreature(nStrRefToDisplay, oCreatureToFloatAbove, bBroadcastToFaction);
530}
531
532int DW_PartyHasItem(object oPC, string sItem)
533{
534 if(GetIsObjectValid(GetItemPossessedBy(oPC, sItem)) == TRUE)
535 return TRUE;
536
537 int nNth = 1;
538 object oHenchman = GetHenchman(oPC, nNth);
539 while(oHenchman != OBJECT_INVALID)
540 {
541 if(GetIsObjectValid(GetItemPossessedBy(oHenchman, sItem)) == TRUE)
542 return TRUE;
543 nNth++;
544 oHenchman = GetHenchman(oPC, nNth);
545 }
546
547 return FALSE;
548}
549
550
551void DW_RemoveEffectByOwner(object oCreature, string sOwnerTag)
552{
553 object oCreator = GetObjectByTag(sOwnerTag);
554 SendDebugMessage("Removing effects on " + GetName(oCreature) + " created by " + GetTag(oCreator));
555 effect eEffect = GetFirstEffect(oCreature);
556 while(GetIsEffectValid(eEffect))
557 {
558 object oEffectCreator = GetEffectCreator(eEffect);
559 SendDebugMessage("Found effect " + IntToString(GetEffectType(eEffect)) + " that was created by " + GetTag(oEffectCreator) + " with name " + GetName(oEffectCreator));
560 if(GetIsObjectValid(oEffectCreator) == FALSE)
561 SendDebugMessage("Effect created by invalid object.");
562
563 if(oEffectCreator == oCreator)
564 {
565 SendDebugMessage("Removing effect " + IntToString(GetEffectType(eEffect)) + " from " + GetName(oCreature));
566 RemoveEffect(oCreature, eEffect);
567 }
568
569 eEffect = GetNextEffect(oCreature);
570 }
571}
572
573void DW_RemoveStackedItem(object oPC, string sTag, int iAmount)
574{
575 object oItem = GetFirstItemInInventory(oPC);
576 int nToRemove = iAmount;
577 SendDebugMessage("Removing " + IntToString(iAmount));
578 while(!(oItem == OBJECT_INVALID))
579 {
580 if(GetTag(oItem) == sTag)
581 {
582 if(GetNumStackedItems(oItem) > nToRemove)
583 {
584 SetItemStackSize(oItem, GetNumStackedItems(oItem) - nToRemove);
585 SendDebugMessage("Removed " + IntToString(GetNumStackedItems(oItem)) + " " + IntToString(nToRemove) + " remaining.");
586 return;
587 }else{
588 nToRemove = nToRemove - GetNumStackedItems(oItem);
589 SendDebugMessage("Destroyed stack of " + IntToString(GetNumStackedItems(oItem)) + " " + IntToString(nToRemove) + " remaining.");
590 DestroyObject(oItem, 0.1f);
591 }
592 }
593 oItem = GetNextItemInInventory(oPC);
594 }
595}
596
597
598
599void DW_RemoveAllCompanions()
600{
601 object oPC = DW_GetPlayer();
602
603 string sRoster = GetFirstRosterMember();
604 while(sRoster != "")
605 {
606 RemoveRosterMemberFromParty(sRoster, oPC, FALSE);
607 RemoveRosterMember(sRoster);
608 sRoster = GetNextRosterMember();
609 }
610}
611
612void DW_RemoveEffectByType(object oPC, int nEffectType)
613{
614 effect eEffect = GetFirstEffect(oPC);
615 while(GetIsEffectValid(eEffect))
616 {
617 int nType = GetEffectType(eEffect);
618 //HS_Debug("Found effect " + IntToString(GetEffectType(eEffect)) + " from " + GetName(oPC));
619 if(nEffectType == nType)
620 {
621 //HS_Debug("Removing effect " + IntToString(GetEffectType(eEffect)) + " from " + GetName(oPC));
622 RemoveEffect(oPC, eEffect);
623 }
624 eEffect = GetNextEffect(oPC);
625 }
626}
627
628void DW_RewardXP(int nXP, string sReward)
629{
630 if(GetLocalInt(GetModule(), sReward) != 1)
631 {
632 SetLocalInt(GetModule(), sReward, 1);
633 GiveXPToCreature(DW_GetPlayer(), nXP);
634 }
635}
636
637void DW_PlaySoundByStrRef(int nRef)
638{
639 // add the custom talk table offset to correct the base StrRef
640 nRef += DW_CUSTOM_TALK_TABLE_OFFSET;
641 PlaySoundByStrRef(nRef, FALSE);
642}
643
644void DW_SpeakStringByStrRef(int nRef, int nVoice = FALSE, int nVolume=TALKVOLUME_TALK)
645{
646 // add the custom talk table offset to correct the base StrRef
647 nRef += DW_CUSTOM_TALK_TABLE_OFFSET;
648 SpeakStringByStrRef(nRef, nVolume);
649 // play voice along with it
650 if(nVoice)
651 PlaySoundByStrRef(nRef, FALSE);
652}
653
654
655void DW_SendMessageToPCByStrRef(object oPC, int nRef)
656{
657 // add the custom talk table offset to correct the base StrRef
658 nRef += DW_CUSTOM_TALK_TABLE_OFFSET;
659 SendMessageToPCByStrRef(oPC, nRef);
660}
661
662
663void DW_SetBounty(string sRegion, int nAmount)
664{
665 SetGlobalInt(sRegion + "_Bounty", nAmount);
666}
667
668
669int GetHasVowed(object oPC, string sVow)
670{
671 if(GetLocalInt(oPC, sVow) > 0)
672 return TRUE;
673 return FALSE;
674}
675
676int GetIsMeleeWeapon(object oWeapon)
677{
678
679 int nType = GetBaseItemType(oWeapon);
680
681 if (nType == BASE_ITEM_BASTARDSWORD
682 || nType == BASE_ITEM_BATTLEAXE
683 || nType == BASE_ITEM_CLUB
684 || nType == BASE_ITEM_DAGGER
685 || nType == BASE_ITEM_DIREMACE
686 || nType == BASE_ITEM_DOUBLEAXE
687 || nType == BASE_ITEM_GREATAXE
688 || nType == BASE_ITEM_GREATSWORD
689 || nType == BASE_ITEM_HALBERD
690 || nType == BASE_ITEM_HANDAXE
691 || nType == BASE_ITEM_HEAVYFLAIL
692 || nType == BASE_ITEM_KAMA
693 || nType == BASE_ITEM_KATANA
694 || nType == BASE_ITEM_KUKRI
695 || nType == BASE_ITEM_LIGHTFLAIL
696 || nType == BASE_ITEM_LIGHTHAMMER
697 || nType == BASE_ITEM_LIGHTMACE
698 || nType == BASE_ITEM_LONGSWORD
699 || nType == BASE_ITEM_MORNINGSTAR
700 || nType == BASE_ITEM_QUARTERSTAFF
701 || nType == BASE_ITEM_RAPIER
702 || nType == BASE_ITEM_SCIMITAR
703 || nType == BASE_ITEM_SCYTHE
704 || nType == BASE_ITEM_SHORTSPEAR
705 || nType == BASE_ITEM_SHORTSWORD
706 || nType == BASE_ITEM_SICKLE
707 || nType == BASE_ITEM_TWOBLADEDSWORD
708 || nType == BASE_ITEM_WARHAMMER
709 || nType == BASE_ITEM_FALCHION
710 || nType == BASE_ITEM_DWARVENWARAXE
711 || nType == BASE_ITEM_WHIP)
712 {
713 return TRUE;
714 }
715 return FALSE;
716}
717
718void DW_RemoveAllEffects(object oTarget)
719{
720 effect eEffect = GetFirstEffect(oTarget);
721
722 while(GetIsEffectValid(eEffect))
723 {
724 RemoveEffect(oTarget, eEffect);
725 eEffect = GetNextEffect(oTarget);
726 }
727}
728
729
730void DW1_ShowAchievements(object oPC, string GUI_ACHIEVEMENTS)
731{
732 int nDW1TimesDied = GetGlobalInt("DW1TimesDied");
733 int nDW1PuzzlesSolved = GetGlobalInt("PuzzlesSolved");
734 int nFocusGemsAcquired = GetGlobalInt("DWGemsAcquired");
735 int nSetItemsAcquired = GetGlobalInt("DWSetAcquired");
736 int nDW1PastWar = GetGlobalInt("DW1PastWar");
737 int nDW1GoalsMade = GetGlobalInt("GoalsMade");
738 int nPlayerKills = GetGlobalInt("PlayerKills");
739 int nDanielKills = GetGlobalInt("DanielKills");
740 int nHeatherKills = GetGlobalInt("HeatherKills");
741 int nDanielReputation = GetGlobalInt("DW_ReputationDaniel");
742 int nHeatherReputation = GetGlobalInt("DW_ReputationHeather");
743 int nSlitherSlayer = GetGlobalInt("SlitherSlayer");
744
745
746
747 SetGUIObjectText(oPC, GUI_ACHIEVEMENTS,"statDW1_1", -1, IntToString(nDW1TimesDied));
748 SetGUIObjectText(oPC, GUI_ACHIEVEMENTS,"statDW1_2", -1, IntToString(nDW1PuzzlesSolved) + " / 2");
749 SetGUIObjectText(oPC, GUI_ACHIEVEMENTS,"statDW1_3", -1, IntToString(nFocusGemsAcquired));
750 SetGUIObjectText(oPC, GUI_ACHIEVEMENTS,"statDW1_4", -1, IntToString(nSetItemsAcquired));
751 SetGUIObjectText(oPC, GUI_ACHIEVEMENTS,"statDW1_5", -1, IntToString(nDW1PastWar) + " / 1");
752 SetGUIObjectText(oPC, GUI_ACHIEVEMENTS,"statDW1_6", -1, IntToString(nDW1GoalsMade));
753 SetGUIObjectText(oPC, GUI_ACHIEVEMENTS,"statDW1_7", -1, IntToString(nHeatherReputation));
754 SetGUIObjectText(oPC, GUI_ACHIEVEMENTS,"statDW1_8", -1, IntToString(nDanielReputation));
755 SetGUIObjectText(oPC, GUI_ACHIEVEMENTS,"statDW1_9", -1, IntToString(nPlayerKills));
756 SetGUIObjectText(oPC, GUI_ACHIEVEMENTS,"statDW1_10", -1, IntToString(nDanielKills));
757 SetGUIObjectText(oPC, GUI_ACHIEVEMENTS,"statDW1_11", -1, IntToString(nHeatherKills));
758 SetGUIObjectText(oPC, GUI_ACHIEVEMENTS,"statDW1_12", -1, IntToString(nSlitherSlayer));
759
760
761 if( nSlitherSlayer >= 40 )
762 {
763 SetGUIObjectText(oPC, GUI_ACHIEVEMENTS,"achievementHerpetophobiaText", -1, "Herpetophobia");
764 SetGUIObjectDisabled(oPC, GUI_ACHIEVEMENTS, "achievementHerpetophobia", FALSE);
765 }else{
766 SetGUIObjectText(oPC, GUI_ACHIEVEMENTS,"achievementHerpetophobiaText", -1, "Kill 40 Slithers");
767 SetGUIObjectDisabled(oPC, GUI_ACHIEVEMENTS, "achievementHerpetophobia", TRUE);
768 }
769
770 if(GetGlobalInt("DW1Champion") == 1)
771 {
772 SetGUIObjectText(oPC, GUI_ACHIEVEMENTS,"achievementChampionText", -1, "Champion");
773 SetGUIObjectDisabled(oPC, GUI_ACHIEVEMENTS, "achievementChampion", FALSE);
774 }else{
775 SetGUIObjectText(oPC, GUI_ACHIEVEMENTS,"achievementChampionText", -1, "Win the Contest with Daniel");
776 SetGUIObjectDisabled(oPC, GUI_ACHIEVEMENTS, "achievementChampion", TRUE);
777 }
778
779 if(GetGlobalInt("MagiSlayer") == 1)
780 {
781 SetGUIObjectText(oPC, GUI_ACHIEVEMENTS,"achievementMagiText", -1, "Magi Slayer");
782 SetGUIObjectDisabled(oPC, GUI_ACHIEVEMENTS, "achievementMagi", FALSE);
783 }else{
784 SetGUIObjectText(oPC, GUI_ACHIEVEMENTS,"achievementMagiText", -1, "Kill an Ogre Magi");
785 SetGUIObjectDisabled(oPC, GUI_ACHIEVEMENTS, "achievementMagi", TRUE);
786 }
787
788 if( nDW1PuzzlesSolved >= 2 )
789 {
790 SetGUIObjectText(oPC, GUI_ACHIEVEMENTS,"achievementPuzzleMasterText", -1, "Puzzle Master");
791 SetGUIObjectDisabled(oPC, GUI_ACHIEVEMENTS, "achievementPuzzleMaster", FALSE);
792 }else{
793 SetGUIObjectText(oPC, GUI_ACHIEVEMENTS,"achievementPuzzleMasterText", -1, "Solve Puzzles Solo");
794 SetGUIObjectDisabled(oPC, GUI_ACHIEVEMENTS, "achievementPuzzleMaster", TRUE);
795 }
796
797 if( nFocusGemsAcquired >= 7 )
798 {
799 SetGUIObjectText(oPC, GUI_ACHIEVEMENTS,"achievementGemSeekerText", -1, "Gem Seeker");
800 SetGUIObjectDisabled(oPC, GUI_ACHIEVEMENTS, "achievementGemSeeker", FALSE);
801 }else{
802 SetGUIObjectText(oPC, GUI_ACHIEVEMENTS,"achievementGemSeekerText", -1, "Find 7 Focus Gems");
803 SetGUIObjectDisabled(oPC, GUI_ACHIEVEMENTS, "achievementGemSeeker", TRUE);
804 }
805
806 if( nDW1GoalsMade >= 5 )
807 {
808 SetGUIObjectText(oPC, GUI_ACHIEVEMENTS,"achievementGoalsText", -1, "Fanatic");
809 SetGUIObjectDisabled(oPC, GUI_ACHIEVEMENTS, "achievementGoals", FALSE);
810 }else{
811 SetGUIObjectText(oPC, GUI_ACHIEVEMENTS,"achievementGoalsText", -1, "Make 5 Goals");
812 SetGUIObjectDisabled(oPC, GUI_ACHIEVEMENTS, "achievementGoals", TRUE);
813 }
814}
815
816// Show achievements for DW2
817void DW2_ShowAchievements(object oPC, string GUI_ACHIEVEMENTS)
818{
819 int nDW2TimesDied = GetGlobalInt("TimesDiedDW2");
820 int nKeysFound = GetGlobalInt("DWKeysFound");
821 int nTreasuresFound = DW_GetStat(DW_STAT_TREASURESFOUND);
822 int nPsiUsed = GetGlobalInt("DWPsiUsed");
823 int nFocusMax = DW_GetFocusMax(oPC);
824 int nPirateCardScore = GetPlayerRating(oPC);
825 SendDebugMessage("Pirate Card Rating:" + IntToString(nPirateCardScore));
826 int nRating = GetPlayerRating(oPC);
827
828
829 int nHeatherFriendship = GetGlobalInt("DW_ReputationHeather");
830 int nHeatherRomance = GetGlobalInt("DW_Reputation_RomanceHeather");
831 int nDanielFriendship = GetGlobalInt("DW_ReputationDaniel");
832 int nDanielRomance = GetGlobalInt("DW_Reputation_RomanceDaniel");
833 int nHeatherOutsideRomance = GetGlobalInt("DW_HeatherRomance");
834 int nDanielOutsideRomance = GetGlobalInt("DW_DanielRomance");
835
836 int nSetItemsAcquired = GetGlobalInt("DWSetAcquired");
837
838
839 SetGUIObjectText(oPC, GUI_ACHIEVEMENTS,"statDW2_1", -1, IntToString(nDW2TimesDied));
840 SetGUIObjectText(oPC, GUI_ACHIEVEMENTS,"statDW2_2", -1, IntToString(nKeysFound));
841 SetGUIObjectText(oPC, GUI_ACHIEVEMENTS,"statDW2_3", -1, IntToString(nTreasuresFound));
842 SetGUIObjectText(oPC, GUI_ACHIEVEMENTS,"statDW2_4", -1, IntToString(nPsiUsed));
843 SetGUIObjectText(oPC, GUI_ACHIEVEMENTS,"statDW2_5", -1, IntToString(nFocusMax));
844 SetGUIObjectText(oPC, GUI_ACHIEVEMENTS,"statDW2_6", -1, IntToString(nPirateCardScore));
845 SetGUIObjectText(oPC, GUI_ACHIEVEMENTS,"statDW2_7", -1, IntToString(nHeatherFriendship));
846 SetGUIObjectText(oPC, GUI_ACHIEVEMENTS,"statDW2_8", -1, IntToString(nHeatherRomance));
847 SetGUIObjectText(oPC, GUI_ACHIEVEMENTS,"statDW2_9", -1, IntToString(nDanielFriendship));
848 SetGUIObjectText(oPC, GUI_ACHIEVEMENTS,"statDW2_10", -1, IntToString(nDanielRomance));
849 SetGUIObjectText(oPC, GUI_ACHIEVEMENTS,"statDW2_11", -1, IntToString(nDanielOutsideRomance));
850 SetGUIObjectText(oPC, GUI_ACHIEVEMENTS,"statDW2_12", -1, IntToString(nHeatherOutsideRomance));
851
852
853
854 if(( nHeatherRomance >= 3 ) ||
855 ( nDanielRomance >= 3 ))
856 {
857 SetGUIObjectText(oPC, GUI_ACHIEVEMENTS,"achievementLoveBoatText", -1, "Love Boat");
858 SetGUIObjectDisabled(oPC, GUI_ACHIEVEMENTS, "achievementLoveBoat", FALSE);
859 }else{
860 SetGUIObjectText(oPC, GUI_ACHIEVEMENTS,"achievementLoveBoatText", -1, "Get 3 Romance with Heather or Daniel");
861 SetGUIObjectDisabled(oPC, GUI_ACHIEVEMENTS, "achievementLoveBoat", TRUE);
862 }
863
864 if(( nHeatherOutsideRomance >= 3 ) ||
865 ( nDanielOutsideRomance >= 3 ))
866 {
867 SetGUIObjectText(oPC, GUI_ACHIEVEMENTS,"achievementMatchMakerText", -1, "Matchmaker");
868 SetGUIObjectDisabled(oPC, GUI_ACHIEVEMENTS, "achievementMatchMaker", FALSE);
869 }else{
870 SetGUIObjectText(oPC, GUI_ACHIEVEMENTS,"achievementMatchMakerText", -1, "Get 3 Outside Romance for Heather or Daniel");
871 SetGUIObjectDisabled(oPC, GUI_ACHIEVEMENTS, "achievementMatchMaker", TRUE);
872 }
873
874 if( nSetItemsAcquired >= 10 )
875 {
876 SetGUIObjectText(oPC, GUI_ACHIEVEMENTS,"achievementPackRatText", -1, "Pack Rat");
877 SetGUIObjectDisabled(oPC, GUI_ACHIEVEMENTS, "achievementPackRat", FALSE);
878 }else{
879 SetGUIObjectText(oPC, GUI_ACHIEVEMENTS,"achievementPackRatText", -1, "Acquire 10 Set Items");
880 SetGUIObjectDisabled(oPC, GUI_ACHIEVEMENTS, "achievementPackRat", TRUE);
881 }
882
883 if( nPirateCardScore >= 50 )
884 {
885 SetGUIObjectText(oPC, GUI_ACHIEVEMENTS,"achievementCardSharkText", -1, "Card Shark");
886 SetGUIObjectDisabled(oPC, GUI_ACHIEVEMENTS, "achievementCardShark", FALSE);
887 }else{
888 SetGUIObjectText(oPC, GUI_ACHIEVEMENTS,"achievementCardSharkText", -1, "Get 50 Points in Pirate Cards");
889 SetGUIObjectDisabled(oPC, GUI_ACHIEVEMENTS, "achievementCardShark", TRUE);
890 }
891
892 if(GetGlobalInt("DWHatTrick") == 1)
893 {
894 SetGUIObjectText(oPC, GUI_ACHIEVEMENTS,"achievementHatTrickText", -1, "Hat Trick");
895 SetGUIObjectDisabled(oPC, GUI_ACHIEVEMENTS, "achievementHatTrick", FALSE);
896 }else{
897 SetGUIObjectText(oPC, GUI_ACHIEVEMENTS,"achievementHatTrickText", -1, "Kill the Mad Hatter");
898 SetGUIObjectDisabled(oPC, GUI_ACHIEVEMENTS, "achievementHatTrick", TRUE);
899 }
900
901 if(nTreasuresFound >= 10)
902 {
903 SetGUIObjectText(oPC, GUI_ACHIEVEMENTS,"achievementTreasureHunterText", -1, "Treasure Hunter");
904 SetGUIObjectDisabled(oPC, GUI_ACHIEVEMENTS, "achievementTreasureHunter", FALSE);
905 }else{
906 SetGUIObjectText(oPC, GUI_ACHIEVEMENTS,"achievementTreasureHunterText", -1, "Dig Up 10 Treasures");
907 SetGUIObjectDisabled(oPC, GUI_ACHIEVEMENTS, "achievementTreasureHunter", TRUE);
908 }
909
910
911 // show psionic powers
912 SetLocalGUIVariable(oPC, GUI_ACHIEVEMENTS, 21, "Spend gems to raise skill");
913 int nSkill;
914 nSkill = DW_GetPsionicSkill(oPC, DW_SKILL_TELEPATHY);
915 int nGems = DW_GetItemCount(oPC, "dw_skill_gem");
916 SetGUIObjectText(oPC, GUI_ACHIEVEMENTS,"psionicGems", -1, IntToString(nGems));
917 if(nSkill > 0)
918 {
919 SetGUIObjectText(oPC, GUI_ACHIEVEMENTS, "psionicSkill_1", -1, IntToString(nSkill));
920 int nNeeded = DW_GetSkillGemsToIncrease(oPC, DW_SKILL_TELEPATHY);
921 SetLocalGUIVariable(oPC, GUI_ACHIEVEMENTS, 21, "Raise skill for " + IntToString(nNeeded) + " gems");
922 if(nNeeded > nGems)
923 {
924 SetGUIObjectDisabled(oPC, GUI_ACHIEVEMENTS, "psionicSkillGain_1", TRUE);
925 SetLocalGUIVariable(oPC, GUI_ACHIEVEMENTS, 21, "Need " + IntToString(nNeeded) + " gems to raise");
926 }else{
927 SetLocalGUIVariable(oPC, GUI_ACHIEVEMENTS, 21, "Raise skill for " + IntToString(nNeeded) + " gems");
928 }
929 }else{
930 SetGUIObjectDisabled(oPC, GUI_ACHIEVEMENTS, "psionicPowerIcon_1", TRUE);
931 SetGUIObjectDisabled(oPC, GUI_ACHIEVEMENTS, "psionicSkillDescription1", TRUE);
932 SetGUIObjectDisabled(oPC, GUI_ACHIEVEMENTS, "psionicSkillGain_1", TRUE);
933 SetGUIObjectText(oPC, GUI_ACHIEVEMENTS,"psionicSkill_Title1", -1, "");
934 }
935 nSkill = DW_GetPsionicSkill(oPC, DW_SKILL_PYROKINETICS);
936 if(nSkill > 0)
937 {
938 SetGUIObjectText(oPC, GUI_ACHIEVEMENTS, "psionicSkill_2", -1, IntToString(nSkill));
939 int nNeeded = DW_GetSkillGemsToIncrease(oPC, DW_SKILL_PYROKINETICS);
940 if(nNeeded > nGems)
941 {
942 SetGUIObjectDisabled(oPC, GUI_ACHIEVEMENTS, "psionicSkillGain_2", TRUE);
943 SetLocalGUIVariable(oPC, GUI_ACHIEVEMENTS, 22, "Need " + IntToString(nNeeded) + " gems to raise");
944 }else{
945 SetLocalGUIVariable(oPC, GUI_ACHIEVEMENTS, 22, "Raise skill for " + IntToString(nNeeded) + " gems");
946 }
947 }else{
948 SetGUIObjectDisabled(oPC, GUI_ACHIEVEMENTS, "psionicPowerIcon_2", TRUE);
949 SetGUIObjectDisabled(oPC, GUI_ACHIEVEMENTS, "psionicSkillDescription2", TRUE);
950 SetGUIObjectDisabled(oPC, GUI_ACHIEVEMENTS, "psionicSkillGain_2", TRUE);
951 SetGUIObjectText(oPC, GUI_ACHIEVEMENTS,"psionicSkill_Title2", -1, "");
952 }
953
954 nSkill = DW_GetPsionicSkill(oPC, DW_SKILL_CHRONOKINESIS);
955 if(nSkill > 0)
956 {
957 SetGUIObjectText(oPC, GUI_ACHIEVEMENTS, "psionicSkill_3", -1, IntToString(nSkill));
958 int nNeeded = DW_GetSkillGemsToIncrease(oPC, DW_SKILL_CHRONOKINESIS);
959 if(nNeeded > nGems)
960 {
961 SetGUIObjectDisabled(oPC, GUI_ACHIEVEMENTS, "psionicSkillGain_3", TRUE);
962 SetLocalGUIVariable(oPC, GUI_ACHIEVEMENTS, 23, "Need " + IntToString(nNeeded) + " gems to raise");
963 }else{
964 SetLocalGUIVariable(oPC, GUI_ACHIEVEMENTS, 23, "Raise skill for " + IntToString(nNeeded) + " gems");
965 }
966 }else{
967 SetGUIObjectDisabled(oPC, GUI_ACHIEVEMENTS, "psionicPowerIcon_3", TRUE);
968 SetGUIObjectDisabled(oPC, GUI_ACHIEVEMENTS, "psionicSkillDescription3", TRUE);
969 SetGUIObjectDisabled(oPC, GUI_ACHIEVEMENTS, "psionicSkillGain_3", TRUE);
970 SetGUIObjectText(oPC, GUI_ACHIEVEMENTS,"psionicSkill_Title3", -1, "");
971 }
972
973 nSkill = DW_GetPsionicSkill(oPC, DW_SKILL_DOMINATION);
974 if(nSkill > 0)
975 {
976 SetGUIObjectText(oPC, GUI_ACHIEVEMENTS, "psionicSkill_4", -1, IntToString(nSkill));
977 int nNeeded = DW_GetSkillGemsToIncrease(oPC, DW_SKILL_DOMINATION);
978 if(nNeeded > nGems)
979 {
980 SetGUIObjectDisabled(oPC, GUI_ACHIEVEMENTS, "psionicSkillGain_4", TRUE);
981 SetLocalGUIVariable(oPC, GUI_ACHIEVEMENTS, 24, "Need " + IntToString(nNeeded) + " gems to raise");
982 }else{
983 SetLocalGUIVariable(oPC, GUI_ACHIEVEMENTS, 24, "Raise skill for " + IntToString(nNeeded) + " gems");
984 }
985 }else{
986 SetGUIObjectDisabled(oPC, GUI_ACHIEVEMENTS, "psionicPowerIcon_4", TRUE);
987 SetGUIObjectDisabled(oPC, GUI_ACHIEVEMENTS, "psionicSkillDescription4", TRUE);
988 SetGUIObjectDisabled(oPC, GUI_ACHIEVEMENTS, "psionicSkillGain_4", TRUE);
989 SetGUIObjectText(oPC, GUI_ACHIEVEMENTS,"psionicSkill_Title4", -1, "");
990 }
991
992 nSkill = DW_GetPsionicSkill(oPC, DW_SKILL_PSIONIC_COMBAT);
993 if(nSkill > 0)
994 {
995 SetGUIObjectText(oPC, GUI_ACHIEVEMENTS, "psionicSkill_5", -1, IntToString(nSkill));
996 int nNeeded = DW_GetSkillGemsToIncrease(oPC, DW_SKILL_PSIONIC_COMBAT);
997 if(nNeeded > nGems)
998 {
999 SetGUIObjectDisabled(oPC, GUI_ACHIEVEMENTS, "psionicSkillGain_5", TRUE);
1000 SetLocalGUIVariable(oPC, GUI_ACHIEVEMENTS, 25, "Need " + IntToString(nNeeded) + " gems to raise");
1001 }else{
1002 SetLocalGUIVariable(oPC, GUI_ACHIEVEMENTS, 25, "Raise skill for " + IntToString(nNeeded) + " gems");
1003 }
1004 }else{
1005 SetGUIObjectDisabled(oPC, GUI_ACHIEVEMENTS, "psionicPowerIcon_5", TRUE);
1006 SetGUIObjectDisabled(oPC, GUI_ACHIEVEMENTS, "psionicSkillDescription5", TRUE);
1007 SetGUIObjectDisabled(oPC, GUI_ACHIEVEMENTS, "psionicSkillGain_5", TRUE);
1008 SetGUIObjectText(oPC, GUI_ACHIEVEMENTS,"psionicSkill_Title5", -1, "");
1009 }
1010
1011}
1012
1013// Show achievements for DW3
1014void DW3_ShowAchievements(object oPC, string GUI_ACHIEVEMENTS)
1015{
1016 int nLuteHeroScore = GetGlobalInt("LuteHeroScore");
1017 int nTorpedoesFired = GetGlobalInt("TorpedoesFired");
1018 int nSharksKilled = GetGlobalInt("SharksKilled");
1019 int nBrainsPlaced = GetGlobalInt("BrainsPlaced");
1020 int nAutomataDisabled = GetGlobalInt("AutomataDisabled");
1021 int nParasitesKilled = GetGlobalInt("ParasitesKilled");
1022 int nMaxWordLength = GetGlobalInt("MaxWordLength");
1023 int nMaxWordPower = GetGlobalInt("MaxWordPower");
1024
1025 SetGUIObjectText(oPC, GUI_ACHIEVEMENTS,"statDW3_1", -1, IntToString(nLuteHeroScore));
1026 SetGUIObjectText(oPC, GUI_ACHIEVEMENTS,"statDW3_2", -1, IntToString(nMaxWordLength));
1027 SetGUIObjectText(oPC, GUI_ACHIEVEMENTS,"statDW3_3", -1, IntToString(nMaxWordPower));
1028 SetGUIObjectText(oPC, GUI_ACHIEVEMENTS,"statDW3_4", -1, IntToString(nAutomataDisabled));
1029 SetGUIObjectText(oPC, GUI_ACHIEVEMENTS,"statDW3_5", -1, IntToString(nTorpedoesFired));
1030 SetGUIObjectText(oPC, GUI_ACHIEVEMENTS,"statDW3_6", -1, IntToString(nSharksKilled));
1031 SetGUIObjectText(oPC, GUI_ACHIEVEMENTS,"statDW3_7", -1, IntToString(nBrainsPlaced));
1032 SetGUIObjectText(oPC, GUI_ACHIEVEMENTS,"statDW3_8", -1, IntToString(nParasitesKilled) + "/18");
1033
1034
1035 if(GetGlobalInt("KilledDragon") == 1)
1036 {
1037 SetGUIObjectText(oPC, GUI_ACHIEVEMENTS,"achievementDragonSlayerText", -1, "Dragon Slayer");
1038 SetGUIObjectDisabled(oPC, GUI_ACHIEVEMENTS, "achievementDragonSlayer", FALSE);
1039 }else{
1040 SetGUIObjectText(oPC, GUI_ACHIEVEMENTS,"achievementDragonSlayerText", -1, "Kill a Dragon");
1041 SetGUIObjectDisabled(oPC, GUI_ACHIEVEMENTS, "achievementDragonSlayer", TRUE);
1042 }
1043 if(GetGlobalInt("KilledValsharoon") == 1)
1044 {
1045 SetGUIObjectText(oPC, GUI_ACHIEVEMENTS,"achievementReaperText", -1, "Reaper");
1046 SetGUIObjectDisabled(oPC, GUI_ACHIEVEMENTS, "achievementReaper", FALSE);
1047 }else{
1048 SetGUIObjectText(oPC, GUI_ACHIEVEMENTS,"achievementReaperText", -1, "Kill Valsharoon");
1049 SetGUIObjectDisabled(oPC, GUI_ACHIEVEMENTS, "achievementReaper", TRUE);
1050 }
1051 if(GetGlobalInt("KilledBeholder") == 1)
1052 {
1053 SetGUIObjectText(oPC, GUI_ACHIEVEMENTS,"achievementBeholderText", -1, "Eye of the Beholder");
1054 SetGUIObjectDisabled(oPC, GUI_ACHIEVEMENTS, "achievementBeholder", FALSE);
1055 }else{
1056 SetGUIObjectText(oPC, GUI_ACHIEVEMENTS,"achievementBeholderText", -1, "Kill a Beholder");
1057 SetGUIObjectDisabled(oPC, GUI_ACHIEVEMENTS, "achievementBeholder", TRUE);
1058 }
1059 if(nLuteHeroScore > 5000)
1060 {
1061 SetGUIObjectText(oPC, GUI_ACHIEVEMENTS,"achievementLuteHeroText", -1, "Lute Hero");
1062 SetGUIObjectDisabled(oPC, GUI_ACHIEVEMENTS, "achievementLuteHero", FALSE);
1063 }else{
1064 SetGUIObjectText(oPC, GUI_ACHIEVEMENTS,"achievementLuteHeroText", -1, "Score over 5,000 at Lute Hero");
1065 SetGUIObjectDisabled(oPC, GUI_ACHIEVEMENTS, "achievementLuteHero", TRUE);
1066 }
1067 if(nMaxWordLength > 7)
1068 {
1069 SetGUIObjectText(oPC, GUI_ACHIEVEMENTS,"achievementWordWarriorText", -1, "Word Warrior");
1070 SetGUIObjectDisabled(oPC, GUI_ACHIEVEMENTS, "achievementWordWarrior", FALSE);
1071 }else{
1072 SetGUIObjectText(oPC, GUI_ACHIEVEMENTS,"achievementWordWarriorText", -1, "Use an 8-letter word in Alphabet Assault");
1073 SetGUIObjectDisabled(oPC, GUI_ACHIEVEMENTS, "achievementWordWarrior", TRUE);
1074 }
1075 if( (DW_GetPsionicSkill(oPC, DW_SKILL_MENTAL_REGENERATION) > 0) &&
1076 (DW_GetPsionicSkill(oPC, DW_SKILL_MENTAL_BARRIER) > 0))
1077 {
1078 SetGUIObjectText(oPC, GUI_ACHIEVEMENTS,"achievementGiftText", -1, "Secret Gift");
1079 SetGUIObjectDisabled(oPC, GUI_ACHIEVEMENTS, "achievementGift", FALSE);
1080 }else{
1081 SetGUIObjectText(oPC, GUI_ACHIEVEMENTS,"achievementGiftText", -1, "Gain Mental Barrier and Mental Regeneration powers");
1082 SetGUIObjectDisabled(oPC, GUI_ACHIEVEMENTS, "achievementGift", TRUE);
1083 }
1084
1085 // show psionic powers
1086 SetLocalGUIVariable(oPC, GUI_ACHIEVEMENTS, 21, "Spend gems to raise skill");
1087 int nSkill;
1088 nSkill = DW_GetPsionicSkill(oPC, DW_SKILL_TELEKINESIS);
1089 int nGems = DW_GetItemCount(oPC, "dw_skill_gem");
1090 SetGUIObjectText(oPC, GUI_ACHIEVEMENTS,"psionicGems", -1, IntToString(nGems));
1091 if(nSkill > 0)
1092 {
1093 SetGUIObjectText(oPC, GUI_ACHIEVEMENTS, "psionicSkill_6", -1, IntToString(nSkill));
1094 int nNeeded = DW_GetSkillGemsToIncrease(oPC, DW_SKILL_TELEKINESIS);
1095 SetLocalGUIVariable(oPC, GUI_ACHIEVEMENTS, 26, "Raise skill for " + IntToString(nNeeded) + " gems");
1096 if(nNeeded > nGems)
1097 {
1098 SetGUIObjectDisabled(oPC, GUI_ACHIEVEMENTS, "psionicSkillGain_6", TRUE);
1099 SetLocalGUIVariable(oPC, GUI_ACHIEVEMENTS, 26, "Need " + IntToString(nNeeded) + " gems to raise");
1100 }else{
1101 SetLocalGUIVariable(oPC, GUI_ACHIEVEMENTS, 26, "Raise skill for " + IntToString(nNeeded) + " gems");
1102 }
1103 }else{
1104 SetGUIObjectDisabled(oPC, GUI_ACHIEVEMENTS, "psionicPowerIcon_6", TRUE);
1105 SetGUIObjectDisabled(oPC, GUI_ACHIEVEMENTS, "psionicSkillDescription6", TRUE);
1106 SetGUIObjectDisabled(oPC, GUI_ACHIEVEMENTS, "psionicSkillGain_6", TRUE);
1107 SetGUIObjectText(oPC, GUI_ACHIEVEMENTS,"psionicSkill_Title6", -1, "");
1108 }
1109
1110
1111 nSkill = DW_GetPsionicSkill(oPC, DW_SKILL_TELEPORTATION);
1112 if(nSkill > 0)
1113 {
1114 SetGUIObjectText(oPC, GUI_ACHIEVEMENTS, "psionicSkill_7", -1, IntToString(nSkill));
1115 int nNeeded = DW_GetSkillGemsToIncrease(oPC, DW_SKILL_TELEPORTATION);
1116 SetLocalGUIVariable(oPC, GUI_ACHIEVEMENTS, 27, "Raise skill for " + IntToString(nNeeded) + " gems");
1117 if(nNeeded > nGems)
1118 {
1119 SetGUIObjectDisabled(oPC, GUI_ACHIEVEMENTS, "psionicSkillGain_7", TRUE);
1120 SetLocalGUIVariable(oPC, GUI_ACHIEVEMENTS, 27, "Need " + IntToString(nNeeded) + " gems to raise");
1121 }else{
1122 SetLocalGUIVariable(oPC, GUI_ACHIEVEMENTS, 27, "Raise skill for " + IntToString(nNeeded) + " gems");
1123 }
1124 }else{
1125 SetGUIObjectDisabled(oPC, GUI_ACHIEVEMENTS, "psionicPowerIcon_7", TRUE);
1126 SetGUIObjectDisabled(oPC, GUI_ACHIEVEMENTS, "psionicSkillDescription7", TRUE);
1127 SetGUIObjectDisabled(oPC, GUI_ACHIEVEMENTS, "psionicSkillGain_7", TRUE);
1128 SetGUIObjectText(oPC, GUI_ACHIEVEMENTS,"psionicSkill_Title7", -1, "");
1129 }
1130
1131 nSkill = DW_GetPsionicSkill(oPC, DW_SKILL_MENTAL_BARRIER);
1132 if(nSkill > 0)
1133 {
1134 SetGUIObjectText(oPC, GUI_ACHIEVEMENTS, "psionicSkill_8", -1, IntToString(nSkill));
1135 int nNeeded = DW_GetSkillGemsToIncrease(oPC, DW_SKILL_MENTAL_BARRIER);
1136 SetLocalGUIVariable(oPC, GUI_ACHIEVEMENTS, 28, "Raise skill for " + IntToString(nNeeded) + " gems");
1137 if(nNeeded > nGems)
1138 {
1139 SetGUIObjectDisabled(oPC, GUI_ACHIEVEMENTS, "psionicSkillGain_8", TRUE);
1140 SetLocalGUIVariable(oPC, GUI_ACHIEVEMENTS, 28, "Need " + IntToString(nNeeded) + " gems to raise");
1141 }else{
1142 SetLocalGUIVariable(oPC, GUI_ACHIEVEMENTS, 28, "Raise skill for " + IntToString(nNeeded) + " gems");
1143 }
1144 }else{
1145 SetGUIObjectDisabled(oPC, GUI_ACHIEVEMENTS, "psionicPowerIcon_8", TRUE);
1146 SetGUIObjectDisabled(oPC, GUI_ACHIEVEMENTS, "psionicSkillDescription8", TRUE);
1147 SetGUIObjectDisabled(oPC, GUI_ACHIEVEMENTS, "psionicSkillGain_8", TRUE);
1148 SetGUIObjectText(oPC, GUI_ACHIEVEMENTS,"psionicSkill_Title8", -1, "");
1149 }
1150
1151 nSkill = DW_GetPsionicSkill(oPC, DW_SKILL_MENTAL_REGENERATION);
1152 if(nSkill > 0)
1153 {
1154 SetGUIObjectText(oPC, GUI_ACHIEVEMENTS, "psionicSkill_9", -1, IntToString(nSkill));
1155 int nNeeded = DW_GetSkillGemsToIncrease(oPC, DW_SKILL_MENTAL_REGENERATION);
1156 SetLocalGUIVariable(oPC, GUI_ACHIEVEMENTS, 29, "Raise skill for " + IntToString(nNeeded) + " gems");
1157 if(nNeeded > nGems)
1158 {
1159 SetGUIObjectDisabled(oPC, GUI_ACHIEVEMENTS, "psionicSkillGain_9", TRUE);
1160 SetLocalGUIVariable(oPC, GUI_ACHIEVEMENTS, 29, "Need " + IntToString(nNeeded) + " gems to raise");
1161 }else{
1162 SetLocalGUIVariable(oPC, GUI_ACHIEVEMENTS, 29, "Raise skill for " + IntToString(nNeeded) + " gems");
1163 }
1164 }else{
1165 SetGUIObjectDisabled(oPC, GUI_ACHIEVEMENTS, "psionicPowerIcon_9", TRUE);
1166 SetGUIObjectDisabled(oPC, GUI_ACHIEVEMENTS, "psionicSkillDescription9", TRUE);
1167 SetGUIObjectDisabled(oPC, GUI_ACHIEVEMENTS, "psionicSkillGain_9", TRUE);
1168 SetGUIObjectText(oPC, GUI_ACHIEVEMENTS,"psionicSkill_Title9", -1, "");
1169 }
1170
1171}
1172
1173void RemoveGear(object oCreature)
1174{
1175 object oHelmet = GetItemInSlot(INVENTORY_SLOT_HEAD, oCreature);
1176 if(oHelmet != OBJECT_INVALID)
1177 AssignCommand(oCreature, ActionUnequipItem(oHelmet));
1178 object oRightHand = GetItemInSlot(INVENTORY_SLOT_RIGHTHAND, oCreature);
1179 if(oRightHand != OBJECT_INVALID)
1180 AssignCommand(oCreature, ActionUnequipItem(oRightHand));
1181 object oLeftHand = GetItemInSlot(INVENTORY_SLOT_LEFTHAND, oCreature);
1182 if(oLeftHand != OBJECT_INVALID)
1183 AssignCommand(oCreature, ActionUnequipItem(oLeftHand));
1184}
1185
1186void SendDebugMessage(string sMessage)
1187{
1188 if(GetLocalInt(GetModule(), "Debug") != 1)
1189 return;
1190 object oPC = GetFirstPC(FALSE);
1191 SendMessageToPC(oPC, sMessage);
1192 WriteTimestampedLogEntry(sMessage);
1193}
1194
1195
1196void SetTransparent(object oCreature)
1197{
1198 effect eGhost = EffectCutsceneGhost();
1199 effect eLink = EffectLinkEffects (EffectVisualEffect(VFX_DUR_CUTSCENE_INVISIBILITY), eGhost);
1200 ApplyEffectToObject(DURATION_TYPE_PERMANENT, eLink, oCreature);
1201
1202}
1203
1204void SetVow(object oPC, string sVow, string sJournal = "", int nJournal = 0)
1205{
1206 SetLocalInt(oPC, sVow, 1);
1207 if(GetStringLength(sJournal) > 0)
1208 {
1209 AddJournalQuestEntry(sJournal, nJournal, oPC);
1210 }
1211}
1212
1213void UnequipGear(object oNPC)
1214{
1215 AssignCommand(oNPC, ActionUnequipItem(GetItemInSlot(INVENTORY_SLOT_HEAD, oNPC)));
1216 AssignCommand(oNPC, ActionUnequipItem(GetItemInSlot(INVENTORY_SLOT_LEFTHAND, oNPC)));
1217 AssignCommand(oNPC, ActionUnequipItem(GetItemInSlot(INVENTORY_SLOT_RIGHTHAND, oNPC)));
1218}
1219
1220int DW_GetAct()
1221{
1222 string sTag = GetTag(GetModule());
1223 WriteTimestampedLogEntry("DW_GetAct: " + sTag);
1224 if(GetStringLength(sTag) < 3)
1225 return 0;
1226 WriteTimestampedLogEntry("DW_GetAct: " + GetSubString(sTag, 2, 1));
1227 return StringToInt(GetSubString(sTag, 2, 1));
1228}
1229
1230
1231// weapon size scripts by Mithdradates
1232
1233const int WEAPON_SIZE_INVALID=0;
1234const int WEAPON_SIZE_TINY=1;
1235const int WEAPON_SIZE_SMALL=2;
1236const int WEAPON_SIZE_MEDIUM=3;
1237const int WEAPON_SIZE_LARGE=4;
1238//Function to determine the size of the weapon being used by the creature
1239int GetWeaponSize(object oCreature=OBJECT_SELF)
1240{
1241 object oWeapon;
1242 if (GetObjectType(oCreature)==OBJECT_TYPE_CREATURE)
1243 oWeapon=GetItemInSlot(INVENTORY_SLOT_RIGHTHAND,oCreature);
1244 else
1245 oWeapon=oCreature;
1246 if (!GetIsObjectValid(oWeapon)) return WEAPON_SIZE_INVALID;
1247 if (GetBaseItemType(oWeapon)==BASE_ITEM_DAGGER) return WEAPON_SIZE_TINY;
1248 if (GetBaseItemType(oWeapon)==BASE_ITEM_DART) return WEAPON_SIZE_TINY;
1249 if (GetBaseItemType(oWeapon)==BASE_ITEM_FALCHION) return WEAPON_SIZE_LARGE;
1250 if (GetBaseItemType(oWeapon)==BASE_ITEM_GREATAXE) return WEAPON_SIZE_LARGE;
1251 if (GetBaseItemType(oWeapon)==BASE_ITEM_GREATSWORD) return WEAPON_SIZE_LARGE;
1252 if (GetBaseItemType(oWeapon)==BASE_ITEM_HALBERD) return WEAPON_SIZE_LARGE;
1253 if (GetBaseItemType(oWeapon)==BASE_ITEM_HANDAXE) return WEAPON_SIZE_SMALL;
1254 if (GetBaseItemType(oWeapon)==BASE_ITEM_HEAVYCROSSBOW) return WEAPON_SIZE_LARGE;
1255 if (GetBaseItemType(oWeapon)==BASE_ITEM_KAMA) return WEAPON_SIZE_TINY;
1256 if (GetBaseItemType(oWeapon)==BASE_ITEM_KUKRI) return WEAPON_SIZE_TINY;
1257 if (GetBaseItemType(oWeapon)==BASE_ITEM_LIGHTHAMMER) return WEAPON_SIZE_SMALL;
1258 if (GetBaseItemType(oWeapon)==BASE_ITEM_LONGBOW) return WEAPON_SIZE_LARGE;
1259 if (GetBaseItemType(oWeapon)==BASE_ITEM_LIGHTMACE) return WEAPON_SIZE_SMALL;
1260 if (GetBaseItemType(oWeapon)==BASE_ITEM_MAGICSTAFF) return WEAPON_SIZE_LARGE;
1261 if (GetBaseItemType(oWeapon)==BASE_ITEM_QUARTERSTAFF) return WEAPON_SIZE_LARGE;
1262 if (GetBaseItemType(oWeapon)==BASE_ITEM_SCYTHE) return WEAPON_SIZE_LARGE;
1263 if (GetBaseItemType(oWeapon)==BASE_ITEM_SHORTSWORD) return WEAPON_SIZE_SMALL;
1264 if (GetBaseItemType(oWeapon)==BASE_ITEM_SHURIKEN) return WEAPON_SIZE_TINY;
1265 if (GetBaseItemType(oWeapon)==BASE_ITEM_SICKLE) return WEAPON_SIZE_SMALL;
1266 if (GetBaseItemType(oWeapon)==BASE_ITEM_SLING) return WEAPON_SIZE_SMALL;
1267 if (GetBaseItemType(oWeapon)==BASE_ITEM_SPEAR) return WEAPON_SIZE_LARGE;
1268 if (GetBaseItemType(oWeapon)==BASE_ITEM_THROWINGAXE) return WEAPON_SIZE_SMALL;
1269 if (GetBaseItemType(oWeapon)==BASE_ITEM_WARMACE) return WEAPON_SIZE_LARGE;
1270 return WEAPON_SIZE_MEDIUM;
1271}
1272
1273
1274//Function to determine whether a creature is using a two-handed weapon
1275int IsWeaponTwoHanded(object oCreature=OBJECT_SELF)
1276{
1277 object oWeapon = GetItemInSlot(INVENTORY_SLOT_RIGHTHAND, oCreature);
1278 SendDebugMessage("Weapon size: " + IntToString(GetWeaponSize(oWeapon)));
1279 SendDebugMessage("Creature size: " + IntToString(GetCreatureSize(oCreature)));
1280 if (GetWeaponSize(oWeapon) > GetCreatureSize(oCreature))
1281 return TRUE;
1282 return FALSE;
1283}
1284
1285
1286// Equip creature with flintlock
1287// If none exists, give them one.
1288void EquipFlintlock(object oCreature)
1289{
1290 // check to make sure they have bullets
1291 object oBullets = GetItemInSlot(INVENTORY_SLOT_BULLETS);
1292 if(oBullets == OBJECT_INVALID)
1293 {
1294 oBullets = CreateItemOnObject("dw_ballandpowder", oCreature, 10);
1295 AssignCommand(oCreature, ActionEquipItem(oBullets, INVENTORY_SLOT_BULLETS ));
1296 }
1297 object oPistol = GetItemInSlot(INVENTORY_SLOT_RIGHTHAND);
1298
1299 // unequip left handed stuff
1300 AssignCommand(oCreature, ActionUnequipItem(GetItemInSlot(INVENTORY_SLOT_LEFTHAND)));
1301
1302 int nFoundPistol = FALSE;
1303 if(GetBaseItemType(oPistol) != BASE_ITEM_SLING)
1304 {
1305 // unequip whatever they have in their right hand
1306 AssignCommand(oCreature, ActionUnequipItem(oPistol));
1307
1308 object oItem = GetFirstItemInInventory(oCreature);
1309 while(oItem != OBJECT_INVALID)
1310 {
1311 if(GetBaseItemType(oItem)==BASE_ITEM_SLING)
1312 {
1313 AssignCommand(oCreature, ActionEquipItem(oItem, INVENTORY_SLOT_RIGHTHAND ));
1314 nFoundPistol = TRUE;
1315 oItem = OBJECT_INVALID;
1316 }else{
1317 oItem = GetNextItemInInventory(oCreature);
1318 }
1319 }
1320 }
1321 if(nFoundPistol == FALSE)
1322 {
1323 oPistol = CreateItemOnObject("dw_flintlock", oCreature);
1324 AssignCommand(oCreature, ActionEquipItem(oPistol, INVENTORY_SLOT_RIGHTHAND ));
1325 }
1326
1327
1328}