Attack Syshook is called, but doesn't work like it should

Get Help on scripting in POL with configurations, config setups, script trouble shooting, etc.
Post Reply
User avatar
tekproxy
Forum Regular
Posts: 352
Joined: Thu Apr 06, 2006 5:11 pm

Attack Syshook is called, but doesn't work like it should

Post by tekproxy »

syshook.cfg:

Code: Select all

SystemHookScript hooks/combat.ecl
{
	Attack Attack
}
hooks/combat.src:

Code: Select all

program Combat()
	print("SystemHook enabled: Attack");
	return 1;
endprogram

exported function Attack(attacker, defender)
	print("This works just fine: " + attacker.name);
	return;
endfunction
Everything works as far as the hook is called, print statements go fine, calculations are made, etc... However, the documentation says that if you hook Attack, you'll have to call the hitscript yourself but it is calling it all by itself. Magicly. POL runs my hook like it should but totally ignores it and the core is still handling combat....... Why?

On OSI the chance to hit is based on the attacker's combat skill vs the defender's' combat skill, or eval int and anatomy, and if the attack hits, parry is checked if the defender is using a melee weapon or shield (with some bushido weirdness thrown in there, but I'm not sure I'm going to use that). I'd handle this stuff in a hit script but the core still likes to make the hit sound even though the attack would have missed and is dealing no damage.

Another question: If I try to do this:

Code: Select all

print ("Weapon info -  objtype: " + (attacker.weapon).objtype + " name: " + (attacker.weapon).name);
It prints the object type but not the name, even though the docs say that Weapon is a distant child UObject, which has a name property. I know I could get the name from config files, but is the documentation wrong?
Aeros
Journeyman Poster
Posts: 69
Joined: Mon Apr 24, 2006 10:56 am

Post by Aeros »

Works fine on our shard, BUT, we return 1 (not 0) when the attack is NOT allowed, and this stops the attack from proceeding. As a safe measure I also pop the player out of warmode.

Dunno if this answers your question?
User avatar
tekproxy
Forum Regular
Posts: 352
Joined: Thu Apr 06, 2006 5:11 pm

Post by tekproxy »

Thanks, that helped. Now I just need to handle the sounds when they miss. For some reason it plays sounds automaticly on hit even though I never tell it to...

Oh, and the hit script is also automagicly called even though the docs say that wont happen unless I do it.
Aeros
Journeyman Poster
Posts: 69
Joined: Mon Apr 24, 2006 10:56 am

Post by Aeros »

If you're using an adapted/customized version of the old 095 distro, the sounds are played in the hitScriptInc.inc.

As for the attack script, it's always automatically called here as well. I dunno about you guys, but I prefer it that way :P
User avatar
Austin
Former Developer
Posts: 621
Joined: Wed Jan 25, 2006 2:30 am

Post by Austin »

If the hook returns 1 at the end of the combat function, then it stops there.
If it returns 0, the core takes over and runs the weapon's hit script.
Post Reply