[Script problem] Summon Hunter's pet

Post » Fri Sep 24, 2010 5:33 am

Hello!
I made a spell that summons an animal companion near the actor to follow and fight with him.
But I encounter some problem with the follow procedure

Summoner will be the Actor (not only player) who casts the spell.
There are 4 different kinds of animals to be summoned accoring a random number.
When the actor casts the spell, according to the number an animal must set its owneship to the summoner. (This is not working)
After that it will be moved near the actor (This is working).

The pet will use follow package and run behind the actor who is his OWNER.
To specify the owner, I used the command "SetOwnership" in script.

But SetOwnership doesnt seem to work in my script....
and z% to get the nane of the summoner, turns a big array for numbers to my console (not the name).

Can anyone tell me my mistake?
(I want everytime an actor casts the spell, the animal to get him as its owner and follow him (that wll be done with package i made)

ATTENTION: The spell has Range ( SELF )


ScriptName 0BCallPetScript

;Declare useful variables
;--------------------------------------------------------------------------------------------------
ref Summoner
ref WolfCompanion
ref BearCompanion
ref BoarCompanion
ref LionCompanion
Short CreatureType
string_var name

;Set the variables with references in GENERAL
;--------------------------------------------------------------------------------------------------
Begin GameMode
set Summoner to GetSelf
set name to Summoner.GetName
set WolfCompanion to PetWolfRef
set BearCompanion to PetBearRef
set BoarCompanion to PetBoarRef
set LionCompanion to PetLionRef

;Roll a random number from 1 to 5
;--------------------------------------------------------------------------------------------------
set CreatureType to rand 1 5

;Set the owner to a specific pet (from dice) to the guys who cast
;the spell (The summoner)
;--------------------------------------------------------------------------------------------------
If CreatureType == 1
WolfCompanion.SetOwnership Summoner
else If CreatureType == 2
BearCompanion.SetOwnership Summoner
elseIf CreatureType == 3
BoarCompanion.SetOwnership Summoner
elseIf CreatureType == 4
LionCompanion.SetOwnership Summoner
EndIf
End


;Summon (move) the specific pet near the guy who casted the spell
;(The summoner) and Disappear other kind of pets who are in game
;(It moves them back to the storage secret cell)
;--------------------------------------------------------------------------------------------------
Begin ScriptEffectStart

PrintToConsole "CreatureType: %.0f" CreatureType

If CreatureType == 1
BearCompanion.MoveTo BearDismissPoint 0,0,10
BoarCompanion.MoveTo BoarDismissPoint 0,0,10
LionCompanion.MoveTo LionDismissPoint 0,0,10
WolfCompanion.MoveTo Summoner 0,0,100
PrintToConsole "z% has summoned his Wolf companion (Lupito)" name

elseIf CreatureType == 2
WolfCompanion.MoveTo WolfDismissPoint 0,0,10
BoarCompanion.MoveTo BoarDismissPoint 0,0,10
LionCompanion.MoveTo LionDismissPoint 0,0,10
BearCompanion.MoveTo Summoner 0,0,100
PrintToConsole "z% has summoned his Bear companion (Balou)" name

elseIf CreatureType == 3
BearCompanion.MoveTo BearDismissPoint 0,0,10
WolfCompanion.MoveTo WolfDismissPoint 0,0,10
LionCompanion.MoveTo LionDismissPoint 0,0,10
BoarCompanion.MoveTo Summoner 0,0,100
PrintToConsole "z% has summoned his Boar companion (Piggy)" name

ElseIf CreatureType == 4
BearCompanion.MoveTo BearDismissPoint 0,0,10
BoarCompanion.MoveTo BoarDismissPoint 0,0,10
WolfCompanion.MoveTo WolfDismissPoint 0,0,10
LionCompanion.MoveTo Summoner 0,0,100
PrintToConsole "z% has summoned his Lion companion (Miaou)" name
EndIf

End

User avatar
FITTAS
 
Posts: 3381
Joined: Sat Jan 13, 2007 4:53 pm

Post » Fri Sep 24, 2010 4:56 pm

Replace z% with %n, and replace "name" with "Summoner". (http://cs.elderscrolls.com/constwiki/index.php/PrintToConsole)

Move your GameMode stuff to ScriptEffectStart, since GameMode doesn't work in magic effect scripts. If you then need the stuff that is already in ScriptEffectStart to run in the next frame, move it to ScriptEffectFinish. (http://cs.elderscrolls.com/constwiki/index.php/Magic_effect_scripts)

That might fix you up. :)


Edit: Oops! You also need to call http://cs.elderscrolls.com/constwiki/index.php/SetOwnership on the base ID of the summoner, not the reference. Use http://cs.elderscrolls.com/constwiki/index.php/GetBaseObject on the Summoner, and store that to a new variable, and use that new variable to SetOwnership.
User avatar
Gwen
 
Posts: 3367
Joined: Sun Apr 01, 2007 3:34 am

Post » Fri Sep 24, 2010 3:56 pm

OH that worked for ownership. BUT....

only for bear and wolf!
The lion and boar dont get ownership and as a result they dont follow the summoner.

I checked script but it the same for all, I checked the creature but all the stats are equal, I checked the creature I peu in game and they dont have any difference.
I really cant fthe reason for this.

CreatureType 1 and 2 work
while
CreatureType 3 and 4 dont...

If I put them ownership with console, they start follow me as they should be. But with script they dont...

Ufff
User avatar
Sxc-Mary
 
Posts: 3536
Joined: Wed Aug 23, 2006 12:53 pm

Post » Fri Sep 24, 2010 12:27 pm

Script execution stops if a command fails, so the most likely thing is a typo that results in a syntactically valid command, so that it will save, but fail when it runs. My favorite one of those is using a baseid instead of a refid or vice versa. I don't think you've done that one, but your script is behaving as if it stops after checking for CreatureType == 3 and just not doing the next command. Can you paste the revised version?
User avatar
phillip crookes
 
Posts: 3420
Joined: Wed Jun 27, 2007 1:39 pm

Post » Fri Sep 24, 2010 8:01 am

Script execution stops if a command fails, so the most likely thing is a typo that results in a syntactically valid command, so that it will save, but fail when it runs. My favorite one of those is using a baseid instead of a refid or vice versa. I don't think you've done that one, but your script is behaving as if it stops after checking for CreatureType == 3 and just not doing the next command. Can you paste the revised version?

User avatar
Annick Charron
 
Posts: 3367
Joined: Fri Dec 29, 2006 3:03 pm

Post » Fri Sep 24, 2010 12:32 pm

ScriptName 0BCallPetScript

ref Summoner
ref owner
ref WolfCompanion
ref BearCompanion
ref BoarCompanion
ref LionCompanion
Short CreatureType
string_var name

Begin ScriptEffectStart

set Summoner to GetSelf
set name to Summoner.GetName
set owner to Summoner.GetBaseObject
set WolfCompanion to PetWolfRef
set BearCompanion to PetBearRef
set BoarCompanion to PetBoarRef
set LionCompanion to PetLionRef

set CreatureType to rand 1 5

If CreatureType == 1
WolfCompanion.SetOwnership Owner
else If CreatureType == 2
BearCompanion.SetOwnership Owner
elseIf CreatureType == 3
BoarCompanion.SetOwnership Owner
elseIf CreatureType == 4
LionCompanion.SetOwnership Owner
EndIf

End

Begin ScriptEffectFinish
;Summon (move) the specific pet near the guy who casted the spell
;(The summoner) and Disappear other kind of pets who are in game
;(It moves them back to the storage secret cell)

PrintToConsole "CreatureType: %.0f" CreatureType

If CreatureType == 1
BearCompanion.MoveTo BearDismissPoint 0,0,10
BoarCompanion.MoveTo BoarDismissPoint 0,0,10
LionCompanion.MoveTo LionDismissPoint 0,0,10
WolfCompanion.MoveTo Summoner 0,0,30
PrintToConsole "%n has summoned his Wolf companion (Lupito)" Summoner

elseIf CreatureType == 2
WolfCompanion.MoveTo WolfDismissPoint 0,0,10
BoarCompanion.MoveTo BoarDismissPoint 0,0,10
LionCompanion.MoveTo LionDismissPoint 0,0,10
BearCompanion.MoveTo Summoner 0,0,30
PrintToConsole "%n has summoned his Bear companion (Balou)" Summoner

elseIf CreatureType == 3
BearCompanion.MoveTo BearDismissPoint 0,0,10
WolfCompanion.MoveTo WolfDismissPoint 0,0,10
LionCompanion.MoveTo LionDismissPoint 0,0,10
BoarCompanion.MoveTo Summoner 0,0,30
PrintToConsole "%n has summoned his Boar companion (Piggy)" Summoner

ElseIf CreatureType == 4
BearCompanion.MoveTo BearDismissPoint 0,0,10
BoarCompanion.MoveTo BoarDismissPoint 0,0,10
WolfCompanion.MoveTo WolfDismissPoint 0,0,10
LionCompanion.MoveTo Summoner 0,0,30
PrintToConsole "%n has summoned his Lion companion (Miaou)" Summoner
EndIf
End
User avatar
Tammie Flint
 
Posts: 3336
Joined: Mon Aug 14, 2006 12:12 am

Post » Fri Sep 24, 2010 10:53 am

edit: Try this:

ref SummonerRefref SummonerBaseshort CreatureTypeBegin ScriptEffectStart	set SummonerRef to GetSelf	set SummonerBase to SummonerRef.GetBaseObject	set CreatureType to rand 1 5EndBegin ScriptEffectFinish	PrintC "CreatureType: %.0f" CreatureType	If CreatureType == 1		PetWolfRef.SetOwnership SummonerBase		PetBearRef.MoveTo BearDismissPoint 0,0,10		PetBoarRef.MoveTo BoarDismissPoint 0,0,10		PetLionRef.MoveTo LionDismissPoint 0,0,10		PetWolfRef.MoveTo SummonerRef 0,0,30		PrintC "%n has summoned his Wolf companion (Lupito)" SummonerRef	ElseIf CreatureType == 2 		PetBearRef.SetOwnership SummonerBase		PetWolfRef.MoveTo WolfDismissPoint 0,0,10		PetBoarRef.MoveTo BoarDismissPoint 0,0,10		PetLionRef.MoveTo LionDismissPoint 0,0,10		PetBearRef.MoveTo SummonerRef 0,0,30		PrintC "%n has summoned his Bear companion (Balou)" SummonerRef	ElseIf CreatureType == 3		PetBoarRef.SetOwnership SummonerBase		PetBearRef.MoveTo BearDismissPoint 0,0,10		PetWolfRef.MoveTo WolfDismissPoint 0,0,10		PetLionRef.MoveTo LionDismissPoint 0,0,10		PetBoarRef.MoveTo SummonerRef 0,0,30		PrintC "%n has summoned his Boar companion (Piggy)" SummonerRef	ElseIf CreatureType == 4		PetLionRef.SetOwnership SummonerBase		PetBearRef.MoveTo BearDismissPoint 0,0,10		PetBoarRef.MoveTo BoarDismissPoint 0,0,10		PetWolfRef.MoveTo WolfDismissPoint 0,0,10		PetLionRef.MoveTo SummonerRef 0,0,30		PrintC "%n has summoned his Lion companion (Miaou)" SummonerRef	EndIf	End


Stuff I changed: Since your pets already had persistent Ref ID's, they didn't need also need to be given reference variables for your purposes. The SetOwnership stuff was moved into the ScriptEffectFinish block because it depends on the same conditions as everything else there, and they didn't need to be in a separate frame, so this just makes the script a little more efficient.

One thing I did notice is that you started the EditorID of the script with a number. You should always start with a letter, because sometimes the engine gets cranky if you start with numbers. If you're just trying to get your stuff to be at the top of the list, prefixing with "aa" or "aaa" or "a00" or something will do the trick.
User avatar
SexyPimpAss
 
Posts: 3416
Joined: Wed Nov 15, 2006 9:24 am

Post » Fri Sep 24, 2010 1:00 pm

OMG It works now!!!
So my actual mistake was:

set WolfCompanion to PetWolfRef
set BearCompanion to PetBearRef
set BoarCompanion to PetBoarRef
set LionCompanion to PetLionRef

that they were out of need, and made my script get confused right?

I have tried to put the SetOwnership together with the summons but I wasnt got the pet summons. Thats why I made them seoperetelly. I suppose It was crushing then because of the my actual mistake.

Anyway! Many thanks :)
User avatar
Jarrett Willis
 
