-- This is a script that can be used to modify particle properties -- -- Created: 8-8-2004 -- Last Updated: -- -- Author : ZhangYang -- Version: 3ds max 6 --******************************************************************** -- MODIFY THIS AT YOUR OWN RISK -- Notes: Ranger _1.02 test on ChannelsUsed pCont do ( pCont.useTime = true pCont.useSpeed = true ) on Init pCont do ( --init var for scenes:Soldier,teamA,TeamB --start of struct Struct Soldier ( Pos=[0,0,0], Status=0, Hp=10, Strengh=1, Timer=0, EmyIndex=0, Vision=100, --function for search near enemy. cur_pos:Currenty soldier position. enemy_Array:enemy team array fn search_near emyPos_Array = (if emyPos_Arra==#() do return 0 --0 means search failed. min_dis=100000 min_index=0 emy_count=emyPos_Array.count for i=1 to emy_count do ( cur_dis=(distance pos emyPos_Array[i]) if min_dis>cur_dis do (min_dis=cur_dis min_index=i ) ) if min_index!=0 and min_dis<=Vision then return min_index else return 0 ) ) --end of struct --init env var Global Team_Num=50 Global Fight_Dis=10,Run_Speed=0.01,Run_Timer=10,Walk_Timer=15,Fight_Timer=8,Min_HP=3,Flee_Timer=5 --Timer or Dis Global Walk_State=1, Run_State=2, Fight_State=3, Flee_State=4, Dead_State=5 --status var Global Walk_Speed=[0.00166667,0,0],Flee_Speed=0.1 --team declare TeamA=#() TeamB=#() --soldier per team for i=1 to Team_Num do ( TeamA[i]=Soldier Hp:10 Status:Walk_State Timer:Walk_Timer --set defualt walking TeamB[i]=Soldier Hp:10 Status:Walk_State Timer:Walk_Timer ) Global Team=#(TeamA,TeamB) --string execute try Global MyTeam=0 Global EmyTeam=0 --end of init ) on Proceed pCont do ( count= pCont.NumParticles() pfsys_Curr=pCont.getParticleSystemNode() if pfsys_Curr.name=="TeamA" do ( MyTeam=1 EmyTeam=2 ) if pfsys_Curr.name=="TeamB" do ( MyTeam=2 EmyTeam=1 ) --collect team pos Pos_col=#() for i in 1 to count do ( pCont.particleIndex=i Team[MyTeam][i].Timer-=1 Case Team[MyTeam][i].status of ( Walk_State: (if MyTeam==1 then pCont.ParticleSpeed=Walk_Speed else pCont.ParticleSpeed=-Walk_Speed --collect the enemy pos to a array for j=1 to count do append Pos_col (Team[EmyTeam][j].pos) Near_emy=Team[MyTeam][i].search_near Pos_col if Near_emy>0 and Team[MyTeam][i].timer<=0 do ( Team[MyTeam][i].status=Run_State -- if enemy in sight. set status to run Team[MyTeam][i].Timer=Run_Timer -- set the timer to run as 5 Team[MyTeam][i].EmyIndex=Near_emy --set target enemy ) if Team[MyTeam][i].timer<=0 do Team[MyTeam][i].timer=Walk_Timer --if one cycle finish , refresh it ) Run_State: ( --load the enemy position if Team[EmyTeam][i].EmyIndex==0 do continue emy_pos=Team[EmyTeam][Team[MyTeam][i].EmyIndex].pos --set myteam speed:emypos-mypos pCont.particlespeed=Run_Speed*normalize(emy_pos-Team[MyTeam][i].pos) emy_dis=distance emy_pos Team[MyTeam][i].pos if emy_dis<=Fight_Dis and Team[MyTeam][i].timer<=0 do ( Team[MyTeam][i].status=Fight_State -- if enemy in sight. set status to run Team[MyTeam][i].Timer=Fight_Timer -- set the timer to run as 5 Continue ) if Team[MyTeam][i].timer<=0 do Team[MyTeam][i].timer=Run_Timer --if one cycle finish , refresh it ) Fight_State: ( --debug use format "Team:% Particle No:% fight Against:% MyHp:% \n" MyTeam i Team[MyTeam][i].EmyIndex Team[MyTeam][i].hp pCont.particleSpeed=[0,0,0] --if hp 0:turn to dead if Team[MyTeam][i].Hp<=0 do ( Team[MyTeam][i].status=Dead_State continue ) --if hp too low:turn to flee if Team[MyTeam][i].Hp=Fight_Dis do ( Team[MyTeam][i].status=Run_State Team[MyTeam][i].timer=Run_Timer ) ) Flee_State: ( if MyTeam==1 then pCont.ParticleSpeed=-Flee_Speed*Walk_Speed else pCont.ParticleSpeed=Flee_Speed*Walk_Speed --debug use format "Team:% Particle No:% Flee MyHp:% \n" MyTeam i Team[MyTeam][i].hp ) Dead_State: ( --debug use format "Team:% Particle No:% Dead \n" MyTeam i pCont.particleSpeed=[0,0,0] ) ) ) ) on Release pCont do ( ) --******************************************************************** --Interface: MaxscriptParticleContainer - argument in all script methods -- Properties: -- // to use in ChannelsUsed method -- .useTime : bool : Read|Write -- .useAge : bool : Read|Write -- .useLifespan : bool : Read|Write -- .useEventTime : bool : Read|Write -- .usePosition : bool : Read|Write -- .useSpeed : bool : Read|Write -- .useAcceleration : bool : Read|Write -- .useOrientation : bool : Read|Write -- .useSpin : bool : Read|Write -- .useScale : bool : Read|Write -- .useTM : bool : Read|Write -- .useSelected : bool : Read|Write -- .useShape : bool : Read|Write -- .useInteger : bool : Read|Write -- .useFloat : bool : Read|Write -- .useVector : bool : Read|Write -- .useMatrix : bool : Read|Write -- // to use in Proceed method -- .particleIndex : index : Read|Write|Validated by Range: 1 to 100000000 // set/get current particle index -- .particleID : index : Read|Write|Validated by Range: 1 to 100000000 // set/get current particle ID -- .particleNew : bool : Read // check if particle just arrived into the event -- .particleTime : time : Read|Write // time of the current status of the particle -- .particleAge : time : Read|Write|Validated by Range: 0f to 9e+006f -- .particleLifespan : time : Read|Write|Validated by Range: 0f to 9e+006f -- .particleEventTime : time : Read|Write|Validated by Range: 0f to 9e+006f // for how long the particle is present in the current event -- .particlePosition : point3 : Read|Write -- .particleSpeed : point3 : Read|Write -- .particleAcceleration : point3 : Read|Write -- .particleOrientation : point3 : Read|Write -- .particleSpin : angleAxis : Read|Write -- .particleScale : float : Read|Write -- .particleScaleXYZ : point3 : Read|Write -- .particleTM : matrix3 : Read|Write // set/get particle transformation matrix -- .particleSelected : bool : Read|Write -- .particleShape : mesh : Read|Write -- .useMtlIndex: bool: Read|Write -- .useMapping: bool: Read|Write -- .particleInteger : integer : Read|Write // to store custom integer data per particle -- .particleFloat : float : Read|Write // to store custom float data per particle -- .particleVector : point3 : Read|Write // to store custom vector data per particle -- .particleMatrix : matrix3 : Read|Write // to store custom matrix data per particle -- Methods: -- // to use in Init, Release and Proceed methods -- getParticleContainer() // get particle container -- // to use in Init and Proceed methods -- getParticleSystem() // get the particle system object -- getParticleSystemNode() // get the particle system node -- // to use in Init method -- getInitActions() // get list of all action objects in the current event -- getInitActionNodes()// get list of all action nodes in the current event -- // to use in Proceed method --