Quick Questions -- Quick Answers, The Eighteenth

Post » Thu May 26, 2011 10:17 pm

I'm having a bit of trouble with a small combat mod of mine. I need a way to apply additional damage to an actor that gets hit. So far I've done this with GetCrossHairRef, IsSoundPlaying and (for the attacking actor) IsAttacking || Is PowerAttacking, then ModAV2 health on the hit actor by the calculated amount. This all works fine, however, due to the fact that my script runs every frame and the conditions are true for multiple frames, the applied damage ends up being applied multiple times, which is problematic for obvious reasons. I've tried looking at the way Adrenaline Fuelled Combat applies damage, but I can't get my head around it.

Any help would be much appreciated.
User avatar
Agnieszka Bak
 
Posts: 3540
Joined: Fri Jun 16, 2006 4:15 pm

Post » Thu May 26, 2011 11:05 pm

Note though that pages warning: "In almost all cases, using a global variable is unnecessary. Variables defined in quest scripts are generally used instead, and accessed via questID.varName, or getQuestVariable questID varName."

So avoid using global variables, unless you need two different mods to communicate without one being dependent on the other.


I don't understand the warning. You say that a global is unnecessary, but I can say that a quest variable is equally unnecessary. I have been using globals in my mods, but the general vibe I get here is that I shouldn't. So before I switch over to quest variables, I gotta ask: why are quest variables better?
User avatar
james tait
 
Posts: 3385
Joined: Fri Jun 22, 2007 6:26 pm

Post » Fri May 27, 2011 7:20 am

I'm having a bit of trouble with a small combat mod of mine. I need a way to apply additional damage to an actor that gets hit. So far I've done this with GetCrossHairRef, IsSoundPlaying and (for the attacking actor) IsAttacking || Is PowerAttacking, then ModAV2 health on the hit actor by the calculated amount. This all works fine, however, due to the fact that my script runs every frame and the conditions are true for multiple frames, the applied damage ends up being applied multiple times, which is problematic for obvious reasons. I've tried looking at the way Adrenaline Fuelled Combat applies damage, but I can't get my head around it.

Any help would be much appreciated.


Instead of isattacking or ispowerattacking, you might want to try isanimgroupplaying. That way you can set up a variable that says "I applied extra damage already" and reset that variable when the actor plays a new animation group.
User avatar
Nany Smith
 
Posts: 3419
Joined: Sat Mar 17, 2007 5:36 pm

Post » Fri May 27, 2011 2:50 am

Is there a way to show ingame what AI package an actor is using?
User avatar
glot
 
Posts: 3297
Joined: Mon Jul 17, 2006 1:41 pm

Post » Fri May 27, 2011 12:14 am

I don't understand the warning. You say that a global is unnecessary, but I can say that a quest variable is equally unnecessary. I have been using globals in my mods, but the general vibe I get here is that I shouldn't. So before I switch over to quest variables, I gotta ask: why are quest variables better?
I think its in case two mods unintentionally create the same global name. That would cause problems.

Can't think of another reason off-hand.
User avatar
Victor Oropeza
 
Posts: 3362
Joined: Sun Aug 12, 2007 4:23 pm

Post » Fri May 27, 2011 7:44 am

I don't understand the warning. You say that a global is unnecessary, but I can say that a quest variable is equally unnecessary. I have been using globals in my mods, but the general vibe I get here is that I shouldn't. So before I switch over to quest variables, I gotta ask: why are quest variables better?

To me, a quest variable is better than a global one for much of the same reason that in C++ or Java, a local class variable is better than a global variable: Encapsulation of data. With quest variables I define the variable locally where it will normally be used - and if I use it from other quests I explicitely qualify it with the quest name, something that makes it easy to see when I refer to non-local variables.

But of course, globals work too, so if you have working scripts, you're better off without changing them.
User avatar
Tina Tupou
 
Posts: 3487
Joined: Fri Mar 09, 2007 4:37 pm

Post » Fri May 27, 2011 6:12 am

I think its in case two mods unintentionally create the same global name. That would cause problems.

Can't think of another reason off-hand.


Although this would probably be easily avoided by prefixing the global with your mod name or your username initials. At first I thought that it was for performance reasons, but then I realized that there's no difference between having a global to keep track of all the time and having a quest variable to track all the time.... so I really don't know either.
User avatar
joseluis perez
 
Posts: 3507
Joined: Thu Nov 22, 2007 7:51 am

Post » Fri May 27, 2011 4:43 am

This works, but there's no reason to make any dummy quest. If you have two quests (QA and QB) each with one script, just define the variable where its most used, and whenever the other scripts need to refer to it, qualify it with the other script's name. Ex:

The script attached to QA defines var1, and the script attached to QB defines var2.

