Wolvman's Scripting Questions

Post » Thu Jan 14, 2010 11:09 pm

Try SetFlee 100 instead of ModFlee 50.
User avatar
The Time Car
 
Posts: 3435
Joined: Sat Oct 27, 2007 7:13 pm

Post » Thu Jan 14, 2010 8:50 pm

That would work nicely too, but I just found that if I use a demoralize creature ability instead of directly modifying the flee value it works nicely too. I think this new setup also solved the problem of it adding the spell over and over again on the same creature. This way I could have a few of the tougher creatures not have a flee value of 100 automatically since I'm wanting stronger creatures like ogrims to sometimes try to fight you even if you are a lycanthrope.

	If ( GetSpell, "LycanthropeFear" == 0 )		CreatureRef->Addspell, "LycanthropeFear"	endif


Still I'm wondering what would be the best way to make the creatures automatically run away from the player when they see him? Because currently the creatures that are passive such as scribs do not run away on sight. I would use startcombat but that would make creatures even on the edge of the cell that are out of the players view start combat with the pc right?
User avatar
Ymani Hood
 
Posts: 3514
Joined: Fri Oct 26, 2007 3:22 am

Post » Thu Jan 14, 2010 4:48 pm

You can try to get the current flee setting, then increase it if it's under a certain amount. Say:

setx CreatureFlee to CreatureRef->GetFleeif ( CreatureFlee  < 50 )     CreatureRef->ModFlee 50endif


This code is untested so it may not work. Changing the if to ifx ( CreatureRef->GetFlee < 50 ) may work as well. I'm not sure with MWSE, so I'd try it the first way then the second if the first doesn't work.
User avatar
Latisha Fry
 
Posts: 3399
Joined: Sat Jun 24, 2006 6:42 am

Post » Fri Jan 15, 2010 1:05 am

Thanks for the help Jac. I just found out that if I add spells through this method it only adds it once even without the " If ( GetSpell, "LycanthropeFear" == 0 ) " part. However if I try to add other changes such as ModFlee it constantly does it forever on each creature repeatedly.

I also found that even with MWSE it doesn't allow me to use "setx CreatureFlee to CreatureRef->GetFlee" or even "setx CreatureFlee to CreatureRef->GetSpell, "LycanthropeFear". The ifx ( CreatureRef->GetFlee < 50 ) does not work as well.

