Aller au contenu

Photo

Aura Heartbeat Script


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

#1
Imperator

Imperator
  • Members
  • 64 messages

I'm trying to make a script which will shoot lightning out at nearby targets.. the closer they are the more likely it'll fire.

 

<= 5 meters is 100%

<=10 meters is 50%

<=20 meters is 20%

 

object oZap_c = GetNearestObject(OBJECT_TYPE_PLACEABLE, OBJECT_SELF, 1);
object oZap_p = GetNearestObject(OBJECT_TYPE_CREATURE, OBJECT_SELF, 1);

eVFX = EffectVisualEffect(VFX_BEAM_LIGHTNING);

ApplyEffectToObject(DURATION_TYPE_INSTANT, eVFX, oZap_c);

ApplyEffectToObject(DURATION_TYPE_INSTANT, eVFX, oZap_p);

 

can anyone help me out so it'll find targets as it moves? I don't necessarily need any help with the distances/ifs/frequencies.



#2
KMdS!

KMdS!
  • Members
  • 189 messages

Will this need to check for all targets within range so as to fire upon all that fail the check (muliple bolts possible) or are you running this so that only one bolt will strike out per hb cycle and therefore search only until a single target fails or no bole occurs that specific iteration?



#3
Imperator

Imperator
  • Members
  • 64 messages

Actually, the first sounds like a good idea. and I'll only have it be a 5 meter radius, multiple bolts hitting every object within that area.



#4
Imperator

Imperator
  • Members
  • 64 messages

Also, is it possible to get a random location with in a certain area around an object to strike lightning at?



#5
Imperator

Imperator
  • Members
  • 64 messages

Nevermind, I figured it out haha. At least the first question, not the second one just above :P



#6
KMdS!

KMdS!
  • Members
  • 189 messages

Without any NW materials on hand at the moment, here is what you might need to do to get a random location within 5m of your bolt caating object.

    //OBJECT_SELF should be the bolt creating object
    vector vVector = GetPosition(OBJECT_SELF);
    // Will generate a value for x anf y between -5.00 to 5.00
    // a Value of 0.0, 0.0 should occur only once in a million
    float fX = IntToFloat(Random(1001)-500);
    float fY = IntToFloat(Random(1001)-500);
 
    // This is the new random vector for the strike location up to 5m away and one meter high.
    vector vNew = (vVector.x +fX, vVector.y +fY, 1.0);

  • Imperator aime ceci

#7
Imperator

Imperator
  • Members
  • 64 messages

Thank you for the reply. I'm trying to think how I could use the locations created though.. since I can't use something like "GetNextLocationInShape." I guess I could if I scripted that but I dunno how. :D

 

Would it be possible for those locations to also create a temporary object/waypoint so it could be incorporated into this script?

 

 

// Aura for lightning Azer, onHeartbeat
void main()
{
effect eVFX;
location lSelf = GetLocation(OBJECT_SELF);
{
object oZap = GetFirstObjectInShape(SHAPE_SPHERE, 5.0, lSelf , TRUE,OBJECT_TYPE_ALL);
eVFX = EffectVisualEffect(VFX_BEAM_LIGHTNING);
ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eVFX, oZap, 1.0);


while(GetIsObjectValid(oZap) &&
GetDistanceToObject(oZap) <= 5.0)
{
oZap = GetNextObjectInShape(SHAPE_SPHERE, 5.0, lSelf , TRUE, OBJECT_TYPE_ALL);
ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eVFX, oZap, 1.0);
effect eElectric = EffectDamage(d6(2), DAMAGE_TYPE_ELECTRICAL, DAMAGE_POWER_NORMAL);
ApplyEffectToObject(DURATION_TYPE_INSTANT, eElectric, oZap);
}
}
}
 



#8
KMdS!

KMdS!
  • Members
  • 189 messages

Ok, Try This. It compiles, but I haven't tested it.


// Aura for lightning Azer, onHeartbeat
 
vector RandomVector(int iMeterRadius = 5)
{
    //OBJECT_SELF should be the bolt creating object
    vector vVector = GetPosition(OBJECT_SELF);
    // Will generate a value for x anf y between -5.00 to 5.00
    // a Value of 0.0, 0.0 should occur only once in a million
    float fX = IntToFloat(Random((iMeterRadius*200)+1)-(iMeterRadius*100))/100;
    float fY = IntToFloat(Random((iMeterRadius*200)+1)-(iMeterRadius*100))/100;
 
    // This is the new random vector for the strike location up to 5m away and one meter high.
    return Vector(vVector.x +fX, vVector.y +fY, 0.0);
}
 
 
void main()
{
    effect eVFX;
    location lSelf = GetLocation(OBJECT_SELF);
    {
        int iCount=0;
        object oZap = GetFirstObjectInShape(SHAPE_SPHERE, 5.0, lSelf , TRUE, OBJECT_TYPE_ALL);
        eVFX = EffectVisualEffect(VFX_BEAM_LIGHTNING);
        while(GetIsObjectValid(oZap))
        {
            if(oZap == OBJECT_SELF)
            {
                oZap = GetNextObjectInShape(SHAPE_SPHERE, 5.0, lSelf , TRUE, OBJECT_TYPE_ALL);
                continue;
            }
            ++iCount;
            ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eVFX, oZap, 1.0);
            effect eElectric = EffectDamage(d6(2), DAMAGE_TYPE_ELECTRICAL);
            ApplyEffectToObject(DURATION_TYPE_INSTANT, eElectric, oZap);
            oZap = GetNextObjectInShape(SHAPE_SPHERE, 5.0, lSelf , TRUE, OBJECT_TYPE_ALL);
        }
        int i;
        object oRandomTarget = OBJECT_INVALID;
        for(i=0; i<(-iCount+3); i++)
        {
            oRandomTarget = CreateObject(OBJECT_TYPE_PLACEABLE, "plc_invisobj", Location(GetArea(OBJECT_SELF), RandomVector(), 0.0));
            ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eVFX, oRandomTarget, 1.0);
            SetIsDestroyable(1,0,0);
            DestroyObject(oRandomTarget, 1.0);
        }
    }
}

  • Imperator aime ceci

#9
KMdS!

KMdS!
  • Members
  • 189 messages

Haha, I just tested it and realized I forgot to exclude the OBJECT SELF, I keep getting hit by the effect, hold off a bit while I fix this.

 

Edit*

 

I fixed it, works really cute, but if you want it to target everything, it will do just that. You will need to set up an exclusion set of items that won't get targeted. You'll see what I mean once you try it. :blink:  I set a default of up to three miscellaneous strikes should there be less than 3 bolts per heartbeat.

 

The code above is the corrected version. Have fun. :D  :D  :D


  • thirdmouse et Imperator aiment ceci

#10
Imperator

Imperator
  • Members
  • 64 messages

thank you so much!

 

coolest_thing_ever.jpg

 

That has gotta be one of the coolest things I've ever seen in nwn :P I need to make a video of it! Most of the credit goes to you though, I wouldn't have been able to program that myself LOL.


  • Taino aime ceci

#11
KMdS!

KMdS!
  • Members
  • 189 messages

HA!!! Just thought the idea was interesting. I had fun with it myself on my server and had to quit to post the work. Took an hour before I could stop.... :D


  • Taino aime ceci