DD Tokki
Well-known member
Code:
void main() {
if(openborvariant("in_level")){ //Here is the conditional!
void self = getlocalvar("self");
charge_attack(self,"attack2",rgbcolor(0x00,0x26,0x88),rgbcolor(0x43,0x00,0xDA),rgbcolor(0x00,0xDA,0x0F),openborvariant("game_speed")*6,"ANI_FREESPECIAL17","ANI_FREESPECIAL21","ANI_FREESPECIAL13","data/sounds/dummy.wav",openborvariant("game_speed")*0.2,"cflash",0,0,0);
}
}
int charge_attack(void self, char key, int color1, int color2, int color3, int max_charge_time, char atk_name1, char atk_name2, char atk_name3, char sound_fx, int sound_duration, char flashing_ent, int flash_frame_length, int on_base_flag, int first_atk_flag) {
int time = openborvariant("elapsed_time");
int p = getentityproperty(self,"playerindex");
int CHARGE_ATK1 = openborconstant(atk_name1);
int CHARGE_ATK2 = openborconstant(atk_name2);
int CHARGE_ATK3 = openborconstant(atk_name3);
if ( playerkeys(self,0,key) ) {
if ( getlocalvar("charge_time") == NULL() ) { // unsetted time
if ( time+max_charge_time >= openborconstant("MAX_INT") ) { // time protection
changeopenborvariant("elapsed_time",0);
time = openborvariant("elapsed_time");
}
setlocalvar("charge_time",time+max_charge_time);
} else { // setted time
int time_range = max_charge_time/3;
int charge_time = time%max_charge_time;
// FLASHING
if ( time < getlocalvar("charge_time")-time_range*2 ) {
flashing_color(self,color1,openborvariant("game_speed")/10,0);
setlocalvar("charge_atk",0);
} else if ( time < getlocalvar("charge_time")-time_range*1 ) {
flashing_color(self,color2,openborvariant("game_speed")/15,0);
setlocalvar("charge_atk",1);
} else {
flashing_color(self,color3,openborvariant("game_speed")/20,0);
setlocalvar("charge_atk",2);
}
// SOUND
if ( getlocalvar("charge_sound_time") == NULL() ) {
if ( sound_fx == NULL() || sound_duration == NULL() ) return -1;
if ( time+max_charge_time >= openborconstant("MAX_INT") ) { // time protection
changeopenborvariant("elapsed_time",0);
time = openborvariant("elapsed_time");
}
playsample(loadsample(sound_fx));
setlocalvar("charge_sound_time",time+sound_duration);
} else if ( time > getlocalvar("charge_sound_time") ) setlocalvar("charge_sound_time",NULL());
// FLASH ENTITY
if ( getlocalvar("charge_flash_ent") == NULL() ) {
float x = getentityproperty(self,"x");
float z = getentityproperty(self,"z");
float y = getentityproperty(self,"y");
float base = getentityproperty(self,"base");
float dir = getentityproperty(self,"direction");
float height = getentityproperty(self,"height");
void subent;
if ( flashing_ent == NULL() ) return -1;
if ( height == NULL() ) height = 0;
clearspawnentry();
setspawnentry("name", flashing_ent);
subent = spawn();
changeentityproperty(subent, "no_adjust_base", 1);
changeentityproperty(subent, "position", x, z, y+(height/2));
changeentityproperty(subent, "base", y+(height/2));
changeentityproperty(subent, "direction", dir);
changeentityproperty(subent, "parent", self);
setlocalvar("charge_flash_ent",subent);
} else {
void subent = getlocalvar("charge_flash_ent");
if ( getentityproperty(subent,"exists") ) {
if ( getentityproperty(subent,"defaultmodel") == flashing_ent ) {
if ( flash_frame_length != NULL() ) {
if ( getentityproperty(subent,"animpos") >= flash_frame_length ) {
killentity(subent);
setlocalvar("charge_flash_ent",NULL());
}
}
} else setlocalvar("charge_flash_ent",NULL());
} else setlocalvar("charge_flash_ent",NULL());
}
}
} else {
if ( getlocalvar("charge_time") != NULL() ) {
float y = getentityproperty(self,"y");
float base = getentityproperty(self,"base");
if ( first_atk_flag == NULL() ) first_atk_flag = 0;
// PERFORM AN ATTACK
if ( getlocalvar("charge_atk") != NULL() ) {
if ( on_base_flag != NULL() && on_base_flag > 0 && y > base ) return 0;
if ( getlocalvar("charge_atk") == 0 ) {
if ( first_atk_flag ) performattack(self,CHARGE_ATK1,1);
} else if ( getlocalvar("charge_atk") == 1 ) performattack(self,CHARGE_ATK2,1);
else performattack(self,CHARGE_ATK3,1);
}
// RESET
clear_flashing(self,0);
setlocalvar("charge_sound_time",NULL());
if ( getentityproperty(getlocalvar("charge_flash_ent"),"exists") && getentityproperty(getlocalvar("charge_flash_ent"),"defaultmodel") == flashing_ent ) killentity(getlocalvar("charge_flash_ent"));
setlocalvar("charge_flash_ent",NULL());
setlocalvar("charge_atk",NULL());
setlocalvar("charge_time",NULL());
}
}
}
void flashing_color(void self, int colour, int frames, int reset_flag) {
int time = openborvariant("elapsed_time");
int flash_frames = frames;
float time_range = flash_frames/2;
int no_colour = rgbcolor(0x00,0x00,0x00);
//int colour1 = rgbcolor(0xFF,0xFF,0x00);
//int colour2 = rgbcolor(0xFF,0x00,0x00);
if ( reset_flag == NULL() ) reset_flag = 0;
time %= flash_frames;
if ( time <= time_range ) {
setlocalvar("next_flash_color",colour);
setlocalvar("step_flash_color", 1);
} else {
setlocalvar("next_flash_color", no_colour);
setlocalvar("step_flash_color", NULL());
}
changedrawmethod(self, "enabled", 1);
if ( reset_flag ) changedrawmethod(self, "reset", 1);
if ( getlocalvar("step_flash_color") == NULL() ) {
changedrawmethod(self, "tintmode", 0);
changedrawmethod(self, "tintcolor", 0);
changedrawmethod(self, "fillcolor", 0);
} else if ( getlocalvar("step_flash_color") == 1 ) {
changedrawmethod(self, "tintmode", 6);
changedrawmethod(self, "fillcolor", 0);
changedrawmethod(self, "tintcolor", getlocalvar("next_flash_color"));
}
if ( reset_flag ) {
changedrawmethod(NULL(), "enabled", 0);
changedrawmethod(NULL(), "reset", 1);
}
}
void clear_flashing(void self, int reset_flag) {
setlocalvar("set_flash_time",NULL());
setlocalvar("next_flash_color",NULL());
setlocalvar("step_flash_color",NULL());
if ( reset_flag == NULL() ) reset_flag = 0;
changedrawmethod(self, "tintmode", 0);
changedrawmethod(self, "tintcolor", 0);
changedrawmethod(self, "fillcolor", 0);
if ( reset_flag ) {
changedrawmethod(self, "enabled", 0);
changedrawmethod(self, "reset", 1);
changedrawmethod(NULL(), "enabled", 0);
changedrawmethod(NULL(), "reset", 1);
}
}
name Rock
type Player
health 100
mpset 100 0 0 6 0 0
speed 11
jumpspeed 13
jumpheight 4
jumpmove 3
risetime 100
makeinv 4
riseinv 4
antigravity -50
defense normal 1
falldie 1
noquake 1
candamage enemy
#==============================================================================================================
palette data/sprites/chara/rock/Idle.gif
icon data/sprites/chara/rock/icon.gif
animationscript data/scripts/scripta.c
ondrawscript data/scripts/continue.c
onblockwscript data/scripts/hitwall.c
onblocksscript data/scripts/hitwall.c
keyscript data/scripts/keymovea.c
script data/scripts/charge.c
[SCRIPT] Charge Attack in Megaman style
/* * PARAMS: * self = entity that performs a charge attack * key = hold button for charge attack: "attack" or "special" etc.. * color1,2,3 = flashing colors. set it in RGB format like -> rgbcolor(0x43,0x00,0xDA) * max_charge_time = time in frames of whole charge time (from min to max...
www.chronocrash.com
I saw the Mega Man Charge Attack script in this link.
I saved the script and applied it to the entity, but nothing changed, so I want to know the exact usage.