So at least I know I can use spells with this method but anything else is still repeating to much to be useful right now :( .
User avatar
keri seymour
 
Posts: 3361
Joined: Thu Oct 19, 2006 4:09 am

Post » Thu Jan 14, 2010 6:07 pm

You *are* adding the spell over and over, but once it's already added the second addition doesn't do anything (except possibly risk an AI glitch - when it comes to AI, MW generally seems to think "recalculate" means "start over", even if the new value is the same as the old). You can't have more than one instance of the same spell in MW, is the point.

The problem with your earlier script is that you aren't specifying anything to operate on when you check if ( getflee ). Something like this should work:
xSetRef CreatureRefset tmp to ( 100 - ( GetFlee ) )if ( tmp <= 0 )	returnendifCreatureRef->ModFlee tmp

User avatar
Esther Fernandez
 
Posts: 3415
Joined: Wed Sep 27, 2006 11:52 am

Post » Fri Jan 15, 2010 2:37 am

Ah, there we go. Thank you Melian that works great.
User avatar
{Richies Mommy}
 
Posts: 3398
Joined: Wed Jun 21, 2006 2:40 pm

Post » Thu Jan 14, 2010 10:57 pm

Another quick question. What's the simplest way to have a script return if the player is in combat? I can't seem to get the xGetCombat function to work on the player so is there a special way to have it read if the player is in combat?
User avatar
Natalie Taylor
 
Posts: 3301
Joined: Mon Sep 11, 2006 7:54 pm

Post » Thu Jan 14, 2010 9:13 pm

xGetCombat gets the combat target - it can't work on the PC because they're not controlled by MW's AI (if you see what I mean).

Finding out whether the player is in combat can be quite difficult, depending on how accurate you want it to be, and how fast. If you're already using GetSoundPlaying to detect events I'd say use that, but if you're not already using it, probably try the invisible companion method (if the invisible companion has its weapon drawn, the player is probably in combat) - there's a resource around somewhere you can use for the companion method. GetSoundPlaying can be a problem since the function just doesn't work on some systems (always returns 0, basically), but when it does work it's faster and more accurate.

If you're already checking all creatures/npcs in the cell though, it might be better to use xGetCombat on them, and see if they're in combat with the player. Haven't tried that myself, but it should work AFAIK.
User avatar
Kevan Olson
 
Posts: 3402
Joined: Tue Oct 16, 2007 1:09 am

Post » Fri Jan 15, 2010 3:09 am

Thanks for the help. I was thinking of using GetSoundPlaying earlier but then I just stumbled upon this method not 10 minutes ago which seems to work so far.

setx pcref to xGetRef "player"setx InCombat to pcref->xGetCombatIf ( InCombat != 0 )returnendif


I've tried it in a few different setups and it has held up 100% of the time. Hopefully it will stay that way.

One thing I would still like to know however, is if there is a way to have my previous LycanthropeCreatureFear script skip over companions? This could help me out a lot in my other scripts as well.

Here is what the script looks like right now.

Begin LycanthropeCreatureFear	long CreatureRef ;change the variables to whatever you want	long tmp	ifx ( CreatureRef )		setx CreatureRef to xNextRef CreatureRef ;finds the next NPC or creature in the cell	else		setx CreatureRef to xFirstNPC ;finds the first NPC or creature in the cell	endif	if ( CreatureRef == 0 )   ;end of list or empty cell		return	endif	setx tmp to CreatureRef->xRefType	if ( tmp != 1095062083 ) ;if not type Creature		return	endif	xSetRef CreatureRef	set tmp to ( getspell, "LycanthropeFear" )	if ( tmp == 1 )		return	endif	CreatureRef->Addspell, "LycanthropeFear"	CreatureRef->modfight 90end

User avatar
Hella Beast
 
Posts: 3434
Joined: Mon Jul 16, 2007 2:50 am

Post » Thu Jan 14, 2010 9:27 pm

Thanks for the help. I was thinking of using GetSoundPlaying earlier but then I just stumbled upon this method not 10 minutes ago which seems to work so far.

Guess I was wrong about that then. Sorry! :blush:

Re companions - you can check AI package, but it won't necessarily work if they're already in combat (it will also turn up some false positives, like some of Abot's creatures, if they're not in combat). If it was me, the first thing I'd try would be checking AI package and something else, maybe distance from player or something, and add a spell (a useless one with super-high cast cost, so it won't ever be cast) as a flag if they're likely to be a companion. Check for the spell and if it's there, assume they're still a companion. Then just test and see if it works.
User avatar
Conor Byrne
 
Posts: 3411
Joined: Wed Jul 11, 2007 3:37 pm

Post » Fri Jan 15, 2010 2:31 am

Edit: Got the problem taken care of but I have new one. How do I go about making a messagebox use %PCRace in the text? When I directly type it into the " " it doesn't function correctly.
User avatar
Danel
 
Posts: 3417
Joined: Tue Feb 27, 2007 8:35 pm

Post » Thu Jan 14, 2010 11:05 pm

Did you try "^PCRace"?
User avatar
Tiff Clark
 
Posts: 3297
Joined: Wed Aug 09, 2006 2:23 am

Post » Thu Jan 14, 2010 4:54 pm

There we go. That worked, thanks melian. I always thought it had to be %PCRace since that's what I always saw used in the journal entries.
User avatar
djimi
 
Posts: 3519
Joined: Mon Oct 23, 2006 6:44 am

Post » Thu Jan 14, 2010 10:00 pm

So does anyone know how to make an NPC forcegreet a werewolf? So far I've got this working when the player is a human but as a werewolf nothing happens. Here are the scripts I'm using .

This simply places an NPC behind the PC when the player activates a werewolf.

