Aller au contenu

Photo

Need Help Modifying A Heartbeat Script


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

#1
A Darker Shade of Soul

A Darker Shade of Soul
  • Members
  • 85 messages
Can someone show me how to convert this over from a heartbeat script to an on_open script please?

[nwscript]//::///////////////////////////////////////////////
//:: NW_O2_SKELETON.nss
//:: Copyright © 2001 Bioware Corp.
//:://////////////////////////////////////////////
/*
   Turns the placeable into a skeleton
   if a player comes near enough.
*/
//:://////////////////////////////////////////////
//:: Created By:   Brent
//:: Created On:   January 17, 2002
//:://////////////////////////////////////////////
void ActionCreate(string sCreature, location lLoc)
{
    CreateObject(OBJECT_TYPE_CREATURE, sCreature, lLoc);
}
void main()
{
   object oCreature = GetNearestCreature(CREATURE_TYPE_PLAYER_CHAR, PLAYER_CHAR_IS_PC);
   if (GetIsObjectValid(oCreature) == TRUE && GetDistanceToObject(oCreature) < 10.0)
   {
    effect eMind = EffectVisualEffect(VFX_FNF_SUMMON_UNDEAD);
    string sCreature = "NW_SKELWARR01";
    // * 10% chance of a skeleton chief instead
    if (Random(100) > 90)
    {
        sCreature = "NW_SKELCHIEF";
    }
    location lLoc = GetLocation(OBJECT_SELF);
    DelayCommand(0.3, ActionCreate(sCreature, lLoc));
    ApplyEffectAtLocation(DURATION_TYPE_INSTANT, eMind, GetLocation(OBJECT_SELF));
    SetPlotFlag(OBJECT_SELF, FALSE);
    DestroyObject(OBJECT_SELF, 0.5);
   }
}[/nwscript]

Modifié par A Darker Shade of Soul, 30 janvier 2011 - 12:05 .


#2
Shadooow

Shadooow
  • Members
  • 4 470 messages

void ObjectToVoid(object o){}

void main()
{
object oPlc = OBJECT_SELF;
object oPC = GetLastOpenenedBy();
 if(!GetIsPC(oPC))
 {
 return;
 }
float fDelay = 0.0;//adjust this to delay the spawn
string sCreature = "NW_SKELWARR01";//change this to resref of whatever creature you want
effect eVFX = EffectVisualEffect(VFX_FNF_SUMMON_UNDEAD);
location lLoc = GetLocation(oPlc);

DelayCommand(fDelay, ApplyEffectAtLocation(DURATION_TYPE_INSTANT, eVFX, lLoc));
DelayCommand(fDelay, ObjectToVoid(CreateObject(OBJECT_TYPE_CREATURE, sCreature, lLoc)));
int bDestroyMe = TRUE;//change to FALSE if you do not want to destroy playeable
 if(bDestroyMe)
 {
  DestroyObject(oPlc,fDelay+0.2);
 }
}


Again was mistaken... Now changed if you care.

Modifié par ShaDoOoW, 30 janvier 2011 - 11:14 .


#3
A Darker Shade of Soul

A Darker Shade of Soul
  • Members
  • 85 messages
I see this appears to be for a door? Will this still work on say a coffin? Thank you none the less though.

#4
Lightfoot8

Lightfoot8
  • Members
  • 2 535 messages
void ActionCreate(string sCreature, location lLoc)

{

    CreateObject(OBJECT_TYPE_CREATURE, sCreature, lLoc);

}

void main()

{



    effect eMind = EffectVisualEffect(VFX_FNF_SUMMON_UNDEAD);

    string sCreature = "NW_SKELWARR01";

    // * 10% chance of a skeleton chief instead

    if (Random(100) > 90)

    {

        sCreature = "NW_SKELCHIEF";

    }

    location lLoc = GetLocation(OBJECT_SELF);

    DelayCommand(0.3, ActionCreate(sCreature, lLoc));

    ApplyEffectAtLocation(DURATION_TYPE_INSTANT, eMind, GetLocation(OBJECT_SELF));

    SetPlotFlag(OBJECT_SELF, FALSE);

    DestroyObject(OBJECT_SELF, 0.5);

} 


#5
A Darker Shade of Soul

