Destruction test mod (custom Barb)

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

Yvan98
Dragon
Posts: 52
Joined: Mon Apr 30, 2007 1:45 pm
Location: Canada

Post by Yvan98 »

I've got a problem with the GotoMapVars code:

Code: Select all

Traceback (innermost last):
  File "DefFuncs.py", line 840, in EndOfPart1
    GotoMapVars.EndOfLevel("Destruction_M2")	
TypeError: no arguments expected

It's also not work with the 'os' code...

Yvan98
Dragon
Posts: 52
Joined: Mon Apr 30, 2007 1:45 pm
Location: Canada

Post by Yvan98 »

Hey pro,

I think it's impossible to use the file 'GotoMapVars.py' with custom character. In your map 'WizardDomain' you have create a new file 'WizGotoMapVars.py' so i have create a new file 'BarbGotoMapVars.py'.


Now i've got a problem with the 'Valkyrie Sword':

Code: Select all

Traceback (innermost last):
  File "Cfg.py", line 45, in ?
    execfile("..\\..\\Scripts\\BarbBladeInit.py")
  File "..\..\Scripts\BarbBladeInit.py", line 85, in ?
    if not BarbGotoMapVars.BeginLevel():  ## Checks for saved info from previous map
  File "..\..\Scripts\BarbGotoMapVars.py", line 294, in BeginLevel
    pj=RestoreMainCharState('MainChar')
  File "..\..\Scripts\BarbGotoMapVars.py", line 236, in RestoreMainCharState
    CreateMainCharWithProps(props)
  File "..\..\Scripts\BarbGotoMapVars.py", line 186, in CreateMainCharWithProps
    flag=Reference.GiveWeaponFlag(i[0])
  File "..\..\Lib\Reference.py", line 1151, in GiveWeaponFlag
    object_data = DefaultObjectData[object.Kind]
KeyError: ProSword16

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

Post by prospero »

Ah..... Now I remember what I originaly made the obj_def.py file for.[:)] It was so new objects could be referenced before the BladeInit.py file. I also seem to have made modded BladeInit.py files
(MyMapBladeInit.py) that have to be installed in Scripts folder, basically replacing this code:

Code: Select all

print "Init PJ"
#
# PJ Init
#
import GotoMapVars
if string.lower(Bladex.GetCurrentMap()) in ['tutorial','2dmap','casa','barb_m1','ragnar_m2','dwarf_m3','ruins_m4']: # Caso especial
  execfile("pj.py")
  print "Found 2DMap"
elif not GotoMapVars.BeginLevel():
  execfile("pj.py")
print "Initted PJ"
with this:

Code: Select all

import MyMapGotoMapVars

if not MyMapGotoMapVars.BeginLevel():  ## Checks for saved info from previous map
  execfile("pj.py")
print "Initted PJ MyMap"
An in cfg.py file...

Code: Select all

execfile("..\\..\\Scripts\sys_init.py")

Bladex.ReadLevel("MyMap.lvl")

execfile("..\\..\\Scripts\<font color="yellow">MyMapBladeInit.py</font id="yellow">")
Then:

Code: Select all

import obj_def
obj_def.InitNewStuff()
Must go in cfg.py, <i>before</i> the MyMapBladeInit.py is exec'd
(and in ActorsInit.py for the save game.

That should solve it. (I think)[8)]

Sorry I'm a bit vague but it's a while since I did this....

Yvan98
Dragon
Posts: 52
Joined: Mon Apr 30, 2007 1:45 pm
Location: Canada

Post by Yvan98 »

Thank Prospero!

It's work[8D]

For the BladeInit.py, check my last reply...BarbBladeInit.py[:p]

Now there still a little problem to fix before i start adding object, music, enemies... How you can keep the 'Scale' of all weapon like in Destruction map[?]

Ex. The Valkyrie Sword got a Scale of 1.3 and all 3 'Espadamagica' got a Scale of 1.5...

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

Post by prospero »

