Jump to content
Heavy Traffic ×

Need help determining when the PC hits any enemies with a certain weapon


SamHe11

Recommended Posts

I'm trying to script a message to pop up when the PC hits any enemies with a specific weapon. So I've started a script that I've attached to the weapon itself, but I'm looking for something like an OnHit to call with the weapon when it connects with any NPC/Creature so the message can trigger. I've found HitOnMe, but my understanding is that's for scripts on the calling object (the NPCs/Creatures themselves). I also tried the MWSE function xGetPCTarget to reference the enemy in the PCs crosshairs (which I've gotten to work fine), and then use that ref in the HitOnMe function in the sword's script. But I'm not having much luck with it.

 

My code looks like this:

short doonce

long pcTargetHit
long pcTarget
long temp

Setx pcTarget to xGetPCTarget


ifx ( pcTarget )   ;GAME CRASHES IF YOU CALL A FUNCTION WHILE TARGET IS 0

	if ( doonce == 0 )
		MessageBox, "You are currently targeting something"	;DEBUG MESSAGE
		set doonce to 1
	endif

	setx pcTargetHit to ( pcTarget -> HitOnMe, test_sword )
	ifx ( pcTargetHit )
		MessageBox, "You have hit the enemy with this sword"    ;DEBUG MESSAGE
	endif

else
	if ( doonce == 0 )
		MessageBox, "You are not targeting anything"		;DEBUG MESSAGE
		Set doonce to 0
	endif
endif 

 

The error that comes up when I try to compile is:

Syntax Error: Expected 'Unknown' but found '(' (()!

Any help with this would be greatly appreciated.

Thanks

 

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...