Where do you find the code to do damage to a player upon resting? This module has a ridiculous amount set, so much so that with 1/79hp, I only received 2hp from resting! I need to find where to change that, I'm sure I've looked at it 5 or 6 times already and just overlooked it.
REST_EVENTTYPE_REST_FINISHED
Débuté par
Rio420
, sept. 04 2013 09:51
#1
Posté 04 septembre 2013 - 09:51
#2
Posté 04 septembre 2013 - 11:25
I did something like this with my rest system. So I only know how that functioned.
First, look at the rest event script for the module under module properties. It is OnRest or some such. Then in the main of that script look for the rest finished sub-event.
In the work I did, I first recorded how many hitpoints the PC had when they started resting, so that may be a part of this too.
First, look at the rest event script for the module under module properties. It is OnRest or some such. Then in the main of that script look for the rest finished sub-event.
In the work I did, I first recorded how many hitpoints the PC had when they started resting, so that may be a part of this too.
#3
Posté 04 septembre 2013 - 11:45
From what I see in the OnRest / rest finished sub event, it calls:
ResetRestingHP()
This is the block of code for ResetRestingHP:
Maybe I'm confused, but it looks like it's getting the current hitpoints of the PC and getting a local integer for the module assigned to HPStartRest and then subtracting that value from the first. And that is the damage. The question is, where is that local int being stored?
ResetRestingHP()
This is the block of code for ResetRestingHP:
void ResetRestingHP(object oPC)
{
int nSHP=GetLocalInt(GetModule(),("HPStartRest"+GetName(oPC)+GetPCPublicCDKey(oPC)));
if(nSHP == 0 || nSHP>=GetCurrentHitPoints(oPC)) return;
int nRestHP = GetCurrentHitPoints(oPC);
int nDam = nRestHP-nSHP;
effect eDamage = EffectDamage(nDam);
ApplyEffectToObject(DURATION_TYPE_INSTANT, eDamage, oPC);
RemoveSpells(oPC);
SendMessageToAllDMs("WARNING: "+GetName(oPC)+" may be trying to cancel rest to re-gain spells.");
object oFam = GetPCFamiliar(oPC);
if(GetIsObjectValid(oFam))
DelayCommand(1.0,pet_rest_dam(oFam, oPC));
}
Maybe I'm confused, but it looks like it's getting the current hitpoints of the PC and getting a local integer for the module assigned to HPStartRest and then subtracting that value from the first. And that is the damage. The question is, where is that local int being stored?
#4
Posté 05 septembre 2013 - 12:03
Yeah, if I'm reading this right, it's basically set up to get the current hp of the player, subtract from the max, thus if I have 1hp out of 70, I'll take 69 damage on resting... wtf? lol
#5
Posté 05 septembre 2013 - 12:11
it doesn't let you recover HP at rest perhaps. You need to look at where it stores that information about HP at start of rest.
#6
Posté 05 septembre 2013 - 12:25
SendMessageToAllDMs("WARNING: "+GetName(oPC)+" may be trying to cancel rest to re-gain spells.");
Based on that line, it seems this might be intended to stop the following:
1, let's say a resting timer exists at 10 minutes
2, Bob the mage has used his spells and can rest
3, he knows that he'll use all of his spells within the next 4-5 minutes so he tries to be clever
4, he rests 95% of the way and then cancels the rest - restoring most of his spells and HP without starting the 10 minute timer
I'd suggest you post the entire rest script if you can't figure it out.
#7
Posté 05 septembre 2013 - 12:39
Here's the entire script, the other script this ties into will follow below this one:
Here's the other file:
Sorry for so much spam in this thread, the scripts are pretty big on this module.
//::///////////////////////////////////////////////
//:: AD On Rest
//:: ad_on_play_rest
//with Purple Rose v 1.1.3
//::///////////////////////////////////////////////
#include "pri_inc"
#include "srace_inc"
#include "ad_inc_food_rest"
#include "hc_inc_fatigue"
#include "ad_inc_cls_restr"
#include "ad_debug_inc"
#include "inc_movement"
int iRESTBREAK;
int iFOODSYSTEM;
int iMinRest;
int nRestHP;
int nSSB;
int nHasFood;
object oBedroll;
int iCount;
int iBedUse;
//object oMod = GetModule();
void InitRestVariables()
{
// FOODSYSTEM - Controls if the player needs to eat
iFOODSYSTEM = 1;
// RESTBREAK - Controls how long between rests in hours
iRESTBREAK = 4;
iMinRest = iRESTBREAK*nConv;
nSSB=SecondsSinceBegin();
}
void SetRestTime(object oPC, int iCount)
{
int iDec = iRESTBREAK/6;
//int n0SSB = GetLocalInt(oMod, "SecSB"+GetName(oPC)+GetPCPublicCDKey(oPC));
if(iDec < 1) iDec =1;
iCount = iCount-iDec;
if(iCount > 0)
{
int nNSB = nSSB-(iCount*60);
if(nNSB < 1) nNSB = 1;
if(GetLastRestEventType() == REST_EVENTTYPE_REST_STARTED)
{
SetLocalInt(oMod, ("LastRest" + GetName(oPC) + GetPCPublicCDKey(oPC)), nNSB);
DelayCommand(6.0, SetRestTime(oPC, iCount));
}
}
}
// void ApplyArmorRestPenalty(object oPC)
//{
// Armor penalty. Check only if rest fully completed.
// if (GetLastRestEventType() == REST_EVENTTYPE_REST_FINISHED ) {
//int bFatigued = GetLocalInt(oPC, "bFatigued");
//int bExhausted = GetLocalInt(oPC, "bExhausted");
// Check for armor, and give a penalty for armor +5 and above.
// object oArmor = GetItemInSlot(INVENTORY_SLOT_CHEST, oPC);
// if(GetChestArmorBaseType(oArmor) > 1 && GetChestArmorBaseType(oArmor) <= 5)
// {
// MakePlayerFatigued(oPC,FATIG);
// }else if(GetChestArmorBaseType(oArmor) > 5) {
// MakePlayerExhausted(oPC,EXHAUS);
// }
// }
// }
int DoesPCHaveBedroll(object oPC)
{
oBedroll = GetItemPossessedBy(oPC,"bedroll");
if (GetIsObjectValid(oBedroll))
return 1;
else {
oBedroll = GetLocalObject(oMod,"inbedroll" + GetName(oPC) + GetPCPublicCDKey(oPC));
if (GetIsObjectValid(oBedroll))
return 1;
}
return 0;
}
void ApplySleepEffects(object oPC)
{
effect eSnore = EffectVisualEffect(VFX_IMP_SLEEP);
ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eSnore, oPC, 7.0);
//insert special effects here. I tried EffectSleep along with different
//animations. They either get overrode by the rest anim or cancel the rest.
ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eSnore, oPC, 7.0);
effect eBad = GetFirstEffect(oPC);
//Search for negative effects
int nBlindMe=1;
while(GetIsEffectValid(eBad))
{
int nEtype=GetEffectType(eBad);
if(nEtype==EFFECT_TYPE_TRUESEEING)
nBlindMe=0;
eBad=GetNextEffect(oPC);
}
if(nBlindMe)
{
effect eBlind = EffectBlindness();
ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eBlind, oPC, 29.0);
}
DelayCommand(7.0, ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eSnore, oPC, 7.0));
}
void RemoveSleepBlindness(object oPC)
{
effect eBad = GetFirstEffect(oPC);
//Search for negative effects
while(GetIsEffectValid(eBad)) {
int nEtype=GetEffectType(eBad);
if (nEtype == EFFECT_TYPE_BLINDNESS) {
//Remove effect if it is negative.
RemoveEffect(oPC, eBad);
}
eBad = GetNextEffect(oPC);
}
}
void ReplaceBedroll(object oPC)
{
oBedroll=GetLocalObject(oMod, "inbedroll"+GetName(oPC)+GetPCPublicCDKey(oPC));
CreateItemOnObject("bedroll", oPC);
DestroyObject(oBedroll);
DeleteLocalObject(oMod, "inbedroll"+GetName(oPC)+GetPCPublicCDKey(oPC));
}
void main()
{
object oPC = GetLastPCRested();
// DEBUG PRINT OUT
if (AD_DEBUG == 1) {
string sDebug = "ad_on_play_rest: "+GetName(oPC)+" attempt to rest";
PrintString(sDebug); }
string sID = GetName(oPC) + GetPCPublicCDKey(oPC);
// See if they are in a Barracks
object oArea = GetArea(oPC);
int nBARRACK = GetLocalInt(oPC, "BARRACKS");
object oFam = GetPCFamiliar(oPC);
if(GetLastRestEventType() == REST_EVENTTYPE_REST_FINISHED){
EffectArmorEncumbrance(oPC);
RestrictionCheckDruid(oPC);
if(GetLocalInt(oPC,"NOSPELLS")==1)
RemoveAllSpellsAndFeats(oPC);
}
if(GetLastRestEventType() == REST_EVENTTYPE_REST_STARTED)
nRestHP = GetCurrentHitPoints(oPC);
// Don't allow rest if it is restricted
object noRest = GetNearestObjectByTag("NORESTWP", oPC);
if(GetIsObjectValid(noRest))
{
AssignCommand( oPC, ClearAllActions());
FloatingTextStringOnCreature("You must rest in a Inn or Tavern!",oPC,FALSE);
return;
}
string sFullArea = GetStringUpperCase(GetTag(oArea));
int nBarks = FindSubString(sFullArea, "BARRACK");
int nSRace = sr_GetSubRace(oPC);
if(nBarks != -1)
{
// Vamp fledgling check
if(nSRace==SUBRACE_VAMPIRE && GetHitDice(oPC)>4)
{
AssignCommand( oPC, ClearAllActions());
FloatingTextStringOnCreature(VAMPNOREST,oPC,FALSE);
}else{
if(GetLastRestEventType() == REST_EVENTTYPE_REST_STARTED)
{
ApplySleepEffects(oPC);
SavePreRestFamiliarHP(oPC, oFam);
}
if(GetLastRestEventType() == REST_EVENTTYPE_REST_FINISHED)
{
SetLocalInt(oPC,"RESTING",0);
DeleteLocalInt(oPC, "REST");
RemoveSleepBlindness(oPC);
SetSubRaceAbilites(oPC, nSRace);
}
}
SetLocalInt(oPC, "BARRACKS",1);
return;
}
if(GetCurrentHitPoints(oPC)<=FloatToInt((IntToFloat(GetMaxHitPoints(oPC))*0.2)))
DeleteLocalInt(oMod, ("LastRest" + sID));
int iBedroll;
int iBedUse = GetLocalInt(oPC, "RSA_BedUse");
if (iBedUse == 0) iBedroll = DoesPCHaveBedroll(oPC);
//Start of Inn Resting Mod
int iCanBedRoll = 1;
int iSleep = 0;
int iKill = 0;
int iWakeUp = 0;
int iRatChance = 0;
int iFail = 0;
string sWhyNoSleep = "Error in pri_on_play_rest script";
string sPoorRoom = "Error in pri_on_play_rest script";
//string sFood = GetLocalString(oPC, "RSA_FoodType");
object oButler = OBJECT_INVALID;
object oPRIForceInnRest = GetNearestObjectByTag("PRIForceInnRest", oPC);
if (GetIsObjectValid(oPRIForceInnRest)) iCanBedRoll = 0;
if(iBedUse > 0)
{
DeleteLocalInt(oMod, ("LastRest" + sID));
GetInnArea(oPC);
iRatChance = GetLocalInt(oPC, "RSA_RatChance");
string sButler = GetLocalString(oPC, "RSA_Butler");
sPoorRoom = GetLocalString(oPC, "RSA_PoorWake");
oButler = GetObjectByTag(sButler);
if(iBedUse == iRSA_POORBED) iWakeUp = 1;
if(iBedUse == iRSA_RICHBED) iKill = GetLocalInt(oButler, "RSA_KillInSleep");
}
if(iBedUse > 0 || (iCanBedRoll > 0 && iBedroll > 0)) iSleep = 1;
if(iSleep == 0 && GetLastRestEventType() == REST_EVENTTYPE_REST_STARTED)
{
AssignCommand(oPC, ClearAllActions());
sWhyNoSleep = NOBEDROLL;
if (iCanBedRoll == 0) sWhyNoSleep = SLEEPINN;
FloatingTextStringOnCreature(sWhyNoSleep, oPC, FALSE);
return;
}
// Vampire for sleeping in a Inn
if(iBedUse > 0 && nSRace==SUBRACE_VAMPIRE && GetHitDice(oPC)>4 &&
GetLastRestEventType() == REST_EVENTTYPE_REST_STARTED)
{
AssignCommand(oPC, ClearAllActions());
FloatingTextStringOnCreature(VAMPNOREST, oPC, FALSE);
return;
}
if((iSleep == 0 && GetLastRestEventType() == REST_EVENTTYPE_REST_CANCELLED) ||
(iSleep == 0 && GetLastRestEventType() == REST_EVENTTYPE_REST_FINISHED))
{
return;
}
//End of Inn Sleeping Mod
InitRestVariables();
// Limit group resting
//if(nSRace=!SUBRACE_VAMPIRE && RestrictPartyRestOnLimitRestHealAndArmorPen(oPC)) return;
// Vampires dont need food
if(nSRace == SUBRACE_VAMPIRE)
{
if(!GetLocalInt(oPC, "IN_COFFIN"))
{
AssignCommand( oPC, ClearAllActions());
FloatingTextStringOnCreature(VAMPNOREST, oPC, FALSE);
return;
}else{
// Vamps dont need food
iFOODSYSTEM = 0;
nHasFood = 1;
}
}
if(GetLastRestEventType() == REST_EVENTTYPE_REST_STARTED)
{
SavePreRestFamiliarHP(oPC, oFam);
if(iFOODSYSTEM) nHasFood = 0;
SetLocalInt(oMod,"HPStartRest" + sID,nRestHP);
object oFood;
int iFail = 0;
// Fail checks
iMinRest = iRESTBREAK*nConv;//(iRESTBREAK+4)*nConv;
if(iBedUse == 0)
{
if(iFail==0) iFail = IsTooSoonToRest(oPC, iMinRest, nSSB, nConv);
if(iFail==0) iFail = IsPCTooWeakToRest(oPC);
if(iFOODSYSTEM && !iFail)
{
if(HasPCEaten(oPC)==1)
nHasFood = 1;
else
iFail = 1;
}
}
if(iFail==0)
{
ApplySleepEffects(oPC);
}else
return;
if(iBedroll && iBedUse == 0)
{
object oNewBedroll=CreateObject(OBJECT_TYPE_PLACEABLE,"bedroll",GetLocation(oPC));
DestroyObject(oBedroll);
SetLocalInt(oMod,"LostBedRoll"+sID,1);
SetLocalObject(oMod,"inbedroll"+sID,oNewBedroll);
}
//PRI Mod
if(iBedUse > 0)
{
if(iWakeUp == 1 && iFail == 0)
{
int iRoll = d100(1);
if(iRoll >= iRatChance)
{
AssignCommand(oPC, ClearAllActions());
SendMessageToPC(oPC, sPoorRoom);
}
}
if(iKill == 1 && iFail == 0)
{
SendMessageToAllDMs(GetName(oPC)+" has been targeted by the Assassin in "+GetName(GetArea(oPC))+".");
location lLoc = GetLocation(GetWaypointByTag("AssassinSpawn"));
object oAssassin = CreateObject(OBJECT_TYPE_CREATURE, "assassian", lLoc, TRUE);
AssignCommand(oAssassin, ActionAttack(oPC, FALSE));
SetLocalInt(oButler, "RSA_KillInSleep", 0);
SendMessageToAllDMs("Assassin in"+GetName(GetArea(oPC))+" is now toggled off!");
}
}
//End of PRI Mod
}
if(iFOODSYSTEM && iFail==0 && nHasFood==1)
{
if(!DidPCSetUpCamp(oPC) && GetLastRestEventType() == REST_EVENTTYPE_REST_STARTED)
{
if(RestrictPartyRestOnLimitRestHealAndArmorPen(oPC)) return;
iCount = iRESTBREAK;
DelayCommand(1.5, SetRestTime(oPC, iCount));
}
}else if(!iFOODSYSTEM && GetLastRestEventType() == REST_EVENTTYPE_REST_STARTED){
iCount = iRESTBREAK;
DelayCommand(1.5, SetRestTime(oPC, iCount));
}
int nLastRestType=GetLastRestEventType();
if(nLastRestType == REST_EVENTTYPE_REST_FINISHED || nLastRestType == REST_EVENTTYPE_REST_CANCELLED)
{
RemoveSleepBlindness(oPC);
if (iBedroll && iBedUse == 0 && nBARRACK==0 && GetLocalInt(oMod,"LostBedRoll"+sID)==1)
{
ReplaceBedroll(oPC);
DeleteLocalInt(oMod,"LostBedRoll"+sID);
}
//set the variables for the current time to mark the pc as resting
SetLocalInt(oPC,"RESTING",0);
DeleteLocalInt(oPC, "REST");
if(nLastRestType == REST_EVENTTYPE_REST_FINISHED)
{
if(iFOODSYSTEM && !iBedUse) GetFoodEaten(oPC);
if(iFOODSYSTEM && iBedUse) ApplyInnRest(oPC, iBedUse);
// Vampire heal
if(!iFOODSYSTEM) ApplyInnRest(oPC, 4);
iCount = iRESTBREAK;
DelayCommand(1.5, SetRestTime(oPC, iCount));
//SetLocalInt(oMod, "SecSB"+sID, nSSB);
// if(nBARRACK==0) ApplyArmorRestPenalty(oPC);
if(nSRace > 0) SetSubRaceAbilites(oPC, nSRace);
if(!GetIsDM(oPC))
SetLocalInt(oMod, ("LastRest" + sID), nSSB);
effect eConDec = ExtraordinaryEffect(EffectAbilityDecrease(ABILITY_CONSTITUTION,GetLocalInt(oMod,"CONPEN"+sID)));
DelayCommand(1.0, DeleteLocalInt(oMod,"HPStartRest" + sID));
}
if(nLastRestType == REST_EVENTTYPE_REST_CANCELLED)
{
SetSubRaceAbilites(oPC, nSRace);
ResetRestingHP(oPC);
}
DeleteLocalInt(oPC, "BARRACKS");
DeleteLocalInt(oPC, "RSA_BedUse");
DeleteLocalInt(oPC, "RSA_HasRoom");
}
}
Here's the other file:
// Food and Rest Functions
//void main() {}
//::////////////////////////////////////////////
//:: Creating Food follow this model
//:: Food_<type><bonus>
//:: i.e. Food_NORM2
//:: TYPES: POOR, NORM, RICH, MAGI
//:: BONUSES: 0, 1
//::////////////////////////////////////////////
#include "ad_text_rest"
#include "hc_i0_plyrstate"
#include "hc_i0_timecheck"
int HasPCEaten(object oPC);
void EatFood(object oPC, object oFood);
void ClearFood(object oPC);
void GetFoodEaten(object oPC);
void ApplyFoodEffects(object oPC, int nHeal, int nBonus);
// Call on Rest Cancel and player enter.
void ResetRestingHP(object oPC);
object GetPCFamiliar(object oPC);
void pet_rest_dam(object oFam, object oPC, int nAny=0);
int RestrictPartyRestOnLimitRestHealAndArmorPen(object oPC);
void SavePreRestFamiliarHP(object oPC, object oFam);
int IsTooSoonToRest(object oPC, int iMinRest, int nSSB, int nConv);
int IsPCTooWeakToRest(object oPC);
int DidPCSetUpCamp(object oPC);
void ApplyInnRest(object oPC, int nHeal);
// Remove all player spells
void RemoveSpells(object oPC);
// Cook some food
void CookFood(string sTag, object oPC);
//:: FUNCTIONS :://
void CookFood(string sTag, object oPC)
{
if(FindSubString(sTag, "FISH")!= -1)
CreateItemOnObject("fish", oPC);
else if(FindSubString(sTag, "BAT")!= -1)
CreateItemOnObject("food_bat", oPC);
else if(FindSubString(sTag, "BADGER")!= -1)
CreateItemOnObject("food_badger", oPC);
else if(FindSubString(sTag, "BEAR")!= -1)
CreateItemOnObject("food_bear", oPC);
else if(FindSubString(sTag, "VENISON")!= -1)
CreateItemOnObject("food_deer", oPC);
else if(FindSubString(sTag, "FELINE")!= -1)
CreateItemOnObject("food_feline", oPC);
else if(FindSubString(sTag, "WOLF")!= -1)
CreateItemOnObject("food_wolf", oPC);
else
CreateItemOnObject("cookedfood", oPC);
}
void ApplyInnRest(object oPC, int nHeal)
{
object oMod = GetModule();
int nHD=GetHitDice(oPC)*nHeal;
int nSHP=GetLocalInt(oMod,("HPStartRest"+GetName(oPC)+GetPCPublicCDKey(oPC)));
int nDam;
int nLTC;
//Double healing rate if long term care was applied successfully.
if(GetLocalInt(oMod, "LONGTERMCARE"+GetName(oPC)+GetPCPublicCDKey(oPC)) == 2)
nLTC=GetHitDice(oPC)*2;
else
nLTC=0;
if(GetCurrentHitPoints() > (nSHP+nHD+nLTC))
{
nDam=(GetCurrentHitPoints() - (nSHP+nHD+nLTC));
effect eDamage = EffectDamage(nDam);
ApplyEffectToObject( DURATION_TYPE_INSTANT, eDamage, oPC);
}
DeleteLocalInt(oMod, "LONGTERMCARE"+GetName(oPC)+GetPCPublicCDKey(oPC));
object oFam = GetPCFamiliar(oPC);
if(GetIsObjectValid(oFam))
DelayCommand(1.0,pet_rest_dam(oFam, oPC));
}
int DidPCSetUpCamp(object oPC)
{
int nCamp = 1;
// Ranger or Druid go no further
if(GetLevelByClass(CLASS_TYPE_RANGER, oPC)>0 || GetLevelByClass(CLASS_TYPE_DRUID, oPC)>0)
return nCamp;
int nCreatureChance = 79;
object oCamp = GetNearestObjectByTag("hc_campfire", oPC);
if(!GetIsObjectValid(oCamp))
nCamp = 0;
string sID = GetName(oPC) + GetPCPublicCDKey(oPC);
if(GetIsObjectValid(oCamp) && GetDistanceBetween(oPC, oCamp) > 6.0)
{
if(d100() <= nCreatureChance)
{
FloatingTextStringOnCreature(NOCAMP, oPC, FALSE);
AssignCommand(oPC, ClearAllActions());
SetLocalInt(GetModule(), ("LastRest" + sID), SecondsSinceBegin());
}
nCamp = 0;
}
return nCamp;
}
int HasPCEaten(object oPC)
{
int nResult = 0;
if(GetLocalInt(oPC,"FOODHEAL")>0)
{
nResult = 1;
}else{
FloatingTextStringOnCreature(TOOHUNGRY, oPC, FALSE);
AssignCommand( oPC, ClearAllActions());
}
return nResult;
}
void EatFood(object oPC, object oFood)
{
string sTag = GetTag(oFood);
string sType = GetStringRight(GetStringLeft(sTag,9),4);
int nNum = GetStringLength(sTag)-9;
int nBonus = StringToInt(GetStringRight(sTag, nNum));
int nHeal;
if(sType == "POOR") nHeal = 1;
if(sType == "NORM") nHeal = 2;
if(sType == "RICH") nHeal = 3;
if(sType == "MAGI") nHeal = 5;
SetLocalInt(oPC, "FOODHEAL", nHeal);
SetLocalInt(oPC, "FOODBONUS", nBonus);
// Effects valid for 8 hours OR until Rest
DelayCommand(HoursToSeconds(8), DeleteLocalInt(oPC, "FOODHEAL"));
DelayCommand(HoursToSeconds(8), DeleteLocalInt(oPC, "FOODBONUS"));
AssignCommand(oPC, ActionPlayAnimation(ANIMATION_FIREFORGET_SALUTE, 1.0));
DelayCommand(0.8, AssignCommand(oPC, ActionSpeakString(MUNCHFOOD)));
SendMessageToPC(oPC, EATFOOD + " [" + GetName(oFood) + "]");
DestroyObject(oFood);
}
void ClearFood(object oPC)
{
DeleteLocalInt(oPC, "FOODHEAL");
DeleteLocalInt(oPC, "FOODBONUS");
}
void GetFoodEaten(object oPC)
{
int nHeal = GetLocalInt(oPC, "FOODHEAL");
int nBonus = GetLocalInt(oPC, "FOODBONUS");
ApplyFoodEffects(oPC, nHeal, nBonus);
ClearFood(oPC);
}
void ApplyFoodEffects(object oPC, int nHeal, int nBonus)
{
object oMod = GetModule();
int nHD=GetHitDice(oPC)*nHeal;
SpeakString(IntToString(nHD));
int nSHP=GetLocalInt(oMod,("HPStartRest"+GetName(oPC)+GetPCPublicCDKey(oPC)));
SpeakString(IntToString(nSHP));
int nDam;
int nLTC;
//Double healing rate if long term care was applied successfully.
if(GetLocalInt(oMod, "LONGTERMCARE"+GetName(oPC)+GetPCPublicCDKey(oPC)) == 2)
nLTC=GetHitDice(oPC)*2;
else
nLTC=0;
if(GetCurrentHitPoints(oPC) > (nSHP+nHD+nLTC))
{
nDam = GetCurrentHitPoints(oPC) - (nSHP+nHD+nLTC);
effect eDamage = EffectDamage(nDam);
ApplyEffectToObject( DURATION_TYPE_INSTANT, eDamage, oPC);
}
DeleteLocalInt(oMod, "LONGTERMCARE"+GetName(oPC)+GetPCPublicCDKey(oPC));
object oFam = GetPCFamiliar(oPC);
if(GetIsObjectValid(oFam))
DelayCommand(1.0,pet_rest_dam(oFam, oPC));
// Do bonuses
if(nBonus == 0) return;
int nModify = d4() + 1;
float fDuration = RoundsToSeconds(d10());
effect eVis = EffectVisualEffect(VFX_IMP_IMPROVE_ABILITY_SCORE);
effect eBonus, eLink;
if(nBonus ==1){ // Poison Food
SendMessageToPC(oPC, "You start to feel sick.");
SendMessageToAllDMs(GetName(oPC)+" ate some poisoned food!");
effect ePoison = EffectPoison(POISON_TINY_SPIDER_VENOM);
ApplyEffectToObject(DURATION_TYPE_PERMANENT, ePoison, oPC);
}
if(nBonus == 2){ // Hero's Feast
effect eRemove = GetFirstEffect(oPC);
while(GetIsEffectValid(eRemove))
{
if(GetEffectType(eRemove)==EFFECT_TYPE_DISEASE||GetEffectType(eRemove)==EFFECT_TYPE_POISON
||GetEffectType(eRemove)==EFFECT_TYPE_NEGATIVELEVEL)
{
RemoveEffect(oPC, eRemove);
}
ApplyEffectToObject(DURATION_TYPE_INSTANT,EffectHeal(d4()+4),oPC);
}
}
if(nBonus==3){ // Badger
eBonus = EffectAbilityIncrease(ABILITY_STRENGTH,nModify);
eLink = EffectLinkEffects(eBonus, eVis);
ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eLink, oPC, fDuration);
}
if(nBonus==4){ // Feline
eBonus = EffectAbilityIncrease(ABILITY_DEXTERITY,nModify);
eLink = EffectLinkEffects(eBonus, eVis);
ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eLink, oPC, fDuration);
}
if(nBonus==5){ // Wolf
eBonus = EffectMovementSpeedIncrease(30);
eLink = EffectLinkEffects(eBonus, eVis);
ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eLink, oPC, fDuration);
}
DeleteLocalInt(oMod,("HPStartRest"+GetName(oPC)+GetPCPublicCDKey(oPC)));
}
void ResetRestingHP(object oPC)
{
int nSHP=GetLocalInt(GetModule(),("HPStartRest"+GetName(oPC)+GetPCPublicCDKey(oPC)));
if(nSHP == 0 || nSHP>=GetCurrentHitPoints(oPC)) return;
int nRestHP = GetCurrentHitPoints(oPC);
int nDam = nRestHP-nSHP;
effect eDamage = EffectDamage(nDam);
ApplyEffectToObject(DURATION_TYPE_INSTANT, eDamage, oPC);
RemoveSpells(oPC);
SendMessageToAllDMs("WARNING: "+GetName(oPC)+" may be trying to cancel rest to re-gain spells.");
object oFam = GetPCFamiliar(oPC);
if(GetIsObjectValid(oFam))
DelayCommand(1.0,pet_rest_dam(oFam, oPC));
}
object GetPCFamiliar(object oPC)
{
object oFam=GetAssociate(ASSOCIATE_TYPE_FAMILIAR, oPC);
if(!GetIsObjectValid(oFam))
oFam=GetAssociate(ASSOCIATE_TYPE_ANIMALCOMPANION, oPC);
return oFam;
}
void pet_rest_dam(object oFam, object oPC, int nAny=0)
{
int nSHP=GetLocalInt(oPC,"FamiliarHealth");
int nHD=GetHitDice(oPC);
int nRestHP=GetCurrentHitPoints(oFam);
if((nRestHP > nSHP+nHD) || nAny) {
int nDam=(nRestHP-(nSHP+nHD));
if(nAny) nDam=nRestHP-nSHP;
effect eDamage = EffectDamage(nDam,
DAMAGE_TYPE_MAGICAL, DAMAGE_POWER_NORMAL);
ApplyEffectToObject( DURATION_TYPE_INSTANT, eDamage, oFam);
}
}
int RestrictPartyRestOnLimitRestHealAndArmorPen(object oPC)
{
object oPM=GetFirstFactionMember(oPC);
while(GetIsObjectValid(oPM))
{
if(GetLocalInt(oPM,"RESTING") && oPM != oPC)
{
AssignCommand(oPC, ClearAllActions());
SendMessageToPC(oPC,"You cannot rest while another party member is resting, sleep in shifts.");
return 1;
}
oPM=GetNextFactionMember(oPC);
}
return 0;
}
void SavePreRestFamiliarHP(object oPC, object oFam)
{
if(GetIsObjectValid(oFam) && !GetLocalInt(oPC,"RESTING"))
SetLocalInt(oPC,"FamiliarHealth",GetCurrentHitPoints(oFam));
}
int IsTooSoonToRest(object oPC, int iMinRest, int nSSB, int nConv)
{
int nNotOkToRest = 0;
string sRestedText = GetName(oPC) + NOTTIRED;
//First get the time last rested and the current time.
int iLastRest = GetLocalInt(GetModule(), ("LastRest" + GetName(oPC) + GetPCPublicCDKey(oPC)));
if (iLastRest && ((iLastRest+iMinRest) > nSSB))
{
AssignCommand(oPC, ClearAllActions());
sRestedText+=" Try again in ";
if(((iMinRest+iLastRest)-nSSB)/nConv > 0)
sRestedText+=IntToString(((iMinRest+iLastRest)-nSSB)/nConv) + " hours.";
else
sRestedText+=IntToString(((iMinRest+iLastRest)-nSSB)/6)+" minutes.";
FloatingTextStringOnCreature(sRestedText,oPC,FALSE);
nNotOkToRest = 1;
}
return nNotOkToRest;
}
int IsPCTooWeakToRest(object oPC)
{
int nNotOkToRest = 0;
if(GPS(oPC)==PS_RECOVERY)
{
FloatingTextStringOnCreature(NOTWELL, oPC, FALSE);
AssignCommand( oPC, ClearAllActions());
nNotOkToRest = 1;
}
return nNotOkToRest;
}
void RemoveSpells(object oPC)
{
if(!GetIsPC(oPC)) return;
int nSpell, nID, nLoop, nFeat;
for(nID=0; nID < 498; nID++)
{
nSpell = GetHasSpell(nID, oPC);
if(nSpell > 0)
{
for(nLoop=0; nLoop < nSpell; nLoop++)
{
// Only removes 1 use at a time
DecrementRemainingSpellUses(oPC, nID);
}
}
}
for(nID=0; nID < 444; nID++)
{
nFeat = GetHasFeat(nID, oPC);
if(nFeat > 0)
{
for(nLoop=0; nLoop < nFeat; nLoop++)
{
// Only removes 1 use at a time
DecrementRemainingFeatUses(oPC, nID);
}
}
}
}
Sorry for so much spam in this thread, the scripts are pretty big on this module.
#8
Posté 05 septembre 2013 - 12:58
Holy moly that code is awful. Like six different references to LAST_REST_EVENT_STARTED (or whatever that constant is) within main alone at different points. Might have been done with the Script Generator or something.
I think I see part/all of the problem and looking into it more, but I have a serious question: how much do you care about the script? It may be simpler to nuke most of the thing...
I think I see part/all of the problem and looking into it more, but I have a serious question: how much do you care about the script? It may be simpler to nuke most of the thing...
Modifié par MagicalMaster, 05 septembre 2013 - 12:59 .
#9
Posté 05 septembre 2013 - 01:04
Actually, far as I know it was written originally by a coder, but that was back in 2004, as for the script, unfortunately it's tied into the food system and ATS crafting system in spots, so I have to keep it as intact as I can. Removing just about anything could and probably will break other things that are currently being used.
Anyhow, what did you see?
Anyhow, what did you see?
#10
Posté 05 septembre 2013 - 01:56
if(GetLastRestEventType() == REST_EVENTTYPE_REST_STARTED)
nRestHP = GetCurrentHitPoints(oPC);
if(GetLastRestEventType() == REST_EVENTTYPE_REST_STARTED)
{
SavePreRestFamiliarHP(oPC, oFam);
if(iFOODSYSTEM) nHasFood = 0;
SetLocalInt(oMod,"HPStartRest" + sID,nRestHP);
}
if(nLastRestType == REST_EVENTTYPE_REST_CANCELLED)
{
SetSubRaceAbilites(oPC, nSRace);
ResetRestingHP(oPC);
}
Looks like the ResetRestingHP thing is only called if you cancel the rest before finishing. Are you actually completing the rest or did you stop earlier?
Otherwise, if you're actually completing the rest, it looks like the ApplyInnRest is more likely the culprit:
void ApplyInnRest(object oPC, int nHeal)
{
object oMod = GetModule();
int nHD=GetHitDice(oPC)*nHeal;
int nSHP=GetLocalInt(oMod,("HPStartRest"+GetName(oPC)+GetPCPublicCDKey(oPC)));
int nDam;
int nLTC;
//Double healing rate if long term care was applied successfully.
if(GetLocalInt(oMod, "LONGTERMCARE"+GetName(oPC)+GetPCPublicCDKey(oPC)) == 2)
nLTC=GetHitDice(oPC)*2;
else
nLTC=0;
if(GetCurrentHitPoints() > (nSHP+nHD+nLTC))
{
nDam=(GetCurrentHitPoints() - (nSHP+nHD+nLTC));
effect eDamage = EffectDamage(nDam);
ApplyEffectToObject( DURATION_TYPE_INSTANT, eDamage, oPC);
}
DeleteLocalInt(oMod, "LONGTERMCARE"+GetName(oPC)+GetPCPublicCDKey(oPC));
object oFam = GetPCFamiliar(oPC);
if(GetIsObjectValid(oFam))
DelayCommand(1.0,pet_rest_dam(oFam, oPC));
}
Perhaps you could clarify exactly where you were resting and what you did prior to resting? How does the food work in the module?
nRestHP = GetCurrentHitPoints(oPC);
if(GetLastRestEventType() == REST_EVENTTYPE_REST_STARTED)
{
SavePreRestFamiliarHP(oPC, oFam);
if(iFOODSYSTEM) nHasFood = 0;
SetLocalInt(oMod,"HPStartRest" + sID,nRestHP);
}
if(nLastRestType == REST_EVENTTYPE_REST_CANCELLED)
{
SetSubRaceAbilites(oPC, nSRace);
ResetRestingHP(oPC);
}
Looks like the ResetRestingHP thing is only called if you cancel the rest before finishing. Are you actually completing the rest or did you stop earlier?
Otherwise, if you're actually completing the rest, it looks like the ApplyInnRest is more likely the culprit:
void ApplyInnRest(object oPC, int nHeal)
{
object oMod = GetModule();
int nHD=GetHitDice(oPC)*nHeal;
int nSHP=GetLocalInt(oMod,("HPStartRest"+GetName(oPC)+GetPCPublicCDKey(oPC)));
int nDam;
int nLTC;
//Double healing rate if long term care was applied successfully.
if(GetLocalInt(oMod, "LONGTERMCARE"+GetName(oPC)+GetPCPublicCDKey(oPC)) == 2)
nLTC=GetHitDice(oPC)*2;
else
nLTC=0;
if(GetCurrentHitPoints() > (nSHP+nHD+nLTC))
{
nDam=(GetCurrentHitPoints() - (nSHP+nHD+nLTC));
effect eDamage = EffectDamage(nDam);
ApplyEffectToObject( DURATION_TYPE_INSTANT, eDamage, oPC);
}
DeleteLocalInt(oMod, "LONGTERMCARE"+GetName(oPC)+GetPCPublicCDKey(oPC));
object oFam = GetPCFamiliar(oPC);
if(GetIsObjectValid(oFam))
DelayCommand(1.0,pet_rest_dam(oFam, oPC));
}
Perhaps you could clarify exactly where you were resting and what you did prior to resting? How does the food work in the module?
Modifié par MagicalMaster, 05 septembre 2013 - 01:56 .
#11
Posté 05 septembre 2013 - 02:03
I did a full rest sequence with 1hp out of 79, after the rest, the character stood up, I took "someone damages you for X amount of damage" total hp gain for the rest was 3hp. As for the food, as far as I can tell it's simply a means to rest, it doesn't seem like it serves any further purpose, there doesn't "appear" to be a quality difference between a trail ration and a piece of bat jerky. Perhaps, there is something hidden within food that could be the culprit? Maybe if I use a better quality food, I'll end up getting a different result? I'll test it out.
#12
Posté 05 septembre 2013 - 02:12
lol no difference in using bat jerky, I only gained 1hp after resting. What the hell? lol.
#13
Posté 05 septembre 2013 - 02:23
When you get the "someone damages you" message, do you also get a message about how "Damage immunity absorbed X damage" or something similar?
And what level are you with what classes?
And where are you resting?
And what level are you with what classes?
And where are you resting?
#14
Posté 05 septembre 2013 - 02:36
Nope, no damage immunity messages, this is a level 2, resting in a standard newbie zone. I've tried placing the campfire and resting, using several different meats, nothing has changed the amount of hp he gains outside of an inn or barracks. Basically, what I "want" it to do, is give at least 25% the hp back, I mean after all, they are wasting food to rest, it should have some sort of benefit.
#15
Posté 05 septembre 2013 - 03:57
To be perfectly honest I'd be just as satisfied with disabling the damage completely, these days, noone wants to sit there waiting on a restrictive rest system, especially on a pw that isn't focused on RP.
#16
Posté 05 septembre 2013 - 04:03
You have 79 HP at level 2?
But the level 2 explains much - that's why you gained 2 HP back. The script determines that you gain 1 HP per level times a healing factor or something or other.
If you want to disable the damage, comment out every line that looks like
ApplyEffectToObject( DURATION_TYPE_INSTANT, eDamage, oPC);
That should do the trick, I think, without impacting anything else.
But the level 2 explains much - that's why you gained 2 HP back. The script determines that you gain 1 HP per level times a healing factor or something or other.
If you want to disable the damage, comment out every line that looks like
ApplyEffectToObject( DURATION_TYPE_INSTANT, eDamage, oPC);
That should do the trick, I think, without impacting anything else.
#17
Posté 05 septembre 2013 - 04:05
Thanks Magical, I'll go ahead and do that, been drinking a bit tonight, so gonna approach this first thing in the morning. Oh, yeah the char with 79 hp was a level 5, I was switching between local testing and on the server itself since I have duplicate module files. 
Thanks for the help tonight, enjoy the rest of your evening.
Thanks for the help tonight, enjoy the rest of your evening.





Retour en haut






