[SCRIPT] Water Puddle Effect v1.61 (old version)

White Dragon

New member
WATER PUDDLE EFFECT (with ripple and splash effect) v1.61

********This is an old post.********
Latest version is here: http://www.chronocrash.com/forum/index.php?topic=2549.0


index.php
index.php
index.php


TODO LIST:
1) Get a splash sound and put it into "data/sounds/water_splash01.wav" path.
2) Make a water splash entity named water_splash like:
index.php


3) Make a ripple entity like:
index.php

  divide it in 2 parts frontal and back. Back part is disblayable at the back of the character,
  frontal part is in front of the character.
  - name frontal ripple entity as water_ripple_front
  - name back ripple entity as water_ripple_back
  make them like:
FRONTAL: BACK:
index.php
 
index.php


Use these features for ripple/splash:
Code:
name WHAT-YOU-WANT
type	none
toflip 1
nomove 1 0

subject_to_wall 0
subject_to_obstacle 0
subject_to_platform 0
subject_to_gravity 0
no_adjust_base 1

4) Make a water puddle empty entity like (changing width/depth/height params if you want):
Code:
name	water_puddle_test
type	none
health	1
nomove	1 0
facing	1
nodieblink 2
nodrop 1
nolife 1
gfxshadow 1

height 20

subject_to_platform 0
subject_to_obstacle 0
subject_to_wall 0
subject_to_hole 0
subject_to_gravity 0
no_adjust_base 1

load water_splash
load water_ripple_front
load water_ripple_back

onspawnscript @script
void main() {
	void self = getlocalvar("self");

	setentityvar(self, 0, "water_puddle"); // name/type
	setentityvar(self, 1, 1024); // width
	setentityvar(self, 2, 20);    // height
	setentityvar(self, 3, 180);  // depth
	setentityvar(self, "map", 0);  // ripple/splash map
	setentityvar(self, "transp", 30);  // alpha transp value
}
@end_script

anim	IDLE
	loop	1
	bbox 0
	delay	1
	offset  0 0
	frame	data/chars/misc/empty.gif

5) In ondrawscript event of your character entity write (example ondrawscript water_puddle_script.c):
Code:
#import "data/scripts/lib_water_puddle.c"

void main() {
  void self = getlocalvar("self");

    // ENTITIES COUNT FUNCS
    check_entities(self);

    if ( getlocalvar("water_puddle_found") == 1 ) check_ripple(self);
}

int check_entities(void self) {
    int i = 0;
    int water_puddle_found_flag = 0, water_puddle_is_on = 0;

    if ( openborvariant("in_level") ) {
        if ( getlevelproperty("type") != 2 ) {
            for (i = 0; i < openborvariant("count_entities"); ++i) { // openborconstant("MAX_ENTS")
                void ent = getentity(i);

                if ( getentityproperty(ent, "exists") ) {
                    /// WATER PUDDLE ///
                    if ( getentityvar(ent, 0) == "water_puddle" ) {
                        int anim_id = getentityproperty(self,"animationid");
                        int water_puddle_flag = 0;

                        water_puddle_found_flag = 1;
                        if ( anim_id == openborconstant("ANI_SPAWN") || anim_id == openborconstant("ANI_RESPAWN") ) {
                            int anim_pos = getentityproperty(self,"animpos");
                            if ( anim_pos <= 1 ) water_puddle_flag = 1;
                        }
                        if ( !water_puddle_flag && !water_puddle_is_on ) water_puddle_is_on = check_water_puddle(self, ent);
                        if ( !water_puddle_is_on && getlocalvar("water_puddle_found") != 1 ) setlocalvar("water_puddle_found",1);
                    }
                } // fine if exists
            } // fine for all_ents

            /// WATER PUDDLE RESET ///
            if ( !water_puddle_found_flag || water_puddle_is_on <= 0 ) {
                reset_water_puddle(self);
            }
        } // fine if level prop
    }
}

6) save your water puddle library in a c file named lib_water_puddle.c

Code:
#define gpp getplayerproperty
#define cpp changeplayerproperty
#define gep getentityproperty
#define cep changeentityproperty
#define ov  openborvariant
#define cv  changeopenborvariant
#define oc  openborconstant
#define clp changelayerproperty
#define glv getlocalvar
#define slv setlocalvar
#define sev setentityvar
#define gev getentityvar
#define sgv setglobalvar
#define ggv getglobalvar

#define SPLASH_SOUNDFX "data/sounds/water_splash01.wav"
#define ENT_WATER_SPLASH "water_splash"
#define ENT_RIPPLE_FRONT "water_ripple_front"
#define ENT_RIPPLE_BACK  "water_ripple_back"
#define RIPPLE_SPAWNING_FRAMES_PAUSE 2
#define SPLASH_DOWN_START_FRAME 2
#define RIPPLE_XSHIFT 3
#define RIPPLE_ASHIFT 0
#define WATER_H_FIX 0

