Aller au contenu

Photo

Enabling a Map Pin from a script? [RESOLVED]


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

#1
R3v3r3nD420

R3v3r3nD420
  • Members
  • 44 messages
I was wondering if anyone has figured out how to set a map pin's Initial State from Not Active to Active via a script?

I am trying to have a quest giver uncover the location on the map when the player accepts the quest.

I cant find an example anywhere, online or in any toolset included scripts, so I am trying to stab in the dark at this myself. Here is what I assume is how the basic script should go, please someone correct me if you know how it is done.

void main()
{
object oMapPin = GetObjectByTag("map_pin_tag")

if (GetObjectActive(oMapPin)) = FALSE

SetMapPinState (object oMapPin, int nEnable)

}


When trying to compile the script it returns an error on the "if (GetObjectActive(oMapPin)) = FALSE" line - Parsing Variable List

I am guessing I just dont have the right syntax here. The settings for the map pins initial state arent in a variable list, it is in its own field "Initial State" with the options being "INVALID", "INACTIVE", "ACTIVE", "GRAYED OUT", "UNLOCKED CONTENT", "COMPLETED", and "DESTROYED".

I'm hoping someone has this sorted out already.

Modifié par R3v3r3nD420, 29 novembre 2009 - 11:22 .


#2
R3v3r3nD420

R3v3r3nD420
  • Members
  • 44 messages
After poking around in the script editor a bit more and looking through the provided list of function I'm thinking perhaps this is closer to being on target?

//This is my attempt to write a script to set a map pin to the ACTIVE state
//when the script is fired from dialogue.

#include "wrappers_h"

void main()

{  
    event ev                    = GetCurrentEvent();
    object oMapPin       = GetObjectByTag("map_pin_tag");
    int nState                  = GetMapPinState("area_map");
    int nEnable              = ??????
    int bEventHandled = FALSE;
    }

{   
    //Hopefully this section will set the map pins state to active
   
    if (nState(oMapPin) =  ??????
    SetMapPinState (object oMapPin, int nEnable)
    }

{
    if (!bEventHandled)
     DisplayFloatyMessage(oPlayer, "ERROR!!!", FLOATY_MESSAGE, 16777215, 20.0);
    {
        HandleEvent(ev, ??????);
    
}

Of course, I could be totally wrong, but its starting to seem like its closer. I'm not sure what to fill in for the ?'s though.

Modifié par R3v3r3nD420, 27 novembre 2009 - 05:20 .


#3
R3v3r3nD420

R3v3r3nD420
  • Members
  • 44 messages
bump



Anyone got any ideas on this?

#4
R3v3r3nD420

R3v3r3nD420
  • Members
  • 44 messages
Ok, it seems as if I was going about it the completely wrong way. After poking around in wrappers_h and the demo mod included with the toolset (thanks Bryan D), I came up with the following script:


//This is my attempt to write a script to set a map pin to the ACTIVE state
//when the script is fired from dialogue.

#include "plt_plot_my_plot"
#include "wrappers_h"

void main()
{
    // If our plot flag is set to False, then we need to do nothing
    if ( WR_GetPlotFlag( PLT_PLOT_MY_PLOT, PLOT_FLAG ) == FALSE )
        return;
        else
            //If our plot flag is set to TRUE, then make the map location visible
            if (WR_GetPlotFlag( PLT_PLOT_MY_PLOT, PLOT_FLAG ) == TRUE )
    {
            object oMapPin = GetObjectByTag("map_pin_tag");
            WR_SetWorldMapLocationStatus(oMapPin, WM_LOCATION_ACTIVE);
     }
 
}
//End Script


This script compiles, and indeed sets the map pin to active, but I can only get it to work if the pins initial state is "GRAYED OUT", and not "NOT ACTIVE" like I had hoped.

Anyone know how to get an invisible map pin to activate and become visible?

#5
giskard44

giskard44
  • Members
  • 137 messages
R3v3r3nD420

Thanks for posting your findings, i'll need to do the same at some point so whilst I cannot help much now, I am reading what your posting. Thanks again mate :)

Heres my thoughs based on what little I know.
I am not at all familar with DA script but know enough languages to be able to read your script and follow it. I spotted what looks like a mistake in your first 3 attempts.

You should be assigning oMapPin  to your pins tag I believe, first.
Then checking the status of oMapPin  second.
Then finally doing a bunch of IFs to find its status and change it as needed.

Step 2 and 3 might even be the same step in Da script.

I have no idea where the commands are listed for DA but i would look for commands that enable or disable pins, sometimes a command may not work correctly because it was replaced by something better. Which means the command you found may be a left over and that may be why its not fully functional. Or you might not have its syntax right yet. Could be anything.

I know now it is possible to enable icon, grey an icon out and even change an icon/replace it. I do not know if bioware disable one icon and enable another or simply swap icons for the same pin but I have seem them do it in the campaign.

So the commands must exist for it and they clearly work because bioware used them

Just take this advice when scripting a game, never assume a command works as advertised and never assume its the only command that can do that job.

Modifié par giskard44, 28 novembre 2009 - 06:02 .


#6
giskard44

giskard44
  • Members
  • 137 messages
Just dug these up for you, these are the valid conditions for a map pin as listed by the toolkit.



Invalid (Default)

Not Active

Active

Greyed Out

Unlocked Content

Completed

Destroyed

#7
Axe_Murderer

Axe_Murderer
  • Members
  • 279 messages
Just a guess here but you probably need both if the pin is not enabled initially:
[dascript]
...
object oMapPin = GetObjectByTag( "map_pin_tag");
SetMapPinState( oMapPin, TRUE);
WR_SetWorldMapLocationStatus( oMapPin, WM_LOCATION_ACTIVE);
...
[/dascript]

Modifié par Axe_Murderer, 28 novembre 2009 - 07:19 .


#8
R3v3r3nD420

R3v3r3nD420
  • Members
  • 44 messages
@ giskard44

No problem :) And thanks for the reply. I was surprised nobody has even brought this up yet, but perhaps not many are to the point in their mods developement to have needed to do this yet. I am a scripting noob so I can only do what I can, and hopefully the community can help with the rest. :)

