Aller au contenu

Photo

little help please.


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

#1
zero-feeling

zero-feeling
  • Members
  • 144 messages
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

#2
Baragg

Baragg
  • Members
  • 271 messages
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 .


#3
zero-feeling

zero-feeling
  • Members
  • 144 messages
sweet, thanks baragg :)

#4
Lightfoot8

Lightfoot8
  • Members
  • 2 535 messages
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...

#5
eeriegeek

eeriegeek
  • Members
  • 47 messages
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.

#6
Lightfoot8

Lightfoot8
  • Members
  • 2 535 messages
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 .


#7
zero-feeling

zero-feeling
  • Members
  • 144 messages
lol... thanks you guys, always like seeing alternative ways to do things... helps me learn better

#8
Baragg

Baragg
  • Members
  • 271 messages
Actually seeing Lightfoot8s way, I like it better.