Help:About DalGurak's combo

Talk about Severance Blade of Darkness modifications and maps here. No tips or tech support questions please, use the forum above. Note that the game is rated 18 so some content may be unsuitable for younger readers.

Moderators: prospero, Ade

User avatar
prospero
Ancient Dragon
Posts: 1800
Joined: Wed Nov 21, 2001 1:42 am
Location: United Kingdom

Post by prospero »

It's a tough map. [B)]

User avatar
mingyue1371
Dragon
Posts: 206
Joined: Fri Aug 05, 2011 4:46 pm
Location: China
Contact:

Post by mingyue1371 »

Yes,a tough map.[:D]
I had a small question that how can I lock on enemies in the long distance [?] Mostly I can see the bad guys in high stairs . but I can not do attacking with my boomerang weapon just because cannot be locked .[B)]
Btw,I found a very cool video[:0] from the forum:
<blockquote id="quote"><font size="1" face="Verdana, Arial, Helvetica" id="quote">quote:<hr height="1" noshade id="quote">
from dogchicken:
[New Enemies]
Ninja Ork [add smoke effect]:
http://www.youtube.com/watch?v=bmFA6-0efII
Cursed Dwarf (http://www.youtube.com/watch?v=XjZ94LIqJS4)
Ork Shaman[2] (http://www.youtube.com/watch?v=pytqUwbuV_Q)
<hr height="1" noshade id="quote"></font id="quote"></blockquote id="quote">
Also I want to know how to achieve it like a crab [:0]or made very cool magic attack[:0][:0][:0]. Can u tell me how to do it exactly?
Thx....[:D]

User avatar
prospero
Ancient Dragon
Posts: 1800
Joined: Wed Nov 21, 2001 1:42 am
Location: United Kingdom

Post by prospero »

As far as I know there is no way of locking onto enemies that are above a certain angle. What you can do is insert some code into the boomerang code so that if you aren't locked to an enemy, you can 'scan' for enemies in sight and target the nearest. There is a ery useful built-in finction in the engine.

this the basic code:

Code: Select all

head_pos=me.Rel2AbsPoint(0.0,0.0,5000.0) 
pj_dir=me.Rel2AbsVector(0.0,-1.0,0.0)
for ename in Bladex.GetEnemiesVisibleFrom(head_pos,50000,pj_dir,0.0):
    ent=Bladex.GetEntity(ename)
        if ent.Person:
            dist=B3DLib.GetXZDistance('Player1', ent.Name)
		if ent.Life>0(ent.Name) and dist>3000:
    targetlist.append(ename)
The targetlist mat be empty, or it may contain the names of multple chars. You can select the first in the list:

target=Bladex.GetEntity(targetlist[0])

or put in clauses to select nearest/most life/archers and exclude any Allies.


Not sure how the cursed Dwarf was done. I think it used some of the unused swimming animations. [8D]

To add the various magic attacks you really need to learn how attacks are handled in the code. Usually they are triggered by Events that are assigned to animations. (check Scripts/Anm_def.py) Functions can be assigned to these Events. Here's one that I have in the Player ChaosKnight data class:

Code: Select all

me.AddAnmEventFunc("Ckxmagicstart", self.PrepareShoot)
me.AddAnmEventFunc("Ckxmagicfire", self.Shoot)
PrepareShoot triggers the FX around his hand as he goes to fire the blue balls. Shoot creates the ball and releases it. Look at the timings in Anm_def.py.

User avatar
mingyue1371
Dragon
Posts: 206
Joined: Fri Aug 05, 2011 4:46 pm
Location: China
Contact:

Post by mingyue1371 »

Hi pro and thx,[:)]
Sorry for my bad python[B)] ,I still dont know how to make the boomerang to select enemies. I put the code above in the class boomerang :

Code: Select all

#boomerang code
.......
		head_pos=me.Rel2AbsPoint(0.0,0.0,5000.0) 
		pj_dir=me.Rel2AbsVector(0.0,-1.0,0.0)
		for ename in Bladex.GetEnemiesVisibleFrom(head_pos,50000,pj_dir,0.0):
		ent=Bladex.GetEntity(ename)
			if ent.Person:
		dist=B3DLib.GetXZDistance('Player1', ent.Name)
			if ent.Life>0(ent.Name) and dist>3000:
		targetlist.append(ename)
		target=Bladex.GetEntity(targetlist[0])
........


But it dosent work and the game was wrong.
so can u tell me how to use the scan enemy fuction? and how to add it to the boomerangweapon code?
still I tried the chk's magic ball,but failed in the last .
I had modified files:DwfCombos.py,DwfAnimationSet.py,anm_def.py,Basic_Funcs.py,Reference.py,ItemTypes.py.
And this is the wrong message in console:

Code: Select all

Traceback (innermost last):
  File "..\..\Lib\Basic_Funcs.py", line 1011, in PrepareShoot
    if self.RightWeapon:
AttributeError: RightWeapon
Tuple with 2 args
Item 0 is: Player1
Item 1 is: Ckxmagicstart
Function (method): <method PlayerPerson.PrepareShoot of PlayerPerson instance at f15b5a4>
Traceback (innermost last):
  File "..\..\Lib\Basic_Funcs.py", line 1047, in Shoot
    target_pos= target.Position			
