2 registered members (AndrewAMD, SBGuy),
987
guests, and 3
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Path makes NPC disappear
#455708
10/28/15 05:41
10/28/15 05:41
|
Joined: Jun 2010
Posts: 590 California
Ruben
OP
User
|
OP
User
Joined: Jun 2010
Posts: 590
California
|
I am trying to make a model walk a certain path titled "path_001" on a spiral staircase in a WED file. I created the path in WED, and it is titled "path_001". I placed a model on the spiral staircase. The model gets placed when I put this code in my program:
...
ENTITY* monster;
...
monster = ent_create("monster.mdl", vector(1,564,247), monster_action );
...
However, when I place this code in the monster_action() function:
...
action monster_code()
{
...
ent_movepath(me, "path_001", 2, 1+2); // THIS CODE HERE
while(1)
{
...
wait(1);
}
}
...the monster that would normally have been placed when the level loaded, does not show up when the game loads. Has anyone else had the problem of a model not being loaded when you try to program it to move along a certain path using the ent_movepath() function?
|
|
|
Re: Path makes NPC disappear
[Re: Ruben]
#455709
10/28/15 06:01
10/28/15 06:01
|
Malice
Unregistered
|
Malice
Unregistered
|
Never had the issue, however use my own path code not this function. Simple debugging
action monster_code()
{
var I_live=0;
...
if(my)
beep();
ent_movepath(me, "path_001", 2, 1+2); // THIS CODE HERE
while(1)
{
if(my)
I_live=1;
DEBUG_VAR(my.x,50);
DEBUG_VAR(my.y,100);
DEBUG_VAR(my.z,150);
DEBUG_VAR(I_live,200);
...
wait(1);
}
}
If you see red numbers and any are none zero, the ent was created, most likely the path name is wrong. Also listen for the BEEP - if you hear the BEEP but do not get the numbers , then ent has slipped into a black hole and become uncreated. EDIT - also not in the ent_create action named monster_action, but action named monster_code.. EDIT2- ACTUAL code for ent_movepath - no way to REMOVE ent
// let an entity move along a closed path with given speed
function ent_movepath(ENTITY* ent,char* pathname,var speed,var mode)
{
proc_kill2(ent_movepath,ent);
var vLastPos[3],vDir[3];
vec_set(vLastPos,ent.x);
var dist = 0;
if(pathname) path_set(ent,pathname);
while(speed)
{
// place the entity along the path
path_spline(ent,ent.x,dist);
dist += speed*time_step;
// adjust the entity to the floor
if(mode&1)
ent_placefloor(ent);
// let the entity look ahead in movement direction
if(mode&2) {
vec_diff(vDir,ent.x,vLastPos);
vec_to_angle(ent.pan,vDir);
vec_set(vLastPos,ent.x);
}
var ehandle = handle(ent);
wait(1);
ent = ptr_for_handle(ehandle);
}
}
You can edit it to debug if path is found, by changing here
var is_path=0;
if(pathname) is_path=path_set(ent,pathname);
while(speed)
{ DEBUG_VAR(is_path,300);
If red '1' at pixel 300 path found, if red '0' path not found. OK bed time for me Have fun Mal
Last edited by Malice; 10/28/15 06:10.
|
|
|
Re: Path makes NPC disappear
[Re: ]
#455712
10/28/15 06:19
10/28/15 06:19
|
Joined: Jun 2010
Posts: 590 California
Ruben
OP
User
|
OP
User
Joined: Jun 2010
Posts: 590
California
|
Never had the issue, however use my own path code not this function. Simple debugging
action monster_code()
{
var I_live=0;
...
if(my)
beep();
ent_movepath(me, "path_001", 2, 1+2); // THIS CODE HERE
while(1)
{
if(my)
I_live=1;
DEBUG_VAR(my.x,50);
DEBUG_VAR(my.y,100);
DEBUG_VAR(my.z,150);
DEBUG_VAR(I_live,200);
...
wait(1);
}
}
If you see red numbers and any are none zero, the ent was created, most likely the path name is wrong. Also listen for the BEEP - if you hear the BEEP but do not get the numbers , then ent has slipped into a black hole and become uncreated. Thank you Malice. Strange. The beep sounded. The x and y red numbers are both increasing rapidly, while the z red number stays at the same number. It seems that for some reason, the monster is being moved continuously with the x and y coordinates. Also, the number 1 in red showed up underneath the top three values, showing that the monster entity was created. When I comment out the ent_movepath() code in the monster_code() function, the entity loads in the spot where I put it, and the red numbers are above 0, and not changing. So, it appears that the ent_movepath() function is somehow causing the entity to move continuously with the x and y coordinates. I set the path along the spiral staircase in a tower, although I noticed that the yellow lines representing the path showed up on top of the tower, instead of inside the tower. I am not sure if that has anything to do with the error.
Last edited by Ruben; 10/28/15 06:28.
|
|
|
Re: Path makes NPC disappear
[Re: Ruben]
#455713
10/28/15 06:40
10/28/15 06:40
|
Malice
Unregistered
|
Malice
Unregistered
|
Really tired now.
Your path should not be on top of the tower. In wed select whole path -> enter vertex mode -> manually select each node and move it into place.
Also place a camera on the monsters back .. vec_set(vec_temp,vector(-150,0,0)); vec_rotate(vec_temp,my.pan); vec_add(vec_temp,my.x); ... maybe vec_to_angle(camera.pan,vec_diff(NULL,my.x,camera.x));
See what he is up to, maybe he has a second family with a hotter, younger wife.
Ok night
|
|
|
Re: Path makes NPC disappear
[Re: ]
#455714
10/28/15 07:11
10/28/15 07:11
|
Joined: Jun 2010
Posts: 590 California
Ruben
OP
User
|
OP
User
Joined: Jun 2010
Posts: 590
California
|
lol
I placed the path directly above where the spiral staircase path is, however the yellow lines and nodes representing the path appears to be located over the top of the tower that the spiral staircase is in, even though the path is in line with the spiral staircase. I thought the path applies to all locations over or under it on the z coordinate, when you create the path in WED.
In creating the path, I opened the WED file, went to Object tab / Add Path / placed the first path node along the spiral staircase / Vertex Move / then clicked on the subsequent node locations in the path along the spiral staircase.
I never thought the height on where the nodes and line were located mattered.
Last edited by Ruben; 10/28/15 07:11.
|
|
|
Re: Path makes NPC disappear
[Re: Ruben]
#455715
10/28/15 07:22
10/28/15 07:22
|
Joined: Jun 2010
Posts: 590 California
Ruben
OP
User
|
OP
User
Joined: Jun 2010
Posts: 590
California
|
Ah, never mind. I relocated the path lower within the tower, approximately where the monster is located. Now I see the monster, and it is moving along the spiral staircase.
Last edited by Ruben; 10/28/15 07:23.
|
|
|
Re: Path makes NPC disappear
[Re: Ruben]
#455778
10/29/15 21:46
10/29/15 21:46
|
Joined: Jun 2010
Posts: 590 California
Ruben
OP
User
|
OP
User
Joined: Jun 2010
Posts: 590
California
|
Okay, so what I am really trying to do is make a monster stand idle on a spiral staircase. If the player gets within a certain distance of the monster, I want the monster to stop standing idle, and follow a path titled "path_000" that I set along the entire spiral staircase from bottom to top. So far, the monster shows up standing idle on the spiral staircase when the level is loaded. When the player gets within the certain distance of it, triggering the c_scan() function within the monster_code() function, I get this pop-up error stating:
Error E1513
Script crash in ent_movepath:
OK Cancel
When I press the OK button, the player just moves forward on its own infinitely without me moving it, until I press the Esc button ending the game. This is the code I have that is making this happen:
action monster_code()
{
...
while(1)
{
...
my.ANIMATION += 3*time_step;
ent_animate(me,"idle",my.ANIMATION,ANM_CYCLE);
c_scan(my.x,my.pan,vector(360,0,750),SCAN_ENTS | SCAN_FLAG2 | IGNORE_ME);
if (you)
{
...
ent_movepath(me, "path_000", 2, 1+2);
...
}
...
ent_bonerotate(my, "Bip01 Spine1", vector(limit2,limit,limit3));
my.tilt = 0;
my.roll = 0;
wait(1);
}
}
It seems that the monster will move along the path if the ent_movepath() is set before the while(1) loop, but not if the ent_movepath() is set within the while(1) loop. I only want the monster to follow the path if the player triggers its c_scan() function, that is within the while(1) loop. Is this allowed with the ent_movepath() function? NOTE: The program even acts strangely if I place the ent_movepath() function before the while(1) loop. If I specify where in the level I want the monster to be placed using the ent_create() function, the monster will be there where I specified, before the c_scan() is triggered - to which the monster disappears altogether. If the ent_movepath() function is before the while(1) loop, the monster will not be where I specified, being totally non-visible. After awhile, the monster shows up coming up from underneath the floor (bottom of the spiral staircase room) where the "path_000" begins, and starts moving up the spiral staircase, along the "path_000" path, from bottom to top. I actually placed the monster a little ways up along the spiral staircase, so how it moves underneath the spiral staircase room is beyond me.
Last edited by Ruben; 10/29/15 22:00.
|
|
|
Re: Path makes NPC disappear
[Re: Ruben]
#455781
10/29/15 22:36
10/29/15 22:36
|
Malice
Unregistered
|
Malice
Unregistered
|
Hello , A few thing to say in no good order First - I have told you not to check if(you) as a Boolean. YOU' will ALWAYS have a value, if c_scan finds nothing YOU still has a value. If you do no want to compare pointer 'if(you ==player), then set YOU=0; before the scan. Next - you are not setting IGNORE_ME, I realize the SCAN_FLAG2 may be used to stop the ME ent from being found and return into the YOU pointer. However if the monster has flag2 set then infact it will find itself and return it's own pointer into the YOU pointer.
//before loop...
var im_on_path=0;
// in loop................................
you=NULL;
c_scan(my.x,my.pan,vector(360,0,750),SCAN_ENTS | SCAN_FLAG2 | IGNORE_ME);
if (you && !im_on_path)
{
im_on_path=1;
...
ent_movepath(me, "path_000", 2, 1+2);
...
}
Next paths in wed have 2 names, one name is this WED list name and it's not important , the second name is it's real name. IN WED -> click path to select it, -> look at it's properties tab -> ignore name in path box, check name in NAME bow. Make sure you have the right path name E1513 in the ent_movepath function can only be caused by -> the ME pointer is invalid or the path name is ivalid. Last - Start a new level -> copy the path however put it in a empty hollow cube, -> add the player and monster to this new test level -> include you script with the actions for player/monster. Run you'r test in a big empty level so you can see what the heck happens to the monster when the player comes near. Final - Always test new code and re-actions in small mostly empty test-level. If it works in the test then you can add it to a larger real level. Your game level is for play testing not for learning by trail. Have fun Mal
Last edited by Malice; 10/29/15 22:37.
|
|
|
Re: Path makes NPC disappear
[Re: ]
#455784
10/29/15 23:09
10/29/15 23:09
|
Malice
Unregistered
|
Malice
Unregistered
|
Here is the actual function from the entmove.c file.
function ent_movepath(ENTITY* ent,char* pathname,var speed,var mode)
{
proc_kill2(ent_movepath,ent);
var vLastPos[3],vDir[3];
vec_set(vLastPos,ent.x);
var dist = 0;
if(pathname) path_set(ent,pathname);
while(speed)
{
// place the entity along the path
path_spline(ent,ent.x,dist);
dist += speed*time_step;
// adjust the entity to the floor
if(mode&1)
ent_placefloor(ent);
// let the entity look ahead in movement direction
if(mode&2) {
vec_diff(vDir,ent.x,vLastPos);
vec_to_angle(ent.pan,vDir);
vec_set(vLastPos,ent.x);
}
var ehandle = handle(ent);
wait(1);
ent = ptr_for_handle(ehandle);
}
}
As I fallow this, I think only if the MY pointer is invalid you would get e1513 You could include a local version of this function and not use the entmove.c version, then you can add some debugging to track it. EDIT - When continuing after the e1513 , you state the monster walks blind forward. I would then think - if no other code is moving it - that path_spline is moving it, but failing somehow do to path_set being invaild.. However I'm not going to do a bunch of testing. EDIT2 - One more note, path_spline moves the ent Without collision. For this reason I wrote my own path function. Based on what you report, I think the monster is moving without collsion to node 0/1(whatever) through the floor. That is why it pops up at the first node through from below the floor, Then the crash might be ent_placefloor() Have fun Mal
Last edited by Malice; 10/29/15 23:32.
|
|
|
Moderated by mk_1, Perro, rayp, Realspawn, Rei_Ayanami, rvL_eXile, Spirit, Superku, Tobias, TSG_Torsten, VeT
|