Posts: 3409
Joined: Thu Jul 19, 2007 6:01 pm

Post » Fri Sep 24, 2010 8:25 pm

Well, that wasn't what was breaking it - the extra variables were just superfluous, is all. What was getting you, I think, was:

else If CreatureType == 2


that little extra space, there. I'm very glad it's working now, in any case!
User avatar
Bereket Fekadu
 
Posts: 3421
Joined: Thu Jul 12, 2007 10:41 pm

Post » Fri Sep 24, 2010 9:42 am

GetOwner
is used to get the Owner fo creature too?
Or just of an object?
User avatar
Tamara Primo
 
Posts: 3483
Joined: Fri Jul 28, 2006 7:15 am

Post » Fri Sep 24, 2010 3:45 pm

You can use it on any reference, including creatures. Here's some http://cs.elderscrolls.com/constwiki/index.php/GetOwner!
User avatar
Georgia Fullalove
 
Posts: 3390
Joined: Mon Nov 06, 2006 11:48 pm

Post » Fri Sep 24, 2010 3:06 pm

I saw the example about 1 day before.
He uses the variable for owner in IF.

I m trying to use it like this way and i dont get any results.
Some simple script that dont work on me.... (I think I m cursed with scripts :P)
When someone or me hit the imp, it must give me his owner's health stat (since I m its owner it must gibe mine)

