![]() |
|
#5
|
|||
|
|||
|
Ok, I did the box tactic, however now i'm not sure how to reference the boxes. When an avatar gets hit I say "if info.object in characters (the character array of avatars). How Can I do this with the boxes?
Also, I had another question regarding avatar hits. I'm having a problem that when a bullet hits the avatar, the avatar is still able to be hit, thus incrementing the hit count. I want the avatar hit count to only be incremented once for every avatar that gets hit. It is not important to know whether an avatar gets hit multiple times. I added a info.object.disable(viz.COLLISION) to disable collisions as soon as they get hit. Code:
info = viz.intersect(pos,futurePos)
if info.intersected:
if info.object in characters:
info.object.disable(viz.COLLISION)
#print "in characters"
if info.object.tag == 0:
soldierCount += 1
if info.object.threatening == TRUE:
threatCount += 1
elif info.threatening == FALSE:
nonthreatCount += 1
elif info.object.tag == 1:
maleCount += 1
if info.object.threatening == TRUE:
threatCount += 1
elif info.object.threatening == FALSE:
nonthreatCount += 1
elif info.object.tag == 2:
femaleCount += 1
if info.object.threatening == TRUE:
threatCount += 1
elif info.object.threatening == FALSE:
nonthreatCount += 1
avatarsHit = avatarsHit + 1
viz.playsound('arrgh.wav')
WaitThenFreeze = vizact.sequence( vizact.waittime(info.object.getduration(7)-.85), vizact.speed_node(0) )
info.object.execute(7)
info.object.clear(viz.ALL)
info.object.clear(viz.CURRENT_ACTION)
info.object.add(WaitThenFreeze) #Add the action to the avatar
RemoveAvatarAction = vizact.call(RemoveAvatar,info.object)
info.object.add(RemoveAvatarAction) #Add action to remove avatar
Code:
def RemoveAvatar(avatar): global avatarCount avatar.visible(0) #Hide avatar avatar.speed(1) #Restore speed characters.remove(avatar) #Remove from list dead_list.append(avatar) #Add to dead list avatarCount += 1 print 'avatar count is: ', avatarCount def RestoreAvatar(): global keyindex if len(dead_list): print "avatar restored" avatar = dead_list.pop() #Ressurrect dead avatar avatar.visible(1) #Make it visible characters.append(avatar) #Add it to avatar list Last edited by betancourtb82; 05-18-2006 at 02:43 PM. |
|
|