A Little Scripting Advice

Post » Wed Aug 18, 2010 8:40 pm

Hi there,

I'm just having a wee go at scripting for Oblivion and I'm finding some of the referencing difficult to figure out, and I've not been able to find anything online addressing this area of scripting.

Basically, I thought to give myself something straight forward-ish to work on I would attempt to do something with one of my pet annoyances - that every time I get into a fight I turn into a human pincushion with 10-30 arrows sticking out of me whether I'm in linens or plate. I started looking at some code online and I could see that there were 'blocks' starting with begin and end that are a bit like functions that get called when the game has a specific event such as someone being hit with a weapon. I saw that there was one that I could apply for each of the arrows available in the game and therefor cover all of them. I don't know how I'm going to get the reference to the arrows once I'm in that block but I'm just trying out one problem at a time. The issue is that I can't seem to get a block that applys to the player. I've been looking at some of the code in other people's mods and they seem to do things like adding a global quest which in turn adds what ever spells or equipment is to be used, so I took that approach. I can add a spell (ability) or an object to the player with a script attached but these scripts although allowing functions like 'beging OnHitWith Arrow1Iron' don't seem to be called when the player is actually hit.

It's occurred to me that perhaps I need to set the target of the script within the script itself somehow but I'm not sure.

http://www.2shared.com/file/F58Dds4G/pincussion.html
User avatar
Inol Wakhid
 
Posts: 3403
Joined: Wed Jun 27, 2007 5:47 am

Post » Wed Aug 18, 2010 5:20 pm

Ok, this should be an easy question for anyone who knows how the scripting works as I've found someone else's script that uses OnHit in a similar way to the way I'm looking at:

Scriptname MartialArtsBlockParryScriptshort PCIsBlockingfloat timershort bMagicEffectBegin OnMagicEffectHit   set bMagicEffect to 1EndBegin OnHit   if (bMagicEffect == 0) && (timer > 0) && (timer <= 0.5)        MessageBox "Normally I'd Parry right now, but this is just a test."    endifEndBegin GameModeset bMagicEffect to 0;If the player has just started blocking, set the variable to track;this state and begin timerif (player.IsBlocking) && (PCIsBlocking == 0)   Set PCIsBlocking to 1   Set timer to 0endif;If the player is currently blocking, increment the timerif (player.IsBlocking) && (PCIsBlocking == 1)   set timer to timer + getSecondsPassedendif;If the player has stopped blocking, reset state and timerif (player.IsBlocking == 0) && (PCIsBlocking == 1)   Set PCIsBlocking to 0   Set timer to 0endifEnd


Unfortunately they didn't actually say how this script was attached to the player.
User avatar
Hayley O'Gara
 
Posts: 3465
Joined: Wed Nov 22, 2006 2:53 am

Post » Wed Aug 18, 2010 1:19 pm

You'd have better luck if you posted in the construction set forum
User avatar
Kara Payne
 
Posts: 3415
Joined: Thu Oct 26, 2006 12:47 am

Post » Wed Aug 18, 2010 10:41 pm

Sorry my mistake :)
User avatar
Suzy Santana
 
Posts: 3572
Joined: Fri Aug 10, 2007 12:02 am


Return to IV - Oblivion