Gene

08/12/2005 17:52:14

Vereis, me gustaria hacer ke los pnjs del area anden a su bola por todo ese mismo area, con los puntos de ruta sirve ya pero es muy kansino, aparte de ke tiene kse kambiar muxas etiketas solamente para ke anden.

si alghuno sabe un guion ke sea ese ke anden aleatoriamente ke lo diga.,

asias

Maya

08/12/2005 19:02:25

EL Script que yo uso es este en el ON Heartbeat, hay muchas otras posibilidades, pero esta me funciona bien y no me da ningun problema de atascos raros.

[quote:c7e67fbcc2]void main()
{
int nValue = Random(10);
if (nValue < 3)
{
vector vCurrent = GetPosition(OBJECT_SELF);
float fOldX = vCurrent.x;
float fOldY = vCurrent.y;
float fOldZ = vCurrent.z;
int nX = Random(7);
int nY = Random(7);
int nSignY = Random(2);
float fNewX;
float fNewY;
float fNewZ = fOldZ;
switch(nSignX)
{
case 0:
fNewX = fOldX + IntToFloat(nX);
break;
case 1:
fNewX = fOldX - IntToFloat(nX);
break;
}
switch(nSignY)
{
case 0:
fNewY = fOldY + IntToFloat(nY);
break;
case 1:
fNewY = fOldY - IntToFloat(nY);
break;
}

object oArea = GetArea(OBJECT_SELF);
vector vNew = Vector(fNewX, fNewY, fNewZ);
float fFacing = GetFacing(OBJECT_SELF);

location lNewSpot = Location(oArea, vNew, fFacing);


AssignCommand(OBJECT_SELF, ActionMoveToLocation(lNewSpot, FALSE));

[color=red:c7e67fbcc2] int nRun = Random(100);
if (nRun < 7)
AssignCommand(OBJECT_SELF, ActionMoveToLocation(lNewSpot, TRUE));
else
AssignCommand(OBJECT_SELF, ActionMoveToLocation(lNewSpot, FALSE));[/color:c7e67fbcc2]


}
}[/quote:c7e67fbcc2]

Las lineas en rojo añadelas si quieres que en vez de andar corran, si no borralas o desactivalas con dos barras //

09/12/2005 00:33:18

Hay un metodo mas sencillo y que a mi me gusta mucho, es el que usa Loinar Firstbone, el enano de la entrada de Calimport que parece que os espia a todos xD.

Solo hay qu eir al PNJ y en la pestaña de avanzado darle a boton de variables y añadir esta

X2_L_SPAWN_USE_AMBIENT

con el valor

1

y que sea de tipo "int"

Andriu_ZGZ

11/12/2005 03:14:55

He probado a añadir la variable y no me funciona, no se si sera por que el X2_L_SPAWN_USE_AMBIENT no lo tengo como recurso en el módulo, pero no me aparece tampoco como recurso del juego *se queda pensativo*.

Un saludico :wink:

Maya

11/12/2005 03:30:43

es que lo bueno de usar un script aparte en el on heart beat es que luego puedes ponerles un tag DAY NOGHT y activar el on spawn de comportamientos con lo que consigues que ese PNJ este en un sitio dedia o a una hora concreta y denoche en otro sitio y luego durante un rango de horas haga lo que le salga del xDDDDde ahi ...

11/12/2005 21:17:56

Pues eso tambien se puede hacer facilmente poniendo en el punto de ruta una etiqueta especial, ya defiinida en el juego, lo usa el barquero de Calimport, por el dia pasea y por la noche se queda en el barco o algo asi :P

No entiendo porque a ti no te va, eso esta ya predefinido en el juego, como lo del varquero es muy sencillo de poner.

Maya

11/12/2005 23:04:10

xDDDD, en su dia no funciono y se diseño este script para solucionar eso de hecho no estaba en al version NWN y si lo estaba no lo vi, con las siguientes versiones sacaron en creo... la expansion 1 lo de DAY NIGHT Tags, en comportaientos, y la lucecita se me encendio , como bien sabes hay muchas maneras de llegar a la misma solucion xDDDDD.

por otro lado en aquella epoca las variables de los NPc para mi eraninexistentes xDDD, me di cuenta de ellas con la expansion dos xDDD, hasta entonces todo se hacia a pico y pala como quien dice.

Gene

13/12/2005 23:51:01