A Darker Shade of Soul
  • Members
  • 85 messages
Thank you as well Lightfoot.

#6
A Darker Shade of Soul

A Darker Shade of Soul
  • Members
  • 85 messages

Lightfoot8 wrote...

void ActionCreate(string sCreature, location lLoc)
{
    CreateObject(OBJECT_TYPE_CREATURE, sCreature, lLoc);
}
void main()
{

    effect eMind = EffectVisualEffect(VFX_FNF_SUMMON_UNDEAD);
    string sCreature = "NW_SKELWARR01";
    // * 10% chance of a skeleton chief instead
    if (Random(100) > 90)
    {
        sCreature = "NW_SKELCHIEF";
    }
    location lLoc = GetLocation(OBJECT_SELF);
    DelayCommand(0.3, ActionCreate(sCreature, lLoc));
    ApplyEffectAtLocation(DURATION_TYPE_INSTANT, eMind, GetLocation(OBJECT_SELF));
    SetPlotFlag(OBJECT_SELF, FALSE);
    DestroyObject(OBJECT_SELF, 0.5);
} 


Hmmm it didn't quite work. I opened the coffin, the visual effect fired and the coffin dissapeared but it didn't spawn the creature or any creature for that matter lol...I put the tag of the creature I wanted in the string sCreature qoutation location but it didn't work. Any ideas?

#7
Xovian

Xovian
  • Members
  • 87 messages
Your quoted script uses a random to spawn the creature, it wont happen every time.
Play with the % numbers to get it where you want it.

If you want it to fire every time you can remove the random script entirely or modify it as such:

if (Random(100) > 90)

Change to:

if (Random(100) > 0)

Modifié par Xovian, 30 janvier 2011 - 04:10 .


#8
Pstemarie

Pstemarie
  • Members
  • 2 745 messages
/* Script generated by
Lilac Soul's NWN Script Generator, v. 2.3

For download info, please visit:
http://nwvault.ign.c...&id=4683&id=625 */

//Put this script OnOpen
#include "nw_i0_generic"

void main()
{

object oPC = GetLastOpenedBy();

if (!GetIsPC(oPC)) return;

object oTarget;
object oSpawn;
location lTarget;
oTarget = oPC;

lTarget = GetLocation(oTarget);

//Change nw_skeleton to the RESREF of the creature you want to spawn.
oSpawn = CreateObject(OBJECT_TYPE_CREATURE, "nw_skeleton", lTarget);

oTarget = oSpawn;

SetIsTemporaryEnemy(oPC, oTarget);

AssignCommand(oTarget, ActionAttack(oPC));

AssignCommand(oTarget, DetermineCombatRound(oPC));

//Visual effects can't be applied to waypoints, so if it is a WP
//the VFX will be applied to the WP's location instead

int nInt;
nInt = GetObjectType(oTarget);

if (nInt != OBJECT_TYPE_WAYPOINT)
DelayCommand(0.5, ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_FNF_SUMMON_UNDEAD), oTarget));
else
DelayCommand(0.5, ApplyEffectAtLocation(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_FNF_SUMMON_UNDEAD), GetLocation(oTarget)));

}

Try this. I generated it from Lilac Soul's Script Generator - nice little tool for such mundane tasks. I didn't bother to clean it up.

@Xovian - the random has nothing to do with Lightfoot's script not working. The way its written it should spawn a skeleton each time, with a 10% chance of spawning a Skeleton Chief instead. My guess would be that when Darker Shade modified the string name he used the creature's TAG and not its RESREF. CreateObject uses the RESREF to call the template, not the template's TAG.

Modifié par Pstemarie, 30 janvier 2011 - 07:19 .


#9
Pstemarie

Pstemarie
  • Members
  • 2 745 messages
To make the coffin disappear, add the following lines to the end of the script:

SetPlotFlag(OBJECT_SELF, FALSE);
DestroyObject(OBJECT_SELF, 0.5);

Note that the script I presented above will spawn the creature next to the PC and force it to attack. If you want the creature to spawn where the coffin was, change the following line:

oTarget = oPC;

TO:

oTarget = OBJECT_SELF;

Modifié par Pstemarie, 30 janvier 2011 - 07:26 .


#10
A Darker Shade of Soul

