Help with Tame Beast scripts...

Post » Tue Jun 19, 2012 9:53 am

This is in a VERY early incarnation of this script. For this setup I basically have a spell called phiTameBeastTrigger which the player can cast at things (it is a "Concentration Aimed" flamethrower type spell like flames). This spell has a magic effect called phiTameBeastSet on it with the following script:

Scriptname phiTameBeastTriggerS extends ActiveMagicEffect  Spell Property phiTaming autoSpell Property phiTamed autoEvent OnEffectStart(Actor akTarget, Actor akCaster)	if akTarget.HasSpell(phiTamed) != 1 && akTarget.HasSpell(phiTaming) != 1		akTarget.AddSpell(phiTaming)		Debug.Notification( "phiTaming Added" )	endifEndEvent

This checks to see if the creature is being tamed or already tamed. (phiTaming and phiTamed are disease spells that get added as placeholders to the creature in question depending on whether they are, you guessed it, tamed or being tamed.) If this check passes and the target creature is neither tamed nor in the process of being tamed, the tame process starts by adding the phiTaming disease spell to the creature.

This part seems to work, and I get the "phiTaming Added" notification. This phiTaming disease spell itself has a spell effect with a script that is SUPPOSED to track the tame progress. Since it is a disease, OnEffectStart SHOULD work. That script looks like this:

Scriptname phiTameBeastTimerS extends ActiveMagicEffect  phiTameBeastTracker1S Property phitrackerquest autoMagicEffect Property phiTameBeastSet autoSpell Property phiTaming autoActor Property phiSpellTarget autoint timer1 = 0int timer2 = 0Event OnEffectStart(Actor akTarget, Actor akCaster)	phiSpellTarget = akTarget	Debug.Trace("Effect started on " + akTarget)	RegisterForUpdate(1)EndEventEvent OnUpdate()	timer1 += 1	if (phiSpellTarget.HasMagicEffect(phiTameBeastSet))		Debug.Notification( "Hit by spell..." )		timer1 = 0		timer2 += 1		if timer2 >= 10			phitrackerquest.phiTameBeastRef1 = phiSpellTarget			phitrackerquest.phitargeted = 1			phiSpellTarget.RemoveSpell(phiTaming)			Debug.Notification( "Sent to quest..." )		endif	else		if timer1 >= 5			timer2 = 0			phiSpellTarget.RemoveSpell(phiTaming)			Debug.Notification( "Tame reset..." )		endif	endifEndEvent

HOWEVER, it appears the script is totally ignoring the magic effect and script on this placeholder ability spell. I never get the notification "Effect started on..." which seems to indicate the OnEffectStart block is never run.

