Question on "Cast"...

Post » Tue May 08, 2012 12:48 am

Im trying to make a Wraith cast a spell for my MP mod.

me.Cast 0100793F xxxxxxx

Is it possible to make the refrence (the x's) whoever I am combating? This a crucial step in my mod so I need an answer.
User avatar
Chris BEvan
 
Posts: 3359
Joined: Mon Jul 02, 2007 4:40 pm

Post » Mon May 07, 2012 2:05 pm

Well, you could cycle through the cell's npcs with GetFirstRef and GetNextRef, check if they are targeting you with getCombatTarget == player and aim for them if they are under a certain distance with getDistance... Or well, thats the first thing that comes to mind... There's probably a better way to do it...

Question, thought. if its a Wraith, why do you have me.Cast instead of Wraith.Cast?
User avatar
Danial Zachery
 
Posts: 3451
Joined: Fri Aug 24, 2007 5:41 am

Post » Mon May 07, 2012 8:02 pm

Well, you could cycle through the cell's npcs with GetFirstRef and GetNextRef, check if they are targeting you with getCombatTarget == player and aim for them if they are under a certain distance with getDistance... Or well, thats the first thing that comes to mind... There's probably a better way to do it...

Question, thought. if its a Wraith, why do you have me.Cast instead of Wraith.Cast?

Because my script is not just for a Wraith, It is for player two, who can be many things. Here is the snippet of the code. I want Caps lock to make him cast a spell.

if IsKeyPressed 20 == 1 ; caps lock             me.Cast 0100793F xxxxxxxxxx

So what would I put for the x's?
User avatar
Rowena
 
Posts: 3471
Joined: Sun Nov 05, 2006 11:40 am

Post » Mon May 07, 2012 10:56 pm

You could probably use http://cs.elderscrolls.com/constwiki/index.php/GetCrosshairRef to get the Player's current target. A note about this bit of the script:

me.Cast 0100793F
Never, ever (for any reason whatsoever) use a FormID in a script. The first two digits of any FormID are actually determined by load order. If your mod loads first after Oblivion.esm, the first two digits will be 01. If it loads second after the Oblivion.esm, the first two digits will be 02 and so on in hexadecimal progression. Calling a FormID in a script like this will rarely (if ever) get the desired result. Use the EditorID of the spell instead, since doing so bypasses this issue.
User avatar
Karine laverre
 
Posts: 3439
Joined: Tue Mar 20, 2007 7:50 am

Post » Mon May 07, 2012 1:06 pm

This is REALLY confusing guys, because I am a bad scripter. This Script I have is someone elses that I edited. I am going to post the whole script. I hope someone is nice enough to edit it so I get my desired effect. The area I need edited are lines 161 to 162.

scn PMControlQuestSCRIPTref me							; the controlled creaturefloat xfactme					; position in Xfloat yfactme					; position in Yfloat zfactme					; position in Zfloat xfact						; position in Xfloat yfact						; position in Yfloat zfact						; position in Zfloat height						; position in Z added depending on Xanglefloat speedmod				; how far the player is placed from the creaturefloat direc						; angle in Zfloat angle						; used to set the angle of the fof to the playersfloat Xangle						; angle player is looking - upp and + downshort attackactivated			; is the creature attacking 1short transformback			; used to transfor back to normal 1Short attackingcreature		; is 1 if the creature can attack need to be 1 for attacksshort started					; has the quest startedfloat fQuestDelayTimefloat movemodfloat distancefloat distanceZfloat distance5float distanceZ5float distance6float distanceZ6float distance7float distanceZ7float healthshort runtoggleref sourceref getCombatTargetfloat MORPHcrimeshort movingfloat dist2float distref source1ref source2short activatecounterBegin Gamemode; when quest starts	if started == 0		player.addspell PMControlSpell		player.addspell SUPERFRENZY		set distance to -2		set distance5 to -2		set distance6 to -2		set distance7 to -2		set started to 1		set fQuestDelayTime to 0.001		StopQuest PMControllQuest	endif	if transformback == 1 && me != 0		player.SetActorAlpha 1		player.setghost 0		player.UnequipItem torch02		EnablePlayerControls		player.addspell PMcontrolAB		set fQuestDelayTime to 0.001		set transformback to 2		me.SetUnconscious 0	elseif transformback == 2		set fQuestDelayTime to 0.001			if moving >= 1 && moving <= 9				set moving to moving + 1				me.RemoveScriptPackage				me.AddScriptPackage PMControldummyPac			elseif moving == 10				set moving to 1				me.RemoveScriptPackage			endif				if player.Getdistance me > 999999999				set moving to 0				me.moveto player			endif			if activatecounter >= 1 && activatecounter < 10				set activatecounter to activatecounter + 1			elseif activatecounter == 10				set activatecounter to 0			endif			if iskeyPressed 32 == 1 && activatecounter == 0				set dist2 to 70 ; changing distance from player				set source1 to me.PlaceAtMe PMControlActivator, 1, dist2, 0				set zfact to me.GetPos z				set zfact to zfact + 100				source1.SetPos z, zfact				set zfact to zfact - dist					if dist < 0						set dist to 0 - dist					endif				set dist to 89 + dist2 - dist				set source2 to me.PlaceAtMe PMControlActivator, 1, dist, 0				source2.SetPos z, zfact				source1.Cast PMControlActivateSpell source2				source1.disable				source2.disable				set activatecounter to 1			endif		set xfactme to me.GetPos x		set yfactme to me.GetPos y		set zfactme to me.GetPos z		set direc to me.GetAngle z		set angle to player.getangle z			if health > me.GetAV health				triggerHitShader 2			endif		set health to me.GetAV health			if IsKeyPressed 13 == 1 ; enter				set transformback to 3			endif		; distance from player to morph---------------------------------			if IsKeyPressed 49 == 1 ;1 key				set distance to distance + 0.05			elseif IsKeyPressed 50 == 1 ;2 key				set distance to distance - 0.05			elseif IsKeyPressed 51 == 1 ;3 key				set distanceZ to distanceZ + 1			elseif IsKeyPressed 52 == 1 ;4 key				set distanceZ to distanceZ - 1			endif			if distance > 9999999999				set distance to 3			elseif distance < -99999999				set distance to -5			endif			if distanceZ > 99999999999				set distanceZ to 300			elseif distanceZ < -200				set distanceZ to -200			endif		;save settings for position 5 6 7 on 8 9 0 and return on backspace---------------------			if IsKeyPressed 56 == 1 ;8 key				set distance5 to distance				set distanceZ5 to distanceZ			endif			if IsKeyPressed 57 == 1 ;9 key				set distance6 to distance				set distanceZ6 to distanceZ			endif			if IsKeyPressed 48 == 1 ;0 key				set distance7 to distance				set distanceZ7 to distanceZ			endif			if IsKeyPressed 53 == 1 ;5 key				set distance to distance5				set distanceZ to distanceZ5			endif			if IsKeyPressed 54 == 1 ;6 key				set distance to distance6				set distanceZ to distanceZ6			endif			if IsKeyPressed 55 == 1 ;7 key				set distance to distance7				set distanceZ to distanceZ7			endif			if IsKeyPressed 8 == 1 ;backspace				set distance to -2				set distanceZ to 0			endif;movement animation control for the CREATURE-------------------------------------------					if IsKeyPressed 20 == 1 ; caps lock						me.Cast 0100793F xxxxxxxxxxxxx					elseif IsKeyPressed 9 == 1 ; tab						set runtoggle to 0					endif					if IsKeyPressed 65 == 1 ;A key						me.PlayGroup left, 1					elseif IsKeyPressed 68 == 1 ;D key						me.PlayGroup right, 1								elseif IsKeyPressed 87 == 1 && IsKeyPressed 16 == 1 ;W and shift							if runtoggle == 0								me.PlayGroup fastforward, 1							else								me.PlayGroup forward, 1							endif					elseif IsKeyPressed 87 ;W only							if runtoggle == 0								me.PlayGroup forward, 1								else								me.PlayGroup fastforward, 1							endif					elseif IsKeyPressed 83 == 1 ; S key						me.PlayGroup backward, 1					else							if me.IsAnimPlaying == 1								me.PlayGroup idle, 1							else								me.pickidle							endif					elseif IsKeyPressed 90 == 1						me.PlayGroup AttackPower , 1					endif					if direc < 0						set angle to 360 - angle					elseif direc > 360						set angle to angle - 360					endif 		player.SetScale 1.0			if me.getdead == 1				set transformback to 3			endif	elseif transformback == 3		me.PlayGroup idle, 1		player.SetScale 1.0		player.setghost 0		EnablePlayerControls		player.SetActorAlpha 1.0		set transformback to 4	elseif transformback == 4		player.removespell PMcontrolAB		set fQuestDelayTime to 1		player.PlayMagicShaderVisuals effectSummonMythicDawn 1		set transformback to 5		me.SetUnconscious 0	elseif transformback == 5		set fQuestDelayTime to 0.001		set MORPHcrime to 0		set me to 0		StopQuest PMControllQuest		set transformback to 0		me.pickidle	endifend
User avatar
STEVI INQUE
 
Posts: 3441
Joined: Thu Nov 02, 2006 8:19 pm

Post » Mon May 07, 2012 9:43 pm

Ok, what are you trying to do, exactly? Also, what does MP stand for? I'm pretty sure you don't need something that large, if you trying to do what I think you are trying to do, thought I'm probably not getting it yet.
User avatar
Robert DeLarosa
 
Posts: 3415
Joined: Tue Sep 04, 2007 3:43 pm

Post » Mon May 07, 2012 4:49 pm

Ok, what are you trying to do, exactly? Also, what does MP stand for? I'm pretty sure you don't need something that large, if you trying to do what I think you are trying to do, thought I'm probably not getting it yet.

Mp = Multi-Player. But this is only with one keyboard, as it is much, much easier than the online ones. This means that Player 2 can Control with ASWD keys. He can also rotate with G and H. But the last thing I need is Attacking (Or I can deal with just blocking). Playing an AnimGroup such as AttackPower does not really make him attack. Which leads me to this thread. The big code I just posted is everything I need for the mod. Im trying to make line 161 for attacking. Do you think you edit this script so I can use it?

I bet this is actually really easy, I just don't understand scripting in the slightest.
User avatar
james reed
 
Posts: 3371
Joined: Tue Sep 18, 2007 12:18 am


Return to IV - Oblivion