Game Development Community

getState not working?

by Larry Dolyniuk · in Technical Issues · 04/17/2010 (6:38 pm) · 1 replies

I have a timer called every 500ms from what I understand, and it does a loop of a function checking if the player is dead, if he is not dead the npc continues to fire. For some reason it is not working, any ideas?

Here are my functions:
function serverCmdKillPlayer(%client, %obj)
{
%player = %client.player;
%obj.KillPlayer(%player);
}
function KillP(%obj)
{
  commandToServer('KillPlayer', %obj);
}
 function AIPlayer::KillPlayer(%this, %obj)
 {
%npc = %this.getName();
%target = %obj.getName();

if(%npc !$= %target)
{
    echo(%obj.getState());
    if(%obj.getState() $= "Move")
    {
%this.schedule(500, KillP, %obj);   
%this.setAimObject(%obj, "0 0 1");
%this.setImageTrigger(0,true); 
 }  
 else
 {

%this.setImageTrigger(0,false);    
    }   
    }
}

#1
04/17/2010 (7:15 pm)
I found out my problem was not getState() but was my schedule, I had the wrong arg format, here's the fix, cheers ;)

function AIPlayer::KillPlayer(%this, %obj)//obj = client
 {
%npc = %this.getName();
%target = %obj.getName();

if(%target !$= %npc)
{ 
%this.setImageTrigger(0,false); 
    if(%obj.getState() !$= "Dead")
    {
 schedule(500, 0, "tickKill", %this, %obj);   
%this.setAimObject(%obj, "0 0 1");
%this.setImageTrigger(0,true);  
 }  
 else
 {
%this.setImageTrigger(0,false); 
    }   
    }
}
function tickKill(%npc, %target)
{
%npc.KillPlayer(%target);
}