[:p] Some knotty problems tonite.[B)]

OK. In the WizGotoMapVars I modded the function CreateEntAux to apply the correct Data to the wizard gear. There are such clauses as this:

Code: Select all

if obj_tuple[1]=="ProStaff1":
    obj.Data=MasklinMagic.WizardStaff(obj)
You could use this:

Code: Select all

if obj_tuple[1]=="ProSword16":		
    obj.Scale=1.3
This will only effect the weapons in the Player Inventory.

Yvan98
Dragon
Posts: 52
Joined: Mon Apr 30, 2007 1:45 pm
Location: Canada

Post by Yvan98 »

Thanks! Work perfectly [:D]

Yvan98
Dragon
Posts: 52
Joined: Mon Apr 30, 2007 1:45 pm
Location: Canada

Post by Yvan98 »

I have been able to make work the 'Chaos map' using all original file.

Lots of work.....and lots of bugs[B)]

There still only one to fix but i can't see how?

Code: Select all

Traceback (innermost last):
  File "DefFuncs.py", line 2237, in RompeAltarPiedra
    Breakings.ExplodeSpecialObject(altar.Name,20000,(-50000,-50000,0))
NameError: altar
Later: Bug fix...

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

Post by prospero »

When you get a NameError it's means that the variable 'altar' has not been declared.

The Altar in question is not created with all the other objects on map load. It is created in this function: DefFuncs line 3061

Code: Select all

def CreaAltar():
	global altar

	altar=Bladex.CreateEntity("Altar","Altar",940435.329945, 341861.349989, 169868.344306,"Physic")
	altar.Scale=1.000000
	altar.Solid=0
	altar.Orientation=0.500000,0.500000,0.500000,-0.500000
	Breakings.SetBreakable(altar.Name,12,100)
So until you call this function the reference 'altar' does not exist.

Yvan98
Dragon
Posts: 52
Joined: Mon Apr 30, 2007 1:45 pm
Location: Canada

Post by Yvan98 »

I find i lot of bugs like that[B)]

The problem is that in 'main game', some files are created with less then 50 lines, so i try to copied the block of code from them into another file (to minimize the number of file).
Ex. In 'Chaos_M17' there is something like 3 files that contain some code for doors and gates, so i put all of them into one file.

When i begin, i was going file by file adding all the block of code into 'DefFuncs.py' but it is possible that i have not respect the order...that the programmers did (Definiciones para puente.py).

But now it's work[8D]

I have remove this block of code and put into 'breaks.py'.

If you check into the 'DefFuncs.py' file (of the main game), you are going to see that many enemies, sounds, objects etc. are create directly from this file and execute later. But when you try it in custom map, you get a lot of 'NameError' or some weird bugs.

This is why i have write that it was a lot of job, i must take all those block of code into a separate file.

Now i'm ready to add more enemies and change the music[:p]

btw. The Darklord work fine[:D]

Daxon
Dragon
Posts: 129
Joined: Tue Nov 23, 2004 5:12 pm
Location: Spain

Post by Daxon »

haha Yvan86 [:D]

So, its true that we can remake blade maps??(Ididnt play pros arena5 :\ i reinstalled blade recently [:I]).

Is possible to make a ''shop maps'' between the campaing?

Yvan98
Dragon
Posts: 52
Joined: Mon Apr 30, 2007 1:45 pm
Location: Canada

Post by Yvan98 »

I'm sure that it's possible to make it work with custom maps...

Only need to copy the folder '2Dmap', rename it and edit file by file.

Yvan98
Dragon
Posts: 52
Joined: Mon Apr 30, 2007 1:45 pm
Location: Canada

Post by Yvan98 »

Need help again[:I]

I'm trying to create a new function with the "Snake Medallion".

Ok, in obj_def.py i've got:

Code: Select all

