Updated Jasperre's AI
Updated Jasperre's AI to 1.4, fixed a few other coding bugs & fully compiled module.
This commit is contained in:
@@ -1,35 +1,36 @@
|
||||
/************************ [On Heartbeat - Move Nearer PC] **********************
|
||||
Filename: j_ai_heart_serch
|
||||
************************* [On Heartbeat - Move Nearer PC] **********************
|
||||
/*/////////////////////// [On Heartbeat - Move Nearer PC] //////////////////////
|
||||
Filename: J_AI_Heart_Serch
|
||||
///////////////////////// [On Heartbeat - Move Nearer PC] //////////////////////
|
||||
This is fired to perform moving nearer the PC, or searching towards them.
|
||||
|
||||
Yes, like the Henchmen and Battle AI code. I am sure they won't mind - if
|
||||
they do, I will remove it :-)
|
||||
************************* [History] ********************************************
|
||||
///////////////////////// [History] ////////////////////////////////////////////
|
||||
1.3 - Added
|
||||
************************* [Workings] *******************************************
|
||||
1.4 - Reformatted as with the rest of the AI
|
||||
///////////////////////// [Workings] ///////////////////////////////////////////
|
||||
This makes the NPC move nearer to a PC. Fires if the spawn condition
|
||||
is on and the timer is not, and only 1/4 heartbeats to lessen the effect.
|
||||
************************* [Arguments] ******************************************
|
||||
///////////////////////// [Arguments] //////////////////////////////////////////
|
||||
Arguments: N/A
|
||||
************************* [On Heartbeat - Move Nearer PC] *********************/
|
||||
///////////////////////// [On Heartbeat - Move Nearer PC] ////////////////////*/
|
||||
|
||||
#include "j_inc_constants"
|
||||
#include "J_INC_CONSTANTS"
|
||||
|
||||
void main()
|
||||
{
|
||||
object oPC = GetNearestCreature(CREATURE_TYPE_PLAYER_CHAR, PLAYER_CHAR_IS_PC);
|
||||
if(GetIsObjectValid(oPC) && GetIsEnemy(oPC) &&
|
||||
GetDistanceToObject(oPC) <
|
||||
IntToFloat(GetBoundriedAIInteger(AI_SEARCH_IF_ENEMIES_NEAR_RANGE, i25, i50, i5)))
|
||||
IntToFloat(GetBoundriedAIInteger(AI_SEARCH_IF_ENEMIES_NEAR_RANGE, 25, 50, 5)))
|
||||
{
|
||||
vector vPC = GetPosition(oPC);
|
||||
// Whats the distance we use to move a bit nearer?
|
||||
int iRandom = i10 + Random(i10);
|
||||
int nRandom = 10 + Random(10);
|
||||
// Randomise a point nearby.
|
||||
vPC.x += IntToFloat(iRandom - (Random(i2 * iRandom + i1)));
|
||||
vPC.y += IntToFloat(iRandom - (Random(i2 * iRandom + i1)));
|
||||
vPC.z += IntToFloat(iRandom - (Random(i2 * iRandom + i1)));
|
||||
vPC.x += IntToFloat(nRandom - (Random(2 * nRandom + 1)));
|
||||
vPC.y += IntToFloat(nRandom - (Random(2 * nRandom + 1)));
|
||||
vPC.z += IntToFloat(nRandom - (Random(2 * nRandom + 1)));
|
||||
// Define the location
|
||||
location lNew = Location(GetArea(oPC), vPC, IntToFloat(Random(359)));
|
||||
SetLocalTimer(AI_TIMER_SEARCHING, GetDistanceToObject(oPC));
|
||||
|
Reference in New Issue
Block a user