Aller au contenu

Photo

Placing a creture on a loaction?


20 réponses à ce sujet

#1
Lotion Soronarr

Lotion Soronarr
  • Members
  • 14 481 messages
What's the proper way to place a creature (NPC) in a game location? I know it can be placed with a script but I can't find functions that seem to do it. I see no GetCreatureByTag function anywhere....*sigh*

#2
BioSpirit

BioSpirit
  • Members
  • 261 messages
There is a function called GetObjectByTag that will do the trick. Also you need SetLocation, GetLocation functions.
For an example:
SetLocation(GetObjectByTag("tag_npc"), GetLocation(GetObjectByTag("tag_waypoint")));

You can create custom location by using "Location" function.

Modifié par BioSpirit, 02 janvier 2010 - 07:36 .


#3
Lotion Soronarr

Lotion Soronarr
  • Members
  • 14 481 messages
Could you be a bit more specific?

I'm not exaclty sure how to make a location. IIRC; Waypoints can't be placed with a script.

I'd need the name o the area, coordinates (I guess mouse coordinates in the editor) and orientation. Teh are is cir200_ar_tower_level_1.are




void main()
{
object oAquae=GetObjectByTag(aquae,0);


location AquaePoint (??????);     <--------------------????????

void SetLocation (oAquae,AquaePoint);
}

Modifié par Lotion Soronnar, 02 janvier 2010 - 08:44 .


#4
Lotion Soronarr

Lotion Soronarr
  • Members
  • 14 481 messages
?????

#5
BioSpirit

BioSpirit
  • Members
  • 261 messages
So, you are trying to place a NPC in the main campaign not in your own area. I haven't tried this, so I don't know does it work.

Open a local copy of the area and place a waypoint where you want the NPC to appear, Take the position information from the waypoint properties.

Create the location in your script:

location loc = Location(oArea, Vector(x, y, z), 0.0); Where x,y,z is the position you took. There seems to be handiness problem so you may need to reverse the signs from x and y coordinates.

Modifié par BioSpirit, 05 janvier 2010 - 10:56 .


#6
DavidSims

DavidSims
  • BioWare Employees
  • 196 messages
Are you trying to create an object, or move an existing object? If you want to create an object, you need to use CreateObject().



To move an object, it's easier to use SetPosition() rather than SetLocation(). SetLocation() let's you specify and area and orientation, but I don't think the area part of that will let you move creatures between areas anyway.



If you just want to move a creature to a waypoint, use UT_LocalJump(), which is really just a wrapper around SetPosition().

#7
Craig Graff

Craig Graff
  • Members
  • 608 messages
A minor clarification: SetLocation lets you move objects between areas, but only if the area you are moving the object to is in memory, usually because it shares an arealist with the current area.

#8
Lotion Soronarr

Lotion Soronarr
  • Members
  • 14 481 messages
Thanks for the clarification...



So If I want to place a NPC in Redciffe (it not placed anywhere ATM) I use CreateObject().

If I want to move it to defend Recliffe at night, then Set Location?



Ok, scratch that...I'll just create a copy of the NPC for Redcliffe at night or something.

More experimentation is needed.

#9
DavidSims

DavidSims
  • BioWare Employees
  • 196 messages
Redcliffe day and night are seperate areas and not in the same area list. You won't be able to move creatures between them.

#10
Lotion Soronarr

Lotion Soronarr
  • Members
  • 14 481 messages
So I'll have to create a copy of the NPC for each area then?
So how do I go about placing a NPC (tag "aquae") into Redcliffe (I have the exact coordinates).

This OK?
----------
void main()
{
    event ev = GetCurrentEvent();
    int nEventType = GetEventType(ev);
    switch(nEventType)
    {
       case EVENT_TYPE_AREALOAD_PRELOADEXIT:
        {
        object oAreaAq = GetArea("arl100cr_perth");
        object oAquae = GetObjectByTag("aquae");
        int aType = GetObjectType(aAquae);
         location aLoc = Location(oAreaAq,(355.699,344.979,36.9077),0);

         CreateObject(aType,"aquae.utc",aLoc);
   }
}

Modifié par Lotion Soronnar, 06 janvier 2010 - 07:10 .


#11
DavidSims

DavidSims
  • BioWare Employees
  • 196 messages
Do you know how to see compile errors? The code you've posted has a number of errors that wouldn't compile. Try this:



void main()

{

event ev = GetCurrentEvent();

int nEventType = GetEventType(ev);

switch(nEventType)

{

case EVENT_TYPE_AREALOAD_PRELOADEXIT:

{

object oArea = GetArea(GetHero());

location aLoc = Location(oArea, Vector(355.699,344.979,36.9077),0.0);



CreateObject(OBJECT_TYPE_CREATURE, R"aquae.utc", aLoc);

break;

}

}

}

#12
Lotion Soronarr

Lotion Soronarr
  • Members
  • 14 481 messages
But wouldn't this place the NPC in any area the PC is currently in, instead of a specific area (Redclifffe)?



But yes...I should have seen the compile errors. I can be downright stupid sometimes.

#13
Craig Graff

Craig Graff
  • Members
  • 608 messages
See the "Insert content into an existing area" section of
social.bioware.com/wiki/datoolset/index.php/How-tos

Set up your 2da so the script only runs when entering Redcliffe, if that's what you want.

Modifié par Craig Graff, 07 janvier 2010 - 10:47 .


#14
Lotion Soronarr

Lotion Soronarr
  • Members
  • 14 481 messages
Thank you very much :)

