wiki example still correct? (or did i simply failed?)

Post » Wed Jun 20, 2012 9:19 pm

hey guys,

my intention:
i am creating new perks for a perk-overhaul. the specific perk should work the way that it automatically casts the spell which is hold in one hand while the player wields a one-handed weapon in the other after and enemy got hit with the weapon.

my problem:
i need to have an activator, like an "onhit" - event. therefore i have to distribute a script containing this onhit-activator.
i wanted to use this wiki-example * as a basic idea to distribute my script, but this example as given seems not to work at all.

my request:
can an experienced modder have a look over it and try it by himself (not just subjunctivly say it "should" work). maybe i am too stupid (i recently started with the creation kit) or the example is missing something or simply doesnt work at all.
the example is a result of this discussion **
also, if anyone has another idea of how to distribute a specific script, i welcome all ideas
i am far beyond having a worked script, i simply try to figure out a basic structure how i can accomplish my idea.
fyi: i am using skse and script dragon extension. not quite sure how they interfere. skse shouldnt do at all since its just an extension.

greetings and thanks in advance
moorleiche2k


for what reason ever i am not allowed to link :( , i will try to figure out how to do this, as long as i dont know why i can just tell you how to find the urls. additionally i can pm you and give the url in the pm - at least if i am allowed to do this in pms

* - link one: search for "dynamically attaching scripts" on the creation kit wiki site
** - link two: search for "dynamically attaching scripts to actors near the player" in this forum
User avatar
Marine Arrègle
 
Posts: 3423
Joined: Sat Mar 24, 2007 5:19 am

Post » Thu Jun 21, 2012 4:51 am

need 5 posts and a member for about a week(?) to post links.

If you have your script, just post it(everything, not parts) so people can have a look at it.
User avatar
Darren
 
Posts: 3354
Joined: Wed Jun 06, 2007 2:33 pm

Post » Thu Jun 21, 2012 12:55 am

Linked article: http://www.creationkit.com/Dynamically_Attaching_Scripts

I wrote it, and the examples work for me (obviously). Of course, no one has told me that they've used it and had it work for them. So maybe there is something wrong with what I wrote. But then again, you're the first person to have said anything about it.

If you're not doing everything exactly like in the article, then like Terra Nova says, post your script.
User avatar
Anna S
 
Posts: 3408
Joined: Thu Apr 19, 2007 2:13 am

Post » Thu Jun 21, 2012 6:56 am

well, ok..
first of all i did (assumingly) exactly what was described in the wiki for several times, without any additions or whatever...
my attempts simply didnt worked out, in other words, there were no notifications like "You did XYZ points of damage." shown.

this time i started righ from the beginning with a few debug-messages.
i used a more ineffective but for me more logical order but still its almost 95%based on the wiki site:


1) created an quest 'aaSpellswordCloakAbilityDistribution' with 'playerref' in 'any' cell and namealias 'aaSpellswordPlayerAlias'.
'aaSpellswordCloakAbility' was added to spells-tab after i created it in 4)

2) created an effect 'aaSpellswordCloakEffect' with 'cloak', 'constant effect' and 'self'.

3) created a "hello world" tutorial script and placed it in the effect 'aaSpellswordQuestCheckEffect'.

Spoiler
Scriptname aaSpellswordQuestCheckScript extends activemagiceffect  {It prints the message "Quest started" to the screen once.}Event OnInit()	Debug.MessageBox("Quest started")EndEvent

4) the effects 2) + 3) were placed in an ability 'aaSpellswordCloakAbility'. the effect 'aaSpellswordCloakEffect' got a magnitude of 14 (it should affect enemies in melee range ,and if idle spare ressources)

5) created script 'aaSpellswordDeliverScript'

