custom_target
entity property to force an entity to target another specific entity. So if you wanted to target a player with the name "Bob", you'll need to set the Hostile and Candamage properties to include Player types, then get the entity pointer for "Bob" and place it into custom_target
.//START THE VARIABLE TO BE USED BY ANY SCRIPT, YOU CAN PUT ON A GLOBAL EVENT LIKE LEVEL.C, UPDATED.C, ETC...
setglobalvar("LEVEL_ENTITY", 65536);
//USE THE PREVIOUS CREATED VARIABLE TO CUSTOM TARGET'S HOSTILE/CANDAMAGE, YOU CAN PUT ON A ENTITY EVENT, LIKE ONSPAWN, ONDRAW, ETC...
changeentityproperty(self, "hostile", getglobalvar("LEVEL_ENTITY"));
changeentityproperty(self, "candamage", getglobalvar("LEVEL_ENTITY"));
@Kratus That's that pretty Interesting, I will do some more research and see how this recommendation works. Thank you!@PS_VITA
As an alternative, you can work with Bloodbane's idea for "factions" script. This way you can have multiple cpu controlled entity's types instead of having only enemy/npc as valid ones, plus you don't need to use aliases for that.
Note that you still need to put the entity type in the character's header to inherit the behavior, but once he spawns you can add a script to immediately change the type. As a suggestion you can create an "onspawn" script for that or put it on an inline script at the spawn animation.
For example, in SORX I have some npc entities that are used for decoration purposes. However, the cpu partners already are npcs too and the enemy are hostile to them.
To prevent enemies attacking decoration entitites, all of them have an "onspawn" script to change its type as soon as they spawn on the level. I don't change the stealth factor because I'm using it for "item detection" by enemies, so the factions script worked fine for my purpose.
C://START THE VARIABLE TO BE USED BY ANY SCRIPT, YOU CAN PUT ON A GLOBAL EVENT LIKE LEVEL.C, UPDATED.C, ETC... setglobalvar("LEVEL_ENTITY", 65536); //USE THE PREVIOUS CREATED VARIABLE TO CUSTOM TARGET'S HOSTILE/CANDAMAGE, YOU CAN PUT ON A ENTITY EVENT, LIKE ONSPAWN, ONDRAW, ETC... changeentityproperty(self, "hostile", getglobalvar("LEVEL_ENTITY")); changeentityproperty(self, "candamage", getglobalvar("LEVEL_ENTITY"));
For example change an enemy to only target and be hostile to Billy2.
That was a random example lol.Mmm...., what will that enemy do when there's no Billy2 at all?
void candam(int Rx, int Rz)
{
void self = getlocalvar("self");
float x = getentityproperty(self, "x");
float z = getentityproperty(self, "z");
void vEntity; //Target entity placeholder.
int iEntity; //Entity enumeration holder.
int iName; //Entity name.
int iMax = openborvariant("ent_max"); //Entity count.
float Tx;
float Tz;
float Disx;
float Disz;
//Enumerate and loop through entity collection.
for(iEntity=0; iEntity<iMax; iEntity++){
vEntity = getentity(iEntity); //Get target entity from current loop.
iName = getentityproperty(vEntity, "defaultname"); //Get target name
if(iName == "ball3" || iName == "barel3" || iName == "box3" || iName == "boxx3" || iName == "rock3" || iName == "wood3"
|| iName == "ball" || iName == "barel" || iName == "box" || iName == "boxx" || iName == "rock" || iName == "wood"
|| iName == "knife2" || iName == "dynam2" || iName == "bomb" || iName == "bomb2" || iName == "boxx1" || iName == "boxx2"){
Tx = getentityproperty(vEntity, "x");
Tz = getentityproperty(vEntity, "z");
Disx = Tx - x;
Disz = Tz - z;
if(Disx >= -Rx && Disx <= Rx && Disz >= -Rz && Disz <= Rz){
changeentityproperty(vEntity, "hostile", openborconstant("TYPE_ENEMY"));
changeentityproperty(vEntity, "candamage", openborconstant("TYPE_ENEMY"));
}
}
}
}
@magggasFor this, when the new enemy appears, he just need an anmation script on his spawn animation that changes the hostile for both enemies. Then use the same script on the looser death animation to revert the winner's hostile setting back to normal. Here is an example of such script:
Code:void candam(int Rx, int Rz) { void self = getlocalvar("self"); float x = getentityproperty(self, "x"); float z = getentityproperty(self, "z"); void vEntity; //Target entity placeholder. int iEntity; //Entity enumeration holder. int iName; //Entity name. int iMax = openborvariant("ent_max"); //Entity count. float Tx; float Tz; float Disx; float Disz; //Enumerate and loop through entity collection. for(iEntity=0; iEntity<iMax; iEntity++){ vEntity = getentity(iEntity); //Get target entity from current loop. iName = getentityproperty(vEntity, "defaultname"); //Get target name if(iName == "ball3" || iName == "barel3" || iName == "box3" || iName == "boxx3" || iName == "rock3" || iName == "wood3" || iName == "ball" || iName == "barel" || iName == "box" || iName == "boxx" || iName == "rock" || iName == "wood" || iName == "knife2" || iName == "dynam2" || iName == "bomb" || iName == "bomb2" || iName == "boxx1" || iName == "boxx2"){ Tx = getentityproperty(vEntity, "x"); Tz = getentityproperty(vEntity, "z"); Disx = Tx - x; Disz = Tz - z; if(Disx >= -Rx && Disx <= Rx && Disz >= -Rz && Disz <= Rz){ changeentityproperty(vEntity, "hostile", openborconstant("TYPE_ENEMY")); changeentityproperty(vEntity, "candamage", openborconstant("TYPE_ENEMY")); } } } }
This script checks for specific entities names, just edit those and remove the the rest names there. In my game there are tons of variations of this script, for example if you want it to check the entity type instead of the name, you get the idea.
Oh and one more thing i forgot, this script does not care if the entity uses alias, it checks and still indetifies an entity by its default name anyway.
@magggas thank you so much for this example as I've been learning of your double dragon game ever since I joined this forum and since you gave me permission to post the ps vita version double dragon back in the gbatemp website.For this, when the new enemy appears, he just need an anmation script on his spawn animation that changes the hostile for both enemies. Then use the same script on the looser death animation to revert the winner's hostile setting back to normal. Here is an example of such script:
Code:void candam(int Rx, int Rz) { void self = getlocalvar("self"); float x = getentityproperty(self, "x"); float z = getentityproperty(self, "z"); void vEntity; //Target entity placeholder. int iEntity; //Entity enumeration holder. int iName; //Entity name. int iMax = openborvariant("ent_max"); //Entity count. float Tx; float Tz; float Disx; float Disz; //Enumerate and loop through entity collection. for(iEntity=0; iEntity<iMax; iEntity++){ vEntity = getentity(iEntity); //Get target entity from current loop. iName = getentityproperty(vEntity, "defaultname"); //Get target name if(iName == "ball3" || iName == "barel3" || iName == "box3" || iName == "boxx3" || iName == "rock3" || iName == "wood3" || iName == "ball" || iName == "barel" || iName == "box" || iName == "boxx" || iName == "rock" || iName == "wood" || iName == "knife2" || iName == "dynam2" || iName == "bomb" || iName == "bomb2" || iName == "boxx1" || iName == "boxx2"){ Tx = getentityproperty(vEntity, "x"); Tz = getentityproperty(vEntity, "z"); Disx = Tx - x; Disz = Tz - z; if(Disx >= -Rx && Disx <= Rx && Disz >= -Rz && Disz <= Rz){ changeentityproperty(vEntity, "hostile", openborconstant("TYPE_ENEMY")); changeentityproperty(vEntity, "candamage", openborconstant("TYPE_ENEMY")); } } } }
This script checks for specific entities names, just edit those and remove the the rest names there. In my game there are tons of variations of this script, for example if you want it to check the entity type instead of the name, you get the idea.
Oh and one more thing i forgot, this script does not care if the entity uses alias, it checks and still indetifies an entity by its default name anyway.