bbox question ?

Mmm... there is a "bbox" wildcard for entityproperty...
utunnels can u explain to us how it works?
How many params does it need?
 
Basically I am using damageentity in a script but the problem is it hits player even if they are in spawn animation or just raised up after knock down and blinking invincible !

So if a check for bbox is made it wont damage unless player can be damaged !
 
Well for now u can simulate it in this way:

#define gep getentityproperty
#define cep changeentityproperty
#define oc openborconstant

int anim_id = gep(ent,"animationid");

if ( gep(ent,"vulnerable") && !gep(ent,"aiflag","inpain") && !gep(ent,"aiflag","falling") && !gep(ent,"aiflag","dead")
    && anim_id != oc("ANI_SPAWN") && anim_id != oc("ANI_RESPAWN") ) {
    damageentity...........
}

and if u want u can simulate bbox with coords by this way:
Code:
#define MAX_PLAYERS openborvariant("maxplayers")

void main() {
  void self = getlocalvar("self");
  int p;

        for ( p = 0; p < MAX_PLAYERS; ++p ) {
            void player = getplayerproperty(p, "entity");
            float x = getentityproperty(self, "x");
            float z = getentityproperty(self, "z");
            float a = getentityproperty(self, "a");
            float xp = getentityproperty(player, "x");
            float zp = getentityproperty(player, "z");
            float ap = getentityproperty(player, "a");

            if ( !getentityproperty(player, "exists") ) continue;

            if ( getentityproperty(player,"x") > x-30 && getentityproperty(player,"x") < x+30 && getentityproperty(player,"z") > z-20 && getentityproperty(player,"z") < z+20 && getentityproperty(player,"a") == getentityproperty(self,"a") ) {
                if ( getentityproperty(player, "invincible") == 0 && getentityproperty(player, "vulnerable") != 0 ) {
                    if ( getentityproperty(player, "aiflag", "dead") != 1 && getentityproperty(player, "aiflag", "falling") != 1 && getentityproperty(player, "aiflag", "inpain") != 1 ) {
.................
                    } // fine if dead/pain/fall
                } // fine if invincible
            } // fine if coords
        } // fine for

}
 
Thanks white dragon "invincible" & "vulnerable" where just the parameters my code needed it works perfect now.

I double checked and these 2 were not in the script reference manual how did you know about them ?

This is the manual I always refer to when scripting : http://www.chronocrash.com/forum/index.php?topic=11.0
 
White Dragon said:

That's a clever solution, but it's not really necessary.

Use the doattack event; it fires on both the attacker and defender when a collision is detected but but before the engine takes any of its default actions - meaning you can add or substitute your own collision effects while still using the built in attack box and bbox system.

Here's some sample code used for a parry system. The important part is lasthitc. By setting that to 0, you turn the last collision "off" before it's passed on to the engine's default hit handling code. The engine will behave as if no hit ever took place leaving you free to do whatever you want without interference.

Event code...
Code:
#include	"data/scripts/com/z_datk.h"

void main()
{
	void    vSelf		= getlocalvar("self");
    
	z_datk(vSelf);	//Call universal doattack function.
}

Function...
Code:
#include	"data/scripts/com/parr0001.h"

void z_datk(void vEnt)
{
	/*
	z_datk
	Damon Vaughn Caskey
	2011_02_25

	Universal doattack event function.

	vEnt:	Caller entity.
	*/
		
    int		iAtkID		= getlocalvar("attackid");
	void	vOther		= getlocalvar("other");

	if(!vEnt){	vEnt = getlocalvar("self");	}

	/*
	log("\n z_datk ~ Cuurent ID: " + iAtkID);
	log("\n z_datk ~ Attack ID: " + getentityproperty(vEnt, "attackid"));
	log("\n z_datk ~ Hit By ID: " + getentityproperty(vEnt, "hitbyid"));
	*/

	if(!getlocalvar("which") && (getentityproperty(vEnt, "hitbyid") != iAtkID))
	{
		if (parr0001(vEnt, vOther))
		{		
			changeopenborvariant("lasthitc", 0);
		}		
	}
		
	changeentityproperty(vEnt, "hitbyid", iAtkID);

	//log("\n z_datk ~ Hit By ID (after): " + getentityproperty(vEnt, "hitbyid"));
}
 
Damon Caskey can I use this way to nullify an attack too?
For example I want to nullify a grab attack if an enemy is "balrog"
But after an attack if I force lasthitc to 0 in  ondoattack event it doesn't work =(

msmalik681 said:
Thanks white dragon "invincible" & "vulnerable" where just the parameters my code needed it works perfect now.

I double checked and these 2 were not in the script reference manual how did you know about them ?

This is the manual I always refer to when scripting : http://www.chronocrash.com/forum/index.php?topic=11.0

You can spy in source code ;)
http://sourceforge.net/p/openbor/engine/HEAD/tree/engine/openborscript.c
 
Oh I know about sourceforge. I better, don't forget I'm a dev too. Technically I'm the lead dev with SX retired, but unless there is some kind of overarching issue or conflict of interest I typically defer to Plombo and UT since they are better coders.

Anyway, I'm the one who added the dottack feature and it should work for what you are doing; that's almost exactly what it was meant for. Nullifying attacks is exactly how I was able to set up my parry system.

It's been a long time since I added it though and there have been many changes by the other devs since then - it might have been broken or changed. I'll poke around when I get a chance and see what I can do.

DC
 
Ok excuse me  damon!! my mistake!! now works perfectly!!
100000000 THANKS!! now my foot soldier works fine (can't grab another foot soldier).

However there is a strange effect (speedy) when I reset continuously the lasthitc =(
I can't use it to getentities or ONTOUCH scripted enitities (like ladders).
For now I found a solution (not works for entities that u can check continuously like stairs).

Code:
// reset hitbyid opp only if isn't in range or if the entity change to another opp
int reset_opp_by_range(void self, void opp, int range_anim_id) {
    void last_opp = getlocalvar("last_opp");

	if ( last_opp && getentityproperty(last_opp,"exists") ) {
		int range_flag = checkrange(self,last_opp,range_anim_id);
		//drawstring(10,170,0,":  "+range_flag );

		if ( !range_flag ) {
			changeentityproperty(last_opp,"hitbyid",0); // attackid
			setlocalvar("last_opp",NULL());
		}
    }

    if ( getentityproperty(opp,"exists") && opp != last_opp ) {
        if ( getentityproperty(last_opp,"exists") ) changeentityproperty(last_opp,"hitbyid",0); // attackid
        setlocalvar("last_opp",opp);
    }
}
 
Back
Top Bottom