Jump to content

Create Object() problem


klusi93

Recommended Posts

Hello!

I've written a script to add a creature to certain areas, but it dosen't seem to work properly. Perhaps I'm just stupid, but I can't figure out what's wrong. The creature appears in the partycamp three times in the same location!!

 

void main()
{

//Check whether I've added Linda already.
if (!IsObjectValid(GetObjectByTag("party_linda")))
{
object oOstagar = GetObjectByTag("pre100ar_kings_camp");
vector vLinda = Vector(510.869f,419.934f,5.24351f);
object oCamp1 = GetObjectByTag("cam100ar_camp_plains");
vector vLinda1 = Vector(145.117f,128.761f,-0.46176f);
object oCamp2 = GetObjectByTag("cam104ar_camp_arch1");
vector vLinda2 = Vector(145.119f,128.762f,-0.46177f);
object oCamp3 = GetObjectByTag("cam110ar_camp_arch3");
vector vLinda3 = Vector(145.118f,128.763f,-0.46178f);

CreateObject(
OBJECT_TYPE_CREATURE,
R"lpm_party_linda.utc",
Location(oOstagar, vLinda, 94.0f)
);

CreateObject(
OBJECT_TYPE_CREATURE,
R"lpm_party_linda.utc",
Location(oCamp1, vLinda1, -22.4f)
);

CreateObject(
OBJECT_TYPE_CREATURE,
R"lpm_party_linda.utc",
Location(oCamp2, vLinda2, -22.5f)
);

CreateObject(
OBJECT_TYPE_CREATURE,
R"lpm_party_linda.utc",
Location(oCamp3, vLinda3, -22.6f)
);

WR_SetPlotFlag(PLT_LINDA_MAIN, PARTY_LINDA_ADDED_TO_OSTAGAR, TRUE);
WR_SetPlotFlag(PLT_LINDA_MAIN, PARTY_LINDA_ADDED_TO_CAMP_ARCH1, TRUE);
WR_SetPlotFlag(PLT_LINDA_MAIN, PARTY_LINDA_ADDED_TO_CAMP, TRUE);
WR_SetPlotFlag(PLT_LINDA_MAIN, PARTY_LINDA_ADDED_TO_CAMP_ARCH3, TRUE);
}
}

Link to comment
Share on other sites

I'd start by adding more 'if/else if' statements.

if Ostagar

isobject valid

location =

create object

set flag added to Ostagar

else if camp1

isobject valid

etc etc etc

Right now you are adding Linda regardless of location after checking to see whether she exists. She is probably actually there 4 times, but the 'Ostagar position' isn't close to the others so you aren't seeing her.

 

Stepping through your code,

Is Linda already added?

If Linda not there

set up 4 locations for Linda

create Linda in 4 locations

set 4 flags for adding Linda

Link to comment
Share on other sites

@mcgoy

 

Thanks for the advice! I got it to work, but I did it a bit differently. I set up seperate scripts for each CreateObject() and setting the plotflag, so I have 4 scripts in total now.

They are build something like this:

 

1. Look if Flag is set and do the following if not:

Crate her in Ostagar

Set Flag PARTY_LINDA_ADDED_TO_OSTAGAR

 

2 Look if Flag is set and do the following if not:

Crate her in Camp_Plains

Set Flag PARTY_LINDA_ADDED_TO_Camp

 

They are fired by a PRCSCR (So they only work when entering a certain area like ostagar) and it seems to work fine now.

But it's certainly ridiculous to have so many scripts for something so simple, so I will look into it and correct it later.

Edited by klusi93
Link to comment
Share on other sites

ARGH - internet decided I didn't need to post a reply so trying again

 

It is always important to get something working before trying to get more efficient/slick. Yes, you could combine into one script although the existing PRCSCR is probably more efficient because there are so few conditions to check.

 

below is A possible solution, pseudocode because I'm too lazy to look up syntax

 

!IsObjectValid

if IsOstagar

{

vector

location

create

else if IsCamp1

vector

location

create

else if IsCamp2

vector

location

create

else if IsCamp3

vector

location

create

else

Displayfloaty "Error ran PRCSCR when shouldn't have"

}

 

 

The SetPlot isn't really necessary unless you want to keep track of where Linda was created.

 

I don't think you NEED to change your current script from the standpoint of efficiency, but learning to use if statements (and case statements, etc etc etc) will be helpful in the long run. If you plan to write more mods or more elaborate mods.

Link to comment
Share on other sites

Yes, I really want to get more confident with scripting, but it's a bit difficult. I mostly follow tutorials at the moment, but I want to get away from "copy-and-paste", so I can create better mods.

Sadly, when it comes to Toolset tutorials, it's either very avanced or simple (That's my feeling at least) and most of them tell you to take their scripts and just to change some things so it fits your purpose.

They hardly explain why they did certain things in their scripts, so it's hard to get a proper footing yourself.

Now, I want to crate a custom Level_up_Template for Linda, but what's written on toolsetwiki gives me a hard time:

 

http://social.bioware.com/wiki/datoolset/index.php/Follower_tutorial#Add_Your_Custom_Autolevel_Template_to_GetCustomFollowerALTable.28.29

 

I aready created ALLinda.gda and M2da.gda and put them in My documents - bioware - addins - my module - module - override - toolsetexport.

But I don't understand the hire_function_include she describes. I know it's an include for the hire_script (The script to get a custom follower to the party. It's fired by a conversation)

Do you know how to get my Level_up_Template to work?

Link to comment
Share on other sites

What is written in the toolset wiki gave me a hard time so I'm not surprised.

 

Rather than jumping into the level up table, I suggest in the strongest possible way that you start some other SMALL projects (i.e. not adding a companion) to learn more programming skills. You know how to use the PRCSCR file, but you need to learn how to use 'if' and 'case' statements (among other things) or you are going to end up doing your entire mod almost entirely with cut/paste.

 

Sunjammer has some wonderful projects/tutorials on the bioware site and I believe he included the B2B files. One of his projects, I plan to leverage at some point to create at least one Quest. :biggrin: I know that you want to get 'straight' to creating your new Companion(s), but it will be much easier if you can create more of your own code. I was a full time programmer many years ago so it was much easier for me to understand the code. And it still isn't/wasn't easy to add new Companions.

 

Most of the wiki tutorials seemed (to me) to go into wonderful detail on some things and then skim over others. So there was almost enough..... but not quite. Until I figured out how to do it and then it was 100% clear and I didn't know why I couldn't figure it out to begin with! :blink:

 

btw - for a recruited Companion CreateObject doesn't need to be done in Camp. The CreateObject was done to create the Companion before being recruited. Although if you may be using different commands/logic so I may be incorrect on that. But I didn't need to do CreateObject and it caused some.... interesting effects

Link to comment
Share on other sites

Thank's for the advice. Perhaps I really should slow down a bit and start with something smaller. :happy:

 

I won't give up on this project , but it will have to wait until i know what I'm doing.

And yes, I realized it would probably be smarter to create her once and just change her location with the PRCSCR. (Am I right?)

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...