(The first line "phiTameBeastTracker1S Property phiTameBeastTracker1 auto" is needed to "plug in" to my quest script phiTameBeastTracker1S where I want to keep track of the reference variable and also set an int. I have declared the variables I want to use for this as properties in that quest script (see below.)

The OnUpdate event is supposed to increment a timer. If the target creature goes for more than 5sec without being hit by the player's spell (with the phiTameBeastSet effect on it), the script should remove the ability placeholder spell. The odd thing is, that appears to work.

However, I never get the "Hit by spell..." "Sent to quest..." or "Tame reset..." notifications.

The 'send to quest' part is basically supposed to set the reference and int variables I set as properties (to make them accessable by other scripts) in my quest script to the current tame target and 1 so I know I got a target. This is supposed to happen if the player casts the tame spell at the target for a sustained 10sec without losing the tame by going 5sec or more without casting it at them. (Again this is a very early model.)

Just to test I was trying to have the quest disable the target creature if this int value was set to 1, which never happened either. Just for the record though, here's that quest script;

Scriptname phiTameBeastTracker1S extends QuestActorBase property phiTameBeastBase1 autoActor property phiTameBeastRef1 autoint property phitargeted autoEvent OnInit()	RegisterForUpdate(1)EndEventEvent OnUpdate()	if phitargeted == 1		phiTameBeastRef1.Disable()	endifEndEvent

EDIT: I realized I was declaring the same names in my quest script as both variables and properties which was not needed. Corrected, but that wasn't the problem.
User avatar
scorpion972
 
Posts: 3515
Joined: Fri Mar 16, 2007 11:20 am

Post » Tue Jun 19, 2012 9:19 am

It might be me ... I don't always understand correctly ...

But, when you say you are adding a spell to the target, do you mean to happen what is happening?

"When an ability or disease is added it shows up as a current magical effect. When a spell or power is added it shows up as a castable power/spell" - From the wiki: http://www.creationkit.com/AddSpell

So ... Is your Spell a disease or ability? If it is not, if it is a spell, then I think you are just giving the spell to the animal (who won't cast it) (I think!)
User avatar
Manuel rivera
 
Posts: 3395
Joined: Mon Sep 10, 2007 4:12 pm

Post » Tue Jun 19, 2012 10:14 am

You are correct, and yes, the spell I am giving them is an Ability, and so should appear as a Magical Effect. Referring to its script as such compiles correctly, so it has to be something else. Good point though. :)
User avatar
Margarita Diaz
 
Posts: 3511
Joined: Sun Aug 12, 2007 2:01 pm

Post » Tue Jun 19, 2012 9:11 am

I may be misunderstanding how HasMagicEffect works. The wiki gives the example:

if (Game.GetPlayer().HasMagicEffect(RockjointEffect))  Debug.Trace("The player has rockjoint")endIf

However, if you look in the CK for "RockjointEffect" under Magic Effect, it isn't there. So, I am wondering if this was just a typo or fake effect for the sake of the example, or if I am incorrect in using the ID of my actual magic effect when I check "if phiSpellTarget.HasMagicEffect(phiTameBeastSet)"?

I don't think this is the problem though. Again, the scripts all compile fine.
User avatar
jadie kell
 
Posts: 3497
Joined: Sat Jul 29, 2006 3:54 pm

Post » Tue Jun 19, 2012 2:48 pm

I was just looking at same thing.

Take a look at Magic > Spell > Disease /// DiseaseRockJoint is there ... but Diseases can only effect certain things (stamina, health and so on ... but I guess you could just make a small amendment, to health or whatever, just to test ... I never know where/how these lists are generated ... must be a Formlist, I guess?)

Have you tried casting at the animal and giving it a "Tamed" disease (which has a small impact on a stat, just to make the disease work)

KEYWORDS: I'm not sure how you set them, for a Disease ... And I think you need them to test whether an animal has the "disease"? (Actually, maybe not for Diseases?)
User avatar
Cat Haines
 
Posts: 3385
Joined: Fri Oct 27, 2006 9:27 am

Post » Tue Jun 19, 2012 10:36 am

EDIT: I am having somewhat of a fun time with it. Just a little. :wink:
User avatar
Ross
 
Posts: 3384
Joined: Thu Aug 10, 2006 7:22 pm

Post » Tue Jun 19, 2012 8:50 am

I am having somewhat of a fun time with it. Just a little. :wink:
That's the spirit! :)

"Concentration Effects are cast while the button is pressed, and continually drain Magicka while the spell remains in effect." - From the wiki.

Does this mean that your taming effect is only Active while you are taming?

What would happen if you made the taming effect a "Constant"?
User avatar
Dan Endacott
 
Posts: 3419
Joined: Fri Jul 06, 2007 9:12 am

Post » Tue Jun 19, 2012 3:18 pm

Still no luck, and running out of ideas what might be going wrong. I suppose it could be that OnEffectStart doesn't track the magic effect from concentration spells, or that and HasMagicEffect don't work on magic effects of the type "script," though I don't think that would be the case and anyway can't find any documentation suggesting it. Plus it compiles.

Anyway, it never gets past the OnEffectStart block and that debug text never fires. My ultimate goal was to make the tame spell able to track even if the player was using one hand or two and decrease the time it takes to tame if they are using both hands. But if the game won't track events from effects on Concentration spells (unconfirmed) I don't see how that would be possible.

It just seems lame to shoot a spell at something once and forget about it. The tame process should be more interactive.
User avatar
Petr Jordy Zugar
 
Posts: 3497
Joined: Tue Jul 03, 2007 10:10 pm

Post » Tue Jun 19, 2012 12:40 pm

Still no luck, and running out of ideas what might be going wrong. I suppose it could be that OnEffectStart doesn't track the magic effect from concentration spells, or that and HasMagicEffect don't work on magic effects of the type "script," though I don't think that would be the case and anyway can't find any documentation suggesting it. Plus it compiles.

Anyway, it never gets past the OnEffectStart block and that debug text never fires. My ultimate goal was to make the tame spell able to track even if the player was using one hand or two and decrease the time it takes to tame if they are using both hands. But if the game won't track events from effects on Concentration spells (unconfirmed) I don't see how that would be possible.

It just seems lame to shoot a spell at something once and forget about it. The tame process should be more interactive.
As I understand it, a Concentration Spell is only active on the target while the PC's mouse-button remains pressed (one or two buttons, depending on dual casting etc)

When are you trying to do this tracking?

While you are casting at the animal, or after you have finished casting?
User avatar
JaNnatul Naimah
 
Posts: 3455
Joined: Fri Jun 23, 2006 8:33 am

Post » Tue Jun 19, 2012 11:26 am

Hey. Well, there's a scripted disease that gets added to the animal, which is SUPPOSED to be tracking HasMagicEffect. So, in theory anyway, since this script is ALWAYS running on them once I add the disease, it should register ANY time they are hit with my spell. Yes, that would be only when the player is casting it.

However, I can cast it and hold it and blast the bejesus out of my test mudcrab, and nothing ever fires. The script never notices they have the effect.
User avatar
roxanna matoorah
 
Posts: 3368
Joined: Fri Oct 13, 2006 6:01 am

Post » Tue Jun 19, 2012 8:38 am

Hey. Well, there's a scripted disease that gets added to the animal, which is SUPPOSED to be tracking HasMagicEffect. So, in theory anyway, since this script is ALWAYS running on them once I add the disease, it should register ANY time they are hit with my spell. Yes, that would be only when the player is casting it.

However, I can cast it and hold it and blast the bejesus out of my test mudcrab, and nothing ever fires. The script never notices they have the effect.

Is it an ability or a disease? From what I understand you have to add abilities as spells but cast diseases (I could be wrong)
User avatar
Robert Bindley
 
Posts: 3474
Joined: Fri Aug 03, 2007 5:31 pm

Post » Tue Jun 19, 2012 8:32 pm

If you give an NPC a disease, that disease will always be present in ActiveEffects (like BoneBreak for the PC, it is there until it is cured).

This is not necessarily what you want but:

1. Cast spell at creature
2. After X seconds of casting ... maybe vary it by creature type? - creature gets Tamed Disease
3. Script needed, on creature, that does X when it has Tamed Disease

More advanced:

1. Cast spell at creature - Check for presense of Tamed Disease (Level X)
2. If no Disease present
3. After X seconds of casting ... maybe vary it by creature type? - creature gets Tamed Disease (L1)
4. If Disease is present, check level
5. After X seconds of casting ... maybe vary it by creature type? - creature gets Tamed Disease (L2)
6. If Tamed Disease == Level 10 then warn player no increase possible

7. Script needed on creature that makes it do X when it has Tamed Disease (LX)


The only thought I have is whether you can time how long the Spell Cast has occurred, so that applying the disease is not a simple click-cast, but must be held on for a while (casting duration)


stupidity note ... creatures respawn, cells - and the stuff in them - go to sleep - what will persist when/if these things happen?
User avatar
Ownie Zuliana
 
Posts: 3375
Joined: Thu Jun 15, 2006 4:31 am

Post » Tue Jun 19, 2012 8:46 am

Little tip rather than;

akTarget.HasSpell(phiTamed) != 1

in your if statement you can use;

!akTarget.HasSpell(phiTamed)

The later is equivalent more readable and unless the compiler is very clever more efficient by a tiny amount.
User avatar
Channing
 
Posts: 3393
Joined: Thu Nov 30, 2006 4:05 pm

Post » Tue Jun 19, 2012 10:14 am

Hey. Well, there's a scripted disease that gets added to the animal, which is SUPPOSED to be tracking HasMagicEffect. So, in theory anyway, since this script is ALWAYS running on them once I add the disease, it should register ANY time they are hit with my spell. Yes, that would be only when the player is casting it.

However, I can cast it and hold it and blast the bejesus out of my test mudcrab, and nothing ever fires. The script never notices they have the effect.

Don't give up!
have you tried http://www.creationkit.com/DoCombatSpellApply_-_Actor? That is the function that the vampire drain spells use to add the vampire disease to the player. I'm thinking AddSpell might not work for diseases. If this is the case the effect is never being added to the target creature and causing you all kinds of problems.

I know that concentration spell scripts run OnEffectStart events and script effects can be checked with HasMagicEffect. I have experimented with these and had some success.
User avatar
MatthewJontully
 
Posts: 3517
Joined: Thu Mar 08, 2007 9:33 am

Post » Tue Jun 19, 2012 3:31 pm

On your on effect start try doing debug.notification instead of debug.trace as you have elsewhere it may be firing but your not setup to see trace.

it does sound like the second effect script fails to fire in which case your script won't mayer.

I plan to investigate a bit more myself tonight. I think their may be something odd about magic.effect events on concentration spells.
User avatar
Daramis McGee
 
Posts: 3378
Joined: Mon Sep 03, 2007 10:47 am

Post » Tue Jun 19, 2012 6:31 pm

Another idea try giving your disease to the player using the console put player.addspell command you need to
Use the form id not the name and may need to increment the second digit of the form id.

Then have a look at active magic effects on the player through the game ui.

If its not there the disease is setup wrong or addspell doesn't apply diseases.
Also try applying a vanilla disease to show which of those it is.

User avatar
NO suckers In Here
 
Posts: 3449
Joined: Thu Jul 13, 2006 2:05 am

Post » Tue Jun 19, 2012 1:57 pm

Let me suggest some troubleshooting steps you can do. From the original post, it seems your spell attempts to add a disease, but the disease doesn't take effect. You get the notification "phiTaming Added" which just means that it tried to add it - you never actually check. Try making a slight modification to your spell script:

Scriptname phiTameBeastTriggerS extends ActiveMagicEffect  Spell Property phiTaming autoSpell Property phiTamed autoEvent OnEffectStart(Actor akTarget, Actor akCaster)	    if (!akTarget.HasSpell(phiTamed) && !akTarget.HasSpell(phiTaming)) ; <-- cleaned this up - OCD			    akTarget.AddSpell(phiTaming)			    if (akTarget.HasSpell(phiTaming))         			   Debug.Notification( "phiTaming Added to target" ) ; <-- changed wording to not confuse with self-added effects			    else					    Debug.Notification( "phiTaming NOT ADDED" ) ; <-- notify on failure too			    endif	    endifEndEvent

If you still get "phiTaming Added" then you know that the disease add succeeded and the problem is in the other script.

A few more things to check, just to make sure (hasn't been mentioned above):
  • Have you assigned actual spells to the phiTaming and phiTamed properties using the spell's script property settings?
  • Is your disease set up to ignore resistances? It may be that whatever you are trying it on has a resistance to disease.
User avatar
Chloe Lou
 
Posts: 3476
Joined: Sat Nov 04, 2006 2:08 am

Post » Tue Jun 19, 2012 9:19 am

Do you intend this to be cast on all forms of enemy, or jsut beasts? you will probably need to implement a check in your script to ensure that only beasts are effected by this (can use keywords for this).

As for the effect, it seems sorta longwinded, and using diseases could be problematic if there are immuntiies and such?

Could it be possible to have your flame thrower effect to slowly drain the aggression of the beast and then if its aggression is 0, a charm effect is applied to it?

That way you could save yourself a lot of scripting, and keep everything nicely within one event.

:)
User avatar
Sista Sila
 
Posts: 3381
Joined: Fri Mar 30, 2007 12:25 pm

Post » Tue Jun 19, 2012 10:23 am

Well thought out suggestion from the sniper devil. That sounds like it should be an efficient alternative.
User avatar
Harinder Ghag
 
Posts: 3405
Joined: Wed Jan 17, 2007 11:26 am

Post » Tue Jun 19, 2012 3:14 pm

As was said before I've looked and you should use DoCombatSpellApply to give a disease not addspell.
User avatar
x_JeNnY_x
 
Posts: 3493
Joined: Wed Jul 05, 2006 3:52 pm

Post » Tue Jun 19, 2012 11:31 am

Do you intend this to be cast on all forms of enemy, or jsut beasts? you will probably need to implement a check in your script to ensure that only beasts are effected by this (can use keywords for this).

As for the effect, it seems sorta longwinded, and using diseases could be problematic if there are immuntiies and such?

Could it be possible to have your flame thrower effect to slowly drain the aggression of the beast and then if its aggression is 0, a charm effect is applied to it?

That way you could save yourself a lot of scripting, and keep everything nicely within one event.

:smile:
Indeed, I intended to eventually implement a check, once the basic functionality was established. The CK has a checkbox to have diseases ignore immunity, so that shouldn't be an issue either. Both good ideas though, I'm still sort of at ground zero.

A charm effect might work. I was sort of thinking of passing the reference to a quest alias though, to take advantage of the scene-based AI and faction controls. Also, the reference would need to be scripted globally, to handle teleporting between cells, through doors, etc. Plus the various command capabilities I would like them to have, basically like my Master Summon mod on steroids.

I'm still picking away at it. Very slowly.
User avatar
Sophie Miller
 
Posts: 3300
Joined: Sun Jun 18, 2006 12:35 am

Post » Tue Jun 19, 2012 11:46 am

a quest will remain active in any cell as will properties on its scripts while the quest active. Don't think globals are needed. Do think about the basic differences between papyrus and the old oblivion language.

Papyrus is object orientated and multithreaded which means the best approach is often entirely different to how you would do the same thing in oblivion.

Globals are rarely needed, and you need to understand that multiple copies of a script can run at the same time and multiple scripts can also be running.

Its not just different syntax its a whole different paradigm. Have a real good read of the wiki then start from scratch.
User avatar
Romy Welsch
 
Posts: 3329
Joined: Wed Apr 25, 2007 10:36 pm

Post » Tue Jun 19, 2012 6:01 pm

Actually, many of the coding strategies I used in Oblivion were made "object oriented," by virtue of the way I went about scripting them. About the only thing that's REALLY changed are keywords and the ability to pass STRING variables. Not such a massive paradigm shift in the grand scheme of things.

True, it wasn't a native object oriented language in Oblivion. I just established convoluted scripts that MADE much of what I did conform to an object oriented logic. So, it wasn't a true object oriented language, but it could be made to work that way, for the limited applications it was capable of.

At least the logic worked that way. These things fell into these domains, and these things could operate on them in these ways. True, you might have to CREATE the functions and "things" to operate in those domains in those ways (in Oblivion), but coming from an "object oriented" programming background, it has always been a part of my approach to coding.

Think of it as "for this, goto this." It wasn't so important that certain elements were "global," because most of the functions available to the context of what commands were coded to be available (outside OBSE) to work with precluded complications inherent to larger programs. There wasn't concern about a data type using the program in a way not intended for that type, because there simply aren't that many types available to the language, and not that many ways they are specifically coded to be used.

It is all adaptation, but less radically different as you would imply. However if there is a specific aspect of an approach you see is the problem, I'd be happy to entertain alternatives. Presently I am only dabbling. When I have more time or incentive, which is to say inspiration I will I am certain be able to port these project into Papyrus with little more effort than learning the new syntax.

For me at least, the basic logical relationships haven't changed all that much.
User avatar
Andrea Pratt
 
Posts: 3396
Joined: Mon Jul 31, 2006 4:49 am


Return to V - Skyrim