AttributeError: 'None' object has no attribute 'Position'
Tuple with 2 args
Item 0 is: Player1
Item 1 is: Ckxmagicfire
Function (method): <method PlayerPerson.Shoot of PlayerPerson instance at f15b5a4>
77722222833wdwdsadwawa
Checked your email,I had send some files toyou.
Btw,I was interested in make magic attacks very much,But later I had a trouble,I hope you can help me.
I want to copy Dalmace's magic combo to Dwarf,then I start to do this work ,I refer to your mod of Dal's revenge,after three hours work,
I can succeed in doing the anim,but no magic effect[:(][:(][:(].
So I send you a email[peterrobinsonfineart@btinternet.com] about the relative files which I modified,Can u help me to solve it ?

Btw,I see your post that you could use the CHK as a player and do magic attacks, Can you send me the file for studying it ?
Best wishes,
Mingyue .[:D]

Sir Random
Dragon
Posts: 737
Joined: Thu Nov 15, 2001 12:58 am
Location: Ireland
Contact:

Post by Sir Random »

<blockquote id="quote"><font size="1" face="Verdana, Arial, Helvetica" id="quote">quote:<hr height="1" noshade id="quote"><i>Originally posted by mingyue1371</i>

Code: Select all

#boomerang code
.......
		head_pos=me.Rel2AbsPoint(0.0,0.0,5000.0) 
		pj_dir=me.Rel2AbsVector(0.0,-1.0,0.0)
		for ename in Bladex.GetEnemiesVisibleFrom(head_pos,50000,pj_dir,0.0):
		ent=Bladex.GetEntity(ename)
			if ent.Person:
		dist=B3DLib.GetXZDistance('Player1', ent.Name)
			if ent.Life>0<font color="red">(ent.Name)</font id="red"> and dist>3000:
		targetlist.append(ename)
		target=Bladex.GetEntity(targetlist[0])
........
But it dosent work and the game was wrong.
<hr height="1" noshade id="quote"></font id="quote"></blockquote id="quote">
Hi mingyue1371,

That code has a few syntax errors, and the text in <font color="red">red</font id="red"> should not be there.

It should look something like this:

Code: Select all

#boomerang code
.......
		head_pos=me.Rel2AbsPoint(0.0,0.0,5000.0) 
		pj_dir=me.Rel2AbsVector(0.0,-1.0,0.0)
		for ename in Bladex.GetEnemiesVisibleFrom(head_pos,50000,pj_dir,0.0):
		        ent=Bladex.GetEntity(ename)
			if ent.Person:
		                dist=B3DLib.GetXZDistance('Player1', ent.Name)
			        if ent.Life>0 and dist>3000:
		                        targetlist.append(ename)
		                        target=Bladex.GetEntity(targetlist[0])
That code should make a list of enemies in the Player's view, and 'target' will reference the first enemy in the list. You could refine the code to select the nearest enemy, farthest enemy, or the enemy most directly in front of the Player.


I think your problem with the chk's magic ball is that no enemy was selected.

User avatar
mingyue1371
Dragon
Posts: 206
Joined: Fri Aug 05, 2011 4:46 pm
Location: China
Contact:

Post by mingyue1371 »

Hi SR,
I put the code in my boomerang code like this :
---------------------------------------------------------------------

Code: Select all

class BoomerangWeapon(PersistantItemType):

	Name=""
	Speed= 15000.0
	Spin= -0.8
	Axis= (1.0, 0.0, 0.0)
	OwnerName= ""
	C= None
	TimeWeaponStarted= None
	R= None
	Rn= None
	w= None
	RSQdist=None
	WeaponActive= 0
	grasped= 0
	tFinished= None
	Weapon= None
	ThrownBy= None
	Target= None
	Time2Grasp=0.4
	spinsound=None
	WeaponFX=None
	
	def __init__ (self, me):
		PersistantItemType.__init__(self, me)
		me.Weapon= 1
		self.Name= me.Name
		#self.Speed= 12000.0
		self.Speed= 15000.0
		self.Spin= -0.8
		self.Axis= (1.0, 0.0, 0.0)
		self.OwnerName= ""
		self.C= None
		self.TimeWeaponStarted= None
		self.R= None
		self.Rn= None
		self.w= None
		self.RSQdist=None
		self.WeaponActive= 0
		self.grasped= 0
		self.tFinished= None
		self.Weapon= None
		self.ThrownBy= None
		self.Target= None
		self.Time2Grasp=0.4
		# Create a looped sound
		SoundName= "..\\..\\Sounds\\vueltas-en-el-aire.wav"
		self.spinsound= Bladex.CreateEntity (me.Name+"LoopSound", "Entity Sound", 0, 0, 0)
		self.spinsound.SetSound (SoundName)
		self.spinsound.MinDistance=5000
		self.spinsound.MaxDistance=30000
		me.Link(self.spinsound)
		GenFX.AddWeaponFX(me.Name, self)

	def __getstate__(self):
		state= PersistantItemType.__getstate__(self)
		ThrownByName=""
		WeaponName=""
		SpinSoundName=""
		if self.Weapon: WeaponName=self.Weapon.Name
		if self.ThrownBy: ThrownByName=self.ThrownBy.Name
		if self.spinsound: SpinSoundName=self.spinsound.Name
		
		state[1]["BoomerangWeapon"]=(self.Name,
								self.Speed,
								self.Spin,
								self.Axis,
								self.OwnerName,
								self.C,
								self.TimeWeaponStarted,
								self.R,
								self.Rn,
								self.w,
								self.RSQdist,
								self.WeaponActive,
								self.grasped,
								self.tFinished,
								WeaponName,
								ThrownByName,
								self.Target,
								self.Time2Grasp,
								SpinSoundName,
								self.WeaponFX)
		
		return state
	
	def __setstate__(self,parm):
		PersistantItemType.__setstate__(self,parm)
		if parm[0]==1:
			parms=parm[1]["BoomerangWeapon"]
			ThrownByName=""
			WeaponName=""
			SpinSoundName=""
			
			(self.Name,
			self.Speed,
			self.Spin,
			self.Axis,
			self.OwnerName,
			self.C,
			self.TimeWeaponStarted,
			self.R,
			self.Rn,
			self.w,
			self.RSQdist,
			self.WeaponActive,
			self.grasped,
			self.tFinished,
			WeaponName,
			ThrownByName,
			self.Target,
			self.Time2Grasp,
			SpinSoundName,
			self.WeaponFX)= parms
			
			if WeaponName: self.Weapon=Bladex.GetEntity(WeaponName)
			if ThrownByName: self.ThrownBy=Bladex.GetEntity(ThrownByName)
			if SpinSoundName: self.spinsound=Bladex.GetEntity(SpinSoundName)
			
		else:
			self.Name="Unnamed"

	def SetTarget(self, TargetName):
		enemy= Bladex.GetEntity(TargetName)
		#print "setting target to "+TargetName
		#print enemy
		if enemy:
			self.Target= enemy.GraspPos ("ViewPoint")
			#print self.Target

###############################################################
#<font color="green">insert code here:
		head_pos=me.Rel2AbsPoint(0.0,0.0,5000.0) 
		pj_dir=me.Rel2AbsVector(0.0,-1.0,0.0)
		for ename in Bladex.GetEnemiesVisibleFrom(head_pos,50000,pj_dir,0.0):
		        ent=Bladex.GetEntity(ename)
			if ent.Person:
		                dist=B3DLib.GetXZDistance('Player1', ent.Name)
			        if ent.Life>0 and dist>3000:
		                        targetlist.append(ename)
		                        target=Bladex.GetEntity(targetlist[0])</font id="green">

#############################################################
	
	def ThrowReleaseEventHandler (self,EntityName,EventName):
		
		weapon= Bladex.GetEntity(self.Name)
		if not weapon:
			return
		self.OwnerName= weapon.Parent
		if not self.OwnerName:
			return
		owner=Bladex.GetEntity(self.OwnerName)
		if not owner or owner.InvRight != self.Name:
			return

		if owner.ActiveEnemy:
			enemy = Bladex.GetEntity(owner.ActiveEnemy)
			if enemy and enemy.Person:
				TargetPos= enemy.GraspPos ("ViewPoint")
		else:
			TargetPos= owner.Rel2AbsPoint(0,-10000.0,0.0)
	
		if weapon.TestHit:
			return

		Actions.RemoveFromInventory (owner, weapon, EventName)
		
		SourcePos= weapon.Position
		# target one metre past the enemies head
		offsetx,offsety,offsetz= B3DLib.Scale(B3DLib.Normalize((TargetPos[0]-SourcePos[0], 

TargetPos[1]-SourcePos[1], TargetPos[2]-SourcePos[2])), 1000.0)
		TargetPos= TargetPos[0]+offsetx, TargetPos[1]+offsety, TargetPos[2]+offsetz

		self.C= (SourcePos[0]+TargetPos[0])*0.5, (SourcePos[1]+TargetPos[1])*0.5, (SourcePos

[2]+TargetPos[2])*0.5
		self.TimeWeaponStarted= Bladex.GetTime()
		self.R= SourcePos[0]-self.C[0], SourcePos[1]-self.C[1], SourcePos[2]-self.C[2]
		self.RSQdist= abs(self.R[0]**2.0+self.R[1]**2.0+self.R[2]**2.0)
		moduloR= math.sqrt(self.RSQdist)
		scale= (moduloR/8.0) / math.sqrt(self.R[2]*self.R[2]+self.R[0]*self.R[0])
		self.Rn= -self.R[2]*scale, 0.0, self.R[0]*scale
		self.w = self.Speed / moduloR
		Bladex.SetAfterFrameFunc("DalWeaponMoveWeapon", self.MoveWeapon)
		self.WeaponActive= 0
		self.grasped= 0
		self.tFinished= Actions.TWOPI/self.w
		self.Weapon= weapon
		self.ThrownBy= owner  # this pointer may not be valid
		self.Time2Grasp= Bladex.GetAnimationDuration("Dgk_catch")*0.239 # currently 0.239 is 

the point for the catch
		self.spinsound.PlaySound(-1)
		weapon.MessageEvent(Reference.MESSAGE_STOP_WEAPON,0,0)
		
	def MoveWeapon (self, time):
		self.Weapon.RemoveFromWorld()
		t= time-self.TimeWeaponStarted
		wt= self.w*t
		cos_wt= math.cos(wt)
		sin_wt= math.sin(wt)
		P= self.R[0]*cos_wt + self.Rn[0]*sin_wt, self.R[1]*cos_wt + self.Rn[1]*sin_wt, self.R[2]*cos_wt 

+ self.Rn[2]*sin_wt
		self.Weapon.Position= P[0]+self.C[0], P[1]+self.C[1], P[2]+self.C[2]
		
		if wt>=Actions.TWOPI:
			owner=Bladex.GetEntity(self.OwnerName)
			if owner:
				inv= owner.GetInventory()
				inv.AddWeapon(self.Weapon.Name)
				if not owner.InvRight:
					inv.LinkRightHand(self.Weapon.Name)
			Bladex.RemoveAfterFrameFunc("DalWeaponMoveWeapon")
		elif wt >= Actions.PI*1.5:
			if self.WeaponActive:
				self.Weapon.MessageEvent(Reference.MESSAGE_STOP_WEAPON,0,0)
				self.Weapon.MessageEvent(Reference.MESSAGE_STOP_TRAIL,0,0)
				self.WeaponActive= 0
		elif wt >= Actions.PI and self.WeaponActive:
			owner=Bladex.GetEntity(self.OwnerName)
			if owner and owner.SQDistance2(self.Weapon) < self.RSQdist/2.0:
				self.Weapon.MessageEvent(Reference.MESSAGE_STOP_WEAPON,0,0)
				self.Weapon.MessageEvent(Reference.MESSAGE_STOP_TRAIL,0,0)
				self.WeaponActive= 0
		elif wt >= Actions.PI*0.5:
			if not self.WeaponActive:
				self.Weapon.MessageEvent

(Reference.MESSAGE_START_WEAPON,0,0)
				self.Weapon.MessageEvent(Reference.MESSAGE_START_TRAIL,0,0)
				self.WeaponActive= 1
		
		if (not self.grasped) and t+self.Time2Grasp >= self.tFinished:
			self.grasped=1
			self.spinsound.StopSound()
			owner=Bladex.GetEntity(self.OwnerName)
			if owner and owner.Life>0:
				owner.Wuea=Reference.WUEA_ENDED
				owner.InterruptCombat()
				owner.LaunchAnmType("catch")
			else:
				self.Weapon.MessageEvent(Reference.MESSAGE_STOP_WEAPON,0,0)
				self.Weapon.MessageEvent(Reference.MESSAGE_STOP_TRAIL,0,0)
				self.WeaponActive= 0
				self.Weapon.Impulse(0,10,0)
				Bladex.RemoveAfterFrameFunc("DalWeaponMoveWeapon")
		# Angular velocity
		self.Weapon.RotateRel(0.0, 0.0, 0.0 ,self.Axis[0],self.Axis[1],self.Axis[2],self.Spin,1)
----------------------------------------------------------------
When I go into the game,I still cannot attack the enemy in the high position with my boomerangweapon, because I cannot lock onto them.

So what should I do ? [B)]
How Can I attack the badguys in the high pos or in the distant Pos ?
If I cannot lock on the enemy,how to attack them?
Thanks very much and Look forward your reply![:)]

Sir Random
Dragon
Posts: 737
Joined: Thu Nov 15, 2001 12:58 am
Location: Ireland
Contact:

Post by Sir Random »

<blockquote id="quote"><font size="1" face="Verdana, Arial, Helvetica" id="quote">quote:<hr height="1" noshade id="quote"><i>Originally posted by mingyue1371</i>

When I go into the game,I still cannot attack the enemy in the high position with my boomerangweapon, because I cannot lock onto them.

So what should I do ? [B)]
How Can I attack the badguys in the high pos or in the distant Pos ?
If I cannot lock on the enemy,how to attack them?
Thanks very much and Look forward your reply![:)]
<hr height="1" noshade id="quote"></font id="quote"></blockquote id="quote">
You could try editing 'Select.py'

