I knew it! Just knew it!
As soon as I got time (and juice) to work on scripting, gremlins would come sit on my shoulder :-(
The following script is set on the x2_special_combat_ai_script variable of my wolfen henchman.
It (supposedly) should:
- Return if pack has already been summoned
- Set up variables (current target, targets location, etc.)
- Play a sound (variable on henchman)
- Look for a valid location around (absurdly close to) target
- create a copy of packmember creature (blueprint resref stored on henchman)
- Repeat 4 & 5 nPackLevel times...
- Set boolean that pack has been summoned
- Turn off henchman AI on round she summons pack
Please look over this bit and heap advice (and scorn, if you really enjoy that sort of thing :-) on my head.
#include "nw_i0_generic"
#include "nw_i0_2q4luskan"
const string sbCont = "X2_SPECIAL_COMBAT_AI_SCRIPT_OK";
void main()
{
//NPC Summon Pack
// IF bPackSummoned is true, return
if (GetLocalInt(OBJECT_SELF,"bPackSummoned") == TRUE) return;
//Get NPC's target and other variables
int nPackLevel = GetLocalInt(OBJECT_SELF,"nPackLevel");
string sPackType = GetLocalString(OBJECT_SELF,"sPackType"); //Creature name
object oCurrTarget =GetLocalObject(OBJECT_SELF,"X2_NW_I0_GENERIC_INTRUDER");
location lTargetLoc = GetLocation(oCurrTarget);
float fRadius; //Random distance from oCurrTarget
float fDir; //Random direction from oCurrTarget
// Play summoning sound
PlaySound(GetLocalString(OBJECT_SELF,"sSummonSound"));
// For each nPackLevel, create a packmember of sPackType out of sight
int nPackNum = nPackLevel;
int nObjectType = OBJECT_TYPE_CREATURE; // Object type to create
int bUseAppearAnimation = FALSE;
int y;
location lInSpot;
while (nPackNum--) // Runs at least once, decrements
{
// Find a distant spot to place new member
lInSpot = GetLocation(OBJECT_INVALID); // clear the location variable
int nNumTries = 26; // max loops for random test
fRadius = IntToFloat(Random(20)/10+1); // Should be rnd(20m)+10m
fDir = IntToFloat(Random(36)*10); // 0 to 350 degrees
y = nNumTries;
while (y--) // Runs at least once, decrements
{
// Generate a location
lInSpot = GenerateNewLocationFromLocation(lTargetLoc, fRadius, fDir, fDir);
if (lInSpot != GetLocation(OBJECT_INVALID))
{
// YES! we found a valid location... can it reach target?
// pathfinding validation here
// Create copy of sPackType at lInSpot, delayed by (nPackLevel*3 seconds)
DelayCommand((3.0f*nPackLevel), CreateObjectVoid(nObjectType, sPackType, lInSpot, FALSE));
y = 0;
}
}
}
//set SummonedPack variable on Summoner
SetLocalInt(OBJECT_SELF,"bPackSummoned", TRUE);
// Stop the rest of the Combat AI From Running. SummonPack will use up first round.
SetLocalInt(OBJECT_SELF,sbCont,TRUE);
}
Edit: Stoopid formatting :-P<...in despair>
Modifié par Rolo Kipp, 23 août 2011 - 08:13 .





Retour en haut







