I am using this exact trick, but many reports that this enemy can't even enter the screen@Kratus may be using script to set the subject_to_screen flag depending on special needs for SORX, but you don't have to do it that way. You can just define the subject_to_screen option in model text files. Entities from that model that are spawned outside of the screen boundaries are free to move about until they cross into the screen. After that, the subject_to_screen takes effect and they can't leave the screen boundary any more.
The option is off by default for enemy and NPC types, and on for players.
DC
thank you for telling me. applied result@Kratus may be using script to set the subject_to_screen flag depending on special needs for SORX, but you don't have to do it that way. You can just define the subject_to_screen option in model text files. Entities from that model that are spawned outside of the screen boundaries are free to move about until they cross into the screen. After that, the subject_to_screen takes effect and they can't leave the screen boundary any more.
The option is off by default for enemy and NPC types, and on for players.
DC
I want spawned enemies to appear off-screen and not be able to exit inside the screen when making contact with the player. An example is Street of Rage 2x, enemies don't leave the screen when they fall.Do you want to allow enemies to be offscreen after being spawned BUT after the enter screen, they aren't allowed to go offscreen anymore?
void edgeLock()
{//Lock the screen edge (for enemies) if take any damage, like SOR4
void self = getlocalvar("self");
void vType = getentityproperty(self,"type");
void sType = getentityproperty(self,"subtype");
int dead = getentityproperty(self, "dead");
if(vType == openborconstant("TYPE_ENEMY")){
if(sType != openborconstant("SUBTYPE_NOTGRAB")){
if(!dead){
changeentityproperty(self, "subject_to_screen", 1);
}
}
}
}
void edgeLock()
{//Unlock the screen edge (for enemies) according to defined instances, like SOR4
void self = getlocalvar("self");
void vType = getentityproperty(self,"type");
if(vType == openborconstant("TYPE_ENEMY")){
void sType = getentityproperty(self,"subtype");
int idling = getentityproperty(self, "aiflag", "idling");
int walking = getentityproperty(self, "aiflag", "walking");
int running = getentityproperty(self, "aiflag", "running");
int rising = getentityproperty(self, "aiflag", "rising");
if(sType != openborconstant("SUBTYPE_NOTGRAB")){
if(idling || walking || running || rising){
changeentityproperty(self, "subject_to_screen", -1);
}
}
}
}
thank you. But I don't know how to use it.Hi @DD Tokki
In the Street of Rage 2x the subject to screen is dinamically changed according to defined sittuations, basically I'm reproducing the SOR4 behaviour.
The feature contains 2 steps:
1) If the enemy take any damage, the subject_to_screen is set to 1 at the "takedamage.c" event.
2) Once the enemy is not getting any hit and is blocked by any screen edge, the subject_to_screen is set to 0 (in fact I set it to -1 for enemies, for some reason this is the default flag value when they are spawned).
Below you can see the scripts:
takedamage.c
C:void edgeLock() {//Lock the screen edge (for enemies) if take any damage, like SOR4 void self = getlocalvar("self"); void vType = getentityproperty(self,"type"); void sType = getentityproperty(self,"subtype"); int dead = getentityproperty(self, "dead"); if(vType == openborconstant("TYPE_ENEMY")){ if(sType != openborconstant("SUBTYPE_NOTGRAB")){ if(!dead){ changeentityproperty(self, "subject_to_screen", 1); } } } }
onblocksscript.c
C:void edgeLock() {//Unlock the screen edge (for enemies) according to defined instances, like SOR4 void self = getlocalvar("self"); void vType = getentityproperty(self,"type"); if(vType == openborconstant("TYPE_ENEMY")){ void sType = getentityproperty(self,"subtype"); int idling = getentityproperty(self, "aiflag", "idling"); int walking = getentityproperty(self, "aiflag", "walking"); int running = getentityproperty(self, "aiflag", "running"); int rising = getentityproperty(self, "aiflag", "rising"); if(sType != openborconstant("SUBTYPE_NOTGRAB")){ if(idling || walking || running || rising){ changeentityproperty(self, "subject_to_screen", -1); } } } }
Is the game crashing? Could you post the log file?thank you. But I don't know how to use it.
If you put a script in the game, the game will end before you do damage to enemies.
name zako-a1
type Enemy
aimove chase
health 100
speed 6
running 14 3.5 2 1
jumpspeed 12
jumpheight 3.8
jumpmove 0 1
risetime -220
grabdistance 20
antigravity -30
falldie 2
gfxshadow 1 2
noquake 1
nolife 1
antigrab 100
grabforce 100
hostile player npc
candamage player npc obstacle
animationscript data/scripts/script.c
ondrawscript data/scripts/hpbar.c
takedamagescript data/scripts/takedamage.c
onblocksscript data/scripts/onblocksscript.c
I've tried applying the script to other games at the same time, but it ends the same way.
게임이 충돌합니까? 로그 파일을 게시할 수 있습니까?
아마도 "상승하는" 인스턴스 때문일 수 있습니다. 내가 틀리지 않은 경우 이 인스턴스는 최신 소스 코드에서만 작동합니다. 빌드 6391 또는 이전 버전을 사용하는 경우 "riseattacking"으로 교체하거나 프로젝트에 필요하지 않은 경우 제거할 수 있습니다.
사실 저는 게임의 일부 캐릭터가 상승 또는 상승 공격 애니메이션 중에 움직일 수 있기 때문에 상승 인스턴스만 사용하고 있습니다.
로그 파일에 너무 많은 정보가 없습니다. takedamage.c 파일을 게시할 수 있습니까?
void main()
{
edgeLock();
}
void edgeLock()
{//Lock the screen edge (for enemies) if take any damage, like SOR4
void self = getlocalvar("self");
void vType = getentityproperty(self,"type");
void sType = getentityproperty(self,"subtype");
int dead = getentityproperty(self, "dead");
if(vType == openborconstant("TYPE_ENEMY")){
if(sType != openborconstant("SUBTYPE_NOTGRAB")){
if(!dead){
changeentityproperty(self, "subject_to_screen", 1);
}
}
}
}
thank you. Finally it runs.If you don't have plans for adding multiple scripts in the takedamage event, replace the "void edgeLock()" by the "void main()".
Otherwise, copy/paste the code below:
C:void main() { edgeLock(); } void edgeLock() {//Lock the screen edge (for enemies) if take any damage, like SOR4 void self = getlocalvar("self"); void vType = getentityproperty(self,"type"); void sType = getentityproperty(self,"subtype"); int dead = getentityproperty(self, "dead"); if(vType == openborconstant("TYPE_ENEMY")){ if(sType != openborconstant("SUBTYPE_NOTGRAB")){ if(!dead){ changeentityproperty(self, "subject_to_screen", 1); } } } }
Great, I'm glad the script workedthank you. Finally it runs.
May I ask one more question?Great, I'm glad the script worked![]()
Yes, in this case you need to combine both in the same event, like this:May I ask one more question?
void number()
{
void self = getlocalvar("self");
void f;
int damage = getlocalvar("damage");
int x, z, a, t;
int atkType = getlocalvar("attacktype");
if(damage > 0 && atkType != openborconstant("ATK_TIMEOVER"))
{
x = getentityproperty(self, "x")+4;
z = getentityproperty(self, "z")+1;
a = getentityproperty(self, "a")+40;
setspawnentry("name", "number");
while(damage)
{
t = damage % 10;
f = spawn();
changeentityproperty(f, "position", x,z,a);
updateframe(f, t);
damage/=10;
x -= 8;
}
}
}
It's a damage script, can I use it in combination with the previous script?
void main()
{
edgeLock();
number();
}
void edgeLock()
{//Lock the screen edge (for enemies) if take any damage, like SOR4
void self = getlocalvar("self");
void vType = getentityproperty(self,"type");
void sType = getentityproperty(self,"subtype");
int dead = getentityproperty(self, "dead");
if(vType == openborconstant("TYPE_ENEMY")){
if(sType != openborconstant("SUBTYPE_NOTGRAB")){
if(!dead){
changeentityproperty(self, "subject_to_screen", 1);
}
}
}
}
void number()
{
void self = getlocalvar("self");
void f;
int damage = getlocalvar("damage");
int x, z, a, t;
int atkType = getlocalvar("attacktype");
if(damage > 0 && atkType != openborconstant("ATK_TIMEOVER"))
{
x = getentityproperty(self, "x")+4;
z = getentityproperty(self, "z")+1;
a = getentityproperty(self, "a")+40;
setspawnentry("name", "number");
while(damage)
{
t = damage % 10;
f = spawn();
changeentityproperty(f, "position", x,z,a);
updateframe(f, t);
damage/=10;
x -= 8;
}
}
}
Thank you very much. The functions I want to do have been implemented.Yes, in this case you need to combine both in the same event, like this:
C:void main() { edgeLock(); number(); } void edgeLock() {//Lock the screen edge (for enemies) if take any damage, like SOR4 void self = getlocalvar("self"); void vType = getentityproperty(self,"type"); void sType = getentityproperty(self,"subtype"); int dead = getentityproperty(self, "dead"); if(vType == openborconstant("TYPE_ENEMY")){ if(sType != openborconstant("SUBTYPE_NOTGRAB")){ if(!dead){ changeentityproperty(self, "subject_to_screen", 1); } } } } void number() { void self = getlocalvar("self"); void f; int damage = getlocalvar("damage"); int x, z, a, t; int atkType = getlocalvar("attacktype"); if(damage > 0 && atkType != openborconstant("ATK_TIMEOVER")) { x = getentityproperty(self, "x")+4; z = getentityproperty(self, "z")+1; a = getentityproperty(self, "a")+40; setspawnentry("name", "number"); while(damage) { t = damage % 10; f = spawn(); changeentityproperty(f, "position", x,z,a); updateframe(f, t); damage/=10; x -= 8; } } }