Script works except for one flaw

Post » Tue Jun 19, 2012 5:11 am

Hey ppl.

I am trying to get the following script to work:


Scriptname myweaponscript extends activemagiceffect

int weaponvalue = http://forums.bethsoft.com/topic/1351312-script-works-except-for-one-flaw/100

Event OnEffectStart(Actor Target, Actor Caster) ;; script triggers on every hit
weaponvalue = http://forums.bethsoft.com/topic/1351312-script-works-except-for-one-flaw/weaponvalue - 10 ;; on every hit the value has 10 removed from it (this does not happen when it should)

if weaponvalue =http://forums.bethsoft.com/topic/1351312-script-works-except-for-one-flaw/= 0 ;; when the value reaches 0 it executes a command
wepdrop.show() ;; shows a message (property)
endif
EndEvent


The script does exactly what it should do with 1 exeption, on every hit a value (weaponvalue) is supposed to have 10 removed from it (starts at 100) but this doesn't seem to happen, anyone have any ideas why?

:ermm:
User avatar
Zach Hunter
 
Posts: 3444
Joined: Wed Aug 08, 2007 3:26 pm

Post » Tue Jun 19, 2012 12:29 am

Magic scripts do NOT store the value from one run to the next.
You would have to use a global variable to store any values you want to keep track of.
User avatar
Brittany Abner
 
Posts: 3401
Joined: Wed Oct 24, 2007 10:48 pm

Post » Tue Jun 19, 2012 7:33 am

Magic scripts do NOT store the value from one run to the next.
You would have to use a global variable to store any values you want to keep track of.

Awwww that svcks.

Is their any way to create a temporary global?

:ermm:
User avatar
Cody Banks
 
Posts: 3393
Joined: Thu Nov 22, 2007 9:30 am

Post » Tue Jun 19, 2012 2:21 am

You could use a token (an unplayable, therefore invisible, piece of armour) or the rank of a faction you create for this purpose to store some extra data on an actor that would persist between instances of your magic effect, and be accessible from your script.

Cipscis
User avatar
dean Cutler
 
Posts: 3411
Joined: Wed Jul 18, 2007 7:29 am

Post » Tue Jun 19, 2012 10:51 am

The rank of a faction you create for this purpose to store some extra data on an actor that would persist between instances of your magic effect, and be accessible from your script. Cipscis

Explain please?
User avatar
Alycia Leann grace
 
Posts: 3539
Joined: Tue Jun 26, 2007 10:07 pm

Post » Tue Jun 19, 2012 9:22 am

He's saying you can fake a global variable, by abusing for example a faction rank (an integer value) or create a non-playable/invisible item and attach a script to that.
User avatar
Mr. Ray
 
Posts: 3459
Joined: Sun Jul 29, 2007 8:08 am

Post » Tue Jun 19, 2012 2:51 am

He's saying you can fake a global variable, by abusing for example a faction rank (an integer value) or create a non-playable/invisible item and attach a script to that.

Using tokens is what I did before but unfortunately didn't work out, its the reason I am using scripted enchantments instead which works perfectly except for that 1 private variable issue.

How would the faction rank thing work? (example)

:ermm:
User avatar
Julie Serebrekoff
 
Posts: 3359
Joined: Sun Dec 24, 2006 4:41 am

Post » Tue Jun 19, 2012 9:43 am

I never abused anything yet, but from the looks of Faction.psc you can use Get/Set/ModReaction(), you just have to create a new faction.
Since that will undoubtedly result in ugly and weird code, you should use a custom property (with getter and setter) to hide that ugliness.
User avatar
Tamika Jett
 
Posts: 3301
Joined: Wed Jun 06, 2007 3:44 am

Post » Tue Jun 19, 2012 2:17 am

surely this should be an on-hit event? and because the magic effect that has this script is applied to the player actor- it can reference a varaible atatched to it?
User avatar
Brandon Wilson
 
Posts: 3487
Joined: Sat Oct 13, 2007 1:31 am

Post » Tue Jun 19, 2012 1:44 pm

surely this should be an on-hit event? and because the magic effect that has this script is applied to the player actor- it can reference a varaible atatched to it?

OnHit only applies to a source that can actually be hit which is only actors.
User avatar
Rudi Carter
 
Posts: 3365
Joined: Fri Sep 01, 2006 11:09 pm

Post » Tue Jun 19, 2012 3:24 am

http://www.creationkit.com/OnHit_-_ObjectReference should work for all http://www.creationkit.com/ObjectReference_Script. Although only http://www.creationkit.com/Actor_Script would be affected by a magic effect, all ObjectReferences will register that they've been hit.

Cipscis
User avatar
Janeth Valenzuela Castelo
 
Posts: 3411
Joined: Wed Jun 21, 2006 3:03 am

Post » Tue Jun 19, 2012 2:41 am

Using global variable is rather simple, and makes more sense than using a faction. Its the same work and process to use a global.

1. Create >Miscellaneous >Global object. Like 'myInputGlobalName'.
2. Attach property of 'global' to your script using the name you gave the global for the auto-fill to work.
3. get your global variable with:
float myVal = myInputGlobalName.GetValue()
Now the local variable 'myVal' will contain your global value.
4. set your global variable with:
myInputGlobalName.SetValue(1)
User avatar
Fiori Pra
 
Posts: 3446
Joined: Thu Mar 15, 2007 12:30 pm

Post » Tue Jun 19, 2012 1:21 am

Thanks for the help guys but I got the script working regardless, it turned out that when the weapon was unequipped it wasn't accounting for the fact that you may be dual-wielding thus threw everything out of whack. I had to add an unequip command under a OnUnequip event (lol).

:banana:
User avatar
Kirsty Collins
 
Posts: 3441
Joined: Tue Sep 19, 2006 11:54 pm


Return to V - Skyrim