Begin InfectionForceGreet	Short DoOnce	Float LocalX	Float LocalY	Float LocalZ	short done	Long Code	Long Current		long target		;________________Beginning of Lycanthrope Activate____________________	Set Code to Key_Activate	Setx Current to xKeyPressed, Code		;________________Beginning of Script Preventions____________________	if ( ranconfig == 0 )		return	endif	If ( ScriptRunning, "BecomeHuman" == 1 )		return	elseif ( ScriptRunning, "BecomeLycanthrope" == 1 )		return	endif	if ( PowerIsActivating == 1 )		return	endif	if ( MenuMode == 1 )		return	endif		;________________End of Script Preventions____________________	if ( Current == 0 )		If ( DoOnce == 1 )			set DoOnce to 0		endif		return	endif	if ( DoOnce == 1 )		return	endif	set DoOnce to 1	Setx Target to xGetPCtarget		;________________Cannot Transform Messages____________________	if ( Target == 0 )		return	endif	xSetRef, Target	If ( Iswerewolf == 0 )		return	endif	xSetRef, Target	if ( gethealth < 1 )		return	endif		;________________End Cannot Transform Messages____________________	placeatpc, ForceGreetNPC, 1, 512, 1 ;place 1 greeter, 512 units beyhind the PCend


Then this script is attached to the NPC to make the player forcegreet it.

begin ForceGreetNPCScript	short Done	if ( getDisabled == 1 )		setdelete, 1		return	endif		;Do Once thing	if ( Done == 0 )		set done to 1		forcegreeting		return	endif		;When we have done talking, diable	if ( Done == 1 ) 		if ( menumode == 0 )			disable			return		endif	endifend


So ya, this works well when the player activates a werewolf in humanform but not when the player activates a werewolf as a werewolf himself. Anyone have any ideas or workarounds for this. The ultimate goal is to get the Dialogue box to pop open and have a few topics to select such as Follow and Stay (already have the topics part done).

When using this method everything works well except that the forcegreeting does nothing. The NPC is always correctly placed and the script runs all the way through.
User avatar
Gracie Dugdale
 
Posts: 3397
Joined: Wed Jun 14, 2006 11:02 pm

Post » Thu Jan 14, 2010 10:48 am

Werewolves can't activate much. Doors are about it. You need to use an invisible box mesh, set it up as a door and ensure it hovers over the thing you want to activate. Werewolf infection has an example of this as well as a mesh you can use.

If you use the mesh you must credit Bodvar.

EDIT:
I think Werewolf Infection does that already so you could just look at that.
User avatar
Quick Draw III
 
Posts: 3372
Joined: Sat Oct 20, 2007 6:27 am

Post » Thu Jan 14, 2010 2:01 pm

Edit: NM, Figured it out.
User avatar
louise hamilton
 
Posts: 3412
Joined: Wed Jun 07, 2006 9:16 am

Post » Thu Jan 14, 2010 8:43 pm

A few more questions.

1.) Is there any easy way to detect if the player has bolts or arrows equipped? I've tried "If ( Player->HasWeaponType == 12/13 )" but neither of them seem to be detecting the bolts or arrows.

2.) Is there a way to have MWSE unequip or remove the arrows/bolts that were equipped on the player and then have it automatically equip them again?

3.) Is there a way to have MWSE unequip or remove whatever shield the player is using and then have it automatically equip that same shield again?

4.) What do I need to type in order for the Ready Weapon key to show up in a messagebox? I've tried ^ActionReadyWeapon, ^ActionReady_Weapon, and a bunch of others but I can't get it to work.
User avatar
LADONA
 
Posts: 3290
Joined: Wed Aug 15, 2007 3:52 am

Post » Thu Jan 14, 2010 11:38 am

Anyone?
User avatar
Justin Hankins
 
Posts: 3348
Joined: Fri Oct 26, 2007 12:36 pm

Post » Fri Jan 15, 2010 1:50 am

Anyone?


Yacoby's werewolf companion has a way of forcegreeting the werewolf NPC, but I have no idea how it works...
User avatar
Roanne Bardsley
 
Posts: 3414
Joined: Wed Nov 08, 2006 9:57 am

