script speed help

Post » Wed Jun 20, 2012 12:29 pm

/not native english speaker

In my first first mod I' tryin to add a more versatile version of telekinesys, As a start I decided to infrodure a "telekinetic force" spell with this script. The spell was desigend to control the force only when the caster is calmed (not running) so litte dealys are not a problem (proper timing to "concentrate" was planed as essential) but I found the scrip to Apply the HavokImpulse too slowly in some situations (the target is pushed several seconds after the spell started ) .

I think that it has something to do with the GetPosition lines .

I'd like to reduce this delay.


Any idea?

Spoiler


 Scriptname voicepusheffectscript2	extends ActiveMagicEffect  int Property PushForce2  Auto  ;for in adjustable intensity future versionint Direccion  ;for in adjustable intensity future version;positions of target an caster relative to worldfloat tarposx float tarposyfloat tarposzfloat plaposxfloat plaposyfloat plaposz;positions of target relative to caster float distradialfloat distradiallxfloat distradialyfloat distradialzfloat distradial2;speed of caster float speed0MagicEffect Property NewProperty  Auto  Event OnEffectStart(actor Target, actor Caster)Direccion=1speed0=Caster.GetAV("SpeedMult")   if !Caster.IsRunning()      plaposx= Caster.GetPositionX()       plaposy= Caster.GetPositionY()       plaposz= Caster.GetPositionZ()       ;reduce caster speed (caster must concentrate  deeply)       Caster.SetAV("SpeedMult", speed0/5)       ; aply force  to moce the targen in the direction the caster is moving       utility.wait(0.01)      Caster.PushActorAway(Target,0 )      Target.ApplyHavokImpulse((Caster.GetPositionX()-plaposx)*900,(Caster.GetPositionY()-plaposy)*900,(Caster.GetPositionZ()-plaposz)*900,500)       ;restore speed       Caster.ForceAV("SpeedMult", speed0)  else     if Caster.IsSneaking() ;casteris abel to throw  the target vericaly          tarposx=Target.GetPositionX()           tarposy=Target.GetPositionY()           tarposz=Target.GetPositionZ()           distradial2= Caster.GetDistance(Target)           Caster.PushActorAway(Target,1 )           Target.ApplyHavokImpulse(00,00,-(distradial2-distradial)/distradial*40, 400)       else           Caster.PushActorAway(Target,1 )          ; the spell is tlaned to act on objects so i use an equivalent of pushactoraway using ApplyHavokImpulse           Target.ApplyHavokImpulse((Caster.GetPositionX()-plaposx)/distradial*100,(Caster.GetPositionY()-plaposy)/distradial*100,(Caster.GetPositionY()-plaposz)/distradial*100, 400)        endif       ; if anythig fails        Caster.PushActorAway(Target,114)    endIf    ; damare te target a litle    Target.DamageActorValue("health", 1)EndEventEvent OnEffectFinish(actor Target, actor Caster)    ;restore speed ; otherwise, the peed is not restored correctly sometimes     Caster.SetAV("SpeedMult",speed0)endEvent





edit:
cleraned and comented code

yes it′s planed to ve a concentration speed.that allows yopu to move the target in any direction relative to the caster wiile walking . ingame descriptin of the spell contains:"walking wile cating the spell allows to chanel correctly tho the flor the reaccion of the makical force on the caster "
example of use: confronting a mage an tho warriors you can thow the warriors in fidderent directions leaving a clear combat betwen you and the mage.


next versions could include :
- able to aplay the telekinetic force to objects
- key strike detection form scrips stender
- a risk factor (an aprentive trying to use this master spell will not valance the magick-force reaction correcty and will be thrown away).
- quest to learn the spell
- and more
thanks and sorry http://www.gamesas.com/user/696011-randomnoob/
User avatar
Umpyre Records
 
Posts: 3436
Joined: Tue Nov 13, 2007 4:19 pm

Post » Wed Jun 20, 2012 10:41 pm

Please post your script inside the code tags ([ code ] [ /code ] without the spaces) to preserve formatting.

There are lots of things that I don't understand in your script, but nothing that seems to indicate why the ApplyHavokImpulse is firing so late. What kind of spell are you putting this on? Is it a concentration type spell?
User avatar
vanuza
 
Posts: 3522
Joined: Fri Sep 22, 2006 11:14 pm

Post » Wed Jun 20, 2012 6:41 pm

thanks and sorry http://www.gamesas.com/user/696011-randomnoob/
User avatar
Lucky Boy
 
Posts: 3378
Joined: Wed Jun 06, 2007 6:26 pm

Post » Wed Jun 20, 2012 11:41 am

problem sloved: too many active mods + a Getposition seems a bit slow

thanks
User avatar
Rhi Edwards
 
Posts: 3453
Joined: Fri Jul 28, 2006 1:42 am


Return to V - Skyrim