#15
DavidSims

DavidSims
  • BioWare Employees
  • 196 messages

Lotion Soronnar wrote...

But wouldn't this place the NPC in any area the PC is currently in, instead of a specific area (Redclifffe)?

But yes...I should have seen the compile errors. I can be downright stupid sometimes.


You can't create creatures in areas the player isn't in. Well, maybe within the area list, but I don't like to rely on that. You have to create the creature using the area load script for the specific area.

#16
Lotion Soronarr

Lotion Soronarr
  • Members
  • 14 481 messages
HMmmm
****


#include "plt_aquae_plot"
#include "wrappers_h"

void main()
{

    if (WR_GetPlotFlag(PLT_AQUAE_PLOT, AQUAE_PLACED_1) == FALSE)
    {
        object oTown = GetObjectByTag("arl100ar_redcliffe_village");
        vector vAqLocation = Vector(288.951f, 381.666f, 40.514f);

        CreateObject(
            OBJECT_TYPE_CREATURE,
            R"aquae.utc",
            Location(oTown, vAqLocation, 180.0f)
        )

        WR_SetPlotFlag("aquae_plot", AQUAE_PLACED_1, TRUE)
    }
}




Why do I get a "E: 19:09:28 - add_aquae_redcliffe.nss - add_aquae_redcliffe.nss(18): No semicolon after expression" compile error? I removed the ; and I still get the same error.

Every single script so far shows 1warning when compliling - and I copy-paste the mfrom tutorials. Are these bogus warnings?


EDIT: I do have a PRSCR_Aquae.gda all setup (wiht the area list name and script name), and still the NPC ain't appearing...

Modifié par Lotion Soronnar, 08 janvier 2010 - 06:15 .


#17
FalloutBoy

FalloutBoy
  • Members
  • 580 messages
Because there is no semicolon after this expression, just like the error says. :)

CreateObject(
            OBJECT_TYPE_CREATURE,
            R"aquae.utc",
            Location(oTown, vAqLocation, 180.0f)
        )

That last ) needs a semicolon after it because it is the end of the expression. You also need one at the end of the line right after it too.

These errors you are seeing are not warnings. They are *errors*. Meaning if you don't fix them, your script won't do anything. You cannot ignore them.

Modifié par FalloutBoy, 08 janvier 2010 - 06:24 .


#18
Lotion Soronarr

Lotion Soronarr
  • Members
  • 14 481 messages
Missed that one. Heh..it was showing the error on line 18.

Complies without errors...NPC still doesn't show up....hmmmmmm


*******
Well, since oyu seem to be in the mood for answering questions:
#include "utility_h"
#include "plt_aquae_plot"
#include "add_custom_party_member_h"

void main() {

object oHero = GetHero();
object oAquae = CreateObject(OBJECT_TYPE_CREATURE, R"aquae.utc", GetLocation(oHero));

hireCustomFollower(oAquae, class_WIZZARD, PLT_AQUAE_PLOT, AQUAE_JOIN);



SetPartyPickerGUIStatus(2);
ShowPartyPickerGUI();
}


I get this:
E: 20:00:46 - party_join_script.nss - party_join_script.nss(10): Variable defined without type (while compiling var_constants_h.nss)

The add_custom_party_member_h is hireCustomFollower_h from the tutorial..I just gave it a different name.

Modifié par Lotion Soronnar, 08 janvier 2010 - 07:04 .


#19
FalloutBoy

FalloutBoy
  • Members
  • 580 messages
What is "class_WIZZARD"? Unless you defined this in one of those headers, I'm pretty sure it's supposed to be "class_WIZARD". Variable defined without type means you are trying to use a variable that doesn't exist because it was never defined. Often because something was misspelled or got upper/lower case mixed up.


#20
Lotion Soronarr

Lotion Soronarr
  • Members
  • 14 481 messages
IT is defined...nevermind..I discovered somewthing else entirely.

I switched back to using the regular UT_HireFollower instead of the modified script.

Get this - if I run the place_aquae_redclifffe and aquae_party_join scripts from the console - BOTH WORK.

She appears in Redcliffe and the joins the party. But playing normally, nether script fires!!!!
I just don't get this..

I get it that I might put a typo somewhere in the PRSCR file (but I copy-pasted resource named directly from the toolset), but hte hire script is called directly from the convo. Has can that possibly misfire???

EDIT: Forget I said anyting. I have been testing so many possible combinations that I forgot I switcehd back to triggering via plot-flags in the convo.
HA!

Modifié par Lotion Soronnar, 08 janvier 2010 - 07:30 .


#21
Lotion Soronarr

Lotion Soronarr
  • Members
  • 14 481 messages
MORON, MORON, MORON, MORON!!!!



PRCSCR... hehe..works now. She appears and I can hire her.



Still need to tweak it a bit, since Iwant to use the hire function that allows her template to be used...that and I get 2 of her, so I have to change Create to Get