Page 1 of 1

help with genericmonster.

Posted: Fri Apr 06, 2007 5:30 pm
by dodger
Hi Everyone,

I need some help ...
I am useing a genericmonster script for my enemy pawn
the problem is i can only kill it with weapons 2 and 3 on the keyboard
all other weapons seem to have no effect ...
i think i need to set up one of ini files but am unsure what to do.

will anyone help ...?
Thank you.

here is the script just in-case.




{

// Generic Monster

SCALE [1] // scale of actor
GROUP [soldier] // name of monster group
BOXWIDTH [40] // width and depth of bounding box
HOSTILEPLAYER [true] // hostile to player
HOSTILEDIFFERENT [false] // hostile to different Pawn group
HOSTILESAME [false] // hostile to same Pawn group
HEALTHATTRIBUTE [health] // name of health attribute
HEALTH [50] // initial amount of health
SIGHTDIST [500] // max distance monster can see at idle
ALERTSIGHTDIST [300] // max distance monster can see when alert
FOV [360] // field of view in degrees
YAWSPEED [120] // speed of rotation in deg/sec
DAMAGEATTRIBUTE [health] // attribute damaged by attack
ALERTTRIGGER [AlertG] // name of alert trigger
// define the type of monster this will be

ATTACKTYPE [missile] // type of attack - melee or missile
PATROL [false] // false - ambush or true - patrol

// idling and turning

STAND [Idle] // idle animation
TURNL [Walk] // turn left animation
TURNR [Walk] // turn right animation

// when in pain

PAIN [Hit] // pain animations
PAIN1 [Hit]
PAIN2 [Hit]
PAIN3 [Hit]
PAINPERCENT [50] // percentage of time pain is shown
PAINSOUND [] // sounds played when in pain
PAINSOUND1 []
PAINSOUND2 []
PAINSOUND3 []

// when dying

DIE [Die] // dying animations
DIE1 [Die_rodilla]
DIE2 [Die_de_frente]
DIE3 [Die_hacia_atras]
DIEHOLD [15] // time corpse still appears
DIEFADE [10] // fadeout time of corpse
DIESOUND [] // sounds played when dying
DIESOUND1 []
DIESOUND2 []
DIESOUND3 []

// when running to attack

RUN [Run] // running animation
RUNSPEED [100] // average run speed
RUNSOUNDDELAY [2] // delay between making sounds when running to attack
RUNSOUND [] // sound played while running to attack

// when walking while patroling

WALK [Run] // walking animation
WALKSPEED [100] // average walking speed

// the projectile attack mode

MISSILEATTACK [Shoot] // missile attacking animation
MISSILEATTACK1 [Shoot]
MISSILEATTACK2 [Shoot]
FIREDELAY [0.8] // delay after animation starts before projectile launch
FIREDELAY1 [0.8]
FIREDELAY2 [0.8]
MISSILESOUND [] // sounds played when shooting
MISSILESOUND1 []
MISSILESOUND2 []
MISSILERANGE [300] // max distance to start missile attack
PROJECTILE [pistol_shell] // projectile name
FIREBONE [Bip01 R Hand] // projectile launch bone
OFFSETX [0] // launch offsets
OFFSETY [0]
OFFSETZ [25]
ATTACKDELAY [2] // time between shots
SKILL [5] // skill level 1 to 10

// the melee attack mode

MELEEATTACK [Idle] // melee attacking animations
MELEEATTACK1 [Idle]
MELEEATTACK2 [Idle]
MELEESOUND [] // sounds played when melee attacking
MELEESOUND1 []
MELEESOUND2 []
MELEERANGE [90] // max distance to start melee attack
MINMELEEDAMAGE [10] // minimum amount of damage per melee attack
MAXMELEEDAMAGE [10] // maximum amount of damage per melee attack
MELEEDELAY [2] // number of seconds between melee damages
MELEEDAMAGESOUND [] // sound played when damage is done

// search for enemy

LOSTTIME [15] // time to search for enemy before giving up
POINTRADIUS [20] // radius from point when considered there

// obstacle avoidance forces for jumping

FORCEUP [30] // obstacle avoidance jump speed
FORCEFORWARD [30] // obstacle avoidance forward speed
FORCESIDE [30] // obstacle avoidance sideways speed

// local variables - do not change


RUNFUNC [monster_run_start] // monster run to attack function
MISSILEFUNC [monster_missile_start] // monster missile function
MELEEFUNC [monster_melee_start] // monster melee function
LOSTFUNC [monster_lost_target_start] // monster lost target function

AS_NONE [0]
AS_MELEE [1]
AS_MISSILE [2]
AS_STRAIGHT [3]
attack_delay [0]
melee_time [0]
lost_time [0]
back_up [false]
back_time [0]
left_time [0]
back_flag [false]
fire_delay [0]
skill_time [0]
attack_state [0]
run_sound_time [0]
missile_sound [NULL]

// spawn pawn and do setup work

Spawn[ ()
{
Console(true);
Scale(SCALE); // scale the actor
if(BOXWIDTH > 0)
{
BoxWidth(BOXWIDTH*SCALE); // set bounding box width/depth
}
AttributeOrder(HEALTHATTRIBUTE, HEALTH, "Death"); // give monster health
HostilePlayer(HOSTILEPLAYER); // set who monster is hostile to
HostileSame(HOSTILESAME);
HostileDifferent(HOSTILEDIFFERENT);
SetFOV(FOV); // set field of view
SetGroup(GROUP); // assign a group to belong to
FindTargetOrder(SIGHTDIST, "FoundTarget", DAMAGEATTRIBUTE); // seen a target to chase
AddPainOrder("IdlePain", 100); // show pain and trigger alert
AvoidOrder("Avoidance");
AddTriggerOrder("IdleToAlert", ALERTTRIGGER, 0); // go to alert when triggered
AddTriggerOrder("GoLowCheck", INTERACTTRIGGER, 0); // go to interactmode when triggered
RotateToPoint(STAND, YAWSPEED, false, ""); // go to point if any specified
MoveToPoint(WALK, WALKSPEED*SCALE, "");
if(PATROL = false)
{
NewOrder("Idle");
}
else
{
NewOrder("Patrol");
}
} ]

// avoid objects when doing a MoveToPoint

Avoidance[ ()
{
if(random(1,10)<3) // backup and move sideways sometimes
{
MoveBackward(WALK, WALKSPEED*SCALE, (WALKSPEED/2)*SCALE, "");
MoveRight(WALK, WALKSPEED*SCALE, (WALKSPEED/2)*SCALE, "");
}
else
{
Jump(RUN, FORCEUP*SCALE, true, "");
if(random(1,10)<6)
{
Move("", FORCEFORWARD*SCALE, (FORCEFORWARD/2)*SCALE, 0, 90, 0, "");
}
else
{
Move("", FORCEFORWARD*SCALE, (FORCEFORWARD/2)*SCALE, 0, -90, 0, "");
}
}
Return();
} ]

// idle in place waiting for something to happen

Idle[ ()
{
// need to monitor if the player is within distance and if so, detect the usekey being pressed
PlayAnimation(STAND, true, "");
PlayerDistOrder(BOXSIZE,"GoLowCheck");

if(random(1,10)>6)
{
if(random(1,10)>5)
{
Rotate(TURNL, 102, 0, 90, 0, "");
PlayAnimation(STAND, true, "");
Rotate(TURNR, 108, 0, -90, 0, "");
}
else
{
Rotate(TURNR, 108, 0, -90, 0, "");
PlayAnimation(STAND, true, "");
Rotate(TURNL, 102, 0, 90, 0, "");
}
}
RestartOrder();
} ]

GoLowCheck[()
{
// Switch to low level
LowLevel("CheckIn");
}]

CheckIn[()
{
// Check if keynumber 22 is pressed. Key 22 is, O
if(self.key_pressed=22)
{
// OK, key is pressed. get in
self.think="GetIn";
return 0;
}
if(self.player_range>BOXSIZE)
{
// Player no longer near pawn. Go to High Level Idle.
HighLevel("Idle");
return 0;
}
}]

GetIn[()
{
// Set Think Time to run every frame.
self.ThinkTime=0;
//SetEventState(DRIVINGTRIG,true);
self.think="InteractPlayer";
}]
// walk the beat from point to point

Patrol[ ()
{
NextPoint();
RotateMoveToPoint(WALK, YAWSPEED, WALKSPEED*SCALE, false, "");
MoveToPoint(WALK, WALKSPEED*SCALE, "");
RestartOrder();
} ]

// show pain at idle then trigger to alert

IdlePain[ ()
{
switch(random(1,4)) // chose between 4 animations
{
case 1
{
PlayAnimation(PAIN, true, PAINSOUND);
}
case 2
{
PlayAnimation(PAIN1, true, PAINSOUND1);
}
case 3
{
PlayAnimation(PAIN2, true, PAINSOUND2);
}
case 4
{
PlayAnimation(PAIN3, true, "PAINSOUND3");
}
}
SetEventState(ALERTTRIGGER, true); // set trigger to go to alert
Return();
} ]

// start shifting from idle to alert

IdleToAlert[ ()
{
FindTargetOrder(ALERTSIGHTDIST, "FoundTarget", DAMAGEATTRIBUTE); // increase viewing distance
AddPainOrder("AlertPain", PAINPERCENT); // show pain
AddTimerOrder(1, 10, "AlertToIdle"); // go to idle after 10 secs
SetEventState(ALERTTRIGGER, false); // turn off alert trigger
NewOrder("Alert");
} ]

// look around at alert looking for enemy

Alert[ ()
{
if(random(1,10)>5)
{
Rotate(TURNL, 102, 0, 90, 0, "");
Rotate(TURNL, 102, 0, 90, 0, "");
Rotate(TURNL, 102, 0, 90, 0, "");
Rotate(TURNL, 102, 0, 90, 0, "");
}
else
{
Rotate(TURNR, 108, 0, -90, 0, "");
Rotate(TURNR, 108, 0, -90, 0, "");
Rotate(TURNR, 108, 0, -90, 0, "");
Rotate(TURNR, 108, 0, -90, 0, "");
}
RestartOrder();
} ]

// show pain at alert

AlertPain[ ()
{
switch(random(1,4)) // play one of 4 animations
{
case 1
{
PlayAnimation(PAIN, true, PAINSOUND);
}
case 2
{
PlayAnimation(PAIN1, true, PAINSOUND1);
}
case 3
{
PlayAnimation(PAIN2, true, PAINSOUND2);
}
case 4
{
PlayAnimation(PAIN3, true, PAINSOUND3);
}
}
Return();
} ]

// timed out at alert

AlertToIdle[ ()
{
FindTargetOrder(SIGHTDIST, "FoundTarget", DAMAGEATTRIBUTE); // decrease viewing distance
AddTriggerOrder("IdleToAlert", ALERTTRIGGER, 0); // go to alert when triggered
AddPainOrder("IdlePain", 100); // show pain
if(PATROL = false)
{
NewOrder("Idle");
}
else
{
RotateToPoint(STAND, YAWSPEED, false, "");
MoveToPoint(WALK, WALKSPEED*SCALE, "");
NewOrder("Patrol");
}
} ]

// found a target to attack

FoundTarget[ ()
{
DelTimerOrder(1); // get rid of alert timer
LowLevel(RUNFUNC); // attack functions are low level
} ]

// lost target while attacking so go back to idle again

LostTarget[ ()
{
FindTargetOrder(SIGHTDIST, "FoundTarget", DAMAGEATTRIBUTE); // seen a target to chase
AddPainOrder("IdlePain", 100); // show pain and trigger alert
AddTriggerOrder("IdleToAlert", ALERTTRIGGER, 0); // go to alert when triggered
if(PATROL = false)
{
NewOrder("Idle");
}
else
{
RotateToPoint(STAND, YAWSPEED, false, "");
MoveToPoint(WALK, WALKSPEED*SCALE, "");
NewOrder("Patrol");
}
} ]

// you died

Death[ ()
{
DelTimerOrder(1); // remove alert timer
AddPainOrder("IdlePain", 0); // remove pain order
FindTargetOrder(0, "FoundTarget", DAMAGEATTRIBUTE); // remove target finding
DelTriggerOrder("IdleToAlert"); // remove alert trigger
SetNoCollision(); // remove bounding box so there are no collisions with corpse
switch(random(1,4)) // chose between 4 death animations
{
case 1
{
AnimateStop(DIE, DIEHOLD, DIESOUND);
}
case 2
{
AnimateStop(DIE1, DIEHOLD, DIESOUND1);
}
case 3
{
AnimateStop(DIE2, DIEHOLD, DIESOUND2);
}
case 4
{
AnimateStop(DIE, DIEHOLD, DIESOUND3);
}
}
if(DIEHOLD >= 0)
{
FadeOut(DIEFADE, 0); // fade out corpse
Remove(true); // remove actor
}
} ]

// Low level attack routines

// Start of run to attack

monster_run_start[ ()
{
Animate(RUN); // play run animation
self.ThinkTime = 0; // start thinking on next frame
self.think = "monster_run"; // go to run attack routine
self.ideal_yaw = enemy_yaw; // set direction to run
self.yaw_speed = YAWSPEED; // set rotation speed
back_up = false; // initialize obstacle avoidance
attack_state = AS_NONE; // not attacking yet
melee_time = time;
run_sound_time = time;
} ]

// run to enemy to attack

monster_run[ ()
{
self.ThinkTime = 0.1;
if(self.health<=0)
{
HighLevel("Death"); // dead
return 0;
}
if((self.in_pain = true) and (random(1,100)<PAINPERCENT))
{
self.think = "monster_run_pain_start"; // in pain
return 0;
}
if(EnemyExist(DAMAGEATTRIBUTE) < 3)
{
HighLevel("LostTarget"); // enemy is gone or dead
return 0;
}
if(enemy_vis = false)
{
self.think = LOSTFUNC; // lost sight of enemy
lost_time = time + LOSTTIME;
return 0;
}
if(run_sound_time < time)
{
if(random(1,10)>7)
{
run_sound_time = time + RUNSOUNDDELAY;
PlaySound(RUNSOUND);
}
}
ai_run(random((RUNSPEED-2)*SCALE,(RUNSPEED+2)*SCALE)); // run toward enemy
} ]

// start of pain while running

monster_run_pain_start[ ()
{
switch(random(1,4)) // play one of 4 pain animations
{
case 1
{
Animate(PAIN);
PlaySound(PAINSOUND);
}
case 2
{
Animate(PAIN1);
PlaySound(PAINSOUND1);
}
case 3
{
Animate(PAIN2);
PlaySound(PAINSOUND2);
}
case 4
{
Animate(PAIN3);
PlaySound(PAINSOUND3);
}
}
SetHoldAtEnd(true); // set to stop at animation end
self.ThinkTime = 0.1;
self.think = "monster_run_pain";
} ]

// wait for animation to stop

monster_run_pain[ ()
{
self.ThinkTime = 0.1;
if(self.animate_at_end = true) // wait for end of animation
{
self.think = "monster_run_start"; // start running again
SetHoldAtEnd(false); // remove animation stop
self.ThinkTime = 0;
}
} ]

// start of lost sight of enemy routine

monster_lost_target_start[ ()
{
Animate(RUN); // play run animation
self.ThinkTime = 0; // start thinking on next frame
self.think = "monster_lost_target";
run_sound_time = time + RUNSOUNDDELAY;
} ]

// go to last known location of enemy

monster_lost_target[ ()
{
self.ThinkTime = 0.1;
if(lost_time<time)
{
HighLevel("LostTarget"); // timed out while looking
return 0;
}
if(self.health<=0)
{
HighLevel("Death"); // died
return 0;
}
if((self.in_pain = true) and (random(1,100)<PAINPERCENT))
{
self.think = "monster_lost_pain_start"; // in pain
return 0;
}
if(EnemyExist(DAMAGEATTRIBUTE) < 3)
{
HighLevel("LostTarget"); // enemy died or was removed
return 0;
}
if(enemy_vis = true)
{
self.think = "monster_run_start"; // seen again so run to attack
self.ThinkTime = 0;
return 0;
}
if(run_sound_time < time)
{
if(random(1,10)>7)
{
run_sound_time = time + RUNSOUNDDELAY;
PlaySound(RUNSOUND);
}
}
if((enemy_range>POINTRADIUS) and (RUNSPEED > 0)) // get close to last known location
{
walk_movetogoal(random((RUNSPEED-2)*SCALE,(RUNSPEED+2)*SCALE));
}
else
{
HighLevel("LostTarget"); // can't find at last known location
return 0;
}
} ]

// start of showing pain while searching

monster_lost_pain_start[ ()
{
switch(random(1,4)) // play one of 4 pain animations
{
case 1
{
Animate(PAIN);
PlaySound(PAINSOUND);
}
case 2
{
Animate(PAIN1);
PlaySound(PAINSOUND1);
}
case 3
{
Animate(PAIN2);
PlaySound(PAINSOUND2);
}
case 4
{
Animate(PAIN3);
PlaySound(PAINSOUND3);
}
}
SetHoldAtEnd(true); // set to stop at end
self.ThinkTime = 0.1;
self.think = "monster_lost_pain";
} ]

// wait till animation is done

monster_lost_pain[ ()
{
self.ThinkTime = 0.1;
if(self.animate_at_end = true) // animation done
{
self.think = "monster_lost_target_start"; // go back to finding target
SetHoldAtEnd(false); // remove stop at end
self.ThinkTime = 0;
}
} ]

// start of missile attack

monster_missile_start[ ()
{
switch(random(1,3)) // play one of 3 missile animations
{
case 1
{
Animate(MISSILEATTACK);
fire_delay = time + FIREDELAY; // set firing delay
missile_sound = MISSILESOUND;
}
case 2
{
Animate(MISSILEATTACK1);
fire_delay = time + FIREDELAY1; // set firing delay
missile_sound = MISSILESOUND1;
}
case 3
{
Animate(MISSILEATTACK2);
fire_delay = time + FIREDELAY2; // set firing delay
missile_sound = MISSILESOUND2;
}
}
SetHoldAtEnd(true);
self.ThinkTime = 0;
self.think = "monster_missile";
UpdateTarget(); // update target location
skill_time = time + (SKILL*0.1); // calculate next update time
attack_delay = time + ATTACKDELAY; // delay until next shot
} ]

// attack target with projectile

monster_missile[ ()
{
self.ThinkTime = 0.1;
if(self.health<=0)
{
SetHoldAtEnd(false);
HighLevel("Death"); // dead
return 0;
}
if((self.in_pain = true) and (random(1,100)<PAINPERCENT))
{
self.think = "monster_missile_pain_start"; // in pain
SetHoldAtEnd(false);
return 0;
}
exist = EnemyExist(DAMAGEATTRIBUTE);
if(exist < 2)
{
SetHoldAtEnd(false);
HighLevel("LostTarget"); // enemy is dead and gone
return 0;
}
if(exist = 2)
{
SetHoldAtEnd(false);
HighLevel("LostTarget"); // enemy is dead but body remains
return 0;
}
if(enemy_vis = false)
{
self.think = LOSTFUNC; // lost sight of enemy
lost_time = time + LOSTTIME;
SetHoldAtEnd(false);
return 0;
}
if(enemy_range>MISSILERANGE)
{
self.think = RUNFUNC; // too far away so run toward
SetHoldAtEnd(false);
return 0;
}
if(skill_time<time) // update according to skill level
{
UpdateTarget(); // update target location
skill_time = time + (SKILL*0.1);
ai_face(); // face enemy while attacking
}

if(fire_delay<time) // delay after animation starts before firing
{
FireProjectile(PROJECTILE, FIREBONE, (OFFSETX*SCALE), (OFFSETY*SCALE), (OFFSETZ*SCALE), DAMAGEATTRIBUTE);
fire_delay = time + 1000; // set delay well ahead so it is ignored
PlaySound(missile_sound);
}

// wait until animation is done before attacking again
// hold animation at end until attack delay is over

if(self.animate_at_end = true)
{
if(attack_delay < time)
{
self.think = "monster_missile_start"; // go back to missile attack
SetHoldAtEnd(false);
self.ThinkTime = 0.1;
}
}
} ]

// start of showing pain

monster_missile_pain_start[ ()
{
switch(random(1,4)) // play one of 4 pain animations
{
case 1
{
Animate(PAIN);
PlaySound(PAINSOUND);
}
case 2
{
Animate(PAIN1);
PlaySound(PAINSOUND1);
}
case 3
{
Animate(PAIN2);
PlaySound(PAINSOUND2);
}
case 4
{
Animate(PAIN3);
PlaySound(PAINSOUND3);
}
}
SetHoldAtEnd(true); // set to stop at end
self.ThinkTime = 0.1;
self.think = "monster_missile_pain";
} ]

// wait until animation is done

monster_missile_pain[ ()
{
self.ThinkTime = 0.1;
if(self.animate_at_end = true) // animation is done
{
self.think = "monster_missile_start"; // go back to missile attack
SetHoldAtEnd(false);
self.ThinkTime = 0;
}
} ]


// start of melee attack

monster_melee_start[ ()
{
switch(random(1,3)) // play one of 3 melee animations
{
case 1
{
Animate(MELEEATTACK);
PlaySound(MELEESOUND);
}
case 2
{
Animate(MELEEATTACK1);
PlaySound(MELEESOUND1);
}
case 3
{
Animate(MELEEATTACK2);
PlaySound(MELEESOUND2);
}
}
SetHoldAtEnd(true); // set to stop at end
self.ThinkTime = 0;
self.think = "monster_melee";
} ]

// melee attack

monster_melee[ ()
{
self.ThinkTime = 0.1;
if(self.health<=0)
{
SetHoldAtEnd(false);
HighLevel("Death"); // you died
return 0;
}
if((self.in_pain = true) and (random(1,100)<PAINPERCENT))
{
SetHoldAtEnd(false);
self.think = "monster_melee_pain_start"; // in pain
return 0;
}
exist = EnemyExist(DAMAGEATTRIBUTE); // see if target is around
if(exist < 2)
{
SetHoldAtEnd(false);
HighLevel("LostTarget"); // enemy is dead and gone
return 0;
}
if(exist = 2)
{
SetHoldAtEnd(false);
HighLevel("DeadTarget"); // enemy is dead but body remains
return 0;
}
if(enemy_vis = false)
{
SetHoldAtEnd(false);
self.think = LOSTFUNC; // lost sight of enemy
lost_time = time + LOSTTIME;
return 0;
}
if(enemy_range>(MELEERANGE*SCALE))
{
SetHoldAtEnd(false);
self.think = RUNFUNC; // too far away so run toward
return 0;
}
ai_face(); // face enemy while attacking
if(self.animate_at_end = true) // animation is done
{
SetHoldAtEnd(false);
switch(random(1,3)) // play one of 3 melee animations
{
case 1
{
Animate(MELEEATTACK);
PlaySound(MELEESOUND);
}
case 2
{
Animate(MELEEATTACK1);
PlaySound(MELEESOUND1);
}
case 3
{
Animate(MELEEATTACK2);
PlaySound(MELEESOUND2);
}
}
SetHoldAtEnd(true); // set to stop at end
}
if(time>melee_time) // if time then damage
{
damage = random(MINMELEEDAMAGE, MAXMELEEDAMAGE); // get damage amount
Damage(damage, DAMAGEATTRIBUTE); // damage target
melee_time = time + MELEEDELAY; // reset time until next damage
PlaySound(MELEEDAMAGESOUND);
}
} ]

// start of showing pain

monster_melee_pain_start[ ()
{
switch(random(1,4)) // play one of 4 pain animations
{
case 1
{
Animate(PAIN);
PlaySound(PAINSOUND);
}
case 2
{
Animate(PAIN1);
PlaySound(PAINSOUND1);
}
case 3
{
Animate(PAIN2);
PlaySound(PAINSOUND2);
}
case 4
{
Animate(PAIN3);
PlaySound(PAINSOUND3);
}
}
SetHoldAtEnd(true); // set to stop at end
self.ThinkTime = 0.1;
self.think = "monster_melee_pain";
} ]

// wait until animation is done

monster_melee_pain[ ()
{
self.ThinkTime = 0.1;
if(self.animate_at_end = true) // animation is done
{
self.think = "monster_melee_start"; // go back to melee attack
SetHoldAtEnd(false);
self.ThinkTime = 0;
melee_time = time + MELEEDELAY; // reset attack deley
}
} ]



// basic AI routines

// run toward enemy and see if you are ready to attack

ai_run[ (dist)
{
if (attack_state = AS_MELEE) // do melee attack
{
ai_run_melee();
return 0;
}
if (attack_state = AS_MISSILE) // do missile attack
{
ai_run_missile();
return 0;
}
if (CheckAnyAttack()) // check if you can start the actual attack
{
return 0;
}
if(RUNSPEED > 0)
{
walk_movetogoal(dist); // else move toward the enemy
}
} ]

// missile attack setup

ai_run_missile[ ()
{
ai_face();
if(FacingIdeal()) // got close enough
{
self.think = MISSILEFUNC; // start missile attack
attack_state = AS_STRAIGHT;
UpdateTarget();
skill_time = time + (SKILL*0.1);
}
} ]

// melee attack setup

ai_run_melee[ ()
{
ai_face(); // turn to face target
if(FacingIdeal()) // got close enough
{
self.think = MELEEFUNC; // start melee attack
self.attack_state = AS_STRAIGHT;
}
} ]

// face enemy

ai_face[ ()
{
self.ideal_yaw = enemy_yaw;
ChangeYaw(); // rotate to face enemy
} ]

// use walkmove to naviagte to enemy

walk_movetogoal[ (dist)
{
if(IsFalling = true)
{
return 0; // don't move while falling
}
if(dist < 0)
{
return 0;
}
if(back_up = false)
{
ai_face(); // turn to face enemy
if(FacingIdeal())
{
if(walkmove(self.current_yaw, dist) = true)
{
return 0; // can move in current direction
}
else
{
if(random(1,10)<3) // backup and move sideways
{
back_up = true;
back_time = time + 0.5;
back_flag = false;
return 0;
}
else
{
ForceUp(FORCEUP*SCALE); // jump up, forward and to side
ForceForward(FORCEFORWARD*SCALE);
if(random(1,10)<6)
{
ForceRight(FORCESIDE*SCALE);
}
else
{
ForceLeft(FORCESIDE*SCALE);
}
}
}
}
}
else
{
if(back_flag = false) // go backward 1/2 sec
{
if(back_time > time)
{
walkmove((self.current_yaw-(180*0.0174532925199433)), dist);
return 0;
}
else
{
back_time = time + 0.5;
back_flag = true;
}
}
if(back_time > time) // go sideways 1/2 sec
{
walkmove((self.current_yaw-(90*0.0174532925199433)), dist);
return 0;
}
back_up = false;
}
} ]


// check if nearly facing enemy

FacingIdeal[ ()
{
selfangle = self.current_yaw/0.0174532925199433; // your direction in degrees
idealangle = self.ideal_yaw/0.0174532925199433; // his direction in degrees
delta = selfangle - idealangle; // difference in directions
if (delta > -20 and delta < 20) // within 20 degrees is close enough
{
return true;
}
return false;
} ]

// check if ready to do actual attacking

CheckAnyAttack[ ()
{
if(ATTACKTYPE = "melee")
{
if(enemy_range<(MELEERANGE*SCALE)) // inside melee range
{
attack_state = AS_MELEE; // do a melee attack
return true;
}
return false;
}

if(ATTACKTYPE = "missile")
{
if(attack_delay>time)
{
return false;
}
if(enemy_range<MISSILERANGE) // inside missile range
{
attack_state = AS_MISSILE; // do a missile attack
return true;
}
}
return false;
} ]

}