Find this function:

Code: Select all

def SelectNextEnemy(pj):
 chartype = Bladex.GetCharType(pj.CharType,pj.CharTypeExt)
 MAX_VISIBLE_ENEMIES_DISTANCE=chartype.MaxCombatDist
 head_pos=pj.Rel2AbsPoint(0.0,0.0,0.0) #,"Head")
 pj_dir=pj.Rel2AbsVector(0.0,-1.0,0.0)
 list=Bladex.GetEnemiesVisibleFrom(head_pos,<font color="red">MAX_VISIBLE_ENEMIES_DISTANCE</font id="red">,pj_dir,<font color="red">0.0</font id="red">)
 list=map(None,list,map(GetEnemiesScorerData,list))
 pj.Data.visible_enemies=list
 if(len(pj.Data.visible_enemies)):
  ShortEnemiesList(pj)
  if(pj.Data.enemy_locked and pj.Data.selected_enemy):
   target=GetNextFromList(pj.Data.selected_enemy,list)
   if(not target):
    pj.Data.enemy_locked=FALSE
    pj.Data.selected_enemy=pj.Data.visible_enemies[0]
   else:
    pj.Data.selected_enemy=target
  else:
   pj.Data.selected_enemy=pj.Data.visible_enemies[0]
 else:
  pj.Data.enemy_locked=FALSE
  pj.Data.selected_enemy=None