class Amuletoserpiente (ItemTypes.ItemOfProtection):
	def __init__ (self, me):
		ItemOfProtection.__init__(self, me)
		self.UsedBy= "Player1"
		self.UseTime= 45.0
		self.Resistances= {}
		self.nUses= 2


	def UseStart (self, ObjectName, use_from):
		ItemOfProtection.UseStart (self, ObjectName, use_from)
		Bladex.GetEntity("Player1").Data.FDefense = 1.01
		Bladex.GetEntity("Player1").Data.FAttack  = 1.01
		# Manuel, quieres poner algun efecto magico aqui

	def UseEnd (self,ObjectName, UserName):
		# Manuel, termina el efecto magico aqui
		ItemOfProtection.UseEnd (self, ObjectName, UserName)

	def __init__(self, PersonName, ItemName, TimeEffect):
		pers=Bladex.GetEntity(PersonName)
		item=Bladex.GetEntity(ItemName)
		time=Bladex.GetTime()
		self.PersonName=PersonName
		self.ItemName=ItemName

		AuraParams0=(240, 0.01, 1.0, 0, 1, 1)
		AuraParams1=(50 , 1.0 , 1.0, 0, 1, 1)
		AuraParams2=(40 , 0.6 , 1.0, 0, 1, 1)

		XtraParam0=('Bladex.GetEntity("'+PersonName+'").SelfIlum', 0.0)
		XtraParam1=('Bladex.GetEntity("'+PersonName+'").SelfIlum', 0.6)
		XtraParam2=('Bladex.GetEntity("'+PersonName+'").SelfIlum', 0.1)

		if item.Kind=="Amuletoserpiente":

			AuraGradient0=(2,  0.8, 0.6, 0.0, 1.0, 0.2  ,  0.4, 0.3, 0.0, 0.0, 0.7)
			AuraGradient1=(2,  1.0, 0.9, 0.5, 1.0, 0.1  ,  0.4, 0.3, 0.0, 0.0, 1.0)

			self.Aura=Auras.MakeAura(PersonName, TimeEffect, AuraParams0, (), (), AuraGradient0  ,  1,  XtraParam0)
			self.Aura.Data.AddEvent (time+1.0,               AuraParams1, (), (), AuraGradient1  ,  1,  XtraParam1)
			self.Aura.Data.AddEvent (time+TimeEffect-4.1,    AuraParams1, (), (), AuraGradient1  ,  1,  XtraParam1)
			self.Aura.Data.AddEvent (time+TimeEffect-3.6,    AuraParams2, (), (), AuraGradient1  ,  1,  XtraParam2)
			self.Aura.Data.AddEvent (time+TimeEffect-3.1,    AuraParams1, (), (), AuraGradient1  ,  1,  XtraParam1)
			self.Aura.Data.AddEvent (time+TimeEffect-2.7,    AuraParams2, (), (), AuraGradient1  ,  1,  XtraParam2)
			self.Aura.Data.AddEvent (time+TimeEffect-2.3,    AuraParams1, (), (), AuraGradient1  ,  1,  XtraParam1)
			self.Aura.Data.AddEvent (time+TimeEffect-2.0,    AuraParams2, (), (), AuraGradient1  ,  1,  XtraParam2)
			self.Aura.Data.AddEvent (time+TimeEffect-1.7,    AuraParams1, (), (), AuraGradient1  ,  1,  XtraParam1)
			self.Aura.Data.AddEvent (time+TimeEffect-1.5,    AuraParams2, (), (), AuraGradient1  ,  1,  XtraParam2)
			self.Aura.Data.AddEvent (time+TimeEffect-1.3,    AuraParams1, (), (), AuraGradient1  ,  1,  XtraParam1)
			self.Aura.Data.AddEvent (time+TimeEffect-1.2,    AuraParams2, (), (), AuraGradient1  ,  1,  XtraParam2)
			self.Aura.Data.AddEvent (time+TimeEffect-1.1,    AuraParams1, (), (), AuraGradient1  ,  1,  XtraParam1)
			self.Aura.Data.AddEvent (time+TimeEffect-1.05,   AuraParams2, (), (), AuraGradient1  ,  1,  XtraParam2)
			self.Aura.Data.AddEvent (time+TimeEffect-1.0,    AuraParams1, (), (), AuraGradient1  ,  1,  XtraParam1)
			self.Aura.Data.AddEvent (time+TimeEffect,        AuraParams0, (), (), AuraGradient0  ,  1,  XtraParam0)
		else:
			pass
