Jump to content

papyrus code issues for telekinesis spell


MindController

Recommended Posts

I'm not completely fluent in papyrus yet, but I'm trying to learn a few things. I'm specifically having trouble trying to make a spell where the npc goes ragdoll and then gets pulled to you.

 

I can make them go ragdoll, but the issue I am having with is getting them to come towards you. I'd appreciate it if someone could take a look at my script and let me know if I'm just doing things completely incorrect and what corrections I need to make to get the effect to happen.

 

Scriptname PullEnemies extends activemagiceffect  

Keyword Property NPCPull  Auto  
 
Event OnEffectStart (Actor target, Actor caster)
if (target.HasKeyword(NPCPull))
Game.GetPlayer().PushActorAway(target, 0)
target.ApplyHavokImpulse (0, 0, 0, 0)
target.TranslateToRef (Game.GetPlayer(), 500)
endif
EndEvent

 

The ApplyHavokImpulse part makes the npc go ragdoll. And then the TranslateToRef is supposed to draw the npc towards you, which it does. But it does so in a very unrealistic manner. It's like the npc is cycling animations and just floats in a straight line towards you.

 

Currently, the casting type is Concentration and the delivery is Target Actor

Link to comment
Share on other sites

TranslateToRef has ...issues. The unit will have glitchy animations regardless of whether you make it "go ragdoll" or not. It is pretty likely that the unit will suddenly be on the ground when you are done pulling, for instance.

 

There are other problems. Your script won't actually end when you stop channelling, so you need to use StopTranslate in your finish event. TranslateTo ignores collisions, so the target will telefrag you when he arrives at your location and becomes solid again, which the game resolves by kicking one of you to the ground. And if you stand in front of a rock on the ground and shoot over it, your target will translate with his feet into the rock which again causes bugs and may enable players to arrange it so the NPC falls through the world.

 

The best way I've found is something like "Project Orion", using repeated directional PushActorAway propulsion originating from a dummy object behind the target and inside the ground. By positioning the dummy object correctly you can apply a force that points towards you and slightly up in the air. Just make sure you know when to stop and implement a feedback mechanism so the target doesn't sail into orbit.

 

In the end I just ditched the whole thing when I realised scripts tend to grind to a halt if you have too many calculations in your loop.

 

 

Edit: You could try applying a magiceffect that sets Mass to 0 and one single PushActorAway to set the target on course for you, then a watchdog loop that delivers the same push in the other direction and removes the magiceffect when the target arrives you. Worth trying? I dunno.

Edited by EnaiSiaion
Link to comment
Share on other sites

Just so you know, PushActorAway accepts negative values (and is about the only physics function that does). If you do something like

Game.GetPlayer().PushActorAway(target, -1)

 

You won't even need the ApplyHavocImpulse. PushActoraway causes ragdoll state all by itself. Since Concentration effects basically recast repeatedly for the duration, this might even be the only line you need. Give it a try.

 

PushActorAway with negative values is one of the most fun physics tricks ever. My Katamari mod is based entirely around it, and my upcoming Whirlwind mod relies heavily on it to suck actors up into it.

 

Link to comment
Share on other sites

But you still need a way to aim the push vertically, so if the target is taller than yourself you won't just pull it into the ground. Adding a dummy object is only 3 lines and you gain the ability to vector aim your push.

 

Idea: why not adjust the pull force based on the target's Mass actor value? This would prevent the situation where your spell is capable of catapulting a chicken to the moon but a mammoth won't even budge.

 

Are there other physics functions besides PushActorAway btw? :unsure:

Link to comment
Share on other sites

But you still need a way to aim the push vertically, so if the target is taller than yourself you won't just pull it into the ground. Adding a dummy object is only 3 lines and you gain the ability to vector aim your push.

 

Idea: why not adjust the pull force based on the target's Mass actor value? This would prevent the situation where your spell is capable of catapulting a chicken to the moon but a mammoth won't even budge.

 

Are there other physics functions besides PushActorAway btw? :unsure:

 

Actually mammoths (and dragons) won't budge in response to pushes or blasts no matter what; they're marked in CK as immune to pushing. Even if you disable that flag they still don't react properly to PushActorAway. I tried and tried and could not make them roll into my Katamari ball :(

 

The only physics functions I'm aware of are PushActorAway and ApplyHavocImpulse. I've also taken up using precisely aligned force explosions to move clutter objects around. Sadly, only PushActorAway accepts negative force values. If I could do negative force explosions it would make this script I'm working on SO. MUCH. EASIER.

 

As for vectoring your force pull, you're right; he should spawn an invisible activator above his character's head and use that for the negative PushActorAway. -1 or -2 is enough to push even a giant around without flinging smaller creatures too violently... but telekinesis -should- require some finesse to use properly ;)

Link to comment
Share on other sites

Just so you know, PushActorAway accepts negative values (and is about the only physics function that does). If you do something like

Game.GetPlayer().PushActorAway(target, -1)

 

You won't even need the ApplyHavocImpulse. PushActoraway causes ragdoll state all by itself. Since Concentration effects basically recast repeatedly for the duration, this might even be the only line you need. Give it a try.

 

PushActorAway with negative values is one of the most fun physics tricks ever. My Katamari mod is based entirely around it, and my upcoming Whirlwind mod relies heavily on it to suck actors up into it.

 

 

Thanks for the reply. I wish I had done more experimenting and just gave the PushActorAway a negative value. I just took the creation kit wiki at face value and assumed you couldn't do it because it didn't provide that example. Seeing as how ApplyHavokImpulse allows negative, though, I suppose I should have gotten it.

 

Thanks to everyone for the help :)

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...