int check_ripple(void self) {
    int is_on_puddle;
    int is_on_base;
    int was_on_puddle = glv("was_on_puddle");
    int was_on_base = glv("was_on_base");
    void ripple = glv("ripple");
    void splash = glv("splash");
    int ripple_frame = RIPPLE_SPAWNING_FRAMES_PAUSE;

    is_on_puddle = is_on_puddle(self); // check if this ent is on puddle (like stairs)
    is_on_base = is_on_base(self); // or is in "y" of puddle

    // CHECK EXISTENCE
    if ( !is_name(ripple,"defaultmodel",ENT_RIPPLE_FRONT) || !is_for(ripple,self) ) { slv("ripple",NULL()); ripple = glv("ripple"); }
    if ( !is_name(splash,"defaultmodel",ENT_WATER_SPLASH) || !is_for(splash,self) ) { slv("splash",NULL()); splash = glv("splash"); }

    if ( is_on_puddle ) {
        if ( is_on_base ) {
            if ( is_stopped(self) ) { // Se il pg è fermo crea un ripple per volta
                if ( ripple == NULL() || !gep(ripple,"exists") ) ripple = ripple_spawn(self,"ripple_front","ripple_back",ENT_RIPPLE_FRONT,ENT_RIPPLE_BACK,get_water_map()); // spawn ent if not exists (mem ripple in a localvar)
            } else {
                // Se il pg è in movimento crea nuovi ripple dopo il frame X
                if ( ripple == NULL() || !gep(ripple,"exists") ) ripple = ripple_spawn(self,"ripple_front","ripple_back",ENT_RIPPLE_FRONT,ENT_RIPPLE_BACK,get_water_map());
                else {
                    if ( ripple != NULL() ) {
                        if ( gep(ripple,"animpos") >= ripple_frame ) ripple = ripple_spawn(self,"ripple_front","ripple_back",ENT_RIPPLE_FRONT,ENT_RIPPLE_BACK,get_water_map());
                    }
                }  // fine if ripple exists
            } // fine if is_in_movement
        } // fine if is_on_base

        if ( !was_on_puddle && !was_on_base ) {
            slv("splash",spawn_splash(self,ENT_WATER_SPLASH,SPLASH_SOUNDFX,SPLASH_DOWN_START_FRAME)); // splash down
            splash = glv("splash");
        }

        // adjust splash position for speedy moves
        if ( !check_splash_pos(self,glv("splash"),ENT_WATER_SPLASH) ) slv("splash",NULL());
    } else {
        if ( is_stopped(self) ) {
            delete_ripple(self,"ripple_front","ripple_back",ENT_RIPPLE_FRONT,ENT_RIPPLE_BACK);
            slv("ripple",NULL());
            ripple == glv("ripple");
        }
    }

    if ( was_on_puddle && !is_on_base && was_on_base ) {
        slv("splash",spawn_splash(self,ENT_WATER_SPLASH,SPLASH_SOUNDFX,get_water_map())); // splash up
        splash = glv("splash");
    }

    slv("was_on_puddle",is_on_puddle);
    slv("was_on_base",is_on_base);
    slv("ripple",ripple);
    slv("splash",splash);
}

int is_on_puddle(void self) {
    if ( getlocalvar("is_on_water_puddle") > 0 ) return 1;
    else return 0;
}

void ripple_spawn(void self, char ripple_front, char ripple_back, char front_ripple_name, char back_ripple_name, int map) {
    if ( map == NULL() ) map = 0;

    slv(ripple_front,spawnsubentity_relative(front_ripple_name,RIPPLE_XSHIFT,0.1,RIPPLE_ASHIFT+get_water_height()-WATER_H_FIX,self));
    slv(ripple_back,spawnsubentity_relative(back_ripple_name,0,-1.0,0,glv(ripple_front)));

    //changeentityproperty(glv(ripple_front),"parent",self);
    changeentityproperty(glv(ripple_back),"parent",self);

    changeentityproperty(glv(ripple_front),"map",map);
    changeentityproperty(glv(ripple_back),"map",map);

    return glv(ripple_front);
}

int delete_ripple(void self, char ripple_front, char ripple_back, char front_ripple_name, char back_ripple_name) {
    if ( gep(glv(ripple_front),"exists") ) {
        if ( is_name(glv(ripple_front),"defaultmodel",front_ripple_name) && is_for(glv(ripple_front),self) ) { killentity(glv(ripple_front)); }
    }
    slv(ripple_front,NULL());

    if ( gep(glv(ripple_back),"exists") ) {
        if ( is_name(glv(ripple_back),"defaultmodel",back_ripple_name) && is_for(glv(ripple_back),self) ) { killentity(glv(ripple_back)); }
    }
    slv(ripple_back,NULL());

    return 1;
}

