Aller au contenu

Photo

camp fire script -edited: need help fixing this one I wrote


9 réponses à ce sujet

#1
Sonmeister

Sonmeister
  • Members
  • 167 messages
I need to light my camp fire.  Does anyone have a little placeable script for this?

EDIT:  OK, I took the time to write this and it compiles but doesn't work.  Any tips?

//:://////////////////////////////////////////////
//    Placeable events
//:://////////////////////////////////////////////

#include "placeable_h"

const string CAMPFIRE = "camp_fire";
const int LIGHT_CAMPFIRE = 4050; //References the VFX_Base 2DA

void main()
{
    event ev     = GetCurrentEvent();
    int   nEvent = GetEventType(ev);
    int nEventHandled = FALSE; //keep track of whether the event has been handled
    switch (nEvent)
    {
        //---------------------------------------------------------------------
        //  Sent by engine when creature clicks on the placeable.
        //---------------------------------------------------------------------
        case EVENT_TYPE_APPLY_EFFECT: // or EVENT_TYPE_PLACEABLE_ONCLICK

        object oCampfire = GetObjectByTag(CAMPFIRE);
        ApplyEffectOnObject (EFFECT_DURATION_TYPE_PERMANENT, EffectVisualEffect(LIGHT_CAMPFIRE),oCampfire);

        nEventHandled = TRUE;
            break;
    }
    if (!nEventHandled) //If this event wasn't handled by this script, let the core script try
    {
        HandleEvent(ev, RESOURCE_SCRIPT_PLACEABLE_CORE);
    }
}

Modifié par Sonmeister, 10 juin 2010 - 10:52 .


#2
TimelordDC

TimelordDC
  • Members
  • 923 messages
Change the event type to EVENT_TYPE_PLACEABLE_ONCLICK (EVENT_TYPE_APPLY_EFFECT is called when an effect is applied) and it should work. I just tried it in one of my areas and it did work.

I had my placeable as an Examinable one, fwiw.

Edit: I had also commented out the nEventHandled = TRUE line since I was also testing something else and was routing this to another script (which ultimately routes to placeable_core). You could try that too - I am assuming you have already checked the standard things like the tag and whether the placeable is examinable, etc.

Modifié par TimelordDC, 11 juin 2010 - 02:12 .


#3
Sonmeister

Sonmeister
  • Members
  • 167 messages
It works, but what I'm trying to do is get the dang campfire burning on entry to the camp. I'm not actually wanting someone to light it, although I may work that into the mod if I can't figure out a pre-burn. Any ideas. I searched the SP scripts and haven't had much luck. Thanks!

#4
Kilrogg_

Kilrogg_
  • Members
  • 296 messages
You just want it to light up as someone enters its radius? Why not just use a trigger?

#5
TimelordDC

TimelordDC
  • Members
  • 923 messages
If you want it on entry to the camp, just put the ApplyEffectOnObject code in the AREALOAD_PRELOADEXIT or AREALOAD_POSTLOADEXIT events. Alternatively, if you just want the campfire to be lit when the player comes near, you can use a trigger like Kilrogg suggested.

#6
Sonmeister

Sonmeister
  • Members
  • 167 messages
I don't have an area script so I was trying to work around that. I'll just write one. I have a couple other things it would be good to have one for. Thanks guys.

#7
_L_o_B_o_

_L_o_B_o_
  • Members
  • 117 messages
Well, if you are editing your own level, then you can add the VFX directly in the level editor. No script needed.

Modifié par _L_o_B_o_, 11 juin 2010 - 11:36 .


#8
Sonmeister

Sonmeister
  • Members
  • 167 messages
It's not my own level - but thanks for the info - good to remember. I got it working with an area load.

#9
DavidSims

DavidSims
  • BioWare Employees
  • 196 messages
To avoid the area load, you could also use the spawn event.

#10
Sonmeister

Sonmeister
  • Members
  • 167 messages
Spawn event - didn't even think of it. Thanks DavidSims.