Change <font color="red">MAX_VISIBLE_ENEMIES_DISTANCE</font id="red"> to whatever distance you want (50000.0)

Change the <font color="red">0.0</font id="red"> to 20000.0 and see if that lets you select enemies above/below you.

EDIT\
You will also need to make the same changes to the function above that one:
def SelectNextEnemy(pj)



This won't make your thrown weapons fly up or down, that requires more work...

User avatar
mingyue1371
Dragon
Posts: 206
Joined: Fri Aug 05, 2011 4:46 pm
Location: China
Contact:

Post by mingyue1371 »

Hi SR,
I had tried as your said:

Code: Select all


def SelectNext(pj):
	global Gpj
	Gpj=pj
	head_pos=pj.Rel2AbsPoint(0.0,0.0,0.0,"Head")
	pj_dir=pj.Rel2AbsVector(0.0,-1.0,0.0)
	list=Bladex.GetObjectEntitiesVisibleFrom(head_pos,<font color="red">50000.0</font id="red">,pj_dir,<font color="red">20000.0</font id="red">)
	list=map(None,list,map(GetSelectionData,list))
	list=filter(IsValidForSelection,list)

	if(pj.Data.selection_locked and pj.Data.selected_entity):
		target=GetFromList(pj.Data.selected_entity,list)
		if(not target):
			pj.Data.selection_locked=FALSE
			target=GetMoreInterestingEntity(pj,list)
		else:
			target=GetNextMoreInterestingEntity(pj,list,pj.Data.selected_entity)
			if(not target):
				target=GetMoreInterestingEntity(pj,list)
	else:
		pj.Data.selection_locked=FALSE
		target=GetMoreInterestingEntity(pj,list)
	
	pj.Data.selected_entity=target

	if(target):
		pj.LookAtEntity(target[0])
	else:
		pj.LookAtEntity("")
		pj.StopLooking()