void spawn_splash(void self, char water_splash_name, char splash_sound_name, int frame, int map) {
    void splash;
    float base = gep(self,"base");

    if ( map == NULL() ) map = 0;

    splash = spawnsubentity_relative(water_splash_name,RIPPLE_XSHIFT,1,NULL(),self);
    changeentityproperty(splash,"position",NULL(),NULL(),base+RIPPLE_ASHIFT+get_water_height()-WATER_H_FIX);
    changeentityproperty(splash,"parent",self);
    changeentityproperty(splash,"map",map);

    if ( frame != NULL() ) {
        changeentityproperty(splash,"animpos",frame);
        playsample(loadsample(splash_sound_name));
    }

    return splash;
}

// return 0 if it doesn't exists
int check_splash_pos(void self, void splash, char model_name) {
    if ( gep(splash,"exists") ) {
        int anim_pos = gep(splash,"animpos");

        if ( !is_name(splash,"defaultmodel",model_name) || !is_for(splash,self) ) return 0;

        if ( anim_pos <= SPLASH_DOWN_START_FRAME ) {
            float x = gep(self,"x");
            float z = gep(self,"z");
            float a = gep(self,"y");
            float base = gep(self,"base");
            int dir = gep(self,"direction");
            float ex = gep(splash,"x");
            float xshift = RIPPLE_XSHIFT;

            if ( !dir ) xshift *= -1;
            if ( ex != x+xshift ) {
                cep(splash,"position",x+xshift,z+1,base+RIPPLE_ASHIFT+get_water_height()-WATER_H_FIX);
            }
        } // fine if animpos

        return 1;
    } else return 0; // fine if exists
}

int get_water_map() {
    return glv("water_map");
}

int set_water_map(int value) {
    return slv("water_map",value);
}

int get_water_height() {
    return glv("water_height");
}

int set_water_height(float value) {
    slv("water_height",value);
}

int check_puddle(void self, int no_a_flag) {
    int i;

    if ( getglobalvar("in_menu") != 1 && getlevelproperty("type") != 2 ) {
        for (i = 0; i < openborvariant("count_entities"); ++i) { // openborconstant("MAX_ENTS")
            void ent = getentity(i);

            if ( getentityproperty(ent, "exists") ) {
                if ( getentityvar(ent, 0) == "water_puddle" ) {
                    if ( no_a_flag && no_a_flag != NULL() ) return check_water_puddle_no_a(self, ent);
                    else return check_water_puddle(self, ent, 1);
                }
            } // fine if exists
        } // fine for all_ents

        return 0;
    }
}

int check_water_puddle(void self, void ent, int check_only_flag) {
                int p = getentityproperty(self, "playerindex");
                float x = getentityproperty(self, "x");
                float z = getentityproperty(self, "z");
                float a = getentityproperty(self, "y");
                float base = getentityproperty(self, "base");
                float ex = getentityproperty(ent, "x");
                float ez = getentityproperty(ent, "z");
                float ea = getentityproperty(ent, "y");
                float ebase = getentityproperty(ent, "base");
                float height = getentityvar(ent, 2);
                float width = getentityvar(ent, 1);
                float depth = getentityvar(ent, 3);
                float new_base, ezhift, exhift;

                if ( height == NULL() ) height = getentityproperty(ent, "height");
                if ( height == NULL() ) height = 0;
                set_water_height(height);
                set_water_map(getentityvar(ent,"map"));

                if (x > ex) exhift = x-ex;
                else exhift = ex-x;

                if ( getentityvar(ent, 0) == "water_puddle" ) {
                    if ( x <= ex+width && x >= ex && z <= ez+2+depth/2 && z >= ez-depth/2 && a <= ebase+2+height && a >= ebase-2 ) {
                        if ( !check_only_flag || check_only_flag == NULL() ) {
                            draw_clipping_transp(self, 140, height, getentityvar(ent,"transp"));
                            clip_character(self, -190, height);
                            setlocalvar("is_on_water_puddle", 1);
                        } else return 1;
                    } else {
                        if ( !check_only_flag || check_only_flag == NULL() ) {
                            if ( getlocalvar("is_on_water_puddle") == 1 ) {
                                reset_water_puddle_clipping(self);
                                setlocalvar("is_on_water_puddle", NULL());
                            }
                        } else return 0;
                    } // fine if coords
                }
}

