Aller au contenu

Photo

Need help with custom item script


  • Veuillez vous connecter pour répondre
3 réponses à ce sujet

#1
lando005

lando005
  • Members
  • 3 messages
I've been working on a custom item script for a sword which I've done several other scripts just like this one, only this time the item activation script is not working in any of the campaings and I cant figure out why.  I've tested the item in a test module and everything works beautifly and once I take the item to the campaing only 2 of the 3 scripts I wrote are functioning.  The scripts are in my override directory and everything is as it should be I just cant get it to work. [script/]void main()
{
    object oPC      = GetItemActivator();
    object oItem    = GetItemActivated();
    object oTarget  = GetItemActivatedTarget();
    location lTarget = GetItemActivatedTargetLocation();
    int nCha = GetAbilityScore(oPC,ABILITY_CHARISMA);
    int nDC = d6(nCha);
    int nDamage = d6(nCha);
    vector vTarget = Vector(0.0,0.0,0.0);
    nDamage = GetReflexAdjustedDamage(nDamage, oTarget, nDC, SAVING_THROW_REFLEX);
    effect eFire = EffectDamage(nDamage,DAMAGE_TYPE_FIRE,DAMAGE_POWER_NORMAL);
    effect eIce = EffectDamage(nDamage,DAMAGE_TYPE_COLD,DAMAGE_POWER_NORMAL);
    effect eAcid = EffectDamage(nDamage,DAMAGE_TYPE_ACID,DAMAGE_POWER_NORMAL);
    effect eElec = EffectDamage(nDamage,DAMAGE_TYPE_ELECTRICAL,DAMAGE_POWER_NORMAL);
    effect eBeam = EffectBeam(VFX_BEAM_PRISMATIC_SPRAY, oPC, BODY_NODE_HAND);
    effect eHit1 = EffectNWN2SpecialEffectFile("sp_fire_hit.sef", OBJECT_INVALID, vTarget);
    effect eHit2 = EffectNWN2SpecialEffectFile("sp_ice_hit.sef", OBJECT_INVALID, vTarget);
    effect eHit3 = EffectNWN2SpecialEffectFile("sp_acid_hit.sef", OBJECT_INVALID, vTarget);
    effect eHit4 = EffectNWN2SpecialEffectFile("sp_lightning_hit.sef", OBJECT_INVALID, vTarget);

     //Your code goes here
    if(GetIsReactionTypeHostile(oTarget, oPC))
    {
        oTarget = GetFirstObjectInShape(SHAPE_CONE, RADIUS_SIZE_HUGE, lTarget, TRUE, OBJECT_TYPE_CREATURE | OBJECT_TYPE_DOOR | OBJECT_TYPE_PLACEABLE, vTarget);
        while (GetIsEnemy(oTarget, oPC))
        {
            SetImmortal(oTarget, FALSE);
            ApplyEffectToObject(DURATION_TYPE_INSTANT, eFire, oTarget);
            ApplyEffectToObject(DURATION_TYPE_INSTANT, eIce, oTarget);
            ApplyEffectToObject(DURATION_TYPE_INSTANT, eAcid, oTarget);
            ApplyEffectToObject(DURATION_TYPE_INSTANT, eElec, oTarget);
            oTarget = GetNextObjectInShape(SHAPE_CONE, RADIUS_SIZE_HUGE, lTarget, TRUE, OBJECT_TYPE_CREATURE | OBJECT_TYPE_DOOR | OBJECT_TYPE_PLACEABLE, vTarget);
            
            ApplyEffectToObject(DURATION_TYPE_TEMPORARY,eHit1,oTarget, 1.0);
            ApplyEffectToObject(DURATION_TYPE_TEMPORARY,eHit2,oTarget, 1.0);
            ApplyEffectToObject(DURATION_TYPE_TEMPORARY,eHit3,oTarget, 1.0);
            ApplyEffectToObject(DURATION_TYPE_TEMPORARY,eHit4,oTarget, 1.0);
            ApplyEffectToObject(DURATION_TYPE_TEMPORARY,eBeam,oTarget, 1.0);
        }        
    }
}[script]

Modifié par lando005, 16 janvier 2011 - 12:54 .


#2
Kaldor Silverwand

Kaldor Silverwand
  • Members
  • 1 598 messages
There is no difference between a tag-based script being in a module or in a campaign. None at all. So moving the scripts to the campaign folder is not the source of your problems. Look elsewhere.



If you are trying to use the item in a campaign or module written by someone else then it may be that they don't allow tag-based scripts. Some of the modules in the vault do not.



I'm not familiar with the GetIsReactionTypeHostile function. I would use GetIsEnemy.



Regards

#3
lando005

lando005
  • Members
  • 3 messages
I already am using the GetIsEnemy function and also I put the script in the my documents override folder just like every other script I've made as far as I can tell everything should be right, I've tried it in a test module and it works but when I load the maing campaign or any of the other add ons this is the only script that wont run.

#4
lando005

lando005
  • Members
  • 3 messages
I figured it out, it's because the shape I was using was a cone, once I switched to a sphere it worked. Now the only thing I need to do is figure out how I can get it to show the combat damage that was done once the script is ran instead of just saying that I used the items special power.