Enemies factions/gangs

Piccolo

Well-known member
As anyone already figured out a good way of implementing different enemies factions/gangs ?

That is ennemies that are hostile to (and can damage) some others enemies only (and players of course).

I'm preparing a funny gang war level where such a function will be crucial, but I could use this in some other levels too (where there is some wild beasts among humans enemies for exemple).

My only guesses atm is to use an entityvar on each enemies and check it somewhere to filter/reject potential targets (maybe in thinkscript ?) or to completly disable hostile on enemies and use an alternate and custom system to handle AI. But I'll try to avoid the later if possible.

It would be awesome if hostile property worked with some kind of custom header subtypes though.
 
Indeed, it should work well in most cases, that is players + two distinct enemy factions. But if you want to add real NPC (~ allies) on that or more than two enemy factions I think you're doomed ;D

Anyway it's a great and easy to use solution, thanks :)
 
Yes, kinda like that :)
you can make many things:

- set/change enemy/npc hostile to something, based on how much players are on the screen
- check gang member life to make they more aggressive
- check players life and be more or less aggresive
- Even check which player is dying and focus on that one! This is pure evil, but its life :)
 
LOL excellent suggestions !

I already thought of some kind of enemy coordination, but with a more controlled approach (that is for exemple 4 ninjas that lunge on one player all at the same time, "ringing", etc)

set/change enemy/npc hostile to something, based on how much players are on the screen"
=> "Eh wait, why are we fighting each others ? There are some badasses of there, and they're kicking our butts !"
 
I already thought of some kind of enemy coordination, but with a more controlled approach (that is for exemple 4 ninjas that lunge on one player all at the same time, "ringing", etc)

You can make all the enemies to check the players life and if they are with low life, then start to use targeted attacks (or targeted projectiles). This is ubber evil, but its up to you, lol.

 
I have some script workaround idea for factions/gangs but it doesn't solve candamage issue. In detail:
- Enemies use custom scripted AI to move around, attack etc
- Enemy's faction/gang is defined with script in their text using entity variable
- When looking for opponent to attack, enemy will try to check other enemies, checking that variable. If it's not same as his/her then set as target to attack. If it's the same, find another target or just be idle until a target appears
- Since enemies would be attacking other enemies, friendly fire is inevitable

Well, that's the idea :)
 
Bump, I tried to come up with a solution today and figured that actually we can already create new types because OpenBOR type operations are bitwise.

So for example, for an enemy belonging to faction 1, in its spawn script :

Code:
		void vSelf = getlocalvar("self");
		changeentityproperty(vSelf, "type", getentityproperty(vSelf, "type") + 2048);
		changeentityproperty(vSelf, "hostile", getentityproperty(vSelf, "hostile") + 4096);
		changeentityproperty(vSelf, "candamage", getentityproperty(vSelf, "candamage") + 4096);

and for an enemy belonging to faction 2, in its spawn script :

Code:
		void vSelf = getlocalvar("self");
		changeentityproperty(vSelf, "type", getentityproperty(vSelf, "type") + 4096);
		changeentityproperty(vSelf, "hostile", getentityproperty(vSelf, "hostile") + 2048);
		changeentityproperty(vSelf, "candamage", getentityproperty(vSelf, "candamage") + 2048);

You can even set hostile and candamage directly via hostile and candamage commands :

Code:
hostile player npc 4096
candamage player npc obstacle 4096

And then everything works as expected (well I guess  :P )
 
That's why I prefer to use the real spawn event (onspawnscript) for this instead of putting it in spawn animation script.

Code:
onspawnscript @script
	#import "data/scripts/spawn/common.c"
	void main(){

		blablabla
		
	}
@end_script

:)
 
Plombo said:
What is the "first frame bug"?

First frame bug is a bug in which scripts or commands don't work properly if declared/run in very first frame
I may need to check this but you can try setting jumpframe 0 0 2 0 in SPAWN animation and see where entity would move when spawned

(couple minutes later)

Oops, that didn't show the bug  :-[

The easiest way to reproduce this bug is by spawning an entity with jumpframe 0 0 2 0 in its SPAWN animation
 
Back
Top Bottom