int check_water_puddle_no_a(void self, void ent) {
                float x = getentityproperty(self, "x");
                float z = getentityproperty(self, "z");
                float a = getentityproperty(self, "y");
                float ex = getentityproperty(ent, "x");
                float ez = getentityproperty(ent, "z");
                float ea = getentityproperty(ent, "y");
                float width = getentityvar(ent, 1);
                float depth = getentityvar(ent, 3);

                if ( getentityvar(ent, 0) == "water_puddle" ) {
                    if ( x <= ex+width && x >= ex && z <= ez+2+depth/2 && z >= ez-depth/2 ) {
                        return 1;
                    } else {
                        return 0;
                    } // fine if coords
                }
}

int reset_water_puddle_clipping(void self, int shadow_flag) {
    changedrawmethod(NULL(), "enabled", 0);
    changedrawmethod(NULL(), "reset", 1);
    setdrawmethod(NULL(), 0);
    changedrawmethod(self, "enabled", 0);
    changedrawmethod(self, "reset", 1);
    setdrawmethod(self, 0);

    if ( !shadow_flag || shadow_flag == NULL() ) {
        if ( !getentityproperty(self,"gfxshadow") ) changeentityproperty(self,"gfxshadow",1);
    }
}

int reset_water_puddle(void self) {
    if ( glv("was_on_puddle") != NULL() || glv("was_on_base") != NULL() || glv("is_on_water_puddle") != NULL() ) {
        reset_water_puddle_clipping(self);
        setlocalvar("water_puddle_found",NULL());
        slv("was_on_puddle",NULL());
        slv("was_on_base",NULL());
        slv("is_on_water_puddle",NULL());
    }
}

int clip_character(void self, float clipx, float clipy) {
    if ( openborvariant("in_level") ) {
        float x = getentityproperty(self, "x");
        float z = getentityproperty(self, "z");
        float a = getentityproperty(self, "y");
        float base = getentityproperty(self, "base");
        int layer = getentityproperty(self, "setlayer");
        float xpos = openborvariant("xpos");
        float ypos = openborvariant("ypos");
        int colourmap = getentityproperty(self, "colourmap");

            changedrawmethod(NULL(), "enabled", 1);
            changedrawmethod(NULL(), "reset", 1);

            if ( getentityproperty(self,"gfxshadow") ) changeentityproperty(self,"gfxshadow",0);

            changedrawmethod(self, "cliph", 256);
            changedrawmethod(self, "clipw", 512);
            changedrawmethod(self, "clipx", clipx);
            changedrawmethod(self, "clipy", -256-clipy+a-base);

            setdrawmethod(self, 1, 256, 256, 0, 0, 0, 0, 1, 0, 0, 0, 0, colourmap);

            changedrawmethod(NULL(), "enabled", 0);
            changedrawmethod(NULL(), "reset", 1);
            setdrawmethod(NULL(), 0);
    }
}

int draw_clipping_transp(void self, float clipx, float clipy, int transp) {
    if ( openborvariant("in_level") ) {
        void spr = getentityproperty(self, "sprite");
        float x = getentityvar(self, "x");
        float z = getentityvar(self, "z");
        float a = getentityvar(self, "y");
        float base = getentityvar(self, "base");
        int facing = getentityvar(self, "direction");
        int layer = getentityproperty(self, "setlayer");
        float xpos = openborvariant("xpos");
        float ypos = openborvariant("ypos");
        int colourmap = getentityproperty(self, "colourmap");

        if ( x == NULL() ) x = getentityproperty(self, "x");
        if ( z == NULL() ) z = getentityproperty(self, "z");
        if ( a == NULL() ) a = getentityproperty(self, "y");
        if ( base == NULL() ) base = getentityproperty(self, "base");
        if ( facing == NULL() ) facing = getentityproperty(self, "direction");
        if ( transp == NULL() ) transp = 0;

        if ( spr != NULL() ) {
            if (facing == 1) facing = 0;
            else facing = 1;

            changedrawmethod(NULL(), "enabled", 1);
            changedrawmethod(NULL(), "reset", 1);

            changedrawmethod(NULL(), "cliph", 356);
            changedrawmethod(NULL(), "clipw", 512);
            changedrawmethod(NULL(), "clipx", x-xpos-clipx);
            changedrawmethod(NULL(), "clipy", z-a-ypos-4-clipy);

            changedrawmethod(NULL(), "channelg", transp);
            changedrawmethod(NULL(), "channelr", transp);
            changedrawmethod(NULL(), "channelb", transp);

            // (entity, int flag, int scalex, int scaley, int flipx, int flipy, int shiftx, int alpha, int remap, int fillcolor, int rotate, int fliprotate, int transparencybg, void* colourmap, int centerx, int centery);
            setdrawmethod(NULL(), 1, 256, 256, facing, 0, 0, 6, 1, 0, 0, 0, 0, colourmap); // map: -1 = Use entity's colormap.

            drawsprite(spr, x-xpos, z-a-ypos-4, z+2, layer);

            changedrawmethod(NULL(), "enabled", 0);
            changedrawmethod(NULL(), "reset", 1);
            setdrawmethod(NULL(), 0);
        }

    }
}

