Custom_target question

Steve Craft

Member
I read some threads that you can use Custom_target to force a entity to attack another specifically,but i have a question that's bugging me since yesterday,it's possible to use more than one Custom_target on same time(let's say, 1 entity focusing on fight only 2 entities with Custom_target)?
 
There's only one custom target variable, so no you can't use it on two entities at once. You CAN force an entity to fight any subset of other entities you want, but it gets a bit more complicated. Custom Target is a convenience feature to handle the common situations whee you need an entity to focus on one specific thing. This comes up a lot in cut-scenes and path-finding.

DC
 
Steve Craft : I read in Discord that you want to create factions with custom_target. I don't know if you can use custom_target for that but I know for sure that you can create factions with other way :).

Would you like to hear more about factions?  8)
 
To create a new faction, you'd need to change entity's type to a new type. Then you need to modify other factions to be able to hostile toward and damage that new faction.

That sounds too technical so I'm going to give example of creating 2 factions :).
1st faction is the enemy and the 2nd faction is new faction. Both factions are hostile toward players and NPC and they can damage both of the latter.

First, you need to set this in enemy''s texts:
Code:
onspawnscript	data/scripts/faction1.c

This is faction1.c :
Code:
void main()
{
    void vSelf = getlocalvar("self");
    changeentityproperty(vSelf, "hostile", 2048 + openborconstant("TYPE_PLAYER") + openborconstant("TYPE_NPC") );
    changeentityproperty(vSelf, "candamage", 2048 + openborconstant("TYPE_PLAYER") + openborconstant("TYPE_OBSTACLE") + openborconstant("TYPE_NPC") );
    changeentityproperty(vSelf, "projectilehit", 2048 + openborconstant("TYPE_PLAYER") + openborconstant("TYPE_OBSTACLE") + openborconstant("TYPE_ENEMY"));
}

Second, set this in new faction's text. This new faction entity could start as enemy type but onspawnscript will change that.
Code:
onspawnscript	data/scripts/faction2.c

This is faction2.c :
Code:
void main()
{
    void vSelf = getlocalvar("self");
    changeentityproperty(vSelf, "type", 2048);
    changeentityproperty(vSelf, "hostile", openborconstant("TYPE_ENEMY") + openborconstant("TYPE_PLAYER") + openborconstant("TYPE_NPC") );
    changeentityproperty(vSelf, "candamage", openborconstant("TYPE_ENEMY") + openborconstant("TYPE_PLAYER") + openborconstant("TYPE_OBSTACLE") + openborconstant("TYPE_NPC") );
    changeentityproperty(vSelf, "projectilehit", 2048 + openborconstant("TYPE_OBSTACLE") + openborconstant("TYPE_ENEMY"));
}

To test this, spawn both enemies and new factions in one level and see how they'll react to each other  ;)
You (as player) can join in too.
 
2048 is just number of new type.
openborconstant("TYPE_ENEMY"), openborconstant("TYPE_PLAYER"), openborconstant("TYPE_OBSTACLE") etc result in a number, multiply of 2.
 
Bloodbane said:
AFAIK 2048 is not used by any type.

Bloodbane

Hmm, I did some tests and it seems that we can create custom types by using numbers... Long time I waited to create more types, something like player, enemy, npc1 and npc2.

Another use for this is to create a custom projectile colision. For example, the player can throw a projectile type "2048" and the enemy can throw a projectile type "4096".
Both projectiles can hit each other and hit your opponents (player or enemy), but both player and enemy can't hit the projectiles. And this way, the npc type will be freed to any other use in the game.

Thanks for this tip. I will continue testing
 
Bloodbane I got what you did (DC explained to me) - you are creating a custom entity type. Neat :)

Another use for this is to create a custom projectile colision. For example, the player can throw a projectile type "2048" and the enemy can throw a projectile type "4096".
Kratus I never understood why "pshot" type was removed. It was very useful.
 
O_Ilusionista

Bloodbane I got what you did (DC explained to me) - you are creating a custom entity type. Neat :)
Thanks for the confirmation, it will be very useful :)

Kratus I never understood why "pshot" type was removed. It was very useful.
Yeah, I agree with you buddy. For some reason, the type pshot is not totally disabled, it's possible to use with scripts but some properties are not activated like the npc type.
But by using these custom types it seems that everything is fully activated. I applied it to some enemies and they worked the same as a regular enemy type.
 
Bloodbane said:
To create a new faction, you'd need to change entity's type to a new type. Then you need to modify other factions to be able to hostile toward and damage that new faction.

That sounds too technical so I'm going to give example of creating 2 factions :).
1st faction is the enemy and the 2nd faction is new faction. Both factions are hostile toward players and NPC and they can damage both of the latter.

First, you need to set this in enemy''s texts:
Code:
onspawnscript	data/scripts/faction1.c

This is faction1.c :
Code:
void main()
{
    void vSelf = getlocalvar("self");
    changeentityproperty(vSelf, "hostile", 2048 + openborconstant("TYPE_PLAYER") + openborconstant("TYPE_NPC") );
    changeentityproperty(vSelf, "candamage", 2048 + openborconstant("TYPE_PLAYER") + openborconstant("TYPE_OBSTACLE") + openborconstant("TYPE_NPC") );
    changeentityproperty(vSelf, "projectilehit", 2048 + openborconstant("TYPE_PLAYER") + openborconstant("TYPE_OBSTACLE") + openborconstant("TYPE_ENEMY"));
}

Second, set this in new faction's text. This new faction entity could start as enemy type but onspawnscript will change that.
Code:
onspawnscript	data/scripts/faction2.c

This is faction2.c :
Code:
void main()
{
    void vSelf = getlocalvar("self");
    changeentityproperty(vSelf, "type", 2048);
    changeentityproperty(vSelf, "hostile", openborconstant("TYPE_ENEMY") + openborconstant("TYPE_PLAYER") + openborconstant("TYPE_NPC") );
    changeentityproperty(vSelf, "candamage", openborconstant("TYPE_ENEMY") + openborconstant("TYPE_PLAYER") + openborconstant("TYPE_OBSTACLE") + openborconstant("TYPE_NPC") );
    changeentityproperty(vSelf, "projectilehit", 2048 + openborconstant("TYPE_OBSTACLE") + openborconstant("TYPE_ENEMY"));
}

To test this, spawn both enemies and new factions in one level and see how they'll react to each other  ;)
You (as player) can join in too.
so this was how to make new factions,sorry for only seeing it now,also thanks for the info
 
Back
Top Bottom