When you need to refer var1 from QB's script you use "QA.var1". When refering to var2 from QA's script you use "QB.var2".

Doing this is even legal from scripts in other plugins, provided the plugin that defines the variable is a master for the one referring to it.


Yeah, just my personal design decision to keep things organized.. I have everything in one spot, so if I need to look at a variable, or what it does, I only need to look there, and my extensive annotations tell me what those variables do, what affects them, and what scripts and quests affect them :)
User avatar
Rachie Stout
 
Posts: 3480
Joined: Sun Jun 25, 2006 2:19 pm

Post » Fri May 27, 2011 3:58 am

He's screwed.

If you want him to be unattackable by enemies, use the SetGhost command additionally (this has nothing to do with the ghost shader effect - it's a setting making actors unattackable, like Haskill, and can also be used on the player).


When the player is unattackable.. does that mean enemies won't attack, or that their attacks will do no harm?

I need some way to get the player stuck while something talks, but at the same time, make sure any enemies nearby don't go berserk on them.

I don't want to have to make a script on every single enemy that toggles their AI on and off.. I mean I will if I have to, but that would be a bit crazy.
User avatar
DAVId Bryant
 
Posts: 3366
Joined: Wed Nov 14, 2007 11:41 pm

Post » Fri May 27, 2011 7:07 am

When the player is unattackable.. does that mean enemies won't attack, or that their attacks will do no harm?

I need some way to get the player stuck while something talks, but at the same time, make sure any enemies nearby don't go berserk on them.

I don't want to have to make a script on every single enemy that toggles their AI on and off.. I mean I will if I have to, but that would be a bit crazy.
If you look in the OBSE thread in the Mods forum, I think Skycaptain recently reported that DisablePlayerControls also disables NPC combat AI. Which means they continue doing whatever they are doing when it is called. I don't know if that means they'd continue attacking or not, but presumably if player is not in combat, then the player can't end up in combat.
User avatar
Blackdrak
 
Posts: 3451
Joined: Thu May 17, 2007 11:40 pm

Post » Fri May 27, 2011 9:13 am

Is there a way to prevent the FaceGen reset that occurs when the Player becomes a vampire? I can change IVampirismAgeOffset to 0, but facial features still change. Is there a non-OBSE method of saving facial features after character creation and then applying them after becoming a vampire?


I'd like to know how to do this as well. I can't use OBSE because I play the d2d version of Oblivion.
I don't want my vampires to be Fugly. Also, using ~ showracemenu to edit the features after becoming a vampire doesnt work. Once you load the game, it automatically resets to the 'Vampire face' for whatever stage of Vampirism you have.
User avatar
Stat Wrecker
 
Posts: 3511
Joined: Mon Sep 24, 2007 6:14 am

Post » Fri May 27, 2011 4:52 am

Without OBSE?

Don't become a vampire.

Alternatively: Keep a save before becoming a vampire, load that save first, then the vampire save.

There are several mods dealing with the vampire issue, but all of them require OBSE, and I don't see any way to solve the issue without OBSE (except, well, not becoming a vampire).
User avatar
Dragonz Dancer
 
Posts: 3441
Joined: Sat Jun 24, 2006 11:01 am

Post » Fri May 27, 2011 12:06 pm

Without OBSE?

Don't become a vampire.

Alternatively: Keep a save before becoming a vampire, load that save first, then the vampire save.

There are several mods dealing with the vampire issue, but all of them require OBSE, and I don't see any way to solve the issue without OBSE (except, well, not becoming a vampire).


Alright. Thanks. :/ I guess I'll just make uses of Helms while I play as a vampire.
User avatar
Enny Labinjo
 
Posts: 3480
Joined: Tue Aug 01, 2006 3:04 pm

Post » Fri May 27, 2011 1:55 am

Quick question about the "One-Mod-Rule", how does it work with quests and adding topics to them? Can two mods safely add topics to the same quest (new ones, not editting existing ones) or is it better to make a shadow-quest and add topics that way?
User avatar
Add Meeh
 
Posts: 3326
Joined: Sat Jan 06, 2007 8:09 am

Post » Thu May 26, 2011 10:07 pm

Hi there, I was wondering - how can you make an item such as the ARTraqevilStone01 holdable and droppable by the player? And sellable by a merchant? I assume making one would cause the others but ask just in case (I'm trying to make a tower defence type game with these being the towers, so being buyable/droppable/pick upabble would be nice [essential])
User avatar
Mr. Allen
 
Posts: 3327
Joined: Fri Oct 05, 2007 8:36 am

Post » Fri May 27, 2011 3:48 am

Quick question about the "One-Mod-Rule", how does it work with quests and adding topics to them? Can two mods safely add topics to the same quest (new ones, not editting existing ones) or is it better to make a shadow-quest and add topics that way?

If two (or more) mods modify the same quest directly (edit things in the quest itself) they will conflict with one another. Which ever one is last in the load order will "win" the conflict. Making a "shadow quest" is the safest bet.
User avatar
Laura Cartwright
 
Posts: 3483
Joined: Mon Sep 25, 2006 6:12 pm

Post » Fri May 27, 2011 2:14 am

Does anybody know of an activator that has no visible parts but can still be activated/targeted? I'm only interested in its model, I'm hoping someone knows of one so I won't have to dig up all the models in the bsa. :PNvm. :)

If two (or more) mods modify the same quest directly (edit things in the quest itself) they will conflict with one another. Which ever one is last in the load order will "win" the conflict. Making a "shadow quest" is the safest bet.
I thought as much, thanks. :)

-kyoma
User avatar
Dewayne Quattlebaum
 
Posts: 3529
Joined: Thu Aug 30, 2007 12:29 pm

Post » Fri May 27, 2011 5:08 am

Im considering my first attempt at Oblivion modding, and I have what is probably the first of many questions.
What would the best way to monitor the game for NPC death be? not a specific character, but each and every NPC? looking at the scripting on the wiki, i see a function to check if a character is dead, but not a general function to monitor the game as a whole.
Thanks!
User avatar
adame
 
Posts: 3454
Joined: Wed Aug 29, 2007 2:57 am

Post » Fri May 27, 2011 1:02 pm

Im considering my first attempt at Oblivion modding, and I have what is probably the first of many questions.
What would the best way to monitor the game for NPC death be? not a specific character, but each and every NPC? looking at the scripting on the wiki, i see a function to check if a character is dead, but not a general function to monitor the game as a whole.
Thanks!

Be careful what you ask for! There are a significant number of NPC's in the game, many of which wander around in areas where there are re-spawning monsters, bandits and other potential deadly foes. If you were to be notified every time any one of them dies, you wouldn't know what to do with all that information. Obviously the engine is not actually running scripts for every off-screen character, but it does have to evaluate their state when they come into scope, and must periodically determine if they're now dead, so the effect is similar.
There are also a number of NPC's who start off dead, as pre-placed victims of supposedly prior events, and the notifications for those would either come at you all at once when the game loads, or not at all, neither of which might be what you need.
So what are you trying to do that you think this would help?
User avatar
Trista Jim
 
Posts: 3308
Joined: Sat Aug 25, 2007 10:39 pm

Post » Fri May 27, 2011 10:24 am

Be careful what you ask for! There are a significant number of NPC's in the game, many of which wander around in areas where there are re-spawning monsters, bandits and other potential deadly foes. If you were to be notified every time any one of them dies, you wouldn't know what to do with all that information. Obviously the engine is not actually running scripts for every off-screen character, but it does have to evaluate their state when they come into scope, and must periodically determine if they're now dead, so the effect is similar.
There are also a number of NPC's who start off dead, as pre-placed victims of supposedly prior events, and the notifications for those would either come at you all at once when the game loads, or not at all, neither of which might be what you need.
So what are you trying to do that you think this would help?


I would like to add some functionality to a few items that are in the vanilla game, like the argonian heart used in... one of the DB quests.

I am going to try to make it so, like clannfear claws, you could get an argonian heart off of any dead argonian. (It will be an ingedient version, not a clutter version) But I havn't spotted any 'racial level list' available, and hand placing would mean any npc made from a mod wouldn't have it, so i was thinking of a script run 'on death of a npc' to see if its the right race, and if it is, place the heart in its inventory. that would also solve the problem of being able to pickpocket someone's heart out. ;)
User avatar
Neliel Kudoh
 
Posts: 3348
Joined: Thu Oct 26, 2006 2:39 am

Post » Fri May 27, 2011 10:18 am

I would like to add some functionality to a few items that are in the vanilla game, like the argonian heart used in... one of the DB quests.

I am going to try to make it so, like clannfear claws, you could get an argonian heart off of any dead argonian. (It will be an ingedient version, not a clutter version) But I havn't spotted any 'racial level list' available, and hand placing would mean any npc made from a mod wouldn't have it, so i was thinking of a script run 'on death of a npc' to see if its the right race, and if it is, place the heart in its inventory. that would also solve the problem of being able to pickpocket someone's heart out. ;)

Here's how I would script this:

Have a script that runs every couple of seconds. The script would loop through all actors in your and the 8 adjacent cells, and checking if they're dead argonians. If they are, you check if they have a specific unplayable item (token). If they don't you add one such unplayable item + an argonian heart. This will need OBSE.

e.g.

ScriptName AddArhonianHeartref actorBegin GameMode  let actor := GetFirstRef 69 1  While actor	if actor.GetDead	  if actor.GetRace == <argonian editor id>		if actor.GetItemCount heartToken == 0		  actor.AddItem heartToken 1		  actor.AddItem argonianHeart 1		endif	  endif	endif  LoopEnd

Note that this is just written down in a hurry and not at all tested.
User avatar
Hilm Music
 
Posts: 3357
Joined: Wed Jun 06, 2007 9:36 pm

Post » Fri May 27, 2011 4:49 am

I'm trying to get a mod to work where I have items that shoot at enemy NPCs. I haven't got round to aiming them at enemies yet but I have got the player able to pick them up. However, whenever you try to drop them from the inventory, they disappear... but don't drop. And when you open the inventory, they're just there again. Anyone tell me what's going on there or how to solve it? Here's the script running on it, its just a jug:

scn JMStoneSCRIPTfloat rechargeTimerbegin gameMode	if IsActionRef player == 1 		Activate	endifendbegin onActivate	set rechargeTimer to 0endBegin gameMode	set rechargeTimer to rechargeTimer - getSecondsPassed	if rechargeTimer>0		return	endif	cast StandardShockDamageTarget1Novice player	set rechargeTimer to 10end

Bear in mind that I only recently started programming so don't have that much knowledge on it...trawling through the TES wiki for commands is hard.
User avatar
Sanctum
 
Posts: 3524
Joined: Sun Aug 20, 2006 8:29 am

Post » Fri May 27, 2011 2:24 am

I'm trying to make a script to prevent the player from regaining full health after waiting/sleeping for any amount of time. Right now I'm only interested in preventing a vampire character from regaining health at all, which should be easier to code. The part of the script controlling this looks like this:
float NoHealthSleptfloat HealthSlept  ; the health you go to rest withshort doonceshort bNoSleepHeal; set in an .inishort vampireSleptBegin GameModerun batchscript blahblah (I mean that I've checked that the .ini loads correctly only once after loading, so bNoSleepHeal == 1)If PCVampire > 0	if ( vampireSlept )		Player.ModAV2 Health NoHealthSlept		set vampireSlept to 0		set doonce to 0	else		set vampireSlept to 0		set doonce to 0	endifendifendBegin MenuMode 1012if PCVampire > 0	if bNoSleepHeal		if doonce == 0			set HealthSlept to Player.GetAV Health			set NoHealthSlept to ( 0 - (( Player.GetBaseAV Health ) - HealthSlept ))			set doonce to 1		endif		if IsTimePassing			set vampireSlept to 1		endif	endifendifEnd


So my idea is to store the player's current health before he goes to rest, then modding the diference with his maximum health out of him after he wakes up.
Edit: I've made it work at last! But there's a nasty side effect... IsTimePassing does not return 1 once you have rested for 1+ hours, but as soon as you hit the "Rest" button. So while in the sleep menu, you can hit the "Rest" button and then quickly the "Stop" button, and IsTimePassing returns 1 even if you didn't actually rest at all. The result is that your health gets modded down without you having gained any from resting == death if you change your mind right before starting to rest.
I know of the IsPCSleeping, but AFAIK that only works for beds and I want to prevent health regain any time the rest menu pops up. So, aside from warning players to be careful, is there any way to prevent the script from messing with your health if no time has actually passed while resting? Also, I'm thinking of possible problems when resting with fortify health spells on, but I'm not sure of how to take them into account.
User avatar
Dean
 
Posts: 3438
Joined: Fri Jul 27, 2007 4:58 pm

Post » Fri May 27, 2011 8:30 am

So, aside from warning players to be careful, is there any way to prevent the script from messing with your health if no time has actually passed while resting? Also, I'm thinking of possible problems when resting with fortify health spells on, but I'm not sure of how to take them into account.
Use the gameHour/gameDaysPassed global to calculate the change yourself.
User avatar
KU Fint
 
Posts: 3402
Joined: Mon Dec 04, 2006 4:00 pm

Post » Fri May 27, 2011 1:54 pm

Here's how I would script this:

Have a script that runs every couple of seconds. The script would loop through all actors in your and the 8 adjacent cells, and checking if they're dead argonians. If they are, you check if they have a specific unplayable item (token). If they don't you add one such unplayable item + an argonian heart. This will need OBSE.


okay, so judging from how you set up the script, there isn't a broadcast event of NPC death that could be tagged onto to execute the script? I had hoped to make it something like a subroutine, that wouldn't affect CPU usage except when it actually has something to do, rather than just monitor the game world constantly.

second question, Why the token? Couldn't I just see if they have the heart, and if not, add it?

Thanks for the help Ghastley & TheNiceOne. I understand how frustrating hand-holding newbies can be. ;)
User avatar
louise hamilton
 
Posts: 3412
Joined: Wed Jun 07, 2006 9:16 am

PreviousNext

Return to IV - Oblivion