I hope I've not forgotten anything!
Enjoy!

Ps. Don't forget to spawn water_puddle empty entity in your level.txt
Example:

Code:
spawn water_puddle_test 1
@script
void main() {
	void self = getlocalvar("self");
	setentityvar(self, 1, 1024); // width
	setentityvar(self, 2, 20);    // height
	setentityvar(self, 3, 180);  // depth
	setentityvar(self, "map", 0);  // ripple/splash map
	setentityvar(self, "transp", 30);  // alpha transp value
}
@end_script
coords 0 180 0
at 0

and remember to load all entities (ex. load splash and ripple entities in water_puddle_test entity)!


[attachment deleted by admin]
 
Add these funcs to lib_water_puddle.c or import them (these are additional funcs from my general lib)
Code:
void spawnsubentity(char ent, float x, float z, float a) {
    void subent;

      clearspawnentry();
      setspawnentry("name", ent);
      subent = spawn();

      changeentityproperty(subent, "position", x, z, a);

    return subent;
}

void spawnsubentity_parent(char ent, float x, float z, float a, void parent) {
    void subent;

      clearspawnentry();
      setspawnentry("name", ent);
      subent = spawn();

      changeentityproperty(subent, "parent", parent);
      changeentityproperty(subent, "position", x, z, a);

    return subent;
}

void spawnsubentity_relative(char ent, float rx, float rz, float ra, void parent) {
    void subent;
    float x, z, a, base;

      clearspawnentry();
      setspawnentry("name", ent);
      subent = spawn();

      if ( getentityproperty(parent,"exists") ) {
          int p_dir = getentityproperty(parent,"direction");

          if (!p_dir) rx *= -1;
          changeentityproperty(subent, "parent", parent);
          x = getentityproperty(parent, "x");
          z = getentityproperty(parent, "z");
          a = getentityproperty(parent, "y");
          base = getentityproperty(parent, "base");
          changeentityproperty(subent, "direction", p_dir);

          changeentityproperty(subent, "parent", parent);
      } else {
          x = 0;
          z = 0;
          a = 0;
      }

      if ( ra != NULL() ) {
        changeentityproperty(subent, "position", x+rx, z+rz, a+ra);
        changeentityproperty(subent, "base", a+ra);
      } else {
        changeentityproperty(subent, "position", x+rx, z+rz, base);
        changeentityproperty(subent, "base", base);
      }

    return subent;
}

int is_on_base(void self) {
    float a = getentityproperty(self,"y");
    float base = getentityproperty(self,"base");

    if ( a <= base ) return 1;
    else return 0;
}

int is_stopped(void self) {
    float xdir = getentityproperty(self,"xdir");
    float zdir = getentityproperty(self,"zdir");
    float tossv = getentityproperty(self,"tossv");

    if ( xdir == 0 && zdir == 0 && tossv == 0 ) return 1;
    else return 0;
}

int is_name(void self, char model, char name) {
    char model_name = getentityproperty(self, model);

    if ( model_name == name ) return 1;
    else return 0;
}

int is_for(void entity, void orig_owner) {
	void parent = getentityproperty(entity,"parent");
	void owner = getentityproperty(entity,"owner");
  	void subentity = getentityproperty(entity, "subentity");

  	if ( parent == NULL() ) parent = owner;
  	if ( parent == NULL() ) parent = subentity;

  	if ( orig_owner == parent ) return 1;
    else return 0;
}

