Jump to content

How to remove previously added HPs


Salk

Recommended Posts

Hello again.

 

I have this situation:

 

IF
LevelGT(Player1,1)
Global("WTPFLVL2","GLOBAL",0)
THEN
    RESPONSE #100
ApplySpellRES("WTPFMLVL",Myself)
ActionOverride(Player1,ReallyForceSpellRES("WTPFCon2",Myself))
SetGlobal("WTPFLVL2","GLOBAL",1)
END


IF
LevelGT(Player1,2)
Global("WTPFLVL3","GLOBAL",0)
THEN
    RESPONSE #100
ApplySpellRES("WTPFMLVL",Myself)
ActionOverride(Player1,ReallyForceSpellRES("WTPFCon2",Myself))
SetGlobal("WTPFLVL3","GLOBAL",1)
END


IF
LevelGT(Player1,3)
Global("WTPFLVL4","GLOBAL",0)
THEN
    RESPONSE #100
ApplySpellRES("WTPFMLVL",Myself)
ActionOverride(Player1,ReallyForceSpellRES("WTPFCon2",Myself))
SetGlobal("WTPFLVL4","GLOBAL",1)
END


...

WTPFCon2 adds 2 HPs to Player1 every time the familiar levels up. It extends up to level 50. After Level 9 WTPFCon5 is applied instead (only 1 HP) and after level 19 WTPFCon5 is applied every second level up.

 

At the dead of the familiar I want to remove all those bonus HPs. Any idea of how to go about doing it?

 

Thanks!

Link to comment

Jarno's suggestion is good. You just need a single incrementing variable for that code.

 

At the dead of the familiar I want to remove all those bonus HPs. Any idea of how to go about doing it?

 

Try doing a similar thing using spells that remove 1 or 2 hit points. You'll need to detect the familiar's death and make sure the script blocks get processed.

 

I believe scripts stop running shortly after the creature dies. It may be possible to put the HP loss blocks at the top of the familiar's script and use a Die() trigger combined with Continue(), but I recall hearing that Die() might not be completely reliable. If you don't do that, you can put the blocks in a separate script (like baldur.bcs) and use the Dead() trigger instead.

 

If they're in a separate script, you'll need a way to prevent losing additional HP as you continue levelling. If you are using an incrementing global variable, the blocks whose criteria you meet when the familiar dies will execute right away, but there's nothing stopping you from meeting the criteria of the other blocks if you level up. To deal with that, you can add a final block that changes the value of the variable (to something like 50 that will nullify all the remaining blocks regardless of what level you are).

 

Now, if you want to be able to cast Find Familiar and regain all those hit points, you'll need that spell to reset some of these global variables (the HP gain variable, the HP loss variable, and the SPRITE_IS_DEAD variable for the familiar).

Link to comment

Jarno's suggestion is good. You just need a single incrementing variable for that code.

 

At the dead of the familiar I want to remove all those bonus HPs. Any idea of how to go about doing it?

 

Try doing a similar thing using spells that remove 1 or 2 hit points. You'll need to detect the familiar's death and make sure the script blocks get processed.

 

I believe scripts stop running shortly after the creature dies. It may be possible to put the HP loss blocks at the top of the familiar's script and use a Die() trigger combined with Continue(), but I recall hearing that Die() might not be completely reliable. If you don't do that, you can put the blocks in a separate script (like baldur.bcs) and use the Dead() trigger instead.

 

If they're in a separate script, you'll need a way to prevent losing additional HP as you continue levelling. If you are using an incrementing global variable, the blocks whose criteria you meet when the familiar dies will execute right away, but there's nothing stopping you from meeting the criteria of the other blocks if you level up. To deal with that, you can add a final block that changes the value of the variable (to something like 50 that will nullify all the remaining blocks regardless of what level you are).

 

Now, if you want to be able to cast Find Familiar and regain all those hit points, you'll need that spell to reset some of these global variables (the HP gain variable, the HP loss variable, and the SPRITE_IS_DEAD variable for the familiar).

 

I had already reset the HP gain variables in the familiar script on Die() condition and when I tested it, it seemed to work fine so I think I'd rather keep it in there instead of baldur.bcs. And I have a spell that removes the same HPs but I was trying to figure out how to keep count of the number of times it should execute, depending on the level.

 

I can imagine that there is a better way other than setting 50 global variables but if it works then I guess it's fine by me.

 

What is the SPRITE_IS_DEAD variable?

Thanks!

Link to comment

As mentioned, you can use 1 variable instead of 50, but I can't imagine a way to avoid needing 50 script blocks.


What is the SPRITE_IS_DEAD variable?

 

When a creature dies, a variable is set. The name of that variable depends on the creature's script name (aka death variable), which is located at 0x280 in the .cre file. If your creature's script name were FAMILIAR1, the variable SPRITE_IS_DEADFAMILIAR1 would be incremented when that creature dies. When the Dead() trigger is used, this variable is checked to determine if the creature is dead.

Link to comment

I can imagine that there is a better way other than setting 50 global variables but if it works then I guess it's fine by me.

What we, Mike and I propose is instead of this:

IF
LevelGT(Player1,1)
Global("WTPFLVL2","GLOBAL",0)
THEN
    RESPONSE #100
ApplySpellRES("WTPFMLVL",Myself)
ActionOverride(Player1,ReallyForceSpellRES("WTPFCon2",Myself))
SetGlobal("WTPFLVL2","GLOBAL",1)
END


IF
LevelGT(Player1,2)
Global("WTPFLVL3","GLOBAL",0)
THEN
    RESPONSE #100
ApplySpellRES("WTPFMLVL",Myself)
ActionOverride(Player1,ReallyForceSpellRES("WTPFCon2",Myself))
SetGlobal("WTPFLVL3","GLOBAL",1)
END

You just use this:

IF
LevelGT(Player1,1)
Global("WTPFLVL","GLOBAL",0)
THEN
    RESPONSE #100
ApplySpellRES("WTPFMLVL",Myself)
ActionOverride(Player1,ReallyForceSpellRES("WTPFCon2",Myself))
SetGlobal("WTPFLVL","GLOBAL",1)
END


IF
LevelGT(Player1,2)
Global("WTPFLVL","GLOBAL",1)
THEN
    RESPONSE #100
ApplySpellRES("WTPFMLVL",Myself)
ActionOverride(Player1,ReallyForceSpellRES("WTPFCon2",Myself))
SetGlobal("WTPFLVL","GLOBAL",2)
END

See, now you have 1 global called WTPFMLVL, instead of 50 WTPFMLVLx, where the x is 1-50.

This actually lessens your chance of failure when you remove the HPs, and then find another familiar, as you don't need to make 50 variants of the set global x to zero, when you can set just the one. And players will hate you for using 50 globals, as over 200 is known to be able to cause LAG, bloat your save game etc.

Link to comment

When a creature dies, a variable is set. The name of that variable depends on the creature's script name (aka death variable), which is located at 0x280 in the .cre file. If your creature's script name were FAMILIAR1, the variable SPRITE_IS_DEADFAMILIAR1 would be incremented when that creature dies. When the Dead() trigger is used, this variable is checked to determine if the creature is dead.

 

If I understand correctly I need to reset the Global SPRITE_IS_DEADSCRIPTNAME in the Die() script only if the Dead() trigger is used somewhere else?

 

By the way, only now do I realize I might have probably used Opcode 195 that seemed to be perfect for the HP and constitution loss... That'd have cut down the size of the script significantly...

Link to comment

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...