...and i've got in dest2O.py:

Code: Select all

o=Bladex.CreateEntity("Amuletoserpiente_574","Amuletoserpiente",336345.118311,43973.2737021,-95003.8059653, Reference.ObjType("Amuletoserpiente"))
o.Scale=1.0
o.Orientation=(1.0,0.0,0.0,0.0)
import obj_def
obj_def.Amuletoserpiente(o)
But there is an error like:

Code: Select all

Traceback (innermost last):
  File "Cfg.py", line 63, in ?
    execfile("dest2O.py")
  File "dest2O.py", line 84, in ?
    obj_def.Amuletoserpiente(o)
TypeError: not enough arguments; expected 4, got 2
I should say that i try many code like:

Code: Select all

o.Data=obj_def.Amuletoserpiente(o.Name)
or

Code: Select all

obj_def.Amuletoserpiente(o.Name)
...but every time i have the error 'TypeError: not enough arguments; expected 4, got 2'

What's wrong?

Vasja
Dragon
Posts: 89
Joined: Mon Sep 05, 2005 6:47 pm

Post by Vasja »

Class Amuletoserpiente has 2 constructors.
The second constructor overwrites the first one.
Use the second __init__(self, PersonName, ItemName, TimeEffect) or write your own class.
And I can't understand class logics, if the class uses the second
constructor.

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

Post by prospero »

Yvan. Vasja is right. You are trying to hybridise 2 classes. It doesn't quite work that way.[;)]But you are on the right lines....

Here is the Power Gem/ProtectionGem code from ProArena1. You should be able to edit to your needs.

They are created though a handy little function:

CreatePowerGem(name, pos):

...which handles every thing for you. Pick a name, e.g "Medalion1" and a position in clear space II use the Player position)approximately where you want it...

CreatePowerGem("Medalion1",(2000,-3000,45000))

and the item is created, dropped to the floor and data applied including person FX.

Code: Select all

