Jump to content

Scripting Questions


AxlDave

Recommended Posts

I am trying to make armour that self-repairs, and enchanted weapons that recharge with every kill. I figure scripting is the best way to accomplish this, though I'm not sure of the commands to use.

 

For the armour, I was thinking of checking the health, and any time it falls below 125% a timer starts which adds 1% health per second. The timer bit I'm okay with, but I don't know how to check for, or add, health - CheckItem.GetHealth didn't work.

 

For the weapon, I'm pretty sure that HasMagicEffect will return whether or not the weapon is enchanted. I also thought I might be able to use how soul gems get filled to recharge the weapon directly. Trouble is, I can't seem to find whatever controls that function.

 

Can anyone offer advice about this, like whether it's possible, how to do it etc?

Link to comment
Share on other sites

yourrefitem.getcurrenthealth >

but to have that as a percentage (getcurrenthealth/getobjecthealth)*100

reference.GetCurrentCharge

GetObjectCharge

i think you must play with some math here like

let requiredcharge := ref.(getobjectcharge-getcurrentcharge)

Edited by kastano
Link to comment
Share on other sites

Awesome, thanks.

 

So I would need

 

scn BlahBlahBlah

 

short GetCurrentHealthPerc

 

BEGIIN GameMode

 

Set GetCurrentHealthPerc to ( GetCurrentHealth / GetObjectHealth ) * 100

if MyItemReference.GetCurrentHealthPerc < 125

 

Rest Of Script Here

 

is that right?

 

 

--EDIT--

 

or would it be

 

Set GetCurrentHealthPerc to ( MyItemReference.GetCurrentHealth / MyItemReference.GetObjectHealth ) * 100

if GetCurrentHealthPerc < 125

Edited by AxlDave
Link to comment
Share on other sites

No worries, thanks for the help.

 

A further question does arise, is it possible, rather than referencing each individual piece of armour, to make a generic reference in an object script that references whatever object it is a script for? Just thinking it might be more versatile that way.

Edited by AxlDave
Link to comment
Share on other sites

the referencing is for making a single script that you may attouch on every object you want to affect

like

set myitemreferance to getself

otherwise you can put the objectid(the name in cs)

also its good to put fquestdelaytime (to a value of 20)because you dont need these scripts to run often

and after the if to call a functionscript which contains your code(if that is possible)

Edited by kastano
Link to comment
Share on other sites

Okay, turns out I need some more advice. Below is the complete script I am currently running, which saves just fine so it must be grammatically correct... however only the "Settings Applied" message shows up, and that only happens once. Even when I damage the armour with a spell. Perhaps there is some basic error I'm not seeing?

 

 

 

scn AXLCrusaderRepairScript

ref        rCrusaderArmour

short    HealthCurrent
short    HealthTotal
short    HealthPercent
short    OnePercent
short    OnePercentIncrease

float    fTimer

BEGIN GameMode

    Message "Settings Applied"
    set rCrusaderArmour to GetSelf
    set HealthCurrent to rCrusaderArmour.GetCurrentHealth
    set HealthTotal to rCrusaderArmour.GetObjectHealth
    set HealthPercent to ( HealthCurrent / HealthTotal ) * 100
    set OnePercent to ( HealthTotal / 100 )
    set OnePercentIncrease to ( HealthCurrent + OnePercent )

    if HealthPercent == 125
        Message "Full Health"
        RETURN

    elseif HealthPercent < 125
        Message "Low Health"

        if fTimer > 0
            Message "Timer Started"
            set fTimer to ( fTimer - GetSecondsPassed )
        endif

        if fTimer == 0
            Message "Success"
            rCrusaderArmour.SetCurrentHealth OnePercentIncrease
            set fTimer to 5
        endif

    endif

END

 

 

Edited by AxlDave
Link to comment
Share on other sites

If the script is running on the Object itself, there is no need for a specific reference.
You can simply call "set HealthCurrent to GetCurrentHealth" and it will automatically use the item it is running on.
Only functions which require a reference as an input parameter will still need what you determined with GetSelf.

I'm not sure you can input those float values from the divisions into short variables, or if the game will rather just round them. It could cause issues though.

However, what will 'not' work in this setup is that "fTimer" will ever be "== 0". The likeliness for it to drop "< 0" with the last subtraction is far too high.
A check for it having dropped "below zero" instead might be better suited here.

And from what I remember all functions like "GetObjectHealth", which are working on the Base Object not a reference,

must be called the 2nd way in the syntax: "set HealthTotal to GetObjectHealth rCrusaderArmour".

So maybe that's why it seems to not work at all to begin with already.

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...