Jump to content

Scripting Troubles


Recommended Posts

I'm trying to write out a script for a boss that will cause an effect at 75% of its health, 50% of its health, and 25% of its health. (The thing it's intended to do is make the boss cast a spell on itself for a pally bubble effect, or adding a shader and making them a 'ghost' for 5 seconds. Here's the script.

 

scn SFKPallyBubbleScript

 

short DoOnce

 

begin gamemode

if SFKCommanderSpringvaleREF.getav health < 75% && SFKCommanderSpringvaleREF.getav health > 50% ( DoOnce )

SFKCommanderSpringvaleREF.cast SFKPallyBubbleAB SFKCommanderSpringvaleREF

endif

elseif SFKCommanderSpringvaleREF.getav health < 50% && SFKCommanderSpringvaleREF.getav health > 25% && ( DoOnce )

SFKCommanderSpringvaleREF.cast SFKPallyBubbleAB SFKCommanderSpringvaleREF

endif

else if SFKCommanderSpringvaleREF.getav health < 25% && SFKCommanderSpringvaleREF.getav health > 0% && ( DoOnce )

SFKCommanderSpringvaleREF.cast SFKPallyBubbleAB SFKCommanderSpringvaleREF

endif

end

 

When I try to save it there's no problems, but when I try to beat the guy up in game, nothing happens; he just dies as usual.

 

Also, while I have this thread open..

1. I'm trying to add a shader to a horse to make it appear ghostly. It's the same shader as applied to other NPC's in my mod as well as some in-game, such as the Forlorn Watchman. When the horse is mounted by the player, the player gains the shader as well, though, and it does not go away once the player dismounts. How do I get rid of the player gaining the shader?

2. To start the mod, the player has to go through a portal after speaking with a certain NPC. I don't want to put the portal inside the city for fear of it causing incompatibilities with Better Cities, Open Cities, etc., and I don't want to put it in the middle of nowhere, because the story requires the NPC to be near people. Where can I jam the NPC and his portal to avoid incompatibilities?

Link to comment
Share on other sites

Oblivion scripting isn't the same as any other scripting. The doonce variable can only be set to a different number, it isn't a function/command.

I don't think game recognizes percentages like that. (actually the only usage I know of percentage is with variables with message(boxes))

You'd have to do some math instead. (Comparing the GetAv with the GetBaseAv with *0.5 etc.etc.)

Link to comment
Share on other sites

The script logical part could be

 

scn SFKPallyBubbleScript

short DoOnce

begin gamemode
If DoOnce != 1   
   if (SFKCommanderSpringvaleREF.getav health <= (SFKCommanderSpringvaleREF.GetBaseActorValue health * 0.25))
      SFKCommanderSpringvaleREF.cast SFKPallyBubbleAB SFKCommanderSpringvaleREF
      Set DoOnce to 1
      Return
  elseif (SFKCommanderSpringvaleREF.getav health <= (SFKCommanderSpringvaleREF.GetBaseActorValue health * 0.5))
     SFKCommanderSpringvaleREF.cast SFKPallyBubbleAB SFKCommanderSpringvaleREF
     Return
  elseif (SFKCommanderSpringvaleREF.getav health <= (SFKCommanderSpringvaleREF.GetBaseActorValue health * 0.75))
     SFKCommanderSpringvaleREF.cast SFKPallyBubbleAB SFKCommanderSpringvaleREF
  Endif
endif
end 

 

PS: Actually I'm unsure if the Return is needed, you could try without it first. Since, if I recall correctly, the Elseif structure simulates the modular "Case" structure.

 

It's not allowed the Else or Elseif without a preceding If, so you must never terminate the block prematurely with an Endif. Notice an already active If (a 'wrong' if) would become linked to that else with undesirables results).

 

PS2: Still a closed block is allowed inside a greater block: example:

 

If condition1
  DoSometing
Elseif condition2
  if conditionX
    DoAnotherthing
  else
    DoAthirdThing
  endif
Elseif condition3
  DoFinalThing
Endif

 

and the internal "If" block does not interferes the other since it's a complete and closed block in itself.

Link to comment
Share on other sites

Ah, CS Wiki doesn't list much about DoOnce. Also, decimals work just as well as percentages, according to math class.. At least it has some obscure applications.