OPTIONAL:
In your dust entity write this animationscript (to hide the dust if you're in a water puddle):
Code:
animationscript @script
#import "data/scripts/lib_water_puddle.c"

void main() {
	void self = getlocalvar("self");
	int animpos = getentityproperty(self,"animpos");
	void parent = getentityproperty(self,"parent");
	void owner = getentityproperty(self,"owner");
  	void subentity = getentityproperty(self, "subentity");
	int is_in_puddle;

  	if ( parent == NULL() ) parent = owner;
  	if ( parent == NULL() ) parent = subentity;

	is_in_puddle = check_puddle(self,1);
	if ( is_in_puddle ) killentity(self);

	if ( getentityproperty(parent,"exists") ) {
		is_in_puddle = check_puddle(parent,1);
		if ( is_in_puddle ) killentity(self);
	}
}
@end_script


[attachment deleted by admin]
 
thanks for the tutorial...
(in my case) i had already experiment with the scripts you ve posted here...
iam using v3.0 Build 3849 i think it doesnt reconize the ondrawscript...
ondrawscript data/scripts/player_ondrawscript.c ... on player .txt
updated.c also seems to crash with no errors...
Is there a way to add the ondrawscript to pervious versions of BOR ?
it seems anything above v3.0 3849 makes all kinds of trouble in animations script..
 
Thanks for the tutorial!
Everything ok,  but i dont understand the part 5.
I never use "ondrawscript event".
How make to use that?

 
jonsilva said:
iam using v3.0 Build 3849 i think it doesnt reconize the ondrawscript...
ondrawscript data/scripts/player_ondrawscript.c ... on player .txt
Is there a way to add the ondrawscript to pervious versions of BOR ?

use script instead ondrawscript (with some bad effects)

dantedevil said:
Everything ok,  but i dont understand the part 5.
I never use "ondrawscript event".
How make to use that?

in your character entity write:
ondrawscript  water_puddle_script.c (water_puddle_script.c contains the script in part 5).
ondrawscript is an event that runs on entity rendering (instead script event runs every frame).
 
use script instead ondrawscript (with some bad effects)

theres seems to be incompatibilities ive changed
getentityproperty (y) to (a) has in older versions y is a (sprite altitude?!)...

but now iam getting an error saying
Runtime error: argument count(3) doesn't match, check your function call: (null).

********** An Error Occurred **********
*            Shutting Down            *

could the error be in the water_puddle_test entity

anim IDLE
@script
void self = getlocalvar("self");

if ( getentityvar(self, 0) == NULL() ) {
setentityvar(self, 0, "water_puddle"); // name/type
setentityvar(self, 1, 1024); // width
setentityvar(self, 2, 15);    // height
setentityvar(self, 3, 180);  // depth
}
@end_script
loop 1
bbox 0
delay 1
offset  0 0
frame data/chars/misc/ladder/01.gif

when i change this line
if ( getentityvar(self, 0) == NULL() )
to
if ( getentityvar(self, 0) )
the game doesnt crash but still no water effect

 
jonsilva said:
getentityproperty (y) to (a) has in older versions y is a (sprite altitude?!)...
Entity altitude, not sprite altitude.

However your version doesnt support NULL() func maybe.
Write this entity:
Code:
name	water_puddle_test
type	none
health	1
nomove	1 0
facing	1
nodieblink 2
nodrop 1
nolife 1
gfxshadow 1

height 15

subject_to_platform 0
subject_to_obstacle 0
subject_to_wall 0
subject_to_hole 0
subject_to_gravity 0
no_adjust_base 1

onspawnscript @script
void main() {
	void self = getlocalvar("self");

	setentityvar(self, 0, "water_puddle"); // name/type
	setentityvar(self, 1, 1024); // width
	setentityvar(self, 2, 15);    // height
	setentityvar(self, 3, 180);  // depth
}
@end_script

anim	IDLE
	loop	1
	bbox 0
	delay	1
	offset  0 0
	frame	data/chars/misc/empty.gif

or write:
onspawnscript water_spawn.c
and in water_spawn.c:
Code:
void main() {
	void self = getlocalvar("self");

	setentityvar(self, 0, "water_puddle"); // name/type
	setentityvar(self, 1, 1024); // width
	setentityvar(self, 2, 15);    // height
	setentityvar(self, 3, 180);  // depth
}
 
setentityvar(self, 0, "water_puddle"); // name/type

theres seems to be functions in (lib_water_puddle.c)

int is_on_puddle
int check_water_puddle
int check_puddle
int check_water_puddle_no_a

could the engine not be rezonizing a water_puddle? (var) (setentityvar(self)

in TMN shellsock theres a water_puddle.c that has all the int's above
 
jonsilva said:
could the engine not be rezonizing a water_puddle? (var) (setentityvar(self)

in TMN shellsock theres a water_puddle.c that has all the int's above

I dont understand very well... your eng it's a bit weird ^__^
It works fine 'cause the value of the entityvar is searched by the library functions.
water_puddle.c == lib_water_puddle.c
however copy the script from this thread and not from TMNT Shell Shocked.
I optimized the script for the tutorial!
 
however copy the script from this thread and not from TMNT Shell Shocked.
I optimized the script for the tutorial!
yes ive already replaced all the old scripts with the ones on the tutorial

but i cant make the onspawnscript command working...

Code:
name	 water_puddle_test
#name	 water_puddle
type	 none
health	 1
nomove	 1 0
facing	 1
nodieblink 2
nodrop 1
nolife 1
gfxshadow 1

height 15

subject_to_platform 0
subject_to_obstacle 0
subject_to_wall 0
subject_to_hole 0
subject_to_gravity 0
no_adjust_base 1

onspawnscript data/scripts/water_spawn.c



#onspawnscript @script
#void main() {
#	 void self = getlocalvar("self");
#	 setentityvar(self, 0, "water_puddle"); // name/type
#	 setentityvar(self, 1, 1024); // width
#	 setentityvar(self, 2, 15);    // height
#	 setentityvar(self, 3, 180);  // depth
#}
#@end_script

#--------------------------------------
#--------------------------------------
#--------------------------------------

anim	 IDLE
	 loop	 1
	 bbox 0
	 delay	 1
	 offset  0 0
	 frame	data/chars/misc/ladder/01.gif

i was using onspawnscript water_spawn.c instead of
onspawnscript data/scripts/water_spawn.c...

but iam still getting a crash... in log

Runtime error: argument count(3) doesn't match, check your function call: (null).

********** An Error Occurred **********
*            Shutting Down            *

There's an exception while executing script 'updateentityscript' data/chars/1ryo/fastryo/fastryo.txt

iam using animations scripts that contain NULL() / NULL())
can it be the count(3) value ?


Hooo... i got everything working now...
i manadge to upgrade the version to OpenBoR v3.0 Build , Compile Date: Dec 30 2013 --- i just had to replace the keyint script (movefoward was showing an error)...
I just dont know how i can change to more recent versions of BOR...
@cmd / animations script seem to be letf out... i dont think its an option for me.. i would had to start making the game from the beginning...
 
iam using the old animation script
animationscript data/scripts/grabscript.c
script data/scripts/player_ondrawscript.c

ive already manadge to make it work by changing the BOR version
(see my post above this one)
i can already the see the player legs in alpha and onspawnscript also works... only the water splash /back/front
are missing...

 
jonsilva said:
only the water splash /back/front are missing...
Are you getting an error?
If this error is count(3) what is the wrong line?
what script?
if you do not give me more information I cannot help you

ps. back/front is for ripple. not splash
ps2. have you loaded "water_splash", "water_ripple_front", "water_ripple_back" entities at runtime?
 
ps. back/front is for ripple. not splash
ps2. have you loaded "water_splash", "water_ripple_front", "water_ripple_back" entities at runtime?

the load was missing... ive just added it in the water_puddle_test entity 

Code:
name	water_puddle_test
type	none
health	1
nomove	1 0
facing	1
#falldie	1
nodieblink 2
nodrop 1
nolife 1

#setlayer -1
#toflip 1
gfxshadow 1

height 85

subject_to_platform 0
subject_to_obstacle 0
subject_to_wall 0
subject_to_hole 0
subject_to_gravity 0
no_adjust_base 1

#ondrawscript	data/scripts/water_puddle.c


load	water_splash	
load	water_ripple_front 
load	water_ripple_back  




anim	IDLE
	@script
		void self = getlocalvar("self");

		if ( getentityvar(self, 0) == NULL() ) {
			setentityvar(self, 0, "water_puddle"); // name/type
			setentityvar(self, 1, 2024); // width
			setentityvar(self, 2, 85);    // height
			setentityvar(self, 3, 380);  // depth
		}
	@end_script

	loop	1
	fastattack 1
	range -120 120
	rangez -60 60
	rangea 0 100

	bbox 0
	delay	1
	offset  0 0
	frame	data/chars/misc/ladder/01.gif




the commands
setentityvar(self, 1, 2024); // width
setentityvar(self, 3, 380);  // depth
seem to be working...
only the   
setentityvar(self, 2, 85);    // height
doesnt seem to change even in TMN shell sock 

 
jonsilva said:
ps. back/front is for ripple. not splash
ps2. have you loaded "water_splash", "water_ripple_front", "water_ripple_back" entities at runtime?

the load was missing... ive just added it in the water_puddle_test entity 

Code:
name	water_puddle_test
type	none
health	1
nomove	1 0
facing	1
#falldie	1
nodieblink 2
nodrop 1
nolife 1

#setlayer -1
#toflip 1
gfxshadow 1

height 85

subject_to_platform 0
subject_to_obstacle 0
subject_to_wall 0
subject_to_hole 0
subject_to_gravity 0
no_adjust_base 1

#ondrawscript	data/scripts/water_puddle.c


load	water_splash	
load	water_ripple_front 
load	water_ripple_back  




anim	IDLE
	@script
		void self = getlocalvar("self");

		if ( getentityvar(self, 0) == NULL() ) {
			setentityvar(self, 0, "water_puddle"); // name/type
			setentityvar(self, 1, 2024); // width
			setentityvar(self, 2, 85);    // height
			setentityvar(self, 3, 380);  // depth
		}
	@end_script

	loop	1
	fastattack 1
	range -120 120
	rangez -60 60
	rangea 0 100

	bbox 0
	delay	1
	offset  0 0
	frame	data/chars/misc/ladder/01.gif




the commands
setentityvar(self, 1, 2024); // width
setentityvar(self, 3, 380);  // depth
seem to be working...
only the   
setentityvar(self, 2, 85);    // height
doesnt seem to change even in TMN shell sock

I use it in check_water_puddle
 
ive only manadge to change the altitute in witch the splash appears

by replacing the line in (int check_water_puddle)
float height = getentityproperty(ent, "height");
to
float height = getentityvar(ent, 2);
Code:
int check_water_puddle(void self, void ent, int check_only_flag) {
                int p = getentityproperty(self, "playerindex");
                float x = getentityproperty(self, "x");
                float z = getentityproperty(self, "z");
                float a = getentityproperty(self, "a");
                float base = getentityproperty(self, "base");
                float ex = getentityproperty(ent, "x");
                float ez = getentityproperty(ent, "z");
                float ea = getentityproperty(ent, "a");
                float ebase = getentityproperty(ent, "base");
                float width = getentityvar(ent, 1);
                float height = getentityvar(ent, 2);
                float depth = getentityvar(ent, 3);
                float new_base, ezhift, exhift;

                // Lunghezza della scala
                if (x > ex) exhift = x-ex;
                else exhift = ex-x;

                if ( getentityvar(ent, 0) == "water_puddle" ) {
                    if ( x <= ex+width && x >= ex && z <= ez+2+depth/2 && z >= ez-depth/2 && a <= ebase+2+height && a >= ebase-2 ) {
                        if ( !check_only_flag || check_only_flag == NULL() ) {
                            draw_clipping_transp(self, 140, height+5, 30);
                            clip_character(self, -190, height);
                            setlocalvar("is_on_water_puddle", 1);
                        } else return 1;
                    } else {
                        if ( !check_only_flag || check_only_flag == NULL() ) {
                            if ( getlocalvar("is_on_water_puddle") == 1 ) {
                                reset_water_puddle(self);
                                setlocalvar("is_on_water_puddle", NULL());
                            }
                        } else return 0;
                    } // fine if coords
                }
}
i can't seem to get any changes in the
                      draw_clipping_transp(self, 140, height+5, 30);
                      clip_character(self, -190, height);

could the player clip be happening elsewere ?
theres this line
            changedrawmethod(self, "clipy", -256-20+a-base); // -100  -> più abbeasi e più tagli
in int clip_character(void self, float clipx, float clipy)

dont change the script please. maybe you've done some script errors.
I'm working for a script improvement and speed-up.
Maybe for tonight
Ok thanks  :)
 
dont change the script please else I cant help you. maybe you've done some script errors.
I'm working for a script improvement and speed-up.
Maybe for tonight
 
updated script:
- speed-up
- more stable script avoiding bugs

Ps. jonsilva dont change my script else I cant help you. change only "y" to "a" to be compatible with older openbor ver. if you want.
    if you follow the tutorial and if you dont forget anything, the script will work fine! sure ;)
    Re-copy the whole new updated script!
 