Spoiler
Scriptname aaSpellswordDeliverScript extends activemagiceffect  Spell Property aaSpellswordHitScriptAbility AutoEvent OnEffectStart(Actor akTarget, Actor akCaster)	akTarget.AddSpell(aaSpellswordHitScriptAbility)	debug.MessageBox("Spell was Cast")EndEvent

this was placed in the effect 'aaSpellswordDeliverEffect' with 'script', 'concentration' and 'aimed'. the effect was then put into a new spell 'aaSpellswordScriptDeliverSpell' with the conditions 'getdead = 0' and 'hasmagiceffect aaSpellswordHitScriptEffect = 0'.

6) 'associated item 1' of 'aaSpellswordCloakEffect' was changed to 'aaSpellswordScriptDeliverSpell'

7) created effect 'aaSpellswordHitScriptEffect' with 'script', 'constant effect' and 'self'. in this effect a script 'aaSpellswordHitScript' was placed.

Spoiler
Scriptname aaSpellswordHitScript extends activemagiceffect  Actor MySelfFloat HealthEvent OnEffectStart(Actor akTarget, Actor akCaster)	MySelf = akTarget	Health = MySelf.GetActorValue("Health")	RegisterForSingleUpdate(0.25)EndEventEvent OnUpdate()	Health = MySelf.GetActorValue("Health")	RegisterForSingleUpdate(0.25)EndEventEvent OnEffectFinish(Actor akTarget, Actor akCaster)	UnregisterForUpdate()EndEventEvent OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, \  bool abSneakAttack, bool abBashAttack, bool abHitBlocked)	Float Damage = Health - MySelf.GetActorValue("Health")	Health = MySelf.GetActorValue("Health")	if (akAggressor == Game.GetPlayer())		Debug.Notification("You did " + Damage as Int + " points of damage.")	debug.Messagebox("You hit your Target")	endifEndEvent

8) the effect was placed in an ability 'aaSpellswordHitScriptAbility'

i replaced almost all notifications with messageboxes since the notificications are not shown ingame (anyone got a clue?).

i made 2 experiences while running:
a clean save with the activated mod gives me a single time the msg-box "Quest started" and afterwards over and over again the msg-box "Spell was Cast". it is interrupted for half-a second every few msg, assumingly because the cycle starts over again.
a not clean save gives me no message boxes at all. however i have the cloak ability and effect shown in my active-effects tab ingame.

assumingly i dont have working state behind adding the spell, so better just ignore this for now.

thats the state of affairs. thanks for you help.

moorleiche2k

ps.: @RandomNoob the non-appereance of notifications as well as not using a clean save might be the reason why i falsy interpreted your example as non-functional. i figured this out while scripting with messageboxes. sorry for the assumption
User avatar
Ricky Rayner
 
Posts: 3339
Joined: Fri Jul 13, 2007 2:13 am

Post » Wed Jun 20, 2012 7:31 pm

What you said about the "Spell was Cast" message box made me scratch my head. So I followed the steps I laid out and discovered that I made a mistake when I wrote the article.

The conditions for "HasMagicEffect" and "GetDead" should be added to the magic effect's Target Conditions and not to the spell's Effect Item Conditions. I've made the changes to the article.

So other than that bug, are you saying that everything else works correctly?
User avatar
Ysabelle
 
Posts: 3413
Joined: Sat Jul 08, 2006 5:58 pm

Post » Wed Jun 20, 2012 11:01 pm

no, it doesnt. at least regarding the message of how much damage one did. and this i tested with messageboxes and not notifications.
regarding my first non-understanding:

i recieve the msg-box "spell was cast" repeatedly. so the spell is cast but seem not recognize that the ability was delivered, if at all.
whats the reason for this?
if the ability 'aaSpellswordHitScriptAbility' is spread to npcs, the spell 'aaSpellswordScriptDeliverSpell' which delivers the ability should stop beeing cast. correct?
if yes, then something is wrong here. my assumptions:

