Author Topic: little help please.  (Read 446 times)

Legacy_zero-feeling

  • Sr. Member
  • ****
  • Posts: 287
  • Karma: +0/-0
little help please.
« on: December 12, 2010, 01:24:38 am »


               so i have this simple script to make placeables glow when a player eners the area:

void main()
{
object oPC = GetEnteringObject();
if (!GetIsPC(oPC)) return;
int nGlow;
object oObject = GetFirstObjectInArea(OBJECT_SELF);
 while(oObject != OBJECT_INVALID)
 {
  if(GetTag(oObject) == "glow_item" && GetLocalInt(oObject,"GLOW") == 0)
  {
  ApplyEffectToObject(DURATION_TYPE_PERMANENT,EffectVisualEffect(VFX_DUR_GLOW_BLUE),oObject);
  SetLocalInt(oObject,"GLOW",1);
  }
 oObject = GetNextObjectInArea(OBJECT_SELF);
 }
}

what i would like help with is making it more versitile, making it be able to handle multiple colors via variables on the placeables.

example: GLOW_BLUE int 1, GLOW_RED int 2, GLOW_GREEN int 3, ect...

not so good at doing variables such as this and have nothing to base an attempt off, so any help would be appreciated.

of course, if theres an even easier way to do this type of script, thats always welcome as well.

thanks
               
               

               
            

Legacy_Baragg

  • Sr. Member
  • ****
  • Posts: 496
  • Karma: +0/-0
little help please.
« Reply #1 on: December 12, 2010, 01:53:40 am »


               Here I added a check for an int on the placeables called "COLOR_GLOW". The numbers go from 0 to 6. So place any of those numbers on your placeable as a int local, and they should glow the appropriate color.


void main()
{
object oPC = GetEnteringObject();
if (!GetIsPC(oPC)) return;
int nGlow, nColor;
object oObject = GetFirstObjectInArea(OBJECT_SELF);

 while(oObject != OBJECT_INVALID)
 {
  if(GetTag(oObject) == "glow_item" && GetLocalInt(oObject,"GLOW") == 0)
  {
   nColor = GetLocalInt(oObject, "COLOR_GLOW");
   switch(nColor)
   {
    case 0://glow blue
        ApplyEffectToObject(DURATION_TYPE_PERMANENT,EffectVisualEffect(VFX_DUR_GLOW_BLUE),oObject);
        SetLocalInt(oObject,"GLOW",1);
        break;
    case 1://glow green
        ApplyEffectToObject(DURATION_TYPE_PERMANENT,EffectVisualEffect(VFX_DUR_GLOW_GREEN),oObject);
        SetLocalInt(oObject,"GLOW",1);
        break;
    case 2://glow orange
        ApplyEffectToObject(DURATION_TYPE_PERMANENT,EffectVisualEffect(VFX_DUR_GLOW_ORANGE),oObject);
        SetLocalInt(oObject,"GLOW",1);
        break;
    case 3://glow purple
        ApplyEffectToObject(DURATION_TYPE_PERMANENT,EffectVisualEffect(VFX_DUR_GLOW_PURPLE),oObject);
        SetLocalInt(oObject,"GLOW",1);
        break;
    case 4://glow red
        ApplyEffectToObject(DURATION_TYPE_PERMANENT,EffectVisualEffect(VFX_DUR_GLOW_RED),oObject);
        SetLocalInt(oObject,"GLOW",1);
        break;
    case 5://glow white
        ApplyEffectToObject(DURATION_TYPE_PERMANENT,EffectVisualEffect(VFX_DUR_GLOW_WHITE),oObject);
        SetLocalInt(oObject,"GLOW",1);
        break;
    case 6://glow yellow
        ApplyEffectToObject(DURATION_TYPE_PERMANENT,EffectVisualEffect(VFX_DUR_GLOW_YELLOW),oObject);
        SetLocalInt(oObject,"GLOW",1);
        break;
    default:
        break;
   }
  }
 oObject = GetNextObjectInArea(OBJECT_SELF);
 }
}



               
               

               


                     Modifié par Baragg, 12 décembre 2010 - 01:56 .
                     
                  


            

Legacy_zero-feeling

  • Sr. Member
  • ****
  • Posts: 287
  • Karma: +0/-0
