EffectDamage();
Zephirius
Member Posts: 419
I can't figure out why I'm not being damaged 1 HP of cold damage in this script???
Any help would be greatly appreciated.
void main()
{
object oPC = GetNearestCreature
(CREATURE_TYPE_PLAYER_CHAR, PLAYER_CHAR_IS_PC, OBJECT_SELF);
if (!GetIsPC(oPC)) return;
/*int DoOnce = GetLocalInt(OBJECT_SELF, GetTag(OBJECT_SELF));
if (DoOnce==TRUE)
{
return;
}
SetLocalInt(OBJECT_SELF, GetTag(OBJECT_SELF), TRUE);*/
int nDie = d20();
if (nDie>=10)
{
effect eCold = EffectVisualEffect(VFX_IMP_HEAD_COLD);
ApplyEffectToObject(DURATION_TYPE_INSTANT, eCold, oPC);
effect eDamage = EffectDamage(1, DAMAGE_TYPE_COLD, DAMAGE_POWER_NORMAL);
ApplyEffectToObject(DURATION_TYPE_INSTANT, eDamage, oPC);
ApplyEffectToObject(DURATION_TYPE_INSTANT, eCold, oPC);
}
}
\Any help would be greatly appreciated.
0
Comments
I would add some debug messages (name of oPC, nDie,...).
You apply the visual effect eCold twice btw.
[edit]Your script works fine for me btw. Which object runs the heartbeat script? A placeable I guess?[/edit]
Not sure what that /* is doing.
The simplest way to debug is to insert SendMessageToPC() calls to display data values at key points, such as PC name after the GetNearestCreature call.
Why not put a placeable in that area and let the placeable run the script?
object oPC = GetFirstPC(); //OBJECT_SELF would be the area if put in the area's HB event while( GetIsObjectValid(oPC) && GetArea(oPC) == OBJECT_SELF ) { //do cold damage and VFX oPC = GetNextPC(); }This loop will find all the PCs in the area, whereas yours just finds whichever is deemed closest to the trigger.
The DoOnce part of the script seems odd to pair with a heartbeat event. The script would potentially do damage once to the player a few seconds after they enter the area, then continue to run every 6 seconds but exit out every time after that. Seems like it should be run once in the OnEnter of the area with the damage and VFX done thru something like: DelayCommand(GetRandomDelay(4.0,15.0),DoColdandVFX());
Anyway, glad you got it working.
90% of my time is debugging. My favorite way to narrow things down is to just add a SendMessageToPC to help narrow down where something is working how I would like. for example.
void main() { object oPC = GetNearestCreature(CREATURE_TYPE_PLAYER_CHAR, PLAYER_CHAR_IS_PC, OBJECT_SELF); SendMessageToPC(oPC, "Step 1. we see the PC "); if (!GetIsPC(oPC)) return; /*int DoOnce = GetLocalInt(OBJECT_SELF, GetTag(OBJECT_SELF)); SendMessageToPC(oPC, "Step 2. Is DoOnce doing what we think it should? " + IntToString(DoOnce)); if (DoOnce==TRUE) { return; } SetLocalInt(OBJECT_SELF, GetTag(OBJECT_SELF), TRUE);*/ int nDie = d20(); SendMessageToPC(oPC, "Step 3. What did it roll? " + IntToString(nDie)); if (nDie>=10) { SendMessageToPC(oPC, "Step 4. Sweet! Lets hurt something! "); effect eCold = EffectVisualEffect(VFX_IMP_HEAD_COLD); ApplyEffectToObject(DURATION_TYPE_INSTANT, eCold, oPC); effect eDamage = EffectDamage(1, DAMAGE_TYPE_COLD, DAMAGE_POWER_NORMAL); ApplyEffectToObject(DURATION_TYPE_INSTANT, eDamage, oPC); ApplyEffectToObject(DURATION_TYPE_INSTANT, eCold, oPC); } }