ya l descubri, hay un scrip por defecto en los pnjs, en onSpaw, solo hay ke manipularle y cpiarle para no sobrescrivirle, solo hay ke kitarle 2 // ke tiene p ke el scrip funcione asi.

Gene

13/12/2005 23:53:22

Adjunt aki el scrip solo hay ke pnerle en OnSpaw de la criatura






//:://////////////////////////////////////////////////
//:: GN_A_MOVERSE
/*
* Default OnSpawn handler with XP1 revisions.
* This corresponds to and produces the same results
* as the default OnSpawn handler in the OC.
*
* This can be used to customize creature behavior in three main ways:
*
* - Uncomment the existing lines of code to activate certain
* common desired behaviors from the moment when the creature
* spawns in.
*
* - Uncomment the user-defined event signals to cause the
* creature to fire events that you can then handle with
* a custom OnUserDefined event handler script.
*
* - Add new code _at the end_ to alter the initial
* behavior in a more customized way.
*/
//:://////////////////////////////////////////////////
//:: Copyright (c) 2002 Floodgate Entertainment
//:: Created By: Naomi Novik
//:: Created On: 12/11/2002
//:://////////////////////////////////////////////////
//:: Updated 2003-08-20 Georg Zoeller: Added check for variables to active spawn in conditions without changing the spawnscript


#include "x0_i0_anims"
// #include "x0_i0_walkway" - in x0_i0_anims
#include "x0_i0_treasure"

#include "x2_inc_switches"