def AutoSelect(pj):
	global Gpj
	Gpj=pj
	head_pos=pj.Rel2AbsPoint(0.0,0.0,0.0,"Head")
	pj_dir=pj.Rel2AbsVector(0.0,-1.0,0.0)
	list=Bladex.GetObjectEntitiesVisibleFrom(head_pos,<font color="red">50000.0</font id="red">,pj_dir,<font color="red">20000.0</font id="red">)
	list=map(None,list,map(GetSelectionData,list))
	list=filter(IsValidForSelection,list)

	if(pj.Data.selection_locked and pj.Data.selected_entity):
		target=GetFromList(pj.Data.selected_entity,list)
		if(not target):
			pj.Data.selection_locked=FALSE
			target=GetMoreInterestingEntity(pj,list)
	else:
		pj.Data.selection_locked=FALSE
		target=GetMoreInterestingEntity(pj,list)
	
	pj.Data.selected_entity=target


def GetEnemiesScorerData(entity_name):
	entity=Bladex.GetEntity(entity_name)
	if(Reference.EnemiesScorerData.has_key(entity_name)):
		return(Reference.EnemiesScorerData[entity_name])
	elif(Reference.EnemiesDefaultScorerData.has_key(entity.MeshName)):
		return(Reference.EnemiesDefaultScorerData[entity.MeshName])
	else:
		if(Reference.EnemiesDefaultScorerData.has_key(entity.Kind)):
			return(Reference.EnemiesDefaultScorerData[entity.Kind])
		else:
			return(None)

def Distance2Pj(enemy_entry):
	global Gpj
	enemy=Bladex.GetEntity(enemy_entry[0])
	return(Gpj.SQDistance2(enemy))


def ShortEnemiesList(pj):
	global Gpj
	Gpj=pj	
	list=pj.Data.visible_enemies
	if(len(list)):
		distances=map(Distance2Pj,list)
		for i in range(len(list)-1):
			for j in range(len(list)-1):
				if(distances[j]>distances[j+1]):
					tmp=distances[j]
					distances[j]=distances[j+1]
					distances[j+1]=tmp
					tmp=list[j]
					list[j]=list[j+1]
					list[j+1]=tmp
				


