Aller au contenu

Photo

Making eggs go splat...or poof...


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

#1
MokahTGS

MokahTGS
  • Members
  • 946 messages
I'm trying to have a clutch of eggs that the player can destroy, but I'm giving them a choice of how to destroy them (or not) and each choice will have a different VFX.  I'm doing this via a conversation and wanted to use a modified version of the ga_destroy script with some added bits to suit my needs.  Here's what I was thinking:

I'd like to add a varible that I can set on the script to determine what VFX to display on a waypoint location.  The varibles should be either a fire explosion, an acid explosion, or a torch set fire.  I can't for the life of me figure out how to change this script to make this happen.

ga_destroy

// ga_destroy/*    This script destroys objects        sTag        = The tag(s) of the object(s) to destroy. You can pass multiple                      tags, seperated by commas (NO SPACES) to destroy multiple objects                      (ie. "Object1,Object2,Object3")                      NOTE: There may eventually be a function to eat white space                      (See Mantis 3296), but for now do not put spaces in the string.        iInstance   = The instance of the object to destroy. Pass -1 to destroy                      all instances.  Pass 0 to destroy the first instance.        fDelay      = The delay before destroying the object(s)
*/// TDE 3/7/05// ChazM 3/8/05   - commented and tweaked.// ChazM 6/7/05   - fixed bug, modified comment// BMA-OEI 1/11/06 removed default param
void PrepForDestruction(object oTarget){ SetPlotFlag(oTarget,FALSE);    SetImmortal(oTarget,FALSE);    AssignCommand(oTarget,SetIsDestroyable(TRUE,FALSE,FALSE));}
// detroy all objects (iInstance=-1) or a specific instance of objectvoid Destroy(string sTagString, int iInstance = 0, float fDelay = 0.0){    if (iInstance == -1)    {   // delete all objects        int iInst = 0;        object oObject = GetObjectByTag(sTagString, iInst);
        while (GetIsObjectValid(oObject))        { PrepForDestruction(oObject);            DestroyObject (oObject, fDelay);            iInst ++;            oObject = GetObjectByTag(sTagString, iInst);        }    }    else    {   // delete a specific instance of object object oTarget = GetObjectByTag(sTagString,iInstance); if(GetIsObjectValid(oTarget)) { PrepForDestruction(oTarget);        DestroyObject (oTarget, fDelay); }    }}


void main(string sTagString, int iInstance, float fDelay){    string sNewString = sTagString;    int iLen = GetStringLength(sTagString);    int iCommaPos = FindSubString( sNewString, "," ); //find first comma
    while(iCommaPos != -1)    {        // get first tag and destroy it        string sTempString = GetSubString(sNewString , 0, iCommaPos);        Destroy(sTempString, iInstance, fDelay);
        // drop first tag and comma        sNewString  = GetSubString(sNewString, iCommaPos + 1, iLen);        // determine new length        iLen = GetStringLength(sNewString);        // get next comma position (returns -1 if not found)        iCommaPos = FindSubString(sNewString, "," );    }
    //sNewString is equal to last tag to destroy    Destroy(sNewString, iInstance, fDelay);}



#2
Tchos

Tchos
  • Members
  • 5 054 messages
Well, you could have another function in there called PlaceEffect(string sEffect) or something, and call that function before the calls to Destroy(). You'll want to get the location of the object and place the effect at the location rather than on the object, because the effect would disappear with the object, possibly never starting in the first place if it's on the object. Since this is a conversation script, you'd declare string sEffect on the void main() part too.

BTW, need some eggs for it?

Modifié par Tchos, 04 mai 2013 - 06:05 .


#3
MokahTGS

MokahTGS
  • Members
  • 946 messages

Tchos wrote...

Well, you could have another function in there called PlaceEffect(string sEffect) or something, and call that function before the calls to Destroy(). You'll want to get the location of the object and place the effect at the location rather than on the object, because the effect would disappear with the object, possibly never starting in the first place if it's on the object. Since this is a conversation script, you'd declare string sEffect on the void main() part too.

BTW, need some eggs for it?


Tchos, thanks...it's the syntax in scripting that I can't seem to understand.  What lines do I put where?

The eggs are not an issue, I'm using the containers fillers with a custom texture...do you have some custom stuff not released yet?

#4
kevL

kevL
  • Members
  • 4 061 messages
// 'tgs_ga_destroy_eggs'



void main(string sTarget, string sWayPoint, string sVis, int bDestroy)

{

//  object oPC = GetPCSpeaker();

//  SendMessageToPC(oPC, "run ( tgs_ga_destroy_eggs )");



  if (bDestroy)

  {

//    SendMessageToPC(oPC, ". . in bDestroy");



    int i = 0;

    object oEgg = GetObjectByTag(sTarget, i);

    while (GetIsObjectValid(oEgg))

    {

//      SendMessageToPC(oPC, ". . in bDestroy : " + IntToString(i));



      DestroyObject(oEgg);



      ++ i;

      oEgg = GetObjectByTag(sTarget, i);

    }

  }



  object oTarget = GetWaypointByTag(sWayPoint);

//  SendMessageToPC(oPC, ". wp Tag : " + GetTag(oTarget));

  effect eVis = EffectNWN2SpecialEffectFile(sVis);

  ApplyEffectToObject(DURATION_TYPE_INSTANT, eVis, oTarget);

}

Modifié par kevL, 11 mai 2013 - 08:57 .


#5
Tchos

Tchos
  • Members
  • 5 054 messages
I think the clutch is supposed to be a placeable, not an inventory item. I missed the part about the waypoint, though. Is that so that the effect will be in a different place than the clutch being destroyed? Otherwise, you could just get the location from the clutch itself. Or, if this conversation is supposed to fire from activating the clutch, you could use an ipoint, since the conversation would have to be owned and fired from something other than the clutch if the clutch is going to be destroyed (since it would breakend the conversation).

I do have a couple of unreleased placeables that might work here. I'll show you in a bit.

#6
Tchos

Tchos
  • Members
  • 5 054 messages
These are the eggs I was talking about.  They're amphibious/fish monster eggs, attached to a surface with some sticky substance.  One whole, one broken open.

Eggs.

#7
MokahTGS

MokahTGS
  • Members
  • 946 messages
The clutch of eggs is a placeable, not an inventory item...and let me say...eeeww...

I suggested the waypoint since there is a pile of eggs and the waypoint would be in the center of them, so the VFX would look correct if spawned at its location.

#8
Tchos

Tchos
  • Members
  • 5 054 messages
Ah, okay, I see what you have in mind.  So, since you have more than one egg, we'll need to put that while loop back into the script.  I'll just remove the bits you probably don't need for this.

I think this will take care of it, but I haven't tried compiling it.
http://pastebin.myrror.net/3395

Just make sure the group of eggs you want to destroy in one go all have the same tag.  Other clutches should have different tags.

#9
MokahTGS

MokahTGS
  • Members
  • 946 messages
Error: ga_destroy_egg.nss(46): Error: NSC1020: Undeclared identifier "iInstance"

#10
Tchos

Tchos
  • Members
  • 5 054 messages
Oops, I didn't clean that out properly. I've fixed it, and test compiled it, and updated the code in the link.

#11
kevL

kevL
  • Members
  • 4 061 messages
The mini-script above is updated too, if you want to take a look at it. What i don't like about the orginal ga_destory is that, unless you plan to use it for objects with multiple tags it has a lot of superfluous code.

note, for example besides the routine for parsing the input string, that SetIsDestroyable() & SetImmortal() strike me as irrelevant for items, and that SetPlot() is in my experience irrelevant also when using DestroyObject() on items,

( i guess the eggs'd be placeables, tho .. )

Modifié par kevL, 05 mai 2013 - 09:11 .


#12
Tchos

Tchos
  • Members
  • 5 054 messages
I left parsing the input string in there just in case Mokah wants to destroy more than one group of differently-tagged items in one command. :)

#13
MokahTGS

MokahTGS
  • Members
  • 946 messages
OK, sorry for taking so long to get this in and comment. A couple comments/questions:

I have the script in and compiled and attached to nodes. The variables:

sTagString = The tag of the object(s) I want destroyed.
sWayPoint = The tag of the waypoint where I want the VFX to appear?
sFX = The name of the VFX I want to use? What are passable names?

Thanks again, BTW. I ask all this because I plan to use this all over the module, but I want to be clear so I can also explain it to others when this is released.

Image IPB

Modifié par MokahTGS, 11 mai 2013 - 04:24 .


#14
Tchos

Tchos
  • Members
  • 5 054 messages
1. Yes
2. Yes, and it has to be a waypoint.  If you don't want it to have to be a waypoint, then change the line:

object oTarget = GetWaypointByTag(sWayPoint);

to:

object oTarget = GetObjectByTag(sWayPoint);

and then you can reference any non-static object, as long as that object isn't getting destroyed.

3. Yes.  Passable names are any .sef file.  Do you have the Powerbar plugin installed?  I highly recommend it for many reasons.  One small part of that plugin is a browser of all kinds of resources, including VFX.  You can easily get the names and preview what the effects look like on the Powerbar under Browse>VFX.

Without the Powerbar, you can find the names of the .sef effects by opening the NWN2_VFX.zip files in your data directory, or by selecting an object in the toolset and clicking the dropdown menu "Appearance (visual effect)" on the properties palette.

You can, but don't need to, include the .sef extension when you write the effect name.  I'd leave it off.

Modifié par Tchos, 11 mai 2013 - 05:29 .


#15
MokahTGS

MokahTGS
  • Members
  • 946 messages
Ok, so in my tests the VFX is not happening...not sure why. Probably because the conversation is firing off of the object that is getting destroyed. I need to rethink how the conversation is fired...maybe via trigger and an iPoint.

#16
MokahTGS

MokahTGS
  • Members
  • 946 messages
Well...I changed it to launch the conversation off a trigger and an iPoint and still no VFX when I click the node. The eggs are destroyed however.

#17
Tchos

Tchos
  • Members
  • 5 054 messages
Right, you can't run the conversation off of something that's being destroyed, or it'll fail. Let me test this out myself. But in the meantime, for the VFX, what did you enter into the field for it?

#18
kevL

kevL
  • Members
  • 4 061 messages
another nickel:

i Revised the script above ( having mistakenly put quotes around sWaypoint ) and added sTarget.

Then i debugged it. On an armoire and a waypoint, Vis "fx_a_devour_spirit" actually worked. Dialog triggered from the armoire as conversation owner ... Destroy on the last node .. vis appeared w/ sFx, and armoire faded out.


i thought maybe you might be having a problem sticking a Vis onto a waypoint and tried using a Location -- but the SpecialEffect played for both Location or OnObject,

- triple check for typos, Mokah


oH, and try changing

ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eVis, oTarget, 10.f);

to

ApplyEffectToObject(DURATION_TYPE_INSTANT, eVis, oTarget);


I also had problems using GetNearestObjectByTag() to get the object itself, so switched to GetObjectByTag()

#19
Tchos

Tchos
  • Members
  • 5 054 messages
I fixed it and successfully tested it.

Change:
ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eVis, oTarget, 10.f);

to

ApplyEffectAtLocation(DURATION_TYPE_TEMPORARY, eVis, GetLocation(oTarget), 10.f);

Also, make sure the placeables are non-static (you did), and make sure the effect you choose is large enough and/or the waypoint is high enough above the object so that the effect is visible.  Small effects can be lost under the placeables.

Modifié par Tchos, 11 mai 2013 - 09:27 .


#20
MokahTGS

MokahTGS
  • Members
  • 946 messages

Tchos wrote...

I fixed it and successfully tested it.

Change:
ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eVis, oTarget, 10.f);

to

ApplyEffectAtLocation(DURATION_TYPE_TEMPORARY, eVis, GetLocation(oTarget), 10.f);

Also, make sure the placeables are non-static (you did), and make sure the effect you choose is large enough and/or the waypoint is high enough above the object so that the effect is visible.  Small effects can be lost under the placeables.


Yup, that got it.  Now I just need to change the amout of damage that is done to the player if they pick the smashy options.