[SOLVED] Min Z Issue

O Ilusionista

Captain 100K
I have an entity (type none) which I want to make subject to min z (or it looks to be on the wall).
I tried to add subject_to_min_z 1 to the header, but it doesn't works. I also set it by script, and doesn't works too.

Should I need to script its position?

Here is the header:

name    tthunder
type    none
subtype arrow
shadow  0
nolife  1
speed  0
remove 0
candamage player npc obstacle

subject_to_wall  1
subject_to_platform 1
subject_to_hole 1
no_adjust_base  0
subject_to_minz 1
subject_to_maxz 1

offscreenkill 200

animationscript data/scripts/grabscript.c
 
O Ilusionista said:

IIRC, TYPE_NONE shortcuts several of the AI routines for optimization. You could theoretically force it to follow an AI pattern that would check for Z, but it would be much simpler to do it manually with onmovezscript and perfectly efficient.

<pseudocode>
Code:
minz  = Level Min Z
pos_z = entity Z

if pos_z < minz

set entity position = minz
 
Thanks, I solved this issue using this code. But not as onmovezscript (since the entity were not moving in Z axis, the script didn't worked), but as ondrawscript

Code:
void main()
{ // Limits z movement to certain z coords
    void self = getlocalvar("self");
    int z = getentityproperty(self,"z"); //Get character's z coordinate
	int minZ = openborvariant("PLAYER_MIN_Z");
	int maxZ = openborvariant("PLAYER_MAX_Z");
	
    if(z < minZ){ // Reached z limit
      changeentityproperty(self, "position", NULL(), minZ+5);
    }
    else if(z > maxZ){ // Reached z limit
      changeentityproperty(self, "position", NULL(), maxZ-5);
    }
}
 
Back
Top Bottom