def SelectNextEnemy(pj):
	chartype = Bladex.GetCharType(pj.CharType,pj.CharTypeExt)
	MAX_VISIBLE_ENEMIES_DISTANCE=chartype.MaxCombatDist
	head_pos=pj.Rel2AbsPoint(0.0,0.0,0.0) #,"Head")
	pj_dir=pj.Rel2AbsVector(0.0,-1.0,0.0)
	list=Bladex.GetEnemiesVisibleFrom(head_pos,<font color="red">50000.0</font id="red">,pj_dir,<font color="red">20000.0</font id="red">)
	list=map(None,list,map(GetEnemiesScorerData,list))
	pj.Data.visible_enemies=list
	if(len(pj.Data.visible_enemies)):
		ShortEnemiesList(pj)
		if(pj.Data.enemy_locked and pj.Data.selected_enemy):
			target=GetNextFromList(pj.Data.selected_enemy,list)
			if(not target):
				pj.Data.enemy_locked=FALSE
				pj.Data.selected_enemy=pj.Data.visible_enemies[0]
			else:
				pj.Data.selected_enemy=target
		else:
			pj.Data.selected_enemy=pj.Data.visible_enemies[0]
	else:
		pj.Data.enemy_locked=FALSE
		pj.Data.selected_enemy=None


import pdb

def GetVisibleEnemies(pj):
	head_pos=pj.Rel2AbsPoint(0.0,0.0,0.0) #,"Head")
	
	if ( pj.AnimName=="g_back" or pj.AnimName=="g2h_back") and pj.AnmPos>0.6:	
		dir_y=1.0		
	else:
		dir_y=-1.0
	chartype = Bladex.GetCharType(pj.CharType,pj.CharTypeExt)
	MAX_VISIBLE_ENEMIES_DISTANCE=chartype.MaxCombatDist
	pj_dir=pj.Rel2AbsVector(0.0,dir_y,0.0)
	list=Bladex.GetEnemiesVisibleFrom(head_pos,MAX_VISIBLE_ENEMIES_DISTANCE,pj_dir,0.0)
	list=map(None,list,map(GetEnemiesScorerData,list))
	pj.Data.visible_enemies=list
	if(len(pj.Data.visible_enemies)):
		ShortEnemiesList(pj)
		if(pj.Data.enemy_locked and pj.Data.selected_enemy):
			target=GetFromList(pj.Data.selected_enemy,list)
			if(not target):
				pj.Data.enemy_locked=FALSE
				pj.Data.selected_enemy=pj.Data.visible_enemies[0]
		else:
			pj.Data.selected_enemy=pj.Data.visible_enemies[0]
	else:
		pj.Data.enemy_locked=FALSE
		pj.Data.selected_enemy=None

But things doesn't work.[:(]
Still I cannot lock onto the high Pos enemies, so the archers shot me with arrows,but I cannot attack him with my powerful Boomerangweapon.[xx(]
Canyou improve it SR?
Thx![^]

User avatar
mingyue1371
Dragon
Posts: 206
Joined: Fri Aug 05, 2011 4:46 pm
Location: China
Contact:

Post by mingyue1371 »

<blockquote id="quote"><font size="1" face="Verdana, Arial, Helvetica" id="quote">quote:<hr height="1" noshade id="quote"><i>Originally posted by prospero</i>

As far as I know there is no way of locking onto enemies that are above a certain angle. What you can do is insert some code into the boomerang code so that if you aren't locked to an enemy, you can 'scan' for enemies in sight and target the nearest. There is a ery useful built-in finction in the engine.

this the basic code:

Code: Select all

head_pos=me.Rel2AbsPoint(0.0,0.0,5000.0) 
pj_dir=me.Rel2AbsVector(0.0,-1.0,0.0)
for ename in Bladex.GetEnemiesVisibleFrom(head_pos,50000,pj_dir,0.0):
    ent=Bladex.GetEntity(ename)
        if ent.Person:
            dist=B3DLib.GetXZDistance('Player1', ent.Name)
		if ent.Life>0(ent.Name) and dist>3000:
    targetlist.append(ename)
The targetlist mat be empty, or it may contain the names of multple chars. You can select the first in the list:

target=Bladex.GetEntity(targetlist[0])

or put in clauses to select nearest/most life/archers and exclude any Allies.

<hr height="1" noshade id="quote"></font id="quote"></blockquote id="quote">

I want to know How to 'scan' for enemies in sight and target the nearest?
Can the high pos enemy be locked on with this method?
If so, What exactly I should do?

User avatar
prospero
Ancient Dragon
Posts: 1800
Joined: Wed Nov 21, 2001 1:42 am
Location: United Kingdom

Post by prospero »

There is a 'ChooseNearest' function that puts the nearest enemy at the front of the list. (Index[0])

You can also sort the list to pick most life/least life - anything you want.

It won't 'lock on' to the enemy, but it you are using magic Hunter Seeker missiles you can elect the enemy as the missile target.

I've been adding a few tweaks to the Chaos Knight missiles. Five different varieties at the moment with different special damage. Also, you can select scatter missiles so that the missiles splits into as many missiles as there are viable targets. The total damage of the multi missiles is the same as a single one.

User avatar
mingyue1371
Dragon
Posts: 206
Joined: Fri Aug 05, 2011 4:46 pm
Location: China
Contact:

Post by mingyue1371 »

Still dont know how to do it .[:(]
Can you show me more exactly which file I should put the code and how to use the function ?[B)]
Should I press a key on the keyboard to enable the 'ChooseNearest' function just like pressing a num0 to lock on a enemy?
Have you finished your Chaos Knight model ? if so ,can you give a link to have a go?[:D]
THx[:D]

Sir Random
Dragon
Posts: 737
Joined: Thu Nov 15, 2001 12:58 am
Location: Ireland
Contact:

Post by Sir Random »

The idea is that the 'boomerang' chooses the nearest enemy when you throw it. You don't have to be locked-on to an enemy, just have it in sight.
The code should be put in the boomerang class, or in whatever function is called by the ThrowReleaseEventHandler (when the player lets go of the boomerang).

User avatar
prospero
Ancient Dragon
Posts: 1800
Joined: Wed Nov 21, 2001 1:42 am
Location: United Kingdom

Post by prospero »

<blockquote id="quote"><font size="1" face="Verdana, Arial, Helvetica" id="quote">quote:<hr height="1" noshade id="quote"><i>Originally posted by mingyue1371</i>

Still dont know how to do it .[:(]
Can you show me more exactly which file I should put the code and how to use the function ?[B)]
Should I press a key on the keyboard to enable the 'ChooseNearest' function just like pressing a num0 to lock on a enemy?
Have you finished your Chaos Knight model ? if so ,can you give a link to have a go?[:D]
THx[:D]


<hr height="1" noshade id="quote"></font id="quote"></blockquote id="quote">

Mingyue. Your question is far too general for a simple answer. I hope you don't mind me saying this, but I feel you are attempting very complex coding without a basic understanding of how the code works.
Things rarely work first time. A great deal of patience is needed. I am only to happy to help if you have a more specific problem with the code. [8)]