I'll try that or a couple of permutations and see what I get.

Would adding a script to the end of "Begin onreset, set DoOnce to 0, end" be necessary to make the script capable of running after a cell reset?

Link to comment
Share on other sites

Ah, CS Wiki doesn't list much about DoOnce. Also, decimals work just as well as percentages, according to math class.. At least it has some obscure applications.

I'll try that or a couple of permutations and see what I get.

Would adding a script to the end of "Begin onreset, set DoOnce to 0, end" be necessary to make the script capable of running after a cell reset?

DoOnce is just a meaningful variable name and I must agree it seems really a Function name :thumbsup: actually there should be such function since it would be very useful.

 

Notice it is local to the script too so it may exist in several scripts independently. You can't change it from outside the actual script... except if it is a quest script where it is considered almost "global" and keeps the results even between game sessions. In that case it would be accessed prefixing the quest name, like: Set Myquest.DoOnce to 0, assuming it is defined in the quest script.

Link to comment
Share on other sites

I've altered the script some.. Now here's what I have.

scn SFKPallyBubbleScript

 

ref self

 

short DoOnce1

short DoOnce2

Short DoOnce3

 

begin gamemode

if ( SFKCommanderSpringvaleREF.getav health <= SFKCommanderSpringvaleREF.getbaseav health * .75 ) && ( DoOnce1 != 1)

SFKCommanderSpringvaleREF.cast SFKPallyBubbleAB SFKCommanderSpringvaleREF

set DoOnce1 to 1

return

endif

elseif ( SFKCommanderSpringvaleREF.getav health <= SFKCommanderSpringvaleREF.getbaseav health * .50 ) && ( DoOnce2 != 1)

SFKCommanderSpringvaleREF.cast SFKPallyBubbleAB SFKCommanderSpringvaleREF

set DoOnce2 to 1

return

endif

else if ( SFKCommanderSpringvaleREF.getav health <= SFKCommanderSpringvaleREF.getbaseav health * .25 ) && ( DoOnce3 != 1)

SFKCommanderSpringvaleREF.cast SFKPallyBubbleAB SFKCommanderSpringvaleREF

set DoOnce3 to 1

return

endif

end

 

 

However, upon testing it now, he gets locked in a casting animation once his health goes below 75%, then it just loops a casting sound when he dies. What causes this?

 

Also, I've created another script to apply to all enemies in the mod, for forcibly lowering their aggro range. It just sets their faction to one that hates the player upon the player getting too close. Here it is.

begin OnLoad

set self to getself ;So the guy knows who gets the script applied to it

end

 

begin onactivate ;If the player should somehow activate them without the distance part going off

setfactionrank SFKWorgenFaction -1 ;Likes player faction, so they won't attack until you get too close

setfactionrank SFKWorgenFaction2 1 ;Hates player faction, as well as prey. Loves other worgies

activate

end

 

begin onhit player ;For when player use arrows/spells without getting close

setfactionrank SFKWorgenFaction -1

setfactionrank SFKWorgenFaction2 1

end

 

begin gamemode

if player.getdistance self <= 250

;If the player comes within 250 units of the mob, they'll aggro. To measure it, line up 250 bottles of beer standing up.

setfactionrank SFKWorgenFaction -1

setfactionrank SFKWorgenFaction2 1

endif

end

 

 

The problem is, when the player gets close to the enemy, it doesn't do anything. It just stands there and will defend itself when attacked. When dead, trying to loot it doesn't do anything (I.E. doesn't open the loot menu). What's wrong with this script?

Link to comment
Share on other sites

For the location problem, I'd pick one of the small populated villages that aren't in their own worldspace. A couple of them have NPCs that are always wandering around the area, and not too many are affected by any popular mods that I'm aware of. I'm thinking Pell's Gate would be a good spot, there are several NPCs who are always right there within a small area, and offhand I can't think of any mods that do anything to that cell. Or maybe one of the Daedric shrines... another place there are generally at least 3 or 4 NPCs standing around in one place who never leave.
Link to comment
Share on other sites

Sound good to me. I'll try a village near to a city.. Umm.. Harm's Folly?

 

Meantime, I'll toy around with th scripting some more. I cannot progress until I complete the scripting, as 3 of the major bosses depend on health-based criteria.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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