class PersonGemFX:

	def __init__(self, PersonName, ItemName, TimeEffect):
		pers=Bladex.GetEntity(PersonName)
		item=Bladex.GetEntity(ItemName)
		time=Bladex.GetTime()
		self.PersonName=PersonName
		self.ItemName=ItemName

		AuraParams0=(240, 0.01, 1.0, 0, 1, 1)
		AuraParams1=(50 , 1.0 , 1.0, 0, 1, 1)
		AuraParams2=(40 , 0.6 , 1.0, 0, 1, 1)

		XtraParam0=('Bladex.GetEntity("'+PersonName+'").SelfIlum', 0.0)
		XtraParam1=('Bladex.GetEntity("'+PersonName+'").SelfIlum', 0.3)
		XtraParam2=('Bladex.GetEntity("'+PersonName+'").SelfIlum', 0.7)

		if item.Kind=="Gemaazul":

			AuraGradient0=(2,  0.2, 0.4, 0.8, 1.0, 0.2  ,  0.0, 0.2, 0.8, 0.0, 0.7)
			AuraGradient1=(2,  0.8, 0.9, 1.0, 1.0, 0.2  ,  0.0, 0.2, 0.9, 0.1, 1.0)

			self.Aura=Auras.MakeAura(PersonName, TimeEffect, AuraParams0, (), (), AuraGradient0  ,  1,  XtraParam0)
			self.Aura.Data.AddEvent (time+1.0,               AuraParams1, (), (), AuraGradient1  ,  1,  XtraParam1)
			self.Aura.Data.AddEvent (time+TimeEffect-4.1,    AuraParams1, (), (), AuraGradient1  ,  1,  XtraParam1)
			self.Aura.Data.AddEvent (time+TimeEffect-3.6,    AuraParams2, (), (), AuraGradient1  ,  1,  XtraParam2)
			self.Aura.Data.AddEvent (time+TimeEffect-3.1,    AuraParams1, (), (), AuraGradient1  ,  1,  XtraParam1)
			self.Aura.Data.AddEvent (time+TimeEffect-2.7,    AuraParams2, (), (), AuraGradient1  ,  1,  XtraParam2)
			self.Aura.Data.AddEvent (time+TimeEffect-2.3,    AuraParams1, (), (), AuraGradient1  ,  1,  XtraParam1)
			self.Aura.Data.AddEvent (time+TimeEffect-2.0,    AuraParams2, (), (), AuraGradient1  ,  1,  XtraParam2)
			self.Aura.Data.AddEvent (time+TimeEffect-1.7,    AuraParams1, (), (), AuraGradient1  ,  1,  XtraParam1)
			self.Aura.Data.AddEvent (time+TimeEffect-1.5,    AuraParams2, (), (), AuraGradient1  ,  1,  XtraParam2)
			self.Aura.Data.AddEvent (time+TimeEffect-1.3,    AuraParams1, (), (), AuraGradient1  ,  1,  XtraParam1)
			self.Aura.Data.AddEvent (time+TimeEffect-1.2,    AuraParams2, (), (), AuraGradient1  ,  1,  XtraParam2)
			self.Aura.Data.AddEvent (time+TimeEffect-1.1,    AuraParams1, (), (), AuraGradient1  ,  1,  XtraParam1)
			self.Aura.Data.AddEvent (time+TimeEffect-1.05,   AuraParams2, (), (), AuraGradient1  ,  1,  XtraParam2)
			self.Aura.Data.AddEvent (time+TimeEffect-1.0,    AuraParams1, (), (), AuraGradient1  ,  1,  XtraParam1)
			self.Aura.Data.AddEvent (time+TimeEffect,        AuraParams0, (), (), AuraGradient0  ,  1,  XtraParam0)

		elif item.Kind=="Gemapurpura": # this is blue - should be purple

			AuraGradient0=(2,  0.2, 0.4, 0.8, 1.0, 0.2  ,  0.0, 0.2, 0.8, 0.0, 0.7)
			AuraGradient1=(2,  0.8, 0.9, 1.0, 1.0, 0.2  ,  0.0, 0.2, 0.9, 0.1, 1.0)

			self.Aura=Auras.MakeAura(PersonName, TimeEffect, AuraParams0, (), (), AuraGradient0  ,  1,  XtraParam0)
			self.Aura.Data.AddEvent (time+1.0,               AuraParams1, (), (), AuraGradient1  ,  1,  XtraParam1)
			self.Aura.Data.AddEvent (time+TimeEffect-4.1,    AuraParams1, (), (), AuraGradient1  ,  1,  XtraParam1)
			self.Aura.Data.AddEvent (time+TimeEffect-3.6,    AuraParams2, (), (), AuraGradient1  ,  1,  XtraParam2)
			self.Aura.Data.AddEvent (time+TimeEffect-3.1,    AuraParams1, (), (), AuraGradient1  ,  1,  XtraParam1)
			self.Aura.Data.AddEvent (time+TimeEffect-2.7,    AuraParams2, (), (), AuraGradient1  ,  1,  XtraParam2)
			self.Aura.Data.AddEvent (time+TimeEffect-2.3,    AuraParams1, (), (), AuraGradient1  ,  1,  XtraParam1)
			self.Aura.Data.AddEvent (time+TimeEffect-2.0,    AuraParams2, (), (), AuraGradient1  ,  1,  XtraParam2)
			self.Aura.Data.AddEvent (time+TimeEffect-1.7,    AuraParams1, (), (), AuraGradient1  ,  1,  XtraParam1)
			self.Aura.Data.AddEvent (time+TimeEffect-1.5,    AuraParams2, (), (), AuraGradient1  ,  1,  XtraParam2)
			self.Aura.Data.AddEvent (time+TimeEffect-1.3,    AuraParams1, (), (), AuraGradient1  ,  1,  XtraParam1)
			self.Aura.Data.AddEvent (time+TimeEffect-1.2,    AuraParams2, (), (), AuraGradient1  ,  1,  XtraParam2)
			self.Aura.Data.AddEvent (time+TimeEffect-1.1,    AuraParams1, (), (), AuraGradient1  ,  1,  XtraParam1)
			self.Aura.Data.AddEvent (time+TimeEffect-1.05,   AuraParams2, (), (), AuraGradient1  ,  1,  XtraParam2)
			self.Aura.Data.AddEvent (time+TimeEffect-1.0,    AuraParams1, (), (), AuraGradient1  ,  1,  XtraParam1)
			self.Aura.Data.AddEvent (time+TimeEffect,        AuraParams0, (), (), AuraGradient0  ,  1,  XtraParam0)

		elif item.Kind=="Gemayell":

			AuraGradient0=(2,  0.8, 0.6, 0.0, 1.0, 0.2  ,  0.4, 0.3, 0.0, 0.0, 0.7)
			AuraGradient1=(2,  1.0, 0.9, 0.5, 1.0, 0.1  ,  0.4, 0.3, 0.0, 0.0, 1.0)

			self.Aura=Auras.MakeAura(PersonName, TimeEffect, AuraParams0, (), (), AuraGradient0  ,  1,  XtraParam0)
			self.Aura.Data.AddEvent (time+1.0,               AuraParams1, (), (), AuraGradient1  ,  1,  XtraParam1)
			self.Aura.Data.AddEvent (time+TimeEffect-4.1,    AuraParams1, (), (), AuraGradient1  ,  1,  XtraParam1)
			self.Aura.Data.AddEvent (time+TimeEffect-3.6,    AuraParams2, (), (), AuraGradient1  ,  1,  XtraParam2)
			self.Aura.Data.AddEvent (time+TimeEffect-3.1,    AuraParams1, (), (), AuraGradient1  ,  1,  XtraParam1)
			self.Aura.Data.AddEvent (time+TimeEffect-2.7,    AuraParams2, (), (), AuraGradient1  ,  1,  XtraParam2)
			self.Aura.Data.AddEvent (time+TimeEffect-2.3,    AuraParams1, (), (), AuraGradient1  ,  1,  XtraParam1)
			self.Aura.Data.AddEvent (time+TimeEffect-2.0,    AuraParams2, (), (), AuraGradient1  ,  1,  XtraParam2)
			self.Aura.Data.AddEvent (time+TimeEffect-1.7,    AuraParams1, (), (), AuraGradient1  ,  1,  XtraParam1)
			self.Aura.Data.AddEvent (time+TimeEffect-1.5,    AuraParams2, (), (), AuraGradient1  ,  1,  XtraParam2)
			self.Aura.Data.AddEvent (time+TimeEffect-1.3,    AuraParams1, (), (), AuraGradient1  ,  1,  XtraParam1)
			self.Aura.Data.AddEvent (time+TimeEffect-1.2,    AuraParams2, (), (), AuraGradient1  ,  1,  XtraParam2)
			self.Aura.Data.AddEvent (time+TimeEffect-1.1,    AuraParams1, (), (), AuraGradient1  ,  1,  XtraParam1)
			self.Aura.Data.AddEvent (time+TimeEffect-1.05,   AuraParams2, (), (), AuraGradient1  ,  1,  XtraParam2)
			self.Aura.Data.AddEvent (time+TimeEffect-1.0,    AuraParams1, (), (), AuraGradient1  ,  1,  XtraParam1)
			self.Aura.Data.AddEvent (time+TimeEffect,        AuraParams0, (), (), AuraGradient0  ,  1,  XtraParam0)
			
	def __getstate__(self):
		return (1,
				self.PersonName,
				self.ItemName,
				GameStateAux.SaveEntityAux(self.Aura),
			)


	def __setstate__(self,parm):
		if parm[0]==1:
			self.PersonName=parm[1]
			self.ItemName=parm[2]
			self.Aura=GameStateAux.LoadEntityAux(parm[3])
		else:
			print "GemFX.__setstate__() -> Version mismatch"
			self.PersonName=""
			self.ItemName=""
			self.Aura=""