ScriptName 0BImpAirBehaviour

ref Imp
ref Summoner
short Health


Begin OnHit

set Imp to GetSelf
set Summoner to Imp.GetOwner
set Health to Summoner.GetAV Health

Message "The owner has %.0f" health

End

User avatar
Claire Jackson
 
Posts: 3422
Joined: Thu Jul 20, 2006 11:38 pm

Post » Fri Sep 24, 2010 9:22 am

Ah! The trouble you may be having is that GetOwner returns a base object, but you need a Reference for Summoner. Maybe when the actor casts the summoning spell, you can save the caster's ref as a variable in someplace that is accessible from other scripts. For example, a global variable, or a quest script variable, or a variable in the script of the creatures themselves; since they are persistent references, you can get variables from their scripts.

To store the variable elsewhere in the spell script,
for a global: "set GLOBALVARIABLENAME to GetSelf"
for a quest script: "set QUESTEDITORID.VARIABLENAME to GetSelf"
for a persistent ref's script: "set PERSISTENTREFID.VARIABLENAME to GetSelf"

To retrieve it in this script here,
from a global: "set Summoner to GLOBALVARIABLENAME"
from a quest script: "set Summoner to QUESTEDITORID.VARIABLENAME"
from a persistent ref's script: "set Summoner to PERSISTENTREFID.VARIABLENAME"