- ability 'aaSpellswordHitScriptAbility' isnt applied at all.
- ability 'aaSpellswordHitScriptAbility' doesnt stay active long enough to prohibit a repeatedly casting of the spell 'aaSpellswordHitScriptAbility' several times a second
- stopping conditions still dont work.

if not, please give me a brief explanation why the spell is casted over and over again. maybe because the 'aaSpellswordCloakAbility' casts it without conditional check but the spell itself doesnt deliver its effects because of the effects conditions?

still, notifications dont work. i changed now all notifications to messageboxes. the messagebox indicating that i did xyz damage still doesnt appear as well as my addition that the npc got hit. tested it on lydia.

ps.: if interested i can sent you the datapackage via "whatsoever". its not just a script but also an .esp edit which makes it complicate to search for errors within a forum.
pps.: how long does an ability stay active on a npc or player in generell? is a script/ability loosened from the character/npc after completion?
User avatar
Daramis McGee
 
Posts: 3378
Joined: Mon Sep 03, 2007 10:47 am

Post » Thu Jun 21, 2012 2:16 am

Like I said in my last post, the reason you repeatedly get the "Spell was Cast" message box is because of the mistake I made in the article. If you would just apply the changes I described, that would no longer be a problem.

I have no idea why your notifications don't work. The ability would stay on the NPC until he/she gets reset or I guess when the mod is removed.

This is a video of me following the article on the wiki. I wasn't reading the directions while creating it so I made a couple mistakes and it took me 3 tries to get it right.

http://youtu.be/4FbzflEesLI
User avatar
Budgie
 
Posts: 3518
Joined: Sat Oct 14, 2006 2:26 pm

Post » Wed Jun 20, 2012 9:05 pm

i did it as you said already on my own a few days before (looked strange even to a greenhorn) and additionally yesterday but didnt do the trick.

BUT:

actually the trick is the property. check your video and you will see that in your 3rd attempt you explicitly change the properties to 'monitorability' in the script->property tab. this i did and.....TADA...its working now even with notifications. seriously i am quite happy that you failed 3 times :tongue:.

FYI: please have a look at the symbol of the script, it changes after you have chosen the property from a fat black cross to cross + pencil. somehow the property needs to be linked seperatly to the corresponding ability/spell.
this did the trick at least for me.

as a side-note: i used this time 'PlayerRef' in the 'QuestAlias' Tab but havent checked its impact so far, so this might be another cause. but i doubt it since the 'CloakAbility' is loaded and functional.

thanks man, you finally brought a 50hour creation kit odysse to an end. now i can start working on the actual functionality of the OnHit-Script-


ps.: what kind of ck-version do you use? i loaded mine via steam and i sadly dont have this fancy "ignore all warnings button".
User avatar
Taylrea Teodor
 
Posts: 3378
Joined: Sat Nov 18, 2006 12:20 am

Post » Thu Jun 21, 2012 10:29 am

It's been mentioned before around here every once in a while:

The "ignore all warnings" is the same as "cancel". It's got something to do with how the ck is translated iirc

- Hypno
User avatar
Monika Krzyzak
 
Posts: 3471
Joined: Fri Oct 13, 2006 11:29 pm

Post » Thu Jun 21, 2012 5:14 am

FYI: please have a look at the symbol of the script, it changes after you have chosen the property from a fat black cross to cross + pencil. somehow the property needs to be linked seperatly to the corresponding ability/spell.
this did the trick at least for me.

Actually, that step is mentioned in the http://www.creationkit.com/Dynamically_Attaching_Scripts#Create_the_Spell. It's a single line after the block of code:

Remember to set the value of the 'MonitorAbility' to the MonitorAbility that we created earlier.
User avatar
Multi Multi
 
Posts: 3382
Joined: Mon Sep 18, 2006 4:07 pm

Post » Thu Jun 21, 2012 8:30 am