A Darker Shade of Soul
  • Members
  • 85 messages
Thanks everyone for your help. And yes I used the tag instead of the resref....

#11
Lightfoot8

Lightfoot8
  • Members
  • 2 535 messages
Yes the Tag was your problem. The script I posted was just what you requested, It was the script you posted with all the HB stuff striped out of it. There was no reason to Check who opened the object since all you really cared about was if it was opened or not.



As far as the %chance it was only there to change the creature to a more powerfull one 10 % of the time. So the script should have been spawning a creature every time If you used a valid ResRef.



Hope you have everything working the way you want.

L8

#12
A Darker Shade of Soul

A Darker Shade of Soul
  • Members
  • 85 messages
Pste, the script fired and this time the creature spawned however it didn't apply the visual effect. I opened the coffin and the lich just appeared w/o the visual. Destroying the coffin isn't really neccessary because this is for a pw so it can keep firing. One thing however I'd like to have happen is have the monster spawn at a wp away from the coffin that way the pc's don't have the advantage of immediate attack being as the lich is a spellcaster and needs time to buff etc. I appreciate all of you guys help.

#13
A Darker Shade of Soul

A Darker Shade of Soul
  • Members
  • 85 messages
@Lightfoot, yep I tried yours again as well with a resref instead of the tag and it worked just how it was supposed to. Only thing being is if it could spawn the lich at a wp to give it time to buff as I said to Pste. I forgot about that when I op'd this :(

#14
Greyfort

Greyfort
  • Members
  • 234 messages
here is rerite of lightfoots script making you spaw creature at way point

// l8_spwn
void ActionCreate(string sCreature, location lLoc)
{
CreateObject(OBJECT_TYPE_CREATURE, sCreature, lLoc);
}
void main()
{

effect eMind = EffectVisualEffect(VFX_FNF_SUMMON_UNDEAD);
string sCreature = "NW_SKELWARR01";
// * 10% chance of a skeleton chief instead
if (Random(100) > 90)
{
sCreature = "NW_SKELCHIEF";
}
location lLoc = GetLocation(GetObjectByTag("NAME OF WAYPOINT HERE"));//GetLocation(OBJECT_SELF);
DelayCommand(0.3, ActionCreate(sCreature, lLoc));
ApplyEffectAtLocation(DURATION_TYPE_INSTANT, eMind, GetLocation(OBJECT_SELF));
SetPlotFlag(OBJECT_SELF, FALSE);
DestroyObject(OBJECT_SELF, 0.5);
}

be sure to put your way point name ware it says NAME OF WAY POINT HERE

and you should be good

Modifié par Greyfort, 30 janvier 2011 - 07:32 .


#15
A Darker Shade of Soul

A Darker Shade of Soul
  • Members
  • 85 messages

Greyfort wrote...

here is rerite of lightfoots script making you spaw creature at way point

// l8_spwn
void ActionCreate(string sCreature, location lLoc)
{
CreateObject(OBJECT_TYPE_CREATURE, sCreature, lLoc);
}
void main()
{

effect eMind = EffectVisualEffect(VFX_FNF_SUMMON_UNDEAD);
string sCreature = "NW_SKELWARR01";
// * 10% chance of a skeleton chief instead
if (Random(100) > 90)
{
sCreature = "NW_SKELCHIEF";
}
location lLoc = GetLocation(GetObjectByTag("NAME OF WAYPOINT HERE"));//GetLocation(OBJECT_SELF);
DelayCommand(0.3, ActionCreate(sCreature, lLoc));
ApplyEffectAtLocation(DURATION_TYPE_INSTANT, eMind, GetLocation(OBJECT_SELF));
SetPlotFlag(OBJECT_SELF, FALSE);
DestroyObject(OBJECT_SELF, 0.5);
}

be sure to put your way point name ware it says NAME OF WAY POINT HERE

and you should be good

 

Lol..gotcha! Thank you.

#16
A Darker Shade of Soul

A Darker Shade of Soul
  • Members
  • 85 messages
It worked like a charm grey...thanks 1ce again :)

#17
Xovian

Xovian
  • Members
  • 87 messages
Silly me.

Just glanced at it and saw the random spawn and thought that was it.

I really should pay more attention to such things, but was in a hurry.

=/