These methods should be all equally effective, just pick which one works best with the rest of your mod. For example, if your creatures already have scripts attached, I'd use their scripts so as not to have to create an empty quest just for this purpose. Or if they aren't scripted but you do have a quest always running, make a new variable there so as not to have to script the creatures just for this. Etc.
User avatar
Poetic Vice
 
Posts: 3440
Joined: Wed Oct 31, 2007 8:19 pm

Post » Fri Sep 24, 2010 8:28 am

My Imp's rersistent reference box is grey and tick!
So my imp has a persistent reference.
Its Reference Editor ID is: MinionImpAir

and the script above is from creature. I mean it run on creature.
I would like to use the persistentref

If i use global variable myaybe it will affect the game.

this works for creature:

ScriptName 0BImpAirBehaviour

ref Imp
ref Summoner
short Health

Begin GameMode

set Imp to GetSelf
set Health to Imp.GetAV Health

End

Begin OnHit

Message "The owner has %.0f" health

End


But if i put
Set Summoner to Imp.GetOwer
it doesnt.

I dont undertsnad it!
The game recongizes the Imp with GetSelf and shows me his health
Why he doesnt recognize Imp's owner.... and crushes

Damn.... my head will break
User avatar
Batricia Alele
 
Posts: 3360
Joined: Mon Jan 22, 2007 8:12 am