def AddPersonGemFX(PersonName, ItemName, TimeEffect):
	pers=Bladex.GetEntity(PersonName)
	item=Bladex.GetEntity(ItemName)
	if ((not item) or (item.Kind not in ("Gema", "GemaRoja", "Gemaazul", "Gemapurpura","Gemayell"))):
		print "El item especificado no existe no hay efecto definido para este tipo de item!"
		return
	pers.Data.PersonGemFX=PersonGemFX(PersonName, ItemName, TimeEffect)
	


class MagicGem:
	def __init__ (self, me):
		me.UseFunc= self.UseStart
		self.Age_num= 0
		self.UsedBy= "Player1"
		self.UseTime= 15.0
		self.OldFDefense = 0.0
		self.OldFAttack	= 0.0
		self.FDefense = 4.0
		self.FAttack = 4.0
		self.nUses= 3
		self.Name= me.Name
		self.ObjId=ObjStore.GetNewId() 
		ObjStore.ObjectsStore[self.ObjId]=self


	def persistent_id(self):
		return self.ObjId


	def __getstate__(self):
		return (1,
					self.ObjId, 
					self.Age_num,
					self.UsedBy,
					self.UseTime,
					self.OldFDefense,
					self.OldFAttack,
					self.FDefense,
					self.FAttack,
					self.nUses,
					self.Name
				)


	def __setstate__(self,parm):
		if parm[0]==1:
			self.ObjId=parm[1]
			ObjStore.ObjectsStore[self.ObjId]=self
			self.Age_num=parm[2]
			self.UsedBy=parm[3]
			self.UseTime=parm[4]
			self.OldFDefense=parm[5]
			self.OldFAttack=parm[6]
			self.FDefense=parm[7]
			self.FAttack=parm[8]
			self.nUses=parm[9]
			self.Name=parm[10]
		else:
			print "MagicGem.__setstate__() -> Version mismatch"
			self.UsedBy= "Player1"
			self.UseTime= 15.0
			self.OldFDefense = 0.0
			self.OldFAttack	= 0.0
			self.FDefense = 4.0
			self.FAttack = 4.0
			self.nUses= 3
			self.Name= me.Name
			self.ObjId=ObjStore.GetNewId() 
			ObjStore.ObjectsStore[self.ObjId]=self
		
		
	def UseStart (self, ObjectName, use_from):
		if use_from==Actions.USE_FROM_INV:
			object= Bladex.GetEntity(ObjectName)
			if object: object.UseFunc= 0
			Bladex.AddScheduledFunc(Bladex.GetTime()+self.UseTime, self.UseEnd,(ObjectName,self.UsedBy), ObjectName+"_UseEnd")
			

	def UseEnd (self,ObjectName, UserName):
		
		self.nUses= self.nUses-1
		if self.nUses<1:
			user= Bladex.GetEntity(UserName)
			if user:
				inv= user.GetInventory()
				if inv:
					inv.RemoveObject(ObjectName)
					object= Bladex.GetEntity(ObjectName)
					if object: object.SubscribeToList("Pin")
					return
		
			# In case of any problems obtaining handles etc...
			Bladex.AddScheduledFunc(Bladex.GetTime()+self.UseTime, self.UseEnd,(ObjectName, UserName), ObjectName+"_UseEnd")
		else:
			object= Bladex.GetEntity(ObjectName)
			if object: object.UseFunc=self.UseStart
			
			
			