User avatar
mingyue1371
Dragon
Posts: 206
Joined: Fri Aug 05, 2011 4:46 pm
Location: China
Contact:

Post by mingyue1371 »

OK and THx pro!
Now I had a specific problem :
I want enable the Ork spit fire balls like Slm,so I mod these files below:

Code: Select all

[Lib\OrkAnimationSet.py]
add:

	anm_name="Ldm_g_spit"
	Bladex.LoadSampledAnimation("..\\..\\Anm\\Ldm_g_spit.BMV","Ork_g_spit",0)        
	Bladex.AddAnmRStep(anm_name,0)     
	Bladex.AddAnmLStep(anm_name,0)     
	Bladex.AddAnmRRelease(anm_name,0.007) 
	Bladex.AddAnmRStep(anm_name,0.201)    
	Bladex.AddAnmRRelease(anm_name,0.740) 
	Bladex.AddAnmRStep(anm_name,0.928)

[anm_def.py]:
    Bladex.AddAnmEvent("Ork_g_spit","Spit",0.470)
    Bladex.AddAnmEvent("Ork_g_spit","HitInitialItp",0.183)
    Bladex.AddAnmEvent("Ork_g_spit","HitFinalItp",0.910)
    Bladex.AddAnmEvent("Ork_g_spit","Start_Weapon",0.405)
    Bladex.AddAnmEvent("Ork_g_spit","Stop_Weapon",0.911)
    
[OrkBAct.py]
Bladex.AddBipedAction("Ork","g_spit","Ork_g_spit",0.0,1.0,0)

[OrkCombos.py]
Bladex.SetActionEventTable("Ork","g_spit","ATTACKING")

ork.AddAttack("g_spit","Ork_g_spit")
ork.AttackTypeFlag("g_spit",ATK_UNIQUE)
[combat.py]

