Page 1 of 1

modified fedeai

Posted: Wed Feb 28, 2007 2:54 pm
by fps
This is a problem i am just getting back to from a long time ago.

This script fights correctly and attacks the standard player but untill you walk inside its field of vision is simply stands with its arms out. what do i need to do to fix this?

Code: Select all

{
    FIREAMMO [pistolbullet] // Projectile fired by pawn
    FIREEFFECT [RocketExplosion] // muzzleflash effect
    WEAPONMODEL [Smg] // Weapon held by pawn
    FIRERATE [0.2] // Weapon firing rate
    GROUP [foe] // Pawn Group - must be targetted by enemies
    ENEMYGROUP [friendly]
    PLAYERSPEED [100] // Walk Speed
    HEALTHATTRIB [health] // health attribute given to pawn
    HEALTHAMOUNT [200] // amount of health given to pawn
    DAMAGEATTRIB [health] // Attribute damaged by pawn
    BOX [24] // Box width
    FIREOFFSET [0]
    FOV [190]
    HEAR_RANGE [700]
    SIGHTDIST [1000]
	HOSTILEPLAYER 		[true]		// hostile to player
	HOSTILEDIFFERENT 	[true] 	// hostile to different Pawn group
	HOSTILESAME 		[false] 	// hostile to same Pawn group
K_FOR [15] //w 
K_BAK [27] //s 
K_LEFT [26] //a 
K_RIGHT [28] //d 
K_FIRE [72] //should be the left mouse button 
K_RUN [36] //left shift 
K_JUMP [46] //space
    HEADBONE [Bip01 Head]
  

    HEADSHOTSPRITE[bloodP]



    FLANK[pawn//elite//male//flank.wav]
    GO[pawn//elite//male//go.wav]
    CAUTION[pawn//elite//male//caution.wav]
    SHOOT[pawn//weapons//gr_mgun1.wav]
    RELOAD[pawn//weapons//gr_reload1.wav]
    HEADSHOT[pawn//takedamage//headshot.wav]
    FOUNDLOSTTARGET[pawn//elite//male//enemys.wav]
    TARGETAQUIRED []
    ALARMED []
    ALERTED []
    WHATWASTHAT []
    ENGUAGE []
    ALERT [pawn//elite//male//enemys.wav]
    PAIN1[pawn//takedamage//rgr_hit_1.wav]
    DEATH1[pawn//takedamage//Aah3.wav]
    WALK_IDLEANIM [guard_idle] // Idle 
    WALK_WALKANIM [patrol_street] // Walk anim
    WALK_BACKANIM [run_jog] // walk back anim
    WALK_STRAFELEFT [strafeL] // Strafe left anim
    WALK_STRAFERIGHT [strafeR] // Strafe right anim
    WALK_NE [patrol_street] // Walk anim
    WALK_SE [patrol_street] // walk back anim
    WALK_NW [patrol_street] // Strafe left anim
    WALK_SW [patrol_street]
    WALK_HOLD [combatidle1]
    WALK_MELEE [machete_attack]
    WALK_FIREAMMO [9mmauto] // Projectile fired by pawn
    WALK_FIREEFFECT [MuzzleFlash] // muzzleflash effect
    WALK_FIRERATE [0.5] // Weapon firing rate
    
    C_WALK_IDLEANIM [idle05] // Idle AnimationSpeed
    C_WALK_SHOOTANIM [run_jog] // Shoot anim
    C_WALK_WALKANIM [run_jog] // Walk anim
    C_WALK_BACKANIM [run_jog] // walk back anim
    C_WALK_STRAFELEFT [strafeL] // Strafe left anim
    C_WALK_STRAFERIGHT [strafeR] // Strafe right anim
    C_WALK_WALK_NE [strafeL] // Walk anim
    C_WALK_WALK_SE [strafeR] // walk back anim
    C_WALK_WALK_NW [strafeL] // Strafe left anim
    C_WALK_WALK_SW [strafeR] // Strafe right anim
    
    C_TO_WALK [crouch2stand]
    WALK_TO_C [idle01]
    
    PISTOL_WALK_IDLEANIM [combatidle1] // Idle AnimationSpeed
    PISTOL_WALK_WALKANIM [run_primary] // Walk anim
    PISTOL_WALK_BACKANIM [run_jog] // walk back anim
    PISTOL_WALK_STRAFELEFT [strafeL] // Strafe left anim
    PISTOL_WALK_STRAFERIGHT [strafeR] // Strafe right anim
    PISTOL_WALK_NE [run_primary] // Walk anim
    PISTOL_WALK_SE [run_jog] // walk back anim
    PISTOL_WALK_NW [run_primary] // Strafe left anim
    PISTOL_WALK_SW [run_jog]
    PISTOL_WALK_HOLD [combatidle2]
    PISTOL_WALK_RELOADANIM [crouch_mp5_reload]
    PISTOL_WALK_DRAW [startled_r]
    START [startled_r]
    PISTOL_WALK_UNDRAW [radio_nod]
    PISTOL_WALK_MELEE [matchete_attack]
    PISTOL_FIREAMMO [pistol_shell] // Projectile fired by pawn
    PISTOL_FIREEFFECT [MuzzleFlash] // muzzleflash effect
    PISTOL_FIRERATE [0.5] // Weapon firing rate
    
    C_PISTOL_WALK_IDLEANIM [run_panic] // Idle AnimationSpeed
    C_PISTOL_WALK_WALKANIM [run_primary] // Walk anim
    C_PISTOL_WALK_BACKANIM [run_jog] // walk back anim
    C_PISTOL_WALK_STRAFELEFT [strafeL] // Strafe left anim
    C_PISTOL_WALK_STRAFERIGHT [strafeR] // Strafe right anim
    C_PISTOL_WALK_NE [hunkered] // Walk anim
    C_PISTOL_WALK_SE [hunkered] // walk back anim
    C_PISTOL_WALK_NW [hunkered] // Strafe left anim
    C_PISTOL_WALK_SW [hunkered]
    C_PISTOL_WALK_HOLD [crouch_wait]
    C_PISTOL_WALK_RELOADANIM [crouch_mp5_reload]
    C_PISTOL_WALK_DRAW [crouchlazer1]
    C_PISTOL_WALK_UNDRAW [crouch_sweep]
    C_PISTOL_WALK_MELEE [frontkick]
    
    TURNL [180L]
    TURNR [180R]

    PISTOL_C_TO_WALK [idle2hunkered]
    PISTOL_WALK_TO_C [hunkered2idle]
    
    JUMPANIM_JUMP [Jump_Run]
    JUMPANIM_GLIDE [jump_glide]
    JUMPANIM_LAND [ceilingfall]
    
    INTERANIM [pushbutton] // Pawn interact anim
    DEATHANIM [death] // Death Anim
    ROOTBONE [Bip01] // Pawn root bone
    WEAPONHAND [Bip01 R Hand] // Pawn weapon bone
    
    ANIM [string] // Do Not Edit
    ANC [0] // Do Not Edit
    LASTANC [0] // Do Not Edit
    DIR [0] // Do Not Edit
    AT [0.5] // Do Not Edit
    INTER [string] // Do Not Edit
    TM [0] // Do Not Edit
    SPEED [0] //Do Not Edit
    TIME [0]
    RANDOMISER [0]
    SOUND_TIME [0]
    ANIM_TIME [0]
    ACTION_TIME [0]
    SEARCH_TIME [0]
    ATTACK_TIME [0]

    
    SEARCH_NUMBER [0]
    MAX_SEARCH_NUMBER [2] // how many time the pawn search the player
    BACK_TO_PATROL [3]
    
    MAG [300]
    BULLET [0]
    Reload [bool]
    Hold [bool]
    Melee[bool]
    Run [bool]
    Moving_Success [bool]
    FALLING_TIME [0]
    LAST_ORDER [string]
    NEXT_ORDER [string]
    ROTATION_ADD [0]
    FIRE_PAUSE [2]
    Patrol [bool]
    WAIT_TIME [0]
    Bot_State [string]
    PREVIOUS_YAW [0]
    
    ENEMYRANGE [1000]
    RANDOM_ATTACK [0]
    X_CAMERA[0]
    
Spawn[()
{
    HostilePlayer(HOSTILEPLAYER); // set who monster is hostile to
    HostileSame(HOSTILESAME);
    HostileDifferent(HOSTILEDIFFERENT);
    TargetGroup(ENEMYGROUP);
    SetFOV(FOV); // set field of view
    SetGroup(GROUP); // assign a group to belong to
    FindTargetOrder(SIGHTDIST,"PreAttack","Health"); // seen a target to chase;
    Console(true);
    BoxWidth(BOX);
    AttributeOrder(HEALTHATTRIB,HEALTHAMOUNT,"Die");
    LowLevel("Setup");
}]
    
Setup[()
{
    self.yaw_speed=270;
    AnimationSpeed(1.2);
    SetBoundingBox(WALK_IDLEANIM, BOX); 
    self.think="Think_START";
    NEXT_ORDER="Idle";
}]

Think_START[()
{
self.think="Idle";
HighLevel(Idle);
return 0;
}]

PreAttack[()
{
LowLevel("Attack");
}]

Attack[()
{
    
if(self.health < 1)
{
    
    AddExplosion("BloodP",GetLastBoneHit(),0,0,0);
    SetTargetPoint(random(500,1000),70,random(500,1000));
    FireProjectile("bloodbullet", "ValveBiped.Bip01_L_UpperArm",0,0,0,"none",0);
    SetTargetPoint(random(-1000,-500),-100000000,random(-500,-1000));
    FireProjectile("bloodbullet", "Bip01 R Foot",0,0,0,"none",0);
    SetTargetPoint(random(-1000,-200),-50,random(1000,200));
    FireProjectile("bloodbullet", "Bip01 R Arm",0,0,0,"none",0);
    PlaySound(DEATH1);        
    //SetEventState(EntityName # "_RagDollize_Me", true);
    //SetEventState("Show_RagDoll", true);
    self.think="Pain_Order";
}

    if(self.health < 150)
    {
        if(GetLastBoneHit() = "Bip01 Head")
            {
              PlaySound(HEADSHOT);
              AddExplosion("bloodP",GetLastBoneHit(),0,0,0);        
              SetEventState(EntityName # "_RagDollize_Me", true);
              SetEventState("Show_RagDoll", true);
              self.think="Pain_Order";
            }
    }
    SetRelBoneRotation(EntityName, "Bip01 Spine2",0,0,X_CAMERA);
    SetRelBoneRotation(EntityName, "Bip01 Spine1",0,0,X_CAMERA);

X_CAMERA = Integer((self.enemy_pitch / 0.017))/3;
  
    if(X_CAMERA > 30)
    {
        X_CAMERA = 30;
    }
    if(X_CAMERA < -5)
    {
        X_CAMERA = -5;
    }
    

	//if(self.in_pain)
	//{
            //PlaySound(PAIN1);   
            //UpdateEnemyVis();
            //RANDOM_ATTACK = 0;
		//}
        //if((GetDistanceTo("Player") < HEAR_RANGE))
            //{
	    //RANDOM_ATTACK = 0;
	    //}
if(self.in_pain) 
{ 
PlaySound("Pain1.wav"); 
UpdateEnemyVis(); 
RANDOM_ATTACK = 0; 
} 
if((IsKeyDown(K_FIRE))and(self.player_range   < HEAR_RANGE)) 
{ 
if((BULLET < 5) and (MAG >0) and (GetDistanceTo("Player") < HEAR_RANGE) and (GetEntityAlpha("SMG")=255)) 
{ 
RANDOM_ATTACK = 0; 
} 
} 
if(((IsKeyDown(K_FOR))or(IsKeyDown(K_BAK))or(IsKeyDown(K_LEFT))or(IsKeyDown(K_RIGHT))or(IsKeyDown(K_JUMP)))) 
{ 
if((self.player_range   < HEAR_RANGE/2) and (IsKeyDown(K_RUN))) 
{ 
UpdateEnemyVis(); 
RANDOM_ATTACK = 0; 
} 
if((self.player_range   < HEAR_RANGE/4) and (IsKeyDown(K_RUN)=false)) 
{ 
UpdateEnemyVis(); 
RANDOM_ATTACK = 0; 
} 
}
        

        debug(self.enemy_vis);


if((IsKeyDown(4)))
    {
        MAG = 2;
        RANDOM_ATTACK = 0;
    }
    
    
if((self.enemy_range < 200))
{
    
    if(RANDOM_ATTACK = 0)
    {
    ACTION_TIME= time;
    RANDOM_ATTACK = random(8,15);
    } 
}
if((self.enemy_range > 200))
{
    if(RANDOM_ATTACK = 0)
    {
    ACTION_TIME= time;
    RANDOM_ATTACK = random(1,15);
    }
}
if((self.enemy_vis) and (Reload=false))
{

    if(time > TIME + 0.2)
    {
       UpdateEnemyVis();
        debug("I have a visual of the target");
    }
self.ideal_yaw=self.last_enemy_yaw;   
        
            
            if((RANDOM_ATTACK >= 10))
            {
              if((BULLET < 5))
              {       
                if(time >ACTION_TIME + 1)
                {
                    RANDOM_ATTACK = 0;
                }
                if((self.time > TM+PISTOL_FIRERATE) )
                {
                    if(self.enemy_range < 60)
                    {
                    TM = time;
                    PlaySound("metal_reverse.wav");
                    Melee = true;
                    }
                    else
                    {
                    TM=self.time;
                    BULLET = BULLET + 1;
                    PlaySound(SHOOT);
                    FireProjectileBlind(PISTOL_FIREAMMO,WEAPONHAND,0,0,0,"health", enemy_pitch);
                    AddExplosion("MuzzleFlash","Bip01 R Hand",0,0,0);
                    FireProjectileBlind(PISTOL_FIREAMMO,WEAPONHAND,0,0,0,"health", enemy_pitch);
                    AddExplosion("MuzzleFlash","Bip01 R Hand",0,0,0);
                    FIREOFFSET = 20;            
                    }
                }
              }  
              else
              {
                if((MAG > = 1))
                    {
                    RANDOM_ATTACK = 0;
                    TM=self.time;
                    PlaySound(RELOAD);
                    Reload = true;
                }
                if((MAG <  1) and (time > TM + PISTOL_FIRERATE))
                {
                    RANDOM_ATTACK = 0;
                    if(self.enemy_range < 60)
                    {
                    TM = time;
                    PlaySound("metal_reverse.wav");
                    Melee = true;
                    }
                    else
                    {
                    RANDOM_ATTACK = 0;
                    TM=self.time;  
                    PlaySound("pistol_empty.wav");
                    }   
                }
              }
            }
            if((RANDOM_ATTACK >= 6) and (RANDOM_ATTACK < 10))
            {
            ANC=11; // different anc values needed to blend again
            AT=0.2;
            ;//ANIM=StringCopy(PISTOL_WALK_WALKANIM#"_Aim");
	    ANIM=StringCopy(PISTOL_WALK_WALKANIM);
            DIR=ConvertDegrees(0);
            TIME=self.time;
                if((time >ACTION_TIME + 1) or (Moving_Success=false) or (GetEventState(EntityName # "_trig")=true))
                {
                RANDOM_ATTACK = 0;
                }
            SPEED=Integer(PLAYERSPEED);
                ForceForward(1);
            }
            if((RANDOM_ATTACK > 3) and (RANDOM_ATTACK < 6))
            {
            ANC=13; // different anc values needed to blend again
            AT=0.2;
            ;//ANIM=StringCopy(PISTOL_WALK_STRAFELEFT#"_Aim");
	    ANIM=StringCopy(PISTOL_WALK_STRAFELEFT);
            DIR=ConvertDegrees(90);
            TIME=self.time;
                if((time >ACTION_TIME + 1) or (Moving_Success=false) or (GetEventState(EntityName # "_trig")=true))
                {
                RANDOM_ATTACK = 0;
                }
            SPEED=Integer(PLAYERSPEED);
                ForceForward(1);
            }
            if((RANDOM_ATTACK > 0) and (RANDOM_ATTACK <= 3))
            {
            ANC=14; // different anc values needed to blend again
            AT=0.2;
            ;//ANIM=StringCopy(PISTOL_WALK_STRAFERIGHT#"_Aim");
            ANIM=StringCopy(PISTOL_WALK_STRAFERIGHT);
            DIR=ConvertDegrees(-90);
            TIME=self.time;
                if((time >ACTION_TIME + 1) or (Moving_Success=false) or (GetEventState(EntityName # "_trig")=true))
                {
                RANDOM_ATTACK = 0;
                }
            SPEED=Integer(PLAYERSPEED);    
                ForceForward(1);
            }
SEARCH_TIME = RANDOM_ATTACK;
}
     
if(Melee = true)
    {
        SPEED=0;
        TIME = time-0.3;
        ANC = 87;
        AT = 0.2;
        ANIM=StringCopy(WALK_MELEE);
        //AddExplosion("PMuzzleFlash","Bip01 R Hand",0,0,0);
        //DamageAtBone(10, 50, "enemy_health", "Bip01 R Hand" );
        if(time>TM+0.5) // weapon need some latency over the animation
        {
        SetEventState(EntityName # "_Melee_Exp", true);
        }
        if(self.animate_at_end)
        {
        Melee=false;
        }
        TM=time+0.3;
    }
    else
    {
        SetEventState(EntityName # "_Melee_Exp", false);
    }       
        


if(self.enemy_vis = false)
{
    //self.ideal_yaw=GetYawToPoint();
    
    if(time < ACTION_TIME + (SEARCH_TIME/4))
    {
        debug("F1");
        if(SEARCH_NUMBER = 1)
        {
            SEARCH_NUMBER = 2;
        }
        TIME=time;
        if(Moving_Success)
        {
        self.ideal_yaw= self.last_enemy_yaw;
        }
        else
        {
            //SEARCH_TIME = SEARCH_TIME * 0.9;
            self.ideal_yaw = GetYawToPoint();
        }
        DIR=0;
        SPEED = Integer(PLAYERSPEED);
        ANIM=StringCopy(PISTOL_WALK_WALKANIM);
        ForceForward(1);
        AT=0.3;
        ANC=645;
    }
    if((time > ACTION_TIME + (SEARCH_TIME/4)) and (time < ACTION_TIME + ((SEARCH_TIME/4)*2)))
    {
        debug("F2");
        TIME=time;
        DIR=0;
        SPEED =0;
        ANIM=StringCopy(PISTOL_WALK_HOLD);
        AT=0.3;
        ANC=905;
        
    }
    if((time > ACTION_TIME + ((SEARCH_TIME/4)*2)) and (time < ACTION_TIME + ((SEARCH_TIME/4)*3)))
    {
        debug("F3a");
        TIME=time;
            
        ChangeYaw();
        //SPEED = Integer(PLAYERSPEED / 2); EDITED
        SPEED = Integer(PLAYERSPEED / 2);
        if(Moving_Success = false)
        {
        self.ideal_yaw = self.last_enemy_yaw + ConvertDegrees(70);
        ANIM=StringCopy(PISTOL_WALK_SW);
        ANC=83;
        DIR = ConvertDegrees(90);
        }
        else
        {
        self.ideal_yaw = self.last_enemy_yaw - ConvertDegrees(70);
        ANIM=StringCopy(PISTOL_WALK_SE);
        ANC=81;
        DIR = ConvertDegrees(-90);
        }    
        AT=0.2;
 
            
        if(Integer(self.current_yaw/0.017) = Integer(self.ideal_yaw/0.017)) 
        { 
        debug("F3b");
        TIME=time;                
        DIR=0;
        SPEED =0;
        ANIM=StringCopy(PISTOL_WALK_HOLD);
        AT=0.3;
        ANC=655;
        }
    }
    if((time > ACTION_TIME + ((SEARCH_TIME/4)*3)) and (time < ACTION_TIME + ((SEARCH_TIME))))
    {
        debug("F4a");
        if(SEARCH_NUMBER = 0)
        {
            SEARCH_NUMBER = 1;
            PlaySound(GO);
        }
            TIME=time;
            ChangeYaw();
            SPEED = Integer(PLAYERSPEED / 2);
            if(Moving_Success = false)
            {
                self.ideal_yaw = self.last_enemy_yaw - ConvertDegrees(70);
            ANIM=StringCopy(PISTOL_WALK_SW);
            ANC=83;
            DIR = ConvertDegrees(90);
            }
            else
            {
                self.ideal_yaw = self.last_enemy_yaw + ConvertDegrees(70);
            ANIM=StringCopy(PISTOL_WALK_SE);
            ANC=81;
            DIR = ConvertDegrees(-90);
            }    
            AT=0.2; 
            
            if(Integer(self.current_yaw/0.017) = Integer(self.ideal_yaw/0.017))
            {   
                debug("F4b holding");
            TIME=time;                
            DIR=0;
            SPEED =0;
            ANIM=StringCopy(PISTOL_WALK_HOLD);
            AT=0.3;
            ANC=65;
            }
    }
    if(time > ACTION_TIME + ((SEARCH_TIME)))
    {
    debug("F5");
        
        if(SEARCH_NUMBER < MAX_SEARCH_NUMBER)
        {
        PlaySound(CAUTION);
        SEARCH_TIME = time;
        RANDOM_ATTACK = 0; // this resets the self.enemy_vis sequence
        }
        
        if(((self.point_vis = false) or (Moving_Success = false)) and (time > TIME +5)) 
        {
        NEXT_ORDER=self.order_name;
        HighLevel("Lost_Target");
        return 0;
        }     
        if(self.point_vis)
        {
            
            TIME = time;
            DIR=0;
            SPEED = Integer(PLAYERSPEED);
            ANIM=StringCopy(PISTOL_WALK_WALKANIM);
            AT=0.3;
            ANC=5;
        }    
    }
}

    if((GetDistanceTo("Player")> HEAR_RANGE*1.5))
        {
            AnimateBlend(PISTOL_WALK_UNDRAW, 0.1);
            ANIM=StringCopy(WALK_IDLEANIM);
            NEXT_ORDER="Walk_NOWEAPON";
            self.think="UnDraw_A_Weapon"; 
        }
        
        
if(FastPointCheck(40))
            {
            NextPoint();
            }
            
if(FIREOFFSET >0)
    {
        FIREOFFSET = FIREOFFSET -2;
    }    
    SetRelBoneRotation(EntityName, "Bip01 R Arm1",FIREOFFSET/6,0,-FIREOFFSET/7);
    SetRelBoneRotation(EntityName, "Bip01 L Arm1",FIREOFFSET/3,0,-FIREOFFSET);
    // EDIT
  
if((Reload = true))
    {
        //back
        TIME=time;
        ANIM=StringCopy(PISTOL_WALK_RELOADANIM);
        ANC=5;
        AT=0.2;
        SPEED=0;
        if((self.animate_at_end))//and(time > TM))
        {
            Reload = false;
            BULLET = 0;
            ANC=0;
            if(MAG > 0)
            {
            MAG = MAG -1;
            }
        }
    }

    if(SPEED != 0)
    {
        if(time > SOUND_TIME + 0.35)
        {
	    ;// footstep sound
            SOUND_TIME = time;
            PlaySound("pawn\\step\\run.wav");
        }
        ChangeYaw();
    }

if((time > TIME +0.4))
{
    DIR=0; // Default straight
    //SPEED=0; //Default - no motion
    AT=0.2; //Default
    ANC=0; //Default
}

if((ANC < 1))
    {
        //no button
        AT=0.3;
        SPEED = 0;
        ANIM=StringCopy(PISTOL_WALK_IDLEANIM);
    }
    
    //handle animations
if(Integer(LASTANC) != Integer(ANC))
    {
        AnimateBlend(ANIM,AT);
    }
    LASTANC=Integer(ANC);
if(self.animate_at_end) 
    {
        AnimateHold(ANIM);
    }
    //handle motions
    Moving_Success = walkmove(self.current_yaw+DIR, SPEED);
    
    //handle health status
    
    if(self.IsFalling)
    {
        FALLING_TIME = time;
        if/*(FALLING_TIME > 1)*/(GetCollideDistance("Bip01 R Foot", 0,-50,0 ) = -1)
        {
            AnimateBlend(JUMPANIM_GLIDE, 0.7);
            TIME= time;
            LAST_ORDER = self.order_name;
            self.think= "Jump";
        }
    }
    
    debug(GetLastBoneHit());
}]

// idle in place waiting for something to happen
Idle[ ()
{
    self.think="Walk_NOWEAPON";
    PlayAnimation(STAND, true, "");
    if(random(1,10)>6)
    {
	if(random(1,10)>5)
	{
		Rotate(TURNL, 102, 0, 90, 0, "");
		PlayAnimation(WALK_IDLEANIM, true, "");
		Rotate(TURNR, 108, 0, -90, 0, "");
	}
	else
	{
		Rotate(TURNR, 108, 0, -90, 0, "");
		PlayAnimation(WALK_IDLEANIM, true, "");
		Rotate(TURNL, 102, 0, 90, 0, "");
	}
    }
    RestartOrder();
} ]


Walk_NOWEAPON[()
{ 
    self.think="Idle";
    if(IsKeyDown(3))
    {
    HighLevel("Die");
    return 0;        
    }
if(self.health < 1)
{
    
            AddExplosion("BloodExplosion",GetLastBoneHit(),0,0,0);
            SetTargetPoint(random(500,1000),70,random(500,1000));
            FireProjectile("bloodbullet",GetLastBoneHit(),0,0,0,"none",0);
            SetTargetPoint(random(-1000,-500),-100000000,random(-500,-1000));
            FireProjectile("bloodbullet",GetLastBoneHit(),0,0,0,"none",0);
            SetTargetPoint(random(-1000,-200),-50,random(1000,200));
            FireProjectile("bloodbullet",GetLastBoneHit(),0,0,0,"none",0);
    PlaySound(DEATH1);        
    SetEventState(EntityName # "_RagDollize_Me", true);
    SetEventState("Show_RagDoll", true);
    self.think="Pain_Order";
}

if(GetLastBoneHit() = HEADBONE)
  {
      HighLevel("Die");
      return 0;
  }
  
debug(self.enemy_vis);

    if((self.enemy_vis) and (self.enemy_range < ENEMYRANGE))
	{
            PlaySound(ALERT); 
            TM = time;
            AnimateBlend(PISTOL_WALK_DRAW, 0.1);
            ANIM=StringCopy(PISTOL_WALK_IDLEANIM);
            NEXT_ORDER="Attack";
            self.think="Draw_A_Weapon";
        }  

    if(IsKeyDown(K_FIRE))
	{
            if((BULLET < 5) and (MAG >0) and (GetDistanceTo("Player") < HEAR_RANGE)) //and (GetEntityAlpha("SMG")=255)
		{
                    PlaySound(ALERT); 
		TM = time;
            AnimateBlend(PISTOL_WALK_DRAW, 0.1);
            ANIM=StringCopy(PISTOL_WALK_IDLEANIM);
            NEXT_ORDER="Attack";
            self.think="Draw_A_Weapon";
		//}
	}
    if(self.in_pain)
    {
        PlaySound(ALERT); 
        UpdateEnemyVis();
        TM = time;
            AnimateBlend(PISTOL_WALK_DRAW, 0.1);
            ANIM=StringCopy(PISTOL_WALK_IDLEANIM);
            NEXT_ORDER="Attack";
            self.think="Draw_A_Weapon";
    }
    
    if(((IsKeyDown(K_FOR))or(IsKeyDown(K_BAK))or(IsKeyDown(K_LEFT))or(IsKeyDown(K_RIGHT))or(IsKeyDown(K_JUMP)))) // and (LeftCopy(CAMERA.order_name, 6) != "Crouch")
        {
            
            if((GetDistanceTo("Player") < HEAR_RANGE/2) and (IsKeyDown(K_RUN)))
            {
                PlaySound(ALERT); 
                UpdateEnemyVis();
                TM = time;
            AnimateBlend(PISTOL_WALK_DRAW, 0.1);
            ANIM=StringCopy(PISTOL_WALK_IDLEANIM);
            NEXT_ORDER="Attack";
            self.think="Draw_A_Weapon";
            }
            if((GetDistanceTo("Player") < HEAR_RANGE/4) and (IsKeyDown(K_RUN)=false))
            {
                PlaySound(ALERT); 
                UpdateEnemyVis();
                TM = time;
            AnimateBlend(PISTOL_WALK_DRAW, 0.1);
            ANIM=StringCopy(PISTOL_WALK_IDLEANIM);
            NEXT_ORDER="Attack";
            self.think="Draw_A_Weapon";
            }
        }
    
    
if(LeftCopy(point_name,1) = "P")
{
    if(WAIT_TIME = 0)
    {
        WAIT_TIME = random (2,5); // random is executed one time only 
    }
    TIME = time;
    Bot_State = "Walk";
}

if(LeftCopy(point_name,1) = "B")
{
    WAIT_TIME = 12;
    // stay a while in the walking direction
    if(time < TIME+ (WAIT_TIME/3)) 
    {
    PREVIOUS_YAW = Integer(self.current_yaw/0.017);
    Bot_State = "Stand";
    }
    // then look behind and stand
    if((time > (TIME+ WAIT_TIME/3)) and (time < (TIME+ (WAIT_TIME/3)*2)))
        {
            Bot_State = "LookBehind";
            self.ideal_yaw = ConvertDegrees(PREVIOUS_YAW - 180);
            ChangeYaw();
            ANIM=StringCopy(WALK_SE);
            ANC=8;
            AT=0.2; 
            
            if(Integer(self.current_yaw/0.017) = Integer(self.ideal_yaw/0.017))
            {            
            Bot_State = "Stand";
            SPEED = 0; 
            }
        }
    //then forward again
    if((time > (TIME+ (WAIT_TIME/3)*2)) and (time < (TIME+ WAIT_TIME)))
        {
        Bot_State = "LookBehind";
            self.ideal_yaw = ConvertDegrees(PREVIOUS_YAW);
            ChangeYaw();
            ANIM=StringCopy(WALK_SW);
            ANC=8;
            AT=0.2; 
            
            if(Integer(self.current_yaw/0.017) = Integer(self.ideal_yaw/0.017))
            {            
            Bot_State = "Stand";
            SPEED = 0; 
            }
        } 
    // time is over
    if(time > (TIME+ WAIT_TIME))
        {
            Bot_State = "Walk";
            WAIT_TIME = 0;
        }
}

if(LeftCopy(point_name,1) = "I")
{
    if(time < TIME+ WAIT_TIME)
    {
    Bot_State = "Stand";
    }
    else
    {
        Bot_State = "Walk";
        WAIT_TIME = 0; 
    }    
}

debug(ANC);
    if(Bot_State = "Walk")
    {
        DIR=0;
        SPEED = Integer(PLAYERSPEED);
        ANIM=StringCopy(WALK_WALKANIM);
        AT=0.3;
        ANC=5;
    }
    
    if((Bot_State = "Stand"))
    {
        SPEED = 0;
        ANIM=StringCopy(WALK_HOLD);
        ANC=0;
        AT=0.2;
    }

    debug(Bot_State);
    debug(ANIM);
    
    DIR=0; // Default straight
    AT=0.2; //Default
    //ANC=0; //Default
        
    if(ANC < 1)
    {
         //no button
         ANIM=StringCopy(WALK_IDLEANIM);
         AT=0.2;
    }
    //handle animations
    if(Integer(LASTANC) != Integer(ANC))
    {
        AnimateBlend(ANIM,AT);
    }
    LASTANC=Integer(ANC);
    if(self.animate_at_end)
    {
        AnimateHold(ANIM);
    }

    //handle motions
    //AutoWalk(self.current_yaw+DIR, SPEED, 30);
    Moving_Success = walkmove(self.ideal_yaw, SPEED);
        
    if(Bot_State != "LookBehind")
    {
        if(Moving_Success)
        {
        self.ideal_yaw= GetYawToPoint();
        SEARCH_TIME = time;
        }
        else
        {
            //SEARCH_TIME = SEARCH_TIME * 0.9;
            if(self.last_enemy_yaw!=0)
            {
            self.ideal_yaw = self.last_enemy_yaw;
            }
            else
            {
                ForceBackward(30);
            }
            if(time > SEARCH_TIME + 5)
            {
                HighLevel("Find_a_Point");
                return 0;
            }
        }
    }
    
    if(SPEED != 0)
    {
        if(time > SOUND_TIME + 0.35)
        {
            SOUND_TIME = time;
            PlaySound("footstep.wav",100);
        }
       ChangeYaw(); 
    }
    
    if(FastPointCheck(40))
    {
        NextPoint();
    }


if(self.IsFalling)
    {
        FALLING_TIME = time;
        if(GetCollideDistance("Bip01 R Foot", 0,-50,0 ) = -1)
        {
            AnimateBlend(JUMPANIM_GLIDE, 0.3);
            TIME= time;
            LAST_ORDER = self.order_name;
            self.think= "Jump";
        }
    }
    
}]
    
Jump[()
{
    debug("fall "# GetCollideDistance("Bip01 R Foot", 0,-50,0 ));
    debug("fall "# self.IsFalling);
    walkmove(self.current_yaw+DIR,SPEED);
    
    self.ideal_yaw = self.camera_yaw;
    ChangeYaw();
    
    if((self.IsFalling = false) or(IsKeyDown(9)))
    {
        AnimateBlend(JUMPANIM_LAND,0.1);
        SPEED = 0;
        self.think="AfterJump";
    }
    
}]

AfterJump[()
{
    if((self.animate_at_end))
    {
        ANC=0;
        AnimateBlend(ANIM, 0.1);
        self.think=LAST_ORDER;
    }
}]

Draw_A_Weapon[()
{
    debug(NEXT_ORDER);
    if((self.animate_at_end))
    {
        ANC=0;
        LASTANC=0;
        TM=time;
        //TIME=time+0.4;
        //self.think=NEXT_ORDER;
        //AnimateBlend(ANIM, 0.2);
        self.think="Step_Ahead";
        return 0;
    }
}]


Step_Ahead[()
{
    if((self.animate_at_end))
    //if(time > TIME +0.4)
    {
        ANC=0;
        TM=time;
        self.think=NEXT_ORDER;

        //HighLevel("Find_a_Point");
        return 0;
    }
}]


UnDraw_A_Weapon[()
{
    debug(NEXT_ORDER);
    if((self.animate_at_end))
    {
        ANC=0;
        LASTANC=0;
        TM=time;
        //TIME=time+0.4;
        //self.think=NEXT_ORDER;
        //AnimateBlend(ANIM, 0.2);
        self.think="Step_Ahead";
        return 0;
    }
}]
Step_Behind[()
{
    if((self.animate_at_end))
    //if(time > TIME +0.4)
    {
        ANC=0;
        TM=time;
        //self.think=NEXT_ORDER;

        HighLevel("Find_a_Point");
        return 0;
    }
}]
Find_a_Point[()
{ 
Delay(WALK_HOLD, 3, "" );
FindPointOrder("FoundPoint");
FindTargetOrder(SIGHTDIST, "Back_To_The_Battle", "health");
}]

FoundPoint[()
{
    RotateToPoint(WALK_NE, 180, false, "pawn/step/walk.wav" );
    LowLevel("Walk_NOWEAPON");
    return 0;
}]

Lost_Target[()
{ 
Delay(PISTOL_WALK_HOLD, 3, "" );
FindPointOrder("Back_To_The_Root");
FindTargetOrder(SIGHTDIST,"Back_To_The_Battle","health");
}]

Back_To_The_Root[()
{
    Animate(START);
    RotateToPoint(PISTOL_WALK_NE, 180, false, "pawn/step/walk.wav" );
    LowLevel("Attack");
    return 0;
}]

Back_To_The_Battle[()
{
    LowLevel("Attack");
    return 0;
}]

Die[()
{
LowLevel("Pain_Order");
    return 0;
}]

Pain_Order[()
{
    AnimateHold(DEATHANIM#"1");
        return 0;

    //PawnRender(false);
    //SetEventState(EntityName # "_Show_RagDoll", true);
    //SetEventState(EntityName # "_RagDollize_Me", false);
    //if(IsKeyDown(9))
    //{
        //SetEventState(EntityName # "_Show_RagDoll", false);
        //PawnRender(true);
        //self.think ="Attack";
    //}
}] 

}
thanks,
fps

Posted: Thu Mar 01, 2007 1:39 am
by shadow
Just quickly looking at your script (time is tight for me)
You seem to be mixing High Level and Low Level commands.

Is this your script, or one you've tried to modify?

Anyways -

Think_START[()
{
self.think="Idle"; <--- this is low level, and not needed here because ...
HighLevel(Idle); <--- this takes you to your high level script
return 0;
}]

... and in your Idle()

Idle[ ()
{
self.think="Walk_NOWEAPON"; <---- this is a Low Level Command(remove this and he should idle in place)
PlayAnimation(STAND, true, "");
if(random(1,10)>6)
...

hope this gets you started

Posted: Fri Mar 02, 2007 4:53 pm
by fps
I will try it when i get back to my home computer.
Yes it is a modified script from the ragdoll phyiscs demo, I'm trying to make it so the pawn can target whatever i want it to with ease.

Thanks for the help,
Fps

Posted: Mon Mar 19, 2007 4:58 pm
by fps
I finally tryed what you posted but it is still freezing and debuging to the console that it is at the thinkstart still and not continuing to the idle order.

I forced it to jump to the idle order by bypassing the think start order and i stays with the default anim and dosent see any enemies at all. I may have forced it to go to idle in low level when i tried this though.

If i get this thing to stay in high level idle will it still check for path points?


If you have any frurther ideas on how i could fix this please help.
thanks,
fps

Posted: Mon Mar 19, 2007 11:21 pm
by shadow
I'm not sure what you changed, but from the above script, in Setup(), change self.think = "Think_START"; to HighLevel(Idle);

Not sure what your trying to do with Think_START() but this should work.

edit- also get rid of the space after the [ in Idle
so it should be Idle[() and not Idle[ ()
and at the end of that order it should be }]

hope it helps