Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Callback when enemy changes to inactive
Reminiscity Offline
Member

Posts: 81
Threads: 16
Joined: Jan 2013
Reputation: 2
#1
Callback when enemy changes to inactive

Hola!

Is there a way to check of enemy is inactive?

My first thought was to use a looping timer that checks if GetEnemyStateName is inactive but there is no such state...

Any ideas?

My mod Amadeus
(This post was last modified: 11-17-2017, 03:19 PM by Reminiscity.)
11-17-2017, 03:13 PM
Find
Mudbill Offline
Muderator

Posts: 3,881
Threads: 59
Joined: Apr 2013
Reputation: 179
#2
RE: Callback when enemy changes to inactive

GetEntityExists() might do what you need. If not, perhaps you can just create your own boolean and manually flip it whenever you enable/disable the enemy.

11-17-2017, 06:38 PM
Find
Reminiscity Offline
Member

Posts: 81
Threads: 16
Joined: Jan 2013
Reputation: 2
#3
RE: Callback when enemy changes to inactive

(11-17-2017, 06:38 PM)Mudbill Wrote: GetEntityExists() might do what you need. If not, perhaps you can just create your own boolean and manually flip it whenever you enable/disable the enemy.

The problem is that it seems like the enemy exists while being inactive. The boolean thing can't work because I have no way to manually flip it when the enemy despawns automatically(when the enemy is out of pathnodes and the player is not looking at it)

(11-17-2017, 07:25 PM)Reminiscity Wrote:
(11-17-2017, 06:38 PM)Mudbill Wrote: GetEntityExists() might do what you need. If not, perhaps you can just create your own boolean and manually flip it whenever you enable/disable the enemy.

The problem is that it seems like the enemy exists while being inactive. The boolean thing can't work because I have no way to manually flip it when the enemy despawns automatically(when the enemy is out of pathnodes and the player is not looking at it)

GOTTEM!!

void checkExist(string &in asTimer){

if(GetEnemyStateName("enemy") != "Hunt" && GetEnemyStateName("enemy") != "Search" && GetEnemyStateName("enemy") != "Patrol"
&& GetEnemyStateName("enemy") != "Wait" && GetEnemyStateName("enemy") != "Alert" && GetEnemyStateName("enemy") != "Investigate"
&& GetEnemyStateName("enemy") != "Track" && GetEnemyStateName("enemy") != "BreakDoor"){

//Do stuff

}

AddTimer("timer_checkExist", 2, "checkExist");

}

My mod Amadeus
(This post was last modified: 11-17-2017, 07:45 PM by Reminiscity.)
11-17-2017, 07:25 PM
Find
Mudbill Offline
Muderator

Posts: 3,881
Threads: 59
Joined: Apr 2013
Reputation: 179
#4
RE: Callback when enemy changes to inactive

Clever! I would suggest making that into its own function alone, something like

PHP Code: (Select All)
bool GetEnemyActive(string &in asEnemyName) {
    if(
GetEnemyStateName(asEnemyName) != "Hunt" 
    
&& GetEnemyStateName(asEnemyName) != "Search" 
    
&& GetEnemyStateName(asEnemyName) != "Patrol"
    
&& GetEnemyStateName(asEnemyName) != "Wait" 
    
&& GetEnemyStateName(asEnemyName) != "Alert" 
    
&& GetEnemyStateName(asEnemyName) != "Investigate"
    
&& GetEnemyStateName(asEnemyName) != "Track" 
    
&& GetEnemyStateName(asEnemyName) != "BreakDoor")
        return 
true;
    return 
false;


Then you could just do

PHP Code: (Select All)
void doStuff(string &in asTimer) {
    if(
GetEnemyActive("enemy")) {
        
//do stuff
    
}


(This post was last modified: 11-17-2017, 09:05 PM by Mudbill.)
11-17-2017, 09:05 PM
Find
FlawlessHappiness Offline
Posting Freak

Posts: 3,980
Threads: 145
Joined: Mar 2012
Reputation: 171
#5
RE: Callback when enemy changes to inactive

Hey. Quick thought.

Instead of checking whether the state is not all of those values, why not just check for the default value when the enemy is inactive?
Presumably, the default value is the empty string: ""

Trying is the first step to success.
(This post was last modified: 11-18-2017, 12:14 AM by FlawlessHappiness.)
11-18-2017, 12:14 AM
Find
Romulator Offline
Not Tech Support ;-)

Posts: 3,628
Threads: 63
Joined: Jan 2013
Reputation: 195
#6
RE: Callback when enemy changes to inactive

(11-18-2017, 12:14 AM)FlawlessHappiness Wrote: Hey. Quick thought.

Instead of checking whether the state is not all of those values, why not just check for the default value when the enemy is inactive?
Presumably, the default value is the empty string: ""

The default value may actually be "idle", since if the enemy state is not anything else, it should instead become idle.

(I think. Don't have the Model Editor on me right now)

Another option is to use ReplaceEntity or something similar. Having two enemies, say suitor_1 and suitor_2. Suitor_1 is the main enemy, and when he is disabled, replace him with suitor_2, then use GetEntityExists on suitor_1.

Discord: Romulator#0001
[Image: 3f6f01a904.png]
(This post was last modified: 11-18-2017, 01:21 AM by Romulator.)
11-18-2017, 01:18 AM
Find
FlawlessHappiness Offline
Posting Freak

Posts: 3,980
Threads: 145
Joined: Mar 2012
Reputation: 171
#7
RE: Callback when enemy changes to inactive

Wouldn't "idle" also be a possible state if it was active? If so, it should currently be checked for as well in the GetEnemyActive method.

For your second thing, how would you know when Suitor_1 is disabled? Isn't that the problem?

Trying is the first step to success.
11-18-2017, 01:37 AM
Find
Romulator Offline
Not Tech Support ;-)

Posts: 3,628
Threads: 63
Joined: Jan 2013
Reputation: 195
#8
RE: Callback when enemy changes to inactive

(11-18-2017, 01:37 AM)FlawlessHappiness Wrote: For your second thing, how would you know when Suitor_1 is disabled? Isn't that the problem?

ReplaceEntity should remove one entity and replace with another, deleting the first, thus having GetEntityExists return false. should though, doesn't mean it will.

Thomas Grip, y u no release source code?

Discord: Romulator#0001
[Image: 3f6f01a904.png]
11-18-2017, 08:41 AM
Find




Users browsing this thread: 1 Guest(s)