OrkAttackData =	[ 
           # inner zone blocks:
            ......
           # attacks:
        [ATTACKDOWN, 1.00, ("STAIRS",),         1200.0, 1800.0, 2500.0, 0.35],

          <font color="green">  [ATTACK, 0.01, ("g_spit",),          200.0, 1500.0, 3950.0, 0.35],
            [ATTACK, 0.02, ("g_spit",),          500.0, 1500.0, 2274.0, 0.35],
            [ATTACK, 0.04, ("g_spit",),          3000.0,9000.0,10000.0, 0.35],</font id="green">            
            [ATTACK, 0.50, ("g_01",),            765.0, 2397.5, 3265.0, 0.35],
            [ATTACK, 0.40, ("g_02",),            873.0, 2123.0, 3373.0, 0.35],
            [ATTACK, 0.40, ("g_06",),            764.0, 2014.0, 3264.0, 0.35],
            [ATTACK, 0.20, ("g_15",),            844.0, 2094.0, 3344.0, 0.35],
            [ATTACK, 0.20, ("g_16",),            243.0, 1493.0, 2743.0, 0.35],
            [ATTACK, 0.15, ("g_18",),           1917.0, 3167.0, 4417.0, 0.35],
            [ATTACK, 0.60, "RespectDistance",      0.0,  500.0, 1200.0, 1.00,1],
            ......

[EnemyTypes.py]
################################################################################
# Define the Ork class
################################################################################
class Ork (Enm_Def.NPCPerson):
	.......
################################################################################
	def FirePrtlHit(self,prtl_name,hit_entity,x,y,z,vx,vy,vz,wcx,wcy,wcz,wdx,wdy,wdz):
		if hit_entity != "BWorld":
			victim=Bladex.GetEntity(hit_entity)
			if victim: 
				#if victim.Person and not victim.Kind=="Salamander":
				if victim.Person and not victim.Kind=="Ork":
					Reference.EntitiesObjectData[prtl_name]= [Reference.OBJ_WEAPON, 0, 0,   1.0,  Reference.THR_STRAIGHT, Reference.W_FLAG_1H, ["Fire", 

+6.0]]
					victim.DamageFunc(hit_entity, self.Name, prtl_name, "Fire", 1, -1, x, y, z, 0)
					if Reference.EntitiesObjectData.has_key(prtl_name):
						del Reference.EntitiesObjectData[prtl_name]

					# Generate a smoke effect
					smoke=Bladex.CreateEntity("FireballSmoke", "Entity Particle System D1", x, y, z)
					smoke.ParticleType="DarkSmoke"
					smoke.YGravity=-3000.0
					smoke.Friction=0.05
					smoke.PPS=8
					smoke.Velocity=0.0, -80.0, 0.0
					smoke.RandomVelocity=5.0
					smoke.DeathTime=Bladex.GetTime()+0.5
					node= 0
					victim.LinkToNode(smoke,node)
					
					# Override hurt anim
					if victim.Life>0:
						Damage.DropInvalidObjectsOnImpact (victim.Name)
						victim.Wuea=Reference.WUEA_ENDED
						if victim.InCombat: 
							victim.InterruptCombat()
							victim.LaunchAnmType("hurt_f_big")
						else: 
							victim.LaunchAnmType("hurt_f_big")
				#elif victim.Weapon:
					#pass
		# This particle should be removed, as it has been converted to smoke
		ptcl=Bladex.GetEntity(prtl_name)
		ptcl.RemoveFromWorld()
			
		
	def SpitFunc(self, fireball_name,end_time,period):
		fireball=Bladex.GetEntity(fireball_name)
		if(fireball):
			prtl=fireball.GetParticleEntity()
			prtl.HitFunc=self.FirePrtlHit
			prtl.ObjCTest= 1
			if(Bladex.GetTime()<end_time):
				Bladex.AddScheduledFunc(Bladex.GetTime()+period,self.SpitFunc,(fireball_name,end_time,period))
				
	def StartSpit (self,EntityName,EventName):
		me = Bladex.GetEntity(EntityName)
		if me.InCombat: 
			SQDistance= me.SQDistance2(Bladex.GetEntity(me.GetEnemyName()))
			max_firefan_dist= 4000.0
			
			# Get an angle to the target
			target= Bladex.GetEntity(me.GetEnemyName())
			target_pos= target.Position
			x,y,z= me.GraspPos("ViewPoint")
			angle= -B3DLib.GetYAngle(target_pos[0]-x,target_pos[1]-y,target_pos[2]-z)
			
			if  SQDistance < (max_firefan_dist*max_firefan_dist):
				# fan out spit
				duration= 0.3
				self.AGE_Number=self.AGE_Number+1
				end_time=Bladex.GetTime()+duration
				period= duration/10.0
				fireball=Bladex.CreateEntity(EntityName+"_Firefanl_"+`self.AGE_Number`,"Entity Particle System D1",x,y,z)
				fireball.ParticleType="Flame"
				fireball.Time2Live=20
				fireball.YGravity=-4900.0
				fireball.Friction=0.12
				fireball.PPS=512
				fireball.DeathTime=end_time;
				F= 5400.0             # Vector magnitude
				vx,vy,vz=me.Rel2AbsVector(0.0, -math.cos(angle)*F, -math.sin(angle)*F)
				fireball.Velocity=vx,vy,vz
				fireball.RandomVelocity=55.0
				self.SpitFunc(fireball.Name, end_time, period)
			else:
				# fireball spit
				nparticles= 70
				duration= 2.0/60.0 # I think this is a minimum
				self.AGE_Number=self.AGE_Number+1
				end_time=Bladex.GetTime()+duration
				period= duration/7.0
				fireball=Bladex.CreateEntity(EntityName+"_Fireball_"+`self.AGE_Number`,"Entity Particle System D1",x,y,z)
				fireball.ParticleType="LargeFire"
				fireball.Time2Live=30
				fireball.YGravity=-400.0
				fireball.Friction=0.075
				fireball.PPS=nparticles/duration
				fireball.DeathTime=end_time;
				F= 25000.0             # Vector magnitude
				vx,vy,vz=me.Rel2AbsVector(0.0, -math.cos(angle)*F, -math.sin(angle)*F)
				fireball.Velocity=vx,vy,vz
				fireball.RandomVelocity=15.0
				self.SpitFunc(fireball.Name, end_time, period)
.......
################################################################################
But when I go into the game and came across the Ork ,I can see the badguys attack me and at the same time the game will crash and quit without any tips.
Anything wrong with the code?

Sir Random
Dragon
Posts: 737
Joined: Thu Nov 15, 2001 12:58 am
Location: Ireland
Contact:

Post by Sir Random »

I don't think Ldm anims will work with Orcs, try Glm_spit.

Post Reply