Posted: Fri Apr 06, 2007 5:35 pm
by darksmaster923
try checking the dmg attribute of ur weapons........ make sure its the same attribute as this HEALTHATTRIBUTE [health] // name of health attribute

Posted: Sat Apr 07, 2007 11:24 am
by Juutis
There's nothing that somehow refers to the player's weapon in the script.
So the problem lies most likely in your weapon.ini and the weapon definitions.

re:re

Posted: Sat Apr 07, 2007 4:29 pm
by dodger
Hi again,
Thank you both for your help...
the problem was in the weapon.ini
the first example script below has only attribute = enemy_health





;*********************************************************
;
; Player Weapons
;
;*********************************************************

;*********************************************************
; C8
;*********************************************************
[c8]
type = weapon
slot = 0
firerate = 0.25
catagory = projectile
projectile = pistol_shell

attribute = enemy_health

ammunition = pistol_shell
ammopershot = 1
shotpermagazine = 13
worksunderwater = true
attacksound = weapon\deagle.wav
reloadsound = weapon\generic_reload.wav
emptysound = weapon\click.wav
muzzleflash3rd = MuzzleFlash
;


so i added altattribute = health to the second example and it works fine




;*********************************************************
;
; Player Weapons
;
;*********************************************************

;*********************************************************
; C8
;*********************************************************
[c8]
type = weapon
slot = 0
firerate = 0.25
catagory = projectile
projectile = pistol_shell

attribute = enemy_health
altattribute = health

ammunition = pistol_shell
ammopershot = 1
shotpermagazine = 13
worksunderwater = true
attacksound = weapon\deagle.wav
reloadsound = weapon\generic_reload.wav
emptysound = weapon\click.wav
muzzleflash3rd = MuzzleFlash
;

once again thank you both for your time and help...

Dodger::: :D

Posted: Tue May 08, 2007 5:31 am
by whatwhat89
in the HEAlTHATTRIBUTE, instead of health put enemy_health.

Posted: Tue May 08, 2007 5:32 am
by whatwhat89
in the HEAlTHATTRIBUTE, instead of health put enemy_health.