Post » Fri Jan 15, 2010 3:21 am

Ya, it uses doors to start up activation but I haven't been able to get that method to work yet. So I think I need an alternative method. I also still need to find answers to the other 4 questions I had before I can move any further in my combat mod and ravenous hunger :( .
User avatar
~Sylvia~
 
Posts: 3474
Joined: Thu Dec 28, 2006 5:19 am

Post » Thu Jan 14, 2010 9:56 pm

So there seems to be a small annoyance with this script.

Begin Werewolf_Running_Sounds	Short doonce	If ( DoOnce == 0 )		If ( player->getsoundplaying "WolfRun" == 1 )			player->playloopsound3d, "WerewolfRun"			set DoOnce to 1		endif	endif	If ( DoOnce == 1 )		If ( player->getsoundplaying "WolfRun" == 0 )			If ( player->getsoundplaying "WereWolfRun" == 1 )				player->stopsound, "WerewolfRun"				set DoOnce to 0			endif		endif	endifend


It simply allows me to replace the werewolf panting sound with one of my own, which lets me give each different werecreature it's own unique panting sound when running on all fours. The thing is, whenever I use playloopsound3d it causes a loud "popping" noise both at the beginning and end of each loop. I don't think that it is the actual sound file because I've tested it with other sound files and they do the same thing. Is there something special I have to do in order to get it to loop without the "popping" or is this something I should pass over to Hrnchamd to see if it's a problem with Morrowind itself?
User avatar
Andrew Perry
 
Posts: 3505
Joined: Sat Jul 07, 2007 5:40 am

Post » Thu Jan 14, 2010 11:39 pm

I'd try this
begin Werewolf_Running_SoundsIf ( player->GetSoundPlaying "WolfRun" )	player->StopSound "WolfRun"	player->PlaySound3D "WerewolfRun"endifend

User avatar
Taylrea Teodor
 
Posts: 3378
Joined: Sat Nov 18, 2006 12:20 am

Post » Thu Jan 14, 2010 9:34 pm

I tried your script out but it doesn't cause the new sound to loop. Instead it plays the WerewolfRun sound once and stops. However because the sound wasn't looped it didn't cause the random pops when it played using your method.

Because I need it to loop the "WerewolfRun" sound as long as "WolfRun" is playing I made another version of the script using PlaySound3D and set it up to loop just like I was using PlayLoopSound3D. Anyways, it started causing the popping noises again even though it wasn't technically using the PlayLoopSound3D function. I'm starting to think that it has something to do with the "3D" functions specifically because looping it using simply "PlaySound" removes the random pops. The problem with using "PlaySound" with this script is that I can't get it to stop playing immediately at the same time the original WolfRun sound loop stops playing which is important.

Here's the alternate version of the script that makes the sound start and stop correctly while looping, but it still has the annoying pops.

begin Werewolf_Running_Sounds	If ( player->GetSoundPlaying "WolfRun" )		If ( player->GetSoundPlaying, "WerewolfRun" == 0 )			player->PlaySound3D "WerewolfRun"		endif	endif	If ( Player->GetSoundPlaying "WolfRun" == 0 )		player->stopsound, "WerewolfRun"	endif	returnend


If you have anymore suggestions I'm wide open for them :) .
User avatar
Eric Hayes
 
Posts: 3392
Joined: Mon Oct 29, 2007 1:57 am

Post » Thu Jan 14, 2010 1:04 pm

Why simply redefining the "WolfRun" sound to a different .wav in the Sounds tab isn't satisfactory?
User avatar
amhain
 
Posts: 3506
Joined: Sun Jan 07, 2007 12:31 pm

Post » Thu Jan 14, 2010 8:33 pm

Why simply redefining the "WolfRun" sound to a different .wav in the Sounds tab isn't satisfactory?

i'm thinking he's making custom werecreatures, and im not sure the cs will play nice for that

edit, werecreatures is correct, weecreatures is just pitiful.
User avatar
herrade
 
Posts: 3469
Joined: Thu Apr 05, 2007 1:09 pm

PreviousNext

Return to III - Morrowind