oh well, then sorry.
i thought the "value" you mentioned was related to the 'monitor ability' inside the script of the 'applying spell' and not to the property window outside of the script-code.
maybe you can clarify this a bit so that greenhorns like me wont get into trouble. i would be grateful for this.
still i am happy that the basic structure is working.

i will have further questions in the future. may i ask you in this thread or shall i open a generell one? dont want to overextend your help.

my problems at the moment:
to be able to cast an equipped spell i need the targets id and the activator. the activator is the 'On-Hit' event, the id of the object is the target id on which the 'On-Hit' event is triggered.
the posted script is used instead of your 'MonitorEffect'-Script.

Spoiler
Scriptname aaSpellswordActivatorScript extends activemagiceffect  Actor MySelfString Property TargetID AutoBool Property TGHit Auto{Defines properties for detection of an On-Hit event on the Object "TargetID"}Event OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, \  bool abSneakAttack, bool abBashAttack, bool abHitBlocked)  {If the object is hit this event switches 'TGHit' to true and saves the ID of the object in 'TargetID'}	if (akAggressor == Game.GetPlayer())		TGHit = true		TargetID = MySelf.GetActorReference()		Debug.Notification("Value of 'TargetGothit is' " + TGHit as Bool + "'and TargetID is'" + TargetID as String + "")	endifEndEventFunction GetActorReference(Actor MyAlias)	MySelf = MyAlias.GetActorReference()EndFunction

the boolean 'TGHit' stuff is working, but TargetID is just a thought and doesnt. obviously the whole script is broken by this. any ideas how to extract the id and place it in 'TargetID' ?

@ Hypno: thanks for the info
User avatar
Nicholas C
 
Posts: 3489
Joined: Tue Aug 07, 2007 8:20 am

Post » Wed Jun 20, 2012 7:12 pm

I think it would be better to open a general thread. As for your script, I have no idea what you're trying to do. To get the reference ID of the object the script is on, use GetTargetActor(). But you can't cast a reference ID into a string. And why are you using functions from the reference alias script at all?
User avatar
nath
 
Posts: 3463
Joined: Mon Jan 22, 2007 5:34 am

Post » Thu Jun 21, 2012 5:11 am

well, to cut the long story short: i need both the actor-id as well as an On-Hit activator. more to come when i post this in the new thread. btw, thanks for the hint with the gettargetactor.
And why are you using functions from the reference alias script at all?
because i am simply unexperienced and didnt knew what "extends" means. want to laugh? i even created another script with 'extends ReferenceAlias' just to get the actor's id :blush:.
User avatar
Ashley Hill
 
Posts: 3516
Joined: Tue Jul 04, 2006 5:27 am

Post » Thu Jun 21, 2012 12:49 am

deleted on myself...will post it in new thread
User avatar
BaNK.RoLL
 
Posts: 3451
Joined: Sun Nov 18, 2007 3:55 pm

Post » Thu Jun 21, 2012 2:37 am

RandomNoob wrote
I wrote it, and the examples work for me (obviously).

First, I'd like to thank you very much. :biggrin:

Secondly, though, I was confused by the call to UnregisterForUpdate in the OnEffectFinish event of the DamageMonitorScript in this example. Surely, since it's an ability, the effect never does finish?
User avatar
Sabrina Steige
 
Posts: 3396
Joined: Mon Aug 20, 2007 9:51 pm

Post » Wed Jun 20, 2012 11:41 pm

Well, if the actor dies, the ability would be dispelled and the effect will finish. However, that part is pretty much just useless fluff I threw in. When a magic effect finishes, everything is automatically unregistered.
User avatar
Nathan Maughan
 
Posts: 3405
Joined: Sun Jun 10, 2007 11:24 pm

Post » Thu Jun 21, 2012 4:37 am

Right, so using updates like that is strictly for those who are about to die.

Thanks!
User avatar
Vera Maslar
 
Posts: 3468
Joined: Wed Sep 27, 2006 2:32 pm


Return to V - Skyrim