theres seems to be a problem maybe in the player (ondrawscript)
5) In ondrawscript event of your character entity write (example ondrawscript water_puddle_script.c):

the water effect works with the old ondrawscript
but the new one is not showing
#import "data/scripts/lib_water_puddle.c"

void main() {
  void self = getlocalvar("self");

    // ENTITIES COUNT FUNCS
    check_entities(self);

    if ( getlocalvar("water_puddle_found") == 1 ) check_ripple(self);
}

int check_entities(void self) {
    int i = 0;
    int water_puddle_found_flag = 0, water_puddle_is_on = 0;

    if ( openborvariant("in_level") != 1 && getlevelproperty("type") != 2 ) { // Waiting, Select
        for (i = 0; i < openborvariant("count_entities"); ++i) { // openborconstant("MAX_ENTS")
            void ent = getentity(i);

            if ( getentityproperty(ent, "exists") ) {
                /// WATER PUDDLE ///
                if ( getentityvar(ent, 0) == "water_puddle" ) {
                    int anim_id = getentityproperty(self,"animationid");
                    int water_puddle_flag = 0;

                    water_puddle_found_flag = 1;
                    if ( anim_id == openborconstant("ANI_SPAWN") || anim_id == openborconstant("ANI_RESPAWN") ) {
                        int anim_pos = getentityproperty(self,"animpos");
                        if ( anim_pos <= 1 ) water_puddle_flag = 1;
                    }
                    if ( !water_puddle_flag && !water_puddle_is_on ) water_puddle_is_on = check_water_puddle(self, ent);
                    if ( !water_puddle_is_on && getlocalvar("water_puddle_found") != 1 ) setlocalvar("water_puddle_found",1);
                }
            } // fine if exists
        } // fine for all_ents

        /// WATER PUDDLE RESET ///
        if ( !water_puddle_found_flag || water_puddle_is_on <= 0 ) {
            reset_water_puddle(self);
        }
    }
}

could there be a missing function called (water_puddle_found) in lib_water_puddle.c ?!

ive tested it in both BOR versions TMN shell sock altitude (y)(a)


 
Back
Top Bottom