Files
HeroesStone_PRC8/_module/nss/jw_golem_inc.nss
Jaysyn904 1eefc84201 Initial Commit
Initial Commit.
2025-09-14 15:40:46 -04:00

323 lines
8.6 KiB
Plaintext

// The PC will create a golem if they do not have one already, have the skills, are
// near the machine and have the right stuff in their bag
void CreateGolem(object oPC);
// Will destroy the PC's saved golem. If they golem is currently out, it will
// be destroyed too.
void DestroyGolem(object oPC);
// Stores the PC's golem, if he currently has one out
// This allows the PC to send the golem home and is called via a conversation
void StoreGolem(object oPC);
// Saves the PC's golem IN THE DATABASE, if he has one
// This function is run on every PC every so often
void SaveGolem(object oPC);
// Gets the PC's golem and automatically makes it a henchman
void RetrieveGolem(object oPC);
// Checks whether this PC has a golem. Note that the golem may be stored and this will still return true
int GetHasGolem(object oPC);
// Checks whether this PC has a golem. This is only used when the player first enters the module
int GetHasGolemOnStartup(object oPC);
// Gets whether oPC has the ability to craft a golem.
int GetGolemSkills(object oPC);
// Sets whether oPC has the ability to craft a golem. Default is true
void SetGolemSkills(object oPC, int nSkills=TRUE);
void SetGolemSkills(object oPC, int nSkills=TRUE)
{
object oBox=GetItemPossessedBy(oPC,"jw_crafting_gem");
SetLocalInt(oBox,"golemskills",nSkills);
}
int GetGolemSkills(object oPC)
{
int nSkills=GetLocalInt(GetItemPossessedBy(oPC,"jw_crafting_gem"),"golemskills");
return nSkills;
}
int GetHasGolemOnStartup(object oPC)
{
int nReturn=FALSE;
object oGolem=RetrieveCampaignObject("NEW_WORLD","mygolem",GetLocation(oPC),oPC,oPC);
if (GetIsObjectValid(oGolem))
{
DestroyObject(oGolem);
SetLocalInt(oPC,"hasgolem",TRUE);
nReturn=TRUE;
}
return nReturn;
}
int GetHasGolem(object oPC)
{
return GetLocalInt(oPC,"hasgolem");
}
void RetrieveGolem(object oPC)
{
object oGolem=GetLocalObject(oPC,"mygolem");
if (GetIsObjectValid(oGolem))
{
SendMessageToPC(oPC,"Your golem has already been summoned.");
return;
}
oGolem=RetrieveCampaignObject("NEW_WORLD","mygolem",GetLocation(oPC),oPC,oPC);
if (GetLocalInt(oPC,"hasgolem")==FALSE)
{
SendMessageToPC(oPC,"You do not appear to have a golem to call");
return;
}
if (!GetIsObjectValid(oGolem))
{
SendMessageToPC(oPC,"You do not appear to have a golem to call.");
return;
}
// Make the golem do animation
effect eAppear = EffectAppear();
ApplyEffectToObject(DURATION_TYPE_INSTANT, eAppear, oGolem);
// Make the golem make some noise
AssignCommand(oGolem,PlayVoiceChat(VOICE_CHAT_BATTLECRY1));
// Make the golem the PC's henchman
AddHenchman(oPC,oGolem);
SetLocalObject(oPC,"mygolem",oGolem);
//int damage = GetCampaignInt("NEW_WORLD","GHP",oPC);
// if(damage > 0)
// {
// ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectDamage(damage), oGolem);
// }
}
void SaveGolem(object oPC)
{
object oGolem=GetLocalObject(oPC,"mygolem");
if (!GetIsObjectValid(oGolem))
{
return;
}
StoreCampaignObject("NEW_WORLD","mygolem",oGolem,oPC);
}
void StoreGolem(object oPC)
{
object oGolem=GetLocalObject(oPC,"mygolem");
if (!GetIsObjectValid(oGolem))
{
SendMessageToPC(oPC,"You do not appear to have a golem currently summoned to store.");
return;
}
StoreCampaignObject("NEW_WORLD","mygolem",oGolem,oPC);
effect eAppear = EffectDisappear();
ApplyEffectToObject(DURATION_TYPE_INSTANT, eAppear, oGolem);
DestroyObject(oGolem);
}
void DestroyGolem(object oPC)
{
object oGolem=GetLocalObject(oPC,"mygolem");
if (GetIsObjectValid(oGolem))
{
RemoveHenchman(oPC,oGolem);
RemoveFromParty(oGolem);
effect eAppear = EffectKnockdown();
ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eAppear, oGolem,6.0);
AssignCommand(oGolem,PlayVoiceChat(VOICE_CHAT_PAIN1));
DestroyObject(oGolem,3.0);
}
DeleteCampaignVariable("NEW_WORLD","mygolem",oPC);
SetLocalInt(oPC,"hasgolem",FALSE);
SendMessageToPC(oPC,"Your golem has been destroyed forever.");
}
void CreateGolem(object oPC)
{
object oGolem=GetLocalObject(oPC,"mygolem");
if (GetIsObjectValid(oGolem))
{
SendMessageToPC(oPC,"You cannot make a golem while you already have one. Store your golem, and then use your craft skills to delete it entirely before making a new one.");
return;
}
if (GetHasGolem(oPC)==TRUE)
{
SendMessageToPC(oPC,"You already have a stored golem. You must use your craft skills to delete it entirely before making a new one.");
return;
}
if (GetGolemSkills(oPC)==FALSE)
{
SendMessageToPC(oPC,"You do now know how to make a golem.");
return;
}
object oDevice;
oDevice=GetNearestObjectByTag("jw_golem_machine",oPC);
if (!GetIsObjectValid(oDevice))
{
SendMessageToPC(oPC,"You need to be near a golem crafting machine.");
return;
}
float fDistance=GetDistanceBetween(oPC,oDevice);
if (fDistance<0.0)
{
SendMessageToPC(oPC,"You need to be near a golem crafting machine.");
return;
}
if (fDistance>5.0)
{
SendMessageToPC(oPC,"You need to be near a golem crafting machine.");
return;
}
// Everything is done, start to make the golem
object oBox=GetItemPossessedBy(oPC,"jw_crafting_gem");
object oHead=GetItemPossessedBy(oBox,"jw_golem_head");
object oPowerCore=GetItemPossessedBy(oBox,"jw_golem_power");
object oChest=GetItemPossessedBy(oBox,"jw_golem_chest");
if ((!GetIsObjectValid(oHead))||(!GetIsObjectValid(oPowerCore))||
(!GetIsObjectValid(oChest)))
{
SendMessageToPC(oPC,"A crucial part is missing.");
return;
}
// Destroy all the ingredients
DestroyObject(oHead);
DestroyObject(oPowerCore);
DestroyObject(oChest);
// Okay, we can make it
oGolem=CreateObject(OBJECT_TYPE_CREATURE,"jw_golem_hench",GetLocation(oPC),TRUE);
// work out what type of golem it is.
// Basic golem
int nType=1;
string sMetal;
int nLevel=7;
if (GetIsObjectValid(GetItemPossessedBy(oBox,"ccr1_xx_xx_xx_ad")))
{
// It is mithral
nType=2;
sMetal="ccr1_xx_xx_xx_ad";
}
else
if (GetIsObjectValid(GetItemPossessedBy(oBox,"ccr1_xx_xx_xx_ac")))
{
// It is adamantite
nType=3;
sMetal="ccr1_xx_xx_xx_ac";
}
else
if (GetIsObjectValid(GetItemPossessedBy(oBox,"ccr1_xx_xx_xx_ab")))
{
// It is lead
nType=4;
sMetal="ccr1_xx_xx_xx_ab";
}
if (nType==1)
{
SetCreatureAppearanceType(oGolem,APPEARANCE_TYPE_SHIELD_GUARDIAN);
}
else
{
SetCreatureAppearanceType(oGolem,APPEARANCE_TYPE_GOLEM_IRON);
// Get levels and destroy metals, if we are using metals
object oMetal = GetItemPossessedBy(oBox,sMetal);
SetPlotFlag(oMetal,0);
DestroyObject(oMetal);
}
// Golem cannot be higher level than wizard levels-1
if (!GetIsDM(oPC))
{
nLevel=GetLevelByClass(CLASS_TYPE_WIZARD,oPC)-2;
}
else
{
nLevel=12;
}
// Level up our golem
int nIdx;
for(nIdx=1; nIdx<=nLevel; nIdx++)
{
LevelUpHenchman(oGolem,CLASS_TYPE_CONSTRUCT,TRUE,PACKAGE_CONSTRUCT);
}
// give it special powers if appropriate
itemproperty iProp;
object oSlam=GetItemInSlot(INVENTORY_SLOT_CWEAPON_B,oGolem);
object oPower=GetItemPossessedBy(oBox,"etr_fire");
if (GetIsObjectValid(oPower))
{
DestroyObject(oPower);
iProp=ItemPropertyDamageBonus(IP_CONST_DAMAGETYPE_FIRE,IP_CONST_DAMAGEBONUS_1d4);
AddItemProperty(DURATION_TYPE_PERMANENT,iProp,oSlam);
}
oPower=GetItemPossessedBy(oBox,"etr_quartz");
if (GetIsObjectValid(oPower))
{
DestroyObject(oPower);
iProp=ItemPropertyDamageBonus(IP_CONST_DAMAGETYPE_ELECTRICAL,IP_CONST_DAMAGEBONUS_1d4);
AddItemProperty(DURATION_TYPE_PERMANENT,iProp,oSlam);
}
oPower=GetItemPossessedBy(oBox,"etr_ice");
if (GetIsObjectValid(oPower))
{
DestroyObject(oPower);
iProp=ItemPropertyDamageBonus(IP_CONST_DAMAGETYPE_COLD,IP_CONST_DAMAGEBONUS_1d4);
AddItemProperty(DURATION_TYPE_PERMANENT,iProp,oSlam);
}
oPower=GetItemPossessedBy(oBox,"etr_acid");
if (GetIsObjectValid(oPower))
{
DestroyObject(oPower);
iProp=ItemPropertyDamageBonus(IP_CONST_DAMAGETYPE_ACID,IP_CONST_DAMAGEBONUS_1d4);
AddItemProperty(DURATION_TYPE_PERMANENT,iProp,oSlam);
}
// Give it a bonus to hit
iProp=ItemPropertyEnhancementBonus(nType);
AddItemProperty(DURATION_TYPE_PERMANENT,iProp,oSlam);
// Give it extra attacks
if (nType>1)
{
nType=nType-1;
ApplyEffectToObject(DURATION_TYPE_PERMANENT,SupernaturalEffect(EffectModifyAttacks(nType)),oGolem);
}
// Make it henchman
AssignCommand(oGolem,PlayVoiceChat(VOICE_CHAT_BATTLECRY1));
// Make the golem the PC's henchman
AddHenchman(oPC,oGolem);
SetLocalObject(oPC,"mygolem",oGolem);
SetLocalInt(oPC,"hasgolem",TRUE);
// Save golem in database
int nSuccess=StoreCampaignObject("NEW_WORLD","mygolem",oGolem,oPC);
if (nSuccess==FALSE)
{
//SendMessageToPC(oPC,"Error - golem failed to save");
}
else
{
//SendMessageToPC(oPC,"Golem saved succesfully");
}
//SetCampaignInt("NEW_WORLD","GHP",0,oPC);
ApplyEffectToObject(DURATION_TYPE_INSTANT,EffectVisualEffect(VFX_FNF_MYSTICAL_EXPLOSION),oDevice);
}