Aller au contenu

Photo

Enable/disable objects between areas?


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

#1
sea-

sea-
  • Members
  • 264 messages
Hi,

I'm building a quest right now where a character is killed off-screen and the player is rewarded by the conversation owner.  I'm handling this by simply disabling the character who is killed, and enabling a corpse placeable, based on the plot flag SMITH_RATTED_OUT, and then depositing gold into the player's inventory.  The area where the plot flag is set is different from where the enable/disable function needs to take place, but they are in the same area list.

Unfortunately, I can't figure out how to get this to work.  I have very little experience with programming and only a bit more with scripting, and haven't been able to get the script to fire properly.  The player receives no gold and neither the corpse appears nor the NPC disappears, so I have to assume it's something more fundamental that I'm getting wrong.

My script currently uses plot_core.nss as a base; aside from the #include plt, the following is what I've added:

        switch(nFlag)
        {
            case SMITH_RATTED_OUT:
            {
                if (nValue==1)
                {
                    object oBody = GetObjectByTag("mason_dead");
                    object oSmith = GetObjectByTag("mason");

                    SetObjectActive(oBody, 0);
                    SetObjectActive(oSmith, 1);
                    RewardMoney(0,0,10);
                }
            }
        }

If anyone could give me some help in building a simple and lean script to handle this, I'd appreciate it.

Modifié par sea-, 16 mars 2011 - 09:59 .


#2
Proleric

Proleric
  • Members
  • 2 346 messages
Sounds like your script isn't running at all.

Some things to check:

Have you set the script property of your plot resource correctly?

Does the script compile without errors in the log?

Are you setting the plot flag in the conversation Action? A common error is to put the flag in the Condition.

Are nFlag and nValue defined in the same way as the example in plot_core?

#3
Proleric

Proleric
  • Members
  • 2 346 messages
Incidentally, you can always set objects active / inactive in the area preload event when WR_GetPlotFlag indicates that the flag is set.

I've always done it that way, as it's less fragile (i.e. it won't break if you subsequently decide to put each area in its own area list for performance reasons).

#4
sea-

sea-
  • Members
  • 264 messages
Thanks for the help!

I feel like an idiot now. No, I did not properly set the script to run in the plot file. Grr. Rookie mistake. :P

So now, what happens is that the player receives the correct reward, but the enabling/disabling of the objects doesn't occur, even if I put them in the same area as where the script fires. Sounds like a syntax error at this point; maybe I'm missing a line somewhere?

Modifié par sea-, 17 mars 2011 - 02:53 .


#5
Proleric

Proleric
  • Members
  • 2 346 messages
LOL I've made that mistake often enough... we're all learning here, trust me Posted Image

Points to check now are that your tags are exactly as specified in the resource templates, and that there is only one instance of each object in the area list.

DisplayStatusMessage can be useful to display diagnostics, e.g. the name of the object retrieved (which will be null if no valid object has been found).

#6
sea-

sea-
  • Members
  • 264 messages
I appreciate the tips. I realised the problem was in the inclusion (or exclusion) of a break statement.

With the assistance here, I also managed to substantially overhaul the scenario, as seen here:



I still had to get the SetObjectActive statements working, except it was for the mercenaries there, not the corpse.

Seems I was on the right track, it was just stupid little errors getting the better of me. :P

Modifié par sea-, 18 mars 2011 - 02:31 .