Solved ondoattack help

Question that is answered or resolved.

O Ilusionista

Captain 100K
Hi there.
I am trying to make this work but I am missing something.
I want to make some entities totally imune to ATTACK17 using ondoattack. I know I could use a defense setting, but I need to use ondoattack because I want to nullify the attack completly (no hitfx, no flash, etc)

This is the code I am using

Code:
void main()
{
	void self;      // Entity running event
	void other;     // Entity attacking or receiving vs. self.
	int which;      // Attacker or defender event?
	int id_hit_by;  // Entity ID of entity attack hit.
	int id_attack;  // Entity ID of entity that performed attack.

	Type		= getlocalvar("attacktype");// Get attack type
	self        = getlocalvar("self");
	other       = getlocalvar("other");
	which		= getlocalvar("which");
	
	// Is this a defending event?
	if(!which))
	{
	    // IDs are not the same? This is how we prevent repeat
	    // hits from the same attack.
	    hit_by_id   = getentityproperty(self, "hitbyid");
        attack_id   = getlocalvar("attackid");
	
	    if(hit_by_id != attack_id) && (Type=="ATK_NORMAL17")
        {
			changeopenborvariant("lasthitc", 0);
        }				
	}
    
    // Set hit id on self to attack ID for the next cycle.
	changeentityproperty(self, "hitbyid", hit_by_id);
}

What I am missing here?
 
Let me get a WIn 7 install I need done going, and then I'll take a closer look.
 
Just created a Gist with your code fixed (I hope, lol). I found two problems.

The first is you need to use a constant for the "which" check. This part wasn't a break, but still - always use constants when you can.

The part that actually broke the code is here. Instead of comparing type to an attack type constant, you just had plan text there. Since the attack type is a number and that text was... well text, it will never match. I fixed it and broke the if into parts for you.

Unless I made a typo or missed something else you should be good to go.

DC

 
Sorry, I was testing it on my old 4432 build.
But I tried on the most recent build I am testing for some time (6325) and it doesn't works either.
 
OK, hitting the road - but I'll look at this closer. I have an idea of what it is, but not sure until I can test further (the constants may not be returning correct values). If so, I'll need to do a patch.

DC
 
 
Back
Top Bottom