Post » Fri Sep 24, 2010 1:57 pm

Scripting can give you a lot to keep track of at once, mentally. Just take it one bit at a time. :)

Okay, so the script is on the imp, that makes it easier. All you need to do is to add this line to the summon spell's script somewhere in the ScriptEffectStart block: "set MinionImpAir.Summoner to GetSelf". Now the imp's script will already have Summoner set to the right reference, so you can do whatever you want with it!
User avatar
sas
 
Posts: 3435
Joined: Thu Aug 03, 2006 8:40 am

Post » Fri Sep 24, 2010 7:05 pm

Scripting can give you a lot to keep track of at once, mentally. Just take it one bit at a time. :)

Okay, so the script is on the imp, that makes it easier. All you need to do is to add this line to the summon spell's script somewhere in the ScriptEffectStart block: "set MinionImpAir.Summoner to GetSelf". Now the imp's script will already have Summoner set to the right reference, so you can do whatever you want with it!


OMG IT worked!
So to make it simple for my mind...

When the caster (Summoner) casts the spell:
He gets a variable for himself (to use it in spell)
(set target to GetSelf)
and then gets another variable for himself (including a prersistent reference) (to use it outside script, other scripts)
(set MinionImpAir.Summoner to GetSelf)

Really i didnt know that GetSelf could be used twice in a single script.
Oh i m grateful!
User avatar
Austin Suggs
 
Posts: 3358
Joined: Sun Oct 07, 2007 5:35 pm

Post » Fri Sep 24, 2010 8:51 am

Hooray! :celebration:
User avatar
Josh Trembly
 
Posts: 3381
Joined: Fri Nov 02, 2007 9:25 am

Post » Fri Sep 24, 2010 9:25 am

On Imp's script:

ref Scamp
ref Summoner

Begin GameMode

set Scamp to GetSelf
set Summoner to TES3ScampFollower.Summoner

if ( timer < 10 )
set timer to timer + getSecondsPassed
else
Scamp.Cast 0BScampAbility3 Summoner
Message "Barney casts (Blood pact) spell on %n" Summoner
set timer to 0
endif
End

and my game CRASHES! Any idea why this happen?
On message I call a persistent variable like that you taught me.
User avatar
Chris Johnston
 
Posts: 3392
Joined: Fri Jul 07, 2006 12:40 pm

Post » Fri Sep 24, 2010 10:38 pm

You still need to declare "timer" as a float variable in the beginning. :)

If that's not it, also test the spell you have the scamp casting by itself somehow. Like, attach it to an activator in the testing hall, to make sure the spell itself isn't what's actually crashing you.
User avatar
Jay Baby
 
Posts: 3369
Joined: Sat Sep 15, 2007 12:43 pm

Post » Fri Sep 24, 2010 8:20 am

You still need to declare "timer" as a float variable in the beginning. :)

If that's not it, also test the spell you have the scamp casting by itself somehow. Like, attach it to an activator in the testing hall, to make sure the spell itself isn't what's actually crashing you.


I actually missed a line here. I have set timer are float! Eveything works ok. I have made many tests and I m alsost sure that the proble is that it caannot understand the persistent variable in the message.
Maybe the %n isnt the right wy to call it? I m fore sure that this need to change.
%n works fine on a local variable.

So the major question is:
"How can I call a persistent variable (out of script variable) in a message line?"
User avatar
Everardo Montano
 
Posts: 3373
Joined: Mon Dec 03, 2007 4:23 am

Post » Fri Sep 24, 2010 6:03 pm

Oooooh, you might have to use http://cs.elderscrolls.com/constwiki/index.php/MessageEx instead of just Message. Oops, sorry! :blush:
User avatar
DeeD
 
Posts: 3439
Joined: Sat Jul 14, 2007 6:50 pm


Return to IV - Oblivion