I dont think steps 2 and 3 are the same as far as I can see, I think Axe_Murderer might have found the missing piece: "SetMapPinState( oMapPin, TRUE);"

Being the designer, I know the initial state of the pin (NOT ACTIVE), and thus dont need to find the state of the pin, just assign it to ACTIVE. My guess is that the pin doesnt initially actually "exist" when set to NOT ACTIVE, and we need to tell the game to make it "exist" with the function: SetMapPinState(oMapPin, TRUE);, then we can go about activating it and making it so the player can travel to it.

What you said previously about functions that are no longer used being left in the toolset I believe was my initial problem, coupled with the fact I'm flying by the seat of my pants here because my programming experience is virtually zero. Not doing too bad so far for a noob eh? Posted Image

@ Axe_Murderer

Thanks mate, I will go test this and report back with my findings.

Modifié par R3v3r3nD420, 29 novembre 2009 - 12:19 .


#9
R3v3r3nD420

R3v3r3nD420
  • Members
  • 44 messages
It works! Indeed the "SetMapPinState( oMapPin, TRUE);" was the missing piece.
For those following along, here is my final script:

//This is my attempt to write a script to set a map pin to the ACTIVE state
//when the script is fired from dialogue.
#include "plt_my_plot"
#include "wrappers_h"

void main()
{
    // If our plot flag is set to False, then we need to do nothing
    if ( WR_GetPlotFlag( PLT_MY_PLOT, QUEST_ACCEPTED ) == FALSE )
        return;
        else
            //If our plot flag is set to TRUE, then make the map location visible
            if (WR_GetPlotFlag( PLT_MY_PLOT, QUEST_ACCEPTED ) == TRUE )
    {
            object oMapPin = GetObjectByTag("map_pin_tag");
            SetMapPinState(oMapPin, TRUE);
            WR_SetWorldMapLocationStatus(oMapPin, WM_LOCATION_ACTIVE);
     }
}
//End Script



Thanks again guys for helping me think this through! And especially Axe_Murderer for providing the specific missing piece :)

Modifié par R3v3r3nD420, 29 novembre 2009 - 11:15 .