IsPoinsterEqual Question...

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!

Moderator: GZDoom Developers

Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.

Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)

IsPoinsterEqual Question...

Postby Logan MTM » Thu Nov 11, 2021 6:52 pm

Hi everyone!

The following code is just for matter of test:
Code: Select allExpand view

//Calling by Monsters

Script "Test" (VOID)
{
If(GetActorProperty(0, APROP_Health) < 1) { Terminate; } //End the Loop If the Monster Dies

If(IsPointerEqual(AAPTR_TARGET, AAPTR_NULL , 6000 , 0)) //Check if the Monster Target is The Player With Tid 6000
 {
 SetActorState(0,"Pain",0);//So make hin say "Ouch!"
 }

Delay(35); //Wait for something, like attacks

Restart; //Loop the Code
}

Everything Works fine until the Monsters deal damage to the Player.
I need o know why. Any help?
Apparently, Monsters loses the TARGET Pointer in IsPointerEqual function BUT still chasing the player.
Thank you all!
User avatar
Logan MTM
I can see you...
 
Joined: 16 Jan 2006
Location: Rio de Janeiro - Brazil

Re: IsPoinsterEqual Question...

Postby Apeirogon » Mon Nov 22, 2021 4:35 am

Script checks is target pointer of a thing with id 6000 is equal to null pointer of a script activator, which is...??????

If you want to check is player a script activator
Code: Select allExpand view
If(IsPointerEqual(AAPTR_TARGET, AAPTR_PLAYER1, 0, 0)) //Check if script activator target is player 1
{
    SetActorState(0,"Pain",0);//So make hin say "Ouch!"
}


For multiplayer support you should use loop to check for all players.
For more info read 'Selector category 3: Static context selectors' here
https://zdoom.org/wiki/Actor_pointer
User avatar
Apeirogon
I have a strange sense of humour
 
Joined: 12 Jun 2017

Re: IsPoinsterEqual Question...

Postby Logan MTM » Mon Nov 22, 2021 5:59 am

Thank you but it is solved. But it still confusing.

Code: Select allExpand view
If(IsPointerEqual(AAPTR_DEFAULT , AAPTR_TARGET , 0 ,6000)) //Check if the Monster Target is The Player With Tid 6000
 {
 SetActorState(0,"Pain",0);//So make hin say "Ouch!"
 }
Delay(35); //Wait for something, like attacks
User avatar
Logan MTM
I can see you...
 
Joined: 16 Jan 2006
Location: Rio de Janeiro - Brazil


Return to Scripting

Who is online

Users browsing this forum: No registered users and 0 guests