little help please.
« Reply #2 on: December 12, 2010, 02:29:18 am »


               sweet, thanks baragg '<img'>
               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
little help please.
« Reply #3 on: December 12, 2010, 02:30:25 am »


               Here is my version.

 int GetGlowFromTag(string sTag)
{
  if (sTag=="GLOW_LIGHT_BLUE")    return VFX_DUR_GLOW_LIGHT_BLUE;
  if (sTag=="GLOW_PURPLE")        return VFX_DUR_GLOW_PURPLE;
  if (sTag=="GLOW_RED")           return VFX_DUR_GLOW_RED;
  if (sTag=="GLOW_LIGHT_RED")     return VFX_DUR_GLOW_LIGHT_RED;
  if (sTag=="GLOW_YELLOW")        return VFX_DUR_GLOW_YELLOW;
  if (sTag=="GLOW_LIGHT_YELLOW")  return VFX_DUR_GLOW_LIGHT_YELLOW;
  if (sTag=="GLOW_GREEN")         return VFX_DUR_GLOW_GREEN;
  if (sTag=="GLOW_LIGHT_GREEN")   return VFX_DUR_GLOW_LIGHT_GREEN;
  if (sTag=="GLOW_ORANGE")        return VFX_DUR_GLOW_ORANGE;
  if (sTag=="GLOW_LIGHT_ORANGE")  return VFX_DUR_GLOW_LIGHT_ORANGE;
  if (sTag=="GLOW_BROWN")         return VFX_DUR_GLOW_BROWN;
  if (sTag=="GLOW_LIGHT_BROWN")   return VFX_DUR_GLOW_LIGHT_BROWN;
  if (sTag=="GLOW_GREY")          return VFX_DUR_GLOW_GREY;
  if (sTag=="GLOW_WHITE")         return VFX_DUR_GLOW_WHITE;
  if (sTag=="GLOW_LIGHT_PURPLE")  return VFX_DUR_GLOW_LIGHT_PURPLE;
  return VFX_DUR_GLOW_BLUE;  // Default color if a correct one is not found.
}
void main()
{
object oPC = GetEnteringObject();
if (!GetIsPC(oPC)) return;
//int nGlow;// This was never used in the script.
string sTag;
object oObject = GetFirstObjectInArea(OBJECT_SELF);
 while(oObject != OBJECT_INVALID)
 {
  sTag=GetStringUpperCase(GetTag(oObject));
  if( GetStringLeft(sTag,5) == "GLOW_" && GetLocalInt(oObject,"GLOW") == 0)
  {
  ApplyEffectToObject(DURATION_TYPE_PERMANENT,EffectVisualEffect(GetGlowFromTag(sTag)),oObject);
  SetLocalInt(oObject,"GLOW",1);
  }
 oObject = GetNextObjectInArea(OBJECT_SELF);
 }
}


Your tags will not need the number just use the color you want. 

example: GLOW_BLUE , GLOW_RED , GLOW_GREEN ,  Glow_Purple ect...
               
               

               
            

Legacy_eeriegeek

  • Jr. Member
  • **
  • Posts: 75
  • Karma: +0/-0
little help please.
« Reply #4 on: December 12, 2010, 04:50:01 am »


               Just for fun you could add a case 7 to Baraag's script with:

ApplyEffectToObject(DURATION_TYPE_PERMANENT,EffectVisualEffect((408+Random(16)),oObject);

to get a random glow color.
               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
little help please.
« Reply #5 on: December 12, 2010, 05:10:51 am »


               Or to add it to mine just add.

if (sTag=="GLOW_RANDOM") return random(16)+408;

To the GetGlowFromTag function to do the same thing.
               
               

               


                     Modifié par Lightfoot8, 12 décembre 2010 - 05:11 .
                     
                  


            

Legacy_zero-feeling

  • Sr. Member
  • ****
  • Posts: 287
  • Karma: +0/-0
little help please.
« Reply #6 on: December 12, 2010, 09:10:15 am »


               lol... thanks you guys, always like seeing alternative ways to do things... helps me learn better
               
               

               
            

Legacy_Baragg

  • Sr. Member
  • ****
  • Posts: 496
  • Karma: +0/-0
little help please.
« Reply #7 on: December 12, 2010, 01:13:25 pm »


               Actually seeing Lightfoot8s way, I like it better.