void main()
{
// ***** Spawn-In Conditions ***** //

// * REMOVE COMMENTS (// ) before the "Set..." functions to activate
// * them. Do NOT touch lines commented out with // *, those are
// * real comments for information.

// * This causes the creature to say a one-line greeting in their
// * conversation file upon perceiving the player. Put [NW_D2_GenCheck]
// * in the "Text Seen When" field of the greeting in the conversation
// * file. Don't attach any player responses.
// *
// SetSpawnInCondition(NW_FLAG_SPECIAL_CONVERSATION);

// * Same as above, but for hostile creatures to make them say
// * a line before attacking.
// *
// SetSpawnInCondition(NW_FLAG_SPECIAL_COMBAT_CONVERSATION);

// * This NPC will attack when its allies call for help
// *
// SetSpawnInCondition(NW_FLAG_SHOUT_ATTACK_MY_TARGET);

// * If the NPC has the Hide skill they will go into stealth mode
// * while doing WalkWayPoints().
// *
// SetSpawnInCondition(NW_FLAG_STEALTH);

//--------------------------------------------------------------------------
// Enable stealth mode by setting a variable on the creature
// Great for ambushes
// See x2_inc_switches for more information about this
//--------------------------------------------------------------------------
if (GetCreatureFlag(OBJECT_SELF, CREATURE_VAR_USE_SPAWN_STEALTH) == TRUE)
{
SetSpawnInCondition(NW_FLAG_STEALTH);
}
// * Same, but for Search mode
// *
// SetSpawnInCondition(NW_FLAG_SEARCH);

//--------------------------------------------------------------------------
// Make creature enter search mode after spawning by setting a variable
// Great for guards, etc
// See x2_inc_switches for more information about this
//--------------------------------------------------------------------------
if (GetCreatureFlag(OBJECT_SELF, CREATURE_VAR_USE_SPAWN_SEARCH) == TRUE)
{
SetSpawnInCondition(NW_FLAG_SEARCH);
}
// * This will set the NPC to give a warning to non-enemies
// * before attacking.
// * NN -- no clue what this really does yet
// *
// SetSpawnInCondition(NW_FLAG_SET_WARNINGS);

// * Separate the NPC's waypoints into day & night.
// * See comment on WalkWayPoints() for use.
// *
// SetSpawnInCondition(NW_FLAG_DAY_NIGHT_POSTING);

// * If this is set, the NPC will appear using the "EffectAppear"
// * animation instead of fading in, *IF* SetListeningPatterns()
// * is called below.
// *
//SetSpawnInCondition(NW_FLAG_APPEAR_SPAWN_IN_ANIMATION);

// * This will cause an NPC to use common animations it possesses,
// * and use social ones to any other nearby friendly NPCs.
// *
// SetSpawnInCondition(NW_FLAG_IMMOBILE_AMBIENT_ANIMATIONS);

//--------------------------------------------------------------------------
// Enable immobile ambient animations by setting a variable
// See x2_inc_switches for more information about this
//--------------------------------------------------------------------------
if (GetCreatureFlag(OBJECT_SELF, CREATURE_VAR_USE_SPAWN_AMBIENT_IMMOBILE) == TRUE)
{
SetSpawnInCondition(NW_FLAG_IMMOBILE_AMBIENT_ANIMATIONS);
}
// * Same as above, except NPC will wander randomly around the
// * area.
// *
SetSpawnInCondition(NW_FLAG_AMBIENT_ANIMATIONS);


//--------------------------------------------------------------------------
// Enable mobile ambient animations by setting a variable
// See x2_inc_switches for more information about this
//--------------------------------------------------------------------------
if (GetCreatureFlag(OBJECT_SELF, CREATURE_VAR_USE_SPAWN_AMBIENT) == TRUE)
{
SetSpawnInCondition(NW_FLAG_AMBIENT_ANIMATIONS);
}
// **** Animation Conditions **** //
// * These are extra conditions you can put on creatures with ambient
// * animations.

// * Civilized creatures interact with placeables in
// * their area that have the tag "NW_INTERACTIVE"
// * and "talk" to each other.
// *
// * Humanoid races are civilized by default, so only
// * set this flag for monster races that you want to
// * behave the same way.
// SetAnimationCondition(NW_ANIM_FLAG_IS_CIVILIZED);

// * If this flag is set, this creature will constantly
// * be acting. Otherwise, creatures will only start
// * performing their ambient animations when they
// * first perceive a player, and they will stop when
// * the player moves away.
// SetAnimationCondition(NW_ANIM_FLAG_CONSTANT);

// * Civilized creatures with this flag set will
// * randomly use a few voicechats. It's a good
// * idea to avoid putting this on multiple
// * creatures using the same voiceset.
// SetAnimationCondition(NW_ANIM_FLAG_CHATTER);

// * Creatures with _immobile_ ambient animations
// * can have this flag set to make them mobile in a
// * close range. They will never leave their immediate
// * area, but will move around in it, frequently
// * returning to their starting point.
// *
// * Note that creatures spawned inside interior areas
// * that contain a waypoint with one of the tags
// * "NW_HOME", "NW_TAVERN", "NW_SHOP" will automatically
// * have this condition set.
// SetAnimationCondition(NW_ANIM_FLAG_IS_MOBILE_CLOSE_RANGE);


// **** Special Combat Tactics *****//
// * These are special flags that can be set on creatures to
// * make them follow certain specialized combat tactics.
// * NOTE: ONLY ONE OF THESE SHOULD BE SET ON A SINGLE CREATURE.

// * Ranged attacker
// * Will attempt to stay at ranged distance from their
// * target.
// SetCombatCondition(X0_COMBAT_FLAG_RANGED);

// * Defensive attacker
// * Will use defensive combat feats and parry
// SetCombatCondition(X0_COMBAT_FLAG_DEFENSIVE);

// * Ambusher
// * Will go stealthy/invisible and attack, then
// * run away and try to go stealthy again before
// * attacking anew.
// SetCombatCondition(X0_COMBAT_FLAG_AMBUSHER);

// * Cowardly
// * Cowardly creatures will attempt to flee
// * attackers.
// SetCombatCondition(X0_COMBAT_FLAG_COWARDLY);


// **** Escape Commands ***** //
// * NOTE: ONLY ONE OF THE FOLLOWING SHOULD EVER BE SET AT ONE TIME.
// * NOTE2: Not clear that these actually work. -- NN

// * Flee to a way point and return a short time later.
// *
// SetSpawnInCondition(NW_FLAG_ESCAPE_RETURN);

// * Flee to a way point and do not return.
// *
// SetSpawnInCondition(NW_FLAG_ESCAPE_LEAVE);

// * Teleport to safety and do not return.
// *
// SetSpawnInCondition(NW_FLAG_TELEPORT_LEAVE);

// * Teleport to safety and return a short time later.
// *
// SetSpawnInCondition(NW_FLAG_TELEPORT_RETURN);



// ***** CUSTOM USER DEFINED EVENTS ***** /


/*
If you uncomment any of these conditions, the creature will fire
a specific user-defined event number on each event. That will then
allow you to write custom code in the "OnUserDefinedEvent" handler
script to go on top of the default NPC behaviors for that event.

Example: I want to add some custom behavior to my NPC when they
are damaged. I uncomment the "NW_FLAG_DAMAGED_EVENT", then create
a new user-defined script that has something like this in it:

if (GetUserDefinedEventNumber() == 1006) {
// Custom code for my NPC to execute when it's damaged
}

These user-defined events are in the range 1001-1007.
*/

// * Fire User Defined Event 1001 in the OnHeartbeat
// *
// SetSpawnInCondition(NW_FLAG_HEARTBEAT_EVENT);

// * Fire User Defined Event 1002
// *
// SetSpawnInCondition(NW_FLAG_PERCIEVE_EVENT);

// * Fire User Defined Event 1005
// *
// SetSpawnInCondition(NW_FLAG_ATTACK_EVENT);

// * Fire User Defined Event 1006
// *
// SetSpawnInCondition(NW_FLAG_DAMAGED_EVENT);

// * Fire User Defined Event 1008
// *
// SetSpawnInCondition(NW_FLAG_DISTURBED_EVENT);

// * Fire User Defined Event 1003
// *
// SetSpawnInCondition(NW_FLAG_END_COMBAT_ROUND_EVENT);

// * Fire User Defined Event 1004
// *
// SetSpawnInCondition(NW_FLAG_ON_DIALOGUE_EVENT);



// ***** DEFAULT GENERIC BEHAVIOR (DO NOT TOUCH) ***** //

// * Goes through and sets up which shouts the NPC will listen to.
// *
SetListeningPatterns();

// * Walk among a set of waypoints.
// * 1. Find waypoints with the tag "WP_" + NPC TAG + "_##" and walk
// * among them in order.
// * 2. If the tag of the Way Point is "POST_" + NPC TAG, stay there
// * and return to it after combat.
//
// * Optional Parameters:
// * void WalkWayPoints(int nRun = FALSE, float fPause = 1.0)
//
// * If "NW_FLAG_DAY_NIGHT_POSTING" is set above, you can also
// * create waypoints with the tags "WN_" + NPC Tag + "_##"
// * and those will be walked at night. (The standard waypoints
// * will be walked during the day.)
// * The night "posting" waypoint tag is simply "NIGHT_" + NPC tag.
WalkWayPoints();

//* Create a small amount of treasure on the creature
if ((GetLocalInt(GetModule(), "X2_L_NOTREASURE") == FALSE) &&
(GetLocalInt(OBJECT_SELF, "X2_L_NOTREASURE") == FALSE) )
{
CTG_GenerateNPCTreasure(TREASURE_TYPE_MONSTER, OBJECT_SELF);
}


// ***** ADD ANY SPECIAL ON-SPAWN CODE HERE ***** //

// * If Incorporeal, apply changes
if (GetCreatureFlag(OBJECT_SELF, CREATURE_VAR_IS_INCORPOREAL) == TRUE)
{
effect eConceal = EffectConcealment(50, MISS_CHANCE_TYPE_NORMAL);
eConceal = ExtraordinaryEffect(eConceal);
effect eGhost = EffectCutsceneGhost();
eGhost = ExtraordinaryEffect(eGhost);
ApplyEffectToObject(DURATION_TYPE_PERMANENT, eConceal, OBJECT_SELF);
ApplyEffectToObject(DURATION_TYPE_PERMANENT, eGhost, OBJECT_SELF);

}

}

Andriu_ZGZ

14/12/2005 17:00:32

He probado el script de Gene y para ciertos pnjs va muy bien, lo combinare con los puntos de ruta y seguire investigando las opciones de Althor y maya.

Gracias, estoy empezando con esto y voy poco a poco.

Un saludico :wink:

moses

17/03/2006 17:03:19

saludos, yo estoy siguiendo el metodo de Althor, que me parece muy sencillito y me da wenos resultados.

Pero rizando el rizo, amigo althor, podrias explicar ese metodo para q de dia esten en un sitio y de noche en otro?

Y rizando aun mas... se podria hacer con tu sistema que x ejemplo si llueve o nieva, tb vayan a otro sitio?, es decir, q de dia esten en la calle, xo si anochece o llueve o nieva de dia q se metan en sus casas o en la posada por ejemplo.

Gracias de antemano!!!

17/03/2006 20:37:46

En este link puedes encontrar mas informacion sobre los prefijos de los puntos de ruta o waypoints, que haran que un pnj se quede en una posicion y aunque se mueva vuelva a ella, que tenga rutas diferentes de dia y de noche, y que por la noche se vaya a una posicion concreta.

http://nwn.bioware.com/builders/sctutorial5.html