White Dragon
New member
Ladders/Climbing Area/Halcove/Stairs/Waves + Water Puddle (Interact Entities)
Maybe this is my more complex script!!
Download and install in your game these my libraries:
lib_interact_ent.zip
add an ondrawscript event to your player entity like:
ondrawscript data/scripts/player_ondrawscript.c
add an ondrawscript event for every enemy you want to interact with these entities like:
ondrawscript data/scripts/enemy_ondrawscript.c
[WATER PUDDLE]
Add a water puddle into your level simply spawning the entity as follows and set its parameters:
For water puddle you can set additional params like:
Attributes for character:
[STAIRS/WAVES]
Add a stair into your level simply spawning the entity as follows and set its parameters:
There are 3 types of stair:
and for waves:
For stairs you can set additional params like:
Attributes for character:
For waves you can set additional params like:
Attributes for character:
For wave you can change the T_WALKOFF variable into .c file.
This is a defined variable that change the minimum distance detection between the character and the wave.
Default value to 4.
Last but not least you must to use a custom shadow when you use a stair. So in your level insert:
[LADDERS/CLIMBING AREA/HALCOVE]
This is more complex.
My library add an AI while the enemy climb a ladder or search a ladder.
You need to write your animations. For my agreement I list animations:
To simulate a climbing animation add an animation script like:
There are 4 types of ladder:
So you can spawn a ladder in this way:
Attributes for character for ladder/climbable area/halcove:
The similar todo list is for halcove.
The animations are:
and the halcove name is just: setentityvar(self, "type", "halcove");
I know that isn't too easy to add a ladder...
[attachment deleted by admin]
Maybe this is my more complex script!!
Download and install in your game these my libraries:
lib_interact_ent.zip
add an ondrawscript event to your player entity like:
ondrawscript data/scripts/player_ondrawscript.c
add an ondrawscript event for every enemy you want to interact with these entities like:
ondrawscript data/scripts/enemy_ondrawscript.c
[WATER PUDDLE]
Add a water puddle into your level simply spawning the entity as follows and set its parameters:
Code:
spawn water_puddle_test 1
@script
void main() {
void self = getlocalvar("self");
setentityvar(self, "type", "water_puddle"); // name/type
setentityvar(self, "width", 300); // width
setentityvar(self, "depth", 80); // depth
setentityvar(self, "height", 50); // height
}
@end_script
coords 0 180 0
at 0
For water puddle you can set additional params like:
- setentityvar(self,"transp",value): 0,1,.., 255 --> from 0 to 255 is the opacity of immersed part of your entity
- setentityvar(self,"map",value): value is the map that you want. this value impacts on ripple/splash
- setentityvar(self,"shift_horizontal",value): float value (positive or negative) in pixels to deform horizontally the rectangle in a diagonal shape (parallelogram)
- setentityvar(self,"shift_vertical",value): float value (positive or negative) in pixels to deform vertically the rectangle in a diagonal shape (parallelogram)
- setentityvar(self, "no_shadow",value); // show or not the shadows in water puddle)
Attributes for character:
- setentityvar(self,"subject_to_water_puddle",value): 0,1 --> detect water puddle or not
- getentityvar(self,"water_puddle"): --> returns entity handler if the character is on water puddle, else returns NULL()
[STAIRS/WAVES]
Add a stair into your level simply spawning the entity as follows and set its parameters:
Code:
spawn stair_empty 1
@script
void main() {
void self = getlocalvar("self");
setentityvar(self, "type", "stair_r"); // name/type
setentityvar(self, "width", 300); // width
setentityvar(self, "depth", 80); // depth
setentityvar(self, "height", 50); // height
}
@end_script
coords 0 180 0
at 0
There are 3 types of stair:
- stair_r = right part is more high than left part
- stair_l = left part is more high than right part
- stair_c = frontal stair
- stair_q = square stair (like a bridge)
and for waves:
- wave_r = right part is more high than left part
- wave_l = left part is more high than right part
- wave_c = square wave
For stairs you can set additional params like:
- setentityvar(self,"subject_to_base",value): 0,1 --> the enity cant stay under the stair
- setentityvar(self,"subject_to_depth",value): 0,1,2 --> USE IT TO BLOCK THE ENTITY. 0 means that you can walk in depth. 2 is for blockade totally in the middle and 1 to block only when the player is stopped. ### I like subject_to_depth to 1 ###
- setentityvar(self,"subject_to_edges",value): 0,1 --> blockade on edges
Attributes for character:
- setentityvar(self,"subject_to_stair",value): 0,1 --> detect stair or not
- getentityvar(self,"is_on_stair"): returns entity handler if the character is on stair, else returns NULL()
For waves you can set additional params like:
- setentityvar(self,"adjust_wave_base_value",value): threshold (float value) --> an additional threshold to detect wave
Attributes for character:
- setentityvar(self,"subject_to_wave",value): 0,1 --> detect wave or not
- getentityvar(self,"is_on_wave"): returns entity handler if the character is on wave, else returns NULL()
For wave you can change the T_WALKOFF variable into .c file.
This is a defined variable that change the minimum distance detection between the character and the wave.
Default value to 4.
Last but not least you must to use a custom shadow when you use a stair. So in your level insert:
Code:
updatescript @script
#import "data/scripts/lib_level.c"
void main() {
int i = 0;
for( i = 0; i <= openborvariant("count_entities"); ++i) {
void ent = getentity(i);
check_shadow(ent,180,-5,0,256,50,220,0,0,1);
}
}
@end_script
[LADDERS/CLIMBING AREA/HALCOVE]
This is more complex.
My library add an AI while the enemy climb a ladder or search a ladder.
You need to write your animations. For my agreement I list animations:
- FOLLOW50 # (FRONT CLIMBING)
- FOLLOW51 # (SIDE CLIMBING LEFT)
- FOLLOW52 # (SIDE CLIMBING RIGHT)
- FOLLOW53 # (FRONT CLIMBING OVER) -> to climb on a ledge
- FOLLOW54 # (SIDE CLIMBING OVER) -> to climb on a ledge
- FOLLOW55 # (FRONT CLIMBING OVER REVERSE) -> to move from one ledge to ladder
- FOLLOW56 # (SIDE CLIMBING OVER REVERSE) -> to move from one ledge to ladder
- FOLLOW57 # (FRONT CLIMBING AREA)
- FOLLOW58 # (SIDE CLIMBING AREA)
- FOLLOW59 # (FRONT CLIMBING AREA OVER REVERSE) -> to move from one ledge to climbing area
- FOLLOW120 # (LADDER H CLIMB)
- FOLLOW121 # (LADDER H GRAB)
To simulate a climbing animation add an animation script like:
Code:
anim FOLLOW50 # (FRONT CLIMBING)
loop 1
@script
void self = getlocalvar("self");
int p = getentityproperty(self, "playerindex");
int frm = 0, tot_frm = 8;
int press_btn = 0;
if ( !playerkeys(p,press_btn,"moveup") && !playerkeys(p,press_btn,"movedown") ) {
if ( getglobalvar("p"+p+"climbing") != NULL() ) changeentityproperty(self, "animpos", getglobalvar("p"+p+"climbing"));
else {
setglobalvar("p"+p+"climbing", 0);
changeentityproperty(self, "animpos", getglobalvar("p"+p+"climbing"));
}
} else if ( getglobalvar("p"+p+"climbing") != NULL() ) {
frm = getglobalvar("p"+p+"climbing")+1;
if ( frm >= tot_frm ) frm = 0;
setglobalvar("p"+p+"climbing", frm);
changeentityproperty(self, "animpos", getglobalvar("p"+p+"climbing"));
} else if ( getglobalvar("p"+p+"climbing") == NULL() ) {
setglobalvar("p"+p+"climbing", 0);
changeentityproperty(self, "animpos", getglobalvar("p"+p+"climbing"));
}
@end_script
delay 8
offset 24 63
bbox 9 5 31 47
frame data/chars/don/climb3.gif
frame data/chars/don/climb1.gif
frame data/chars/don/climb0.gif
frame data/chars/don/climb1.gif
frame data/chars/don/climb3.gif
frame data/chars/don/climb1a.gif
frame data/chars/don/climb0a.gif
frame data/chars/don/climb1a.gif
There are 4 types of ladder:
- ladder_r = right ladder
- ladder_l = left ladder
- ladder_v = vertical ladder
- ladder_h = horizontal ladder
So you can spawn a ladder in this way:
Code:
spawn ladder_name 1
@script
void main() {
void self = getlocalvar("self");
setentityvar(self, "type", "ladder_v"); // name/type
setentityvar(self, "width", 300); // width
setentityvar(self, "height", 50); // height
}
@end_script
coords 0 180 0
at 0
Attributes for character for ladder/climbable area/halcove:
- getentityvar(self,"ladder"): returns entity handler if the character is on ladder/climbable area/halcove, else returns NULL()
The similar todo list is for halcove.
The animations are:
- FOLLOW46 # (HALCOVE TURN LEFT)
- FOLLOW47 # (HALCOVE TURN RIGHT)
- FOLLOW48 # (HALCOVE CLIMBING)
- FOLLOW49 # (HALCOVE SLIDING DOWN)
and the halcove name is just: setentityvar(self, "type", "halcove");
I know that isn't too easy to add a ladder...
[attachment deleted by admin]