class PowerGem (MagicGem):
	def __init__ (self, me):
		MagicGem.__init__(self, me)
		self.UsedBy= "Player1"
		self.UseTime= 90.0
		self.OldFDefense = 0.0
		self.OldFAttack	= 0.0
		self.FDefense = 4.0
		self.FAttack = 4.0
		self.nUses= 3
		
		Reference.EntitiesSelectionData[self.Name]=(7,4000,MenuText.GetMenuText('Power Gem'))
		

	def UseStart (self, ObjectName, use_from):
		me=Bladex.GetEntity(self.UsedBy)
		if me.Data.Resistances["Slash"]>0.1:
			Actions.ReportMsg("No Powerup with Extra Protection")
			return
		MagicGem.UseStart (self, ObjectName, use_from)
		
		self.OldFAttack = 1.0
		me.Data.FAttack = self.FAttack
		AddPersonGemFX(self.UsedBy, ObjectName, self.UseTime)
		Actions.ReportMsg("You Have Extra Power!")
		print"power on"

	def UseEnd (self,ObjectName, UserName):
		me=Bladex.GetEntity(UserName)
		me.Data.FAttack = self.OldFAttack
		MagicGem.UseEnd (self, ObjectName, UserName)
		Actions.ReportMsg("The Power Has Left You")
		print"power off"
		



