Jump to content

Learning scripting, need a little help


PeterTran

Recommended Posts

How would you make a script that uses the moveto.player command on your target? Let's say I make a spell, where I cast it on an enemy and it does damage to the enemy (like a concentration spell), but once the enemy dies, it automatically moves the enemy to me via the console command moveto.player. I would appreciate any advice on how I would go about this. Thanks.
Link to comment
Share on other sites

First, this note from the wiki page:

 

MoveTo() should be avoided for placing other actors in sight of the player, as they will suddenly appear in an unrealistic way

 

If you want to use it anyways, you could place this script on the enemy:

 

Scriptname MoveDeadEnemy extends Actor


Event OnDeath(Actor akKiller)
if(akKiller == Game.GetPlayer())	
	MoveTo(Game.Getplayer())
endif
EndEvent

Link to comment
Share on other sites

First, this note from the wiki page:

 

MoveTo() should be avoided for placing other actors in sight of the player, as they will suddenly appear in an unrealistic way

 

If you want to use it anyways, you could place this script on the enemy:

 

Scriptname MoveDeadEnemy extends Actor


Event OnDeath(Actor akKiller)
if(akKiller == Game.GetPlayer())	
	MoveTo(Game.Getplayer())
endif
EndEvent

 

Thanks, I just needed something that I could work off of, and you gave me just that!

Link to comment
Share on other sites

This version will fade out the dead actor, move it 40 units in front of the player, then fade the dead actor back in.

 

When "akKiller" is the player reference, there's no need to call Game.GetPlayer() again to get the player reference in the MoveTo command. Just call it on akKiller, it's more cpu efficient.

 

I'm not sure if this would work if it is part of a magic effect script, as the effect would normally dispel when the actor dies. you could try ticking the "no death dispel" option in the magic effect. You might then need to call "Dispel()" at the end of the OnDeath() event block.

 

Scriptname MoveDeadEnemy extends Actor
{moves a dead actor to 40 units in front of the player}

Event OnDeath(Actor akKiller) 
       float aZ
       If akKiller == Game.GetPlayer()
	aZ = akKiller.GetAngleZ()
	Disable(true)	; disable me with fade-out effect
               MoveTo(akKiller, 40 * Math.Sin(aZ), 40 * Math.Cos(aZ), 0)
	Enable(true)	; enable me with fade-in effect
       EndIf 
EndEvent

Edited by steve40
Link to comment
Share on other sites

  • Recently Browsing   0 members

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