Author Topic: just learning to script, but I need a script that does this for my mod  (Read 292 times)

Legacy_harjoblog

  • Newbie
  • *
  • Posts: 38
  • Karma: +0/-0


                I am at the very beginning of learning to script. So I do not know much about it. The script I need will do this once a PC enters a trigger

if pc has armor1 or armor2 or armor3 or armor4 or armor5 equipped do nothing
otherwise 1 point of damage is dealt to PC

so if the pc isn't wearing one of the 5 armors listed, they are damaged 1 point everytime they enter the trigger

I have this working with only one item, but I do not know how to make the script check for one of the five armors equiped.
This is my script for one item working from the script generator, but again, I don't know enough about scripting to be able to have the generator have or conditions nor do I know about scripting to write it out by hand.
any help is appreciated.

[       
/*  *  Script generated by LS Script Generator, v.TK.0 * *  For download info, please visit: *  http://nwvault.ign.c...il&id=1502 */// Put this script OnEnter.

void main(){    effect eVFX;    effect eDamage;
    // Get the creature who triggered this event.    object oPC = GetEnteringObject();
    // Only fire for (real) PCs.    if ( !GetIsPC(oPC)  ||  GetIsDMPossessed(oPC) )        return;
    // If the PC does not have the item "coldprotectarmorlight" equipped.    if ( "coldprotectarmorlight" != GetTag(GetItemInSlot(INVENTORY_SLOT_CHEST, oPC)) )    {        // Cause damage.        eDamage = EffectDamage(1, DAMAGE_TYPE_COLD);        eVFX = EffectVisualEffect(VFX_COM_HIT_FROST);        ApplyEffectToObject(DURATION_TYPE_INSTANT, eDamage, oPC)        ApplyEffectToObject(DURATION_TYPE_INSTANT, eVFX   , oPC)    }} ]
               
               

               


                     Modifié par harjoblog, 10 juillet 2012 - 09:47 .
                     
                  


            

Legacy_harjoblog

  • Newbie
  • *
  • Posts: 38
  • Karma: +0/-0
just learning to script, but I need a script that does this for my mod
« Reply #1 on: July 10, 2012, 10:45:38 pm »


               
               
               

               


                     Modifié par harjoblog, 10 juillet 2012 - 09:46 .
                     
                  


            

Legacy_GhostOfGod

  • Hero Member
  • *****
  • Posts: 1490
  • Karma: +0/-0
just learning to script, but I need a script that does this for my mod
« Reply #2 on: July 10, 2012, 10:48:15 pm »


               Could do something like so:


void main()
{
    // Get the creature who triggered this event.
    object oPC = GetEnteringObject();
    effect eVFX;
    effect eDamage;
    string sTag = GetTag(GetItemInSlot(INVENTORY_SLOT_CHEST, oPC));
    // Only fire for (real) PCs.
    if ( !GetIsPC(oPC)  ||  GetIsDMPossessed(oPC) ) return;
    // If the PC does not have the item "coldprotectarmorlight" equipped.
    if ( sTag != "coldprotectarmorlight" ||
         sTag != "" ||
         sTag != "" ||
         sTag != "" ||
         sTag != "")
    {
        // Cause damage.
        eDamage = EffectDamage(1, DAMAGE_TYPE_COLD);
        eVFX = EffectVisualEffect(VFX_COM_HIT_FROST);
        ApplyEffectToObject(DURATION_TYPE_INSTANT, eDamage, oPC);
        ApplyEffectToObject(DURATION_TYPE_INSTANT, eVFX   , oPC);
    }
}

Just fill in your other tags.
Hope that helps.
               
               

               


                     Modifié par GhostOfGod, 10 juillet 2012 - 09:48 .
                     
                  


            

Legacy_harjoblog

  • Newbie
  • *
  • Posts: 38
  • Karma: +0/-0
just learning to script, but I need a script that does this for my mod
« Reply #3 on: July 10, 2012, 11:05:31 pm »


               I tried it and it does damage but it ignores the tags of the armor if they're worn
               
               

               
            

Legacy_Failed.Bard

  • Hero Member
  • *****
  • Posts: 1409
  • Karma: +0/-0
just learning to script, but I need a script that does this for my mod
« Reply #4 on: July 10, 2012, 11:57:33 pm »


               

GhostOfGod wrote...


    if ( sTag != "coldprotectarmorlight" ||
         sTag != "" ||
         sTag != "" ||
         sTag != "" ||
         sTag != "")
 


  Those should be ands, not ors:

     if ( sTag != "coldprotectarmorlight" &&
         sTag != "" &&
         sTag != "" &&
         sTag != "" &&
         sTag != "")
               
               

               


                     Modifié par Failed.Bard, 10 juillet 2012 - 10:58 .
                     
                  


            

Legacy_GhostOfGod

  • Hero Member
  • *****
  • Posts: 1490
  • Karma: +0/-0
just learning to script, but I need a script that does this for my mod
« Reply #5 on: July 11, 2012, 12:53:11 am »


               Oh jeez sorry bout that. Thanks FB. Done "||" so much with "==" I wasn't paying attention to the backwards thinking. ':whistle:'
               
               

               
            

Legacy_harjoblog

  • Newbie
  • *
  • Posts: 38
  • Karma: +0/-0
just learning to script, but I need a script that does this for my mod
« Reply #6 on: July 11, 2012, 04:57:07 am »


               Thanks guys, It's still not working so I'm not sure what I'm doing wrong. I've triple checked all the tags to make sure they're right. I'm putting this script on enter of the generic trigger.

[void main()
{
   // Get the creature who triggered this event.
   object oPC = GetEnteringObject();
   effect eVFX;
   effect eDamage;
   string sTag = GetTag(GetItemInSlot(INVENTORY_SLOT_CHEST, oPC));
   // Only fire for (real) PCs.
   if ( !GetIsPC(oPC)  ||  GetIsDMPossessed(oPC) ) return;
   // If the PC does not have the item "coldprotectarmorlight" equipped.
   if ( sTag != "coldprotectarmorlight"&&
        sTag != "coldprotectionarmorcloth01"&&
        sTag != "coldprotectionarmorcloth02"&&
        sTag != "coldprotectionarmormedium"&&
        sTag != "coldprotectionarmorheavy")
   {
       // Cause damage.
       eDamage = EffectDamage(1, DAMAGE_TYPE_COLD);
       eVFX = EffectVisualEffect(VFX_COM_HIT_FROST);
       ApplyEffectToObject(DURATION_TYPE_INSTANT, eDamage, oPC);
       ApplyEffectToObject(DURATION_TYPE_INSTANT, eVFX   , oPC);
   }
}]

but I still can't get it to not fire the damage when wearing one of the listed armors.
               
               

               
            

Legacy_ShadowM

  • Hero Member
  • *****
  • Posts: 1373
  • Karma: +0/-0
just learning to script, but I need a script that does this for my mod
« Reply #7 on: July 11, 2012, 05:36:05 am »


               void main()
{
// Get the creature who triggered this event.
object oPC = GetEnteringObject();
effect eVFX = EffectVisualEffect(VFX_COM_HIT_FROST);
effect eDamage = EffectDamage(1, DAMAGE_TYPE_COLD,DAMAGE_POWER_NORMAL);
string sTag = GetTag(GetItemInSlot(INVENTORY_SLOT_CHEST, oPC));
// Only fire for (real) PCs.
if (!GetIsPC(oPC) || GetIsDMPossessed(oPC) ) return;
// If the PC does not have the item "coldprotectarmorlight" equipped.
if ( sTag == "coldprotectarmorlight"||
sTag == "coldprotectionarmorcloth01"||
sTag == "coldprotectionarmorcloth02"||
sTag == "coldprotectionarmormedium"||
sTag == "coldprotectionarmorheavy")return;

// Cause damage.
ApplyEffectToObject(DURATION_TYPE_INSTANT, eDamage, oPC);
ApplyEffectToObject(DURATION_TYPE_INSTANT, eVFX , oPC);
}
               
               

               
            

Legacy_harjoblog

  • Newbie
  • *
  • Posts: 38
  • Karma: +0/-0
just learning to script, but I need a script that does this for my mod
« Reply #8 on: July 11, 2012, 06:15:10 am »


               I still couldn't get it to not damage when pc enter the trigger, so I had to make one item that canceled the trigger damage instead of multiple ones. Thanks for all you guys help.
               
               

               
            

Legacy_ShadowM

  • Hero Member
  • *****
  • Posts: 1373
  • Karma: +0/-0
just learning to script, but I need a script that does this for my mod
« Reply #9 on: July 11, 2012, 05:10:53 pm »


               That means your tags are wrong , I tested it in game and worked fine. And this is only for chest piece not other equped items
               
               

               
            

Legacy_harjoblog

  • Newbie
  • *
  • Posts: 38
  • Karma: +0/-0
just learning to script, but I need a script that does this for my mod
« Reply #10 on: July 12, 2012, 06:29:27 am »


               It is working, I remade the items with the proper tags, (my eyes must have been wearing when I kept testing it out, since one tag was right, but the character I was using couldn't wear that armor) I thank you guys for your help and I'm glad to see people are still doing this kind of help for such an old game.
Thanks again.