class ProtectionGem (MagicGem):
	def __init__ (self, me):
		MagicGem.__init__(self, me)
		self.UsedBy= "Player1"
		self.UseTime= 90.0
		self.nUses= 3
		
		Reference.EntitiesSelectionData[self.Name]=(7,4000,MenuText.GetMenuText('Protection Gem'))
		

	def UseStart (self, ObjectName, use_from):
		me=Bladex.GetEntity(self.UsedBy)
		if me.Data.FAttack>1.0:
			Actions.ReportMsg("No Extra Protection while Powered Up")
			return
		MagicGem.UseStart (self, ObjectName, use_from)
		me.Data.Resistances['Impale']= 0.95
		me.Data.Resistances['Slash'] = 0.95
		me.Data.Resistances['Crush'] = 0.95
		AddPersonGemFX(self.UsedBy, ObjectName, self.UseTime)
		Actions.ReportMsg("You Have Extra Protection!")
		print"power on"

	def UseEnd (self,ObjectName, UserName):
		me=Bladex.GetEntity(UserName)
		me.Data.Resistances= copy.copy(CharStats.GetCharResistances(me.Kind))
		MagicGem.UseEnd (self, ObjectName, UserName)
		Actions.ReportMsg("The Protection Has Left You")
		print"protection off"
		





		
def CreatePowerGem (name,pos):
	gem=Bladex.CreateEntity(name,"Gemaazul",pos[0],pos[1],pos[2], "Weapon")
	gem.Scale=1.0
	gem.SelfIlum=-1
	gem.Impulse(0,0,0)
	gem.Data=PowerGem(gem)
	return gem.Data
			
	
def CreateProtectionGem (name,pos):
	gem=Bladex.CreateEntity(name,"Gemayell",pos[0],pos[1],pos[2], "Weapon")
	gem.Scale=1.1
	gem.SelfIlum=-1
	gem.Impulse(0,0,0)
	gem.Data=ProtectionGem(gem)
	return gem.Data
			
Hope that helps.[:)]

Yvan98
Dragon
Posts: 52
Joined: Mon Apr 30, 2007 1:45 pm
Location: Canada

Post by Yvan98 »

Thank you guys!

but i was getting a thousand of error, so i scratch this code...

it was only to find a solution for my 'Aquilonia Sword' that was wasting too much stamina.

I have created this new sword that will be enable to execute 2 special combo in a row[8D]

I only try to do something 'new' with an unused item of the game like the 'Snake Medallion'.

In fact, i try to give a boost of stamina with that 'Amulet' but i think that it will be more simple for me to put more 'PowerPotion' in my map...

Post Reply