Jump to content

[LE] Need help with revert form script


Recommended Posts

I am making an indpendant demon transformation spell that does not rely on/altar the playervampire or playerwerewolf scripts. I can get the player to transform into the demon form fine. But my revert form spell is not working. This is what I have (both scripts are attached to seperate magic effects for seperate spellls:

 

Demon Transform

Scriptname MW1979DemonChangeFormScript extends ActiveMagicEffect  

Quest Property CompanionsTrackingQuest auto
Faction Property PlayerWerewolfFaction auto
Shout Property MonsterShout auto
Race Property PolymorphRace auto
Spell Property PolymorphSpell auto
Faction Property MonsterFaction auto
Weapon Property MonsterWeapon auto
Ammo Property MonsterAmmo Auto
Armor Property MonsterArmor Auto
SPELL Property SPELLCLEAR1 Auto
SPELL Property SPELLCLEAR2 Auto
WEAPON Property WEAPONCLEAR1 Auto
WEAPON Property WEAPONCLEAR2 Auto

Event OnEffectStart(Actor Target, Actor Caster)

if (Target.GetActorBase().GetRace() != PolymorphRace)
		Target.SetRace(PolymorphRace)
		Game.GetPlayer().SetHeadTracking(false)
		Game.GetPlayer().UnequipAll()
		Game.GetPlayer().AddSpell(SPELLCLEAR1)
		Game.GetPlayer().EquipSpell(SPELLCLEAR1, 0)
		Game.GetPlayer().AddSpell(SPELLCLEAR2)
		Game.GetPlayer().EquipSpell(SPELLCLEAR2, 1)
		Game.GetPlayer().AddItem(WEAPONCLEAR1)
		Game.GetPlayer().EquipItem(WEAPONCLEAR1, 0)
		Game.GetPlayer().AddItem(WEAPONCLEAR2)
		Game.GetPlayer().EquipItem(WEAPONCLEAR2, 1)
		Game.GetPlayer().EquipSpell(PolymorphSpell, 0)
		Game.GetPlayer().AddSpell(PolymorphSpell)
		Game.GetPlayer().EquipSpell(PolymorphSpell, 0)
		Game.GetPlayer().AddToFaction(MonsterFaction)
		Game.GetPlayer().AddItem(MonsterWeapon)
		Game.GetPlayer().EquipItem(MonsterWeapon, 1)
		Game.GetPlayer().AddItem(MonsterAmmo, 99)
		Game.GetPlayer().EquipItem(MonsterAmmo)
		Game.GetPlayer().AddItem(MonsterArmor)
		Game.GetPlayer().EquipItem(MonsterArmor)
		Game.SetPlayerReportCrime(false)
		Game.GetPlayer().SetAttackActorOnSight(true)
		Game.GetPlayer().AddToFaction(PlayerWerewolfFaction)
		Game.GetPlayer().AddShout(MonsterShout)
		Game.GetPlayer().EquipShout(MonsterShout)
	Endif
EndEvent

Event OnEffectFinish(Actor Target, Actor Caster)

	Game.GetPlayer().RemoveSpell(PolymorphSpell)
	Game.GetPlayer().UnEquipSpell(PolymorphSpell, 0)
	Game.GetPlayer().RemoveFromFaction(MonsterFaction)
	Game.GetPlayer().RemoveItem(MonsterWeapon)
	Game.GetPlayer().UnEquipItem(MonsterWeapon, 1)
	Game.GetPlayer().RemoveShout(MonsterShout)
	Game.GetPlayer().UnEquipShout(MonsterShout)
	Game.GetPlayer().RemoveItem(MonsterAmmo, 99)
	Game.GetPlayer().UnEquipItem(MonsterAmmo)
	Game.GetPlayer().RemoveItem(MonsterArmor)
	Game.GetPlayer().UnEquipItem(MonsterArmor)
	Game.GetPlayer().AddSpell(SPELLCLEAR1)
	Game.GetPlayer().EquipSpell(SPELLCLEAR1, 0)
	Game.GetPlayer().AddSpell(SPELLCLEAR2)
	Game.GetPlayer().EquipSpell(SPELLCLEAR2, 1)
	Game.GetPlayer().AddItem(WEAPONCLEAR1)
	Game.GetPlayer().EquipItem(WEAPONCLEAR1, 0)
	Game.GetPlayer().AddItem(WEAPONCLEAR2)
	Game.GetPlayer().EquipItem(WEAPONCLEAR2, 1)
	Game.EnablePlayerControls()
	Game.SetPlayerReportCrime(true)
	Game.GetPlayer().SetAttackActorOnSight(false)
	Game.GetPlayer().RemoveFromFaction(PlayerWerewolfFaction)

	Debug.Trace("WEREWOLF: Setting race " + (CompanionsTrackingQuest as CompanionsHousekeepingScript).PlayerOriginalRace + " on " + Game.GetPlayer())

	Game.GetPlayer().SetRace((CompanionsTrackingQuest as CompanionsHousekeepingScript).PlayerOriginalRace)

EndEvent

This part has no problems and works fine

 

 

Revert back to human

Scriptname MW1979RevertOriginalFormScript extends ActiveMagicEffect  

Quest Property CompanionsTrackingQuest auto
Faction Property PlayerWerewolfFaction auto
Shout Property MonsterShout auto
Race Property PolymorphRace auto
Spell Property PolymorphSpell auto
Faction Property MonsterFaction auto
Weapon Property MonsterWeapon auto
Ammo Property MonsterAmmo Auto
Armor Property MonsterArmor Auto
SPELL Property SPELLCLEAR1 Auto
SPELL Property SPELLCLEAR2 Auto
WEAPON Property WEAPONCLEAR1 Auto
WEAPON Property WEAPONCLEAR2 Auto

Event OnEffectStart(Actor Target, Actor Caster)

	Game.GetPlayer().RemoveSpell(PolymorphSpell)
	Game.GetPlayer().UnEquipSpell(PolymorphSpell, 0)
	Game.GetPlayer().RemoveFromFaction(MonsterFaction)
	Game.GetPlayer().RemoveItem(MonsterWeapon)
	Game.GetPlayer().UnEquipItem(MonsterWeapon, 1)
	Game.GetPlayer().RemoveShout(MonsterShout)
	Game.GetPlayer().UnEquipShout(MonsterShout)
	Game.GetPlayer().RemoveItem(MonsterAmmo, 99)
	Game.GetPlayer().UnEquipItem(MonsterAmmo)
	Game.GetPlayer().RemoveItem(MonsterArmor)
	Game.GetPlayer().UnEquipItem(MonsterArmor)
	Game.GetPlayer().AddSpell(SPELLCLEAR1)
	Game.GetPlayer().EquipSpell(SPELLCLEAR1, 0)
	Game.GetPlayer().AddSpell(SPELLCLEAR2)
	Game.GetPlayer().EquipSpell(SPELLCLEAR2, 1)
	Game.GetPlayer().AddItem(WEAPONCLEAR1)
	Game.GetPlayer().EquipItem(WEAPONCLEAR1, 0)
	Game.GetPlayer().AddItem(WEAPONCLEAR2)
	Game.GetPlayer().EquipItem(WEAPONCLEAR2, 1)
	Game.SetPlayerReportCrime(true)
	Game.GetPlayer().SetAttackActorOnSight(false)
	Game.GetPlayer().RemoveFromFaction(PlayerWerewolfFaction)

	Debug.Trace("WEREWOLF: Setting race " + (CompanionsTrackingQuest as CompanionsHousekeepingScript).PlayerOriginalRace + " on " + Game.GetPlayer())

	Game.GetPlayer().SetRace((CompanionsTrackingQuest as CompanionsHousekeepingScript).PlayerOriginalRace)

EndEvent

Now when I press z to use this power in demon form nothing happens. I dont change back to human form. does anyone know what I am doing wrong??

Link to comment
Share on other sites

UPDATE: I just noticed the script is working but only if I press the Z button multiple times in a row with the revert Form Power equipped. This only works if I add a race property and change the line

 

Game.GetPlayer().SetRace((CompanionsTrackingQuest as CompanionsHousekeepingScript).PlayerOriginalRace) to Game.GetPlayer().SetRace(MyRace)

 

There has to be someway of storing the players race via script without having to use the companions housekeeping script as this is the part of the script that is not working

Edited by morrowind1979
Link to comment
Share on other sites

Two things.

 

1. The CompanionsTrackingQuest may or may not be running. If it is not running, you cannot pull data from it and you will need to create your own management quest and script to store the race data in a property.

 

2. Even if the CompanionsTrackingQuest were running, you are not passing the player's original race into the PlayerOriginalRace variable. Thus when trying to transform back there is no data indicating what race to transform back into.

 

In your first script where you transform from original race, try adding the following at a point prior to changing the player's race:

(CompanionsTrackingQuest as CompanionsHousekeepingScript).PlayerOriginalRace = Target.GetRace()
Target.SetRace(PolymorphRace)

This should allow you to transform back as it stores the data in the PlayerOriginalRace property, provided that the CompanionsTrackingQuest is actually running.

 

FYI - if the player is the target, why waste processing time wtih Game.GetPayer()? You can just use the Target variable throughout the event.

Link to comment
Share on other sites

I

 

Two things.

 

1. The CompanionsTrackingQuest may or may not be running. If it is not running, you cannot pull data from it and you will need to create your own management quest and script to store the race data in a property.

 

2. Even if the CompanionsTrackingQuest were running, you are not passing the player's original race into the PlayerOriginalRace variable. Thus when trying to transform back there is no data indicating what race to transform back into.

 

In your first script where you transform from original race, try adding the following at a point prior to changing the player's race:

(CompanionsTrackingQuest as CompanionsHousekeepingScript).PlayerOriginalRace = Target.GetRace()
Target.SetRace(PolymorphRace)

This should allow you to transform back as it stores the data in the PlayerOriginalRace property, provided that the CompanionsTrackingQuest is actually running.

 

FYI - if the player is the target, why waste processing time wtih Game.GetPayer()? You can just use the Target variable throughout the event

Thanks I will give it a try. My only concern however is that GetRace function will not be carried between both seperate Magic effects/scripts

Link to comment
Share on other sites

I

 

Two things.

 

1. The CompanionsTrackingQuest may or may not be running. If it is not running, you cannot pull data from it and you will need to create your own management quest and script to store the race data in a property.

 

2. Even if the CompanionsTrackingQuest were running, you are not passing the player's original race into the PlayerOriginalRace variable. Thus when trying to transform back there is no data indicating what race to transform back into.

 

In your first script where you transform from original race, try adding the following at a point prior to changing the player's race:

(CompanionsTrackingQuest as CompanionsHousekeepingScript).PlayerOriginalRace = Target.GetRace()
Target.SetRace(PolymorphRace)

This should allow you to transform back as it stores the data in the PlayerOriginalRace property, provided that the CompanionsTrackingQuest is actually running.

 

FYI - if the player is the target, why waste processing time wtih Game.GetPayer()? You can just use the Target variable throughout the event

Thanks I will give it a try. My only concern however is that GetRace function will not be carried between both seperate Magic effects/scripts

Hey The Getrace function did carry between the two scripts. It works perfectly now and I only have to press Z once to revert form instead of rattling the button multiple times. Thanks, you always solve all my scripting issues. One of these days I will find one that bamboozles you too lol :laugh:

Link to comment
Share on other sites

  • Recently Browsing   0 members

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