[Papyrus] Is there a way to know when the player is fighting

Post » Wed Jun 20, 2012 12:10 am

Please see last psot for solution to this problem!
User avatar
Justin
 
Posts: 3409
Joined: Sun Sep 23, 2007 12:32 am

Post » Tue Jun 19, 2012 6:45 pm

If I remember correctly, the player is set to be essential during brawls, so that could help, at least. To prevent false positives, though, you should take a look at what happens when you enter a brawl and see if there's anything more specific that you can check.

Cipscis
User avatar
Wayland Neace
 
Posts: 3430
Joined: Sat Aug 11, 2007 9:01 am

Post » Wed Jun 20, 2012 12:09 am

If I remember the script correctly that handles the brawls all it does is set the player and the NPC to essential state and forcefully equip the unarmed weapon. So I'd say testing for the player being essential and having unarmed as the equipped item should be a safe test to know if he's in a brawl.
User avatar
Nathan Maughan
 
Posts: 3405
Joined: Sun Jun 10, 2007 11:24 pm

Post » Wed Jun 20, 2012 4:53 am

it has to be quest related because every brawl starts with conversation
User avatar
James Baldwin
 
Posts: 3366
Joined: Tue Jun 05, 2007 11:11 am

Post » Tue Jun 19, 2012 5:19 pm

I took a look at FreeFormRiften19 (the quest controlling the brawl with Hofgrir) and it calls a function from the DialogueFavorGeneric quest, which sends a story event using the FavorBrawlEvent keyword. I don't know how to track it further.
User avatar
Laura Cartwright
 
Posts: 3483
Joined: Mon Sep 25, 2006 6:12 pm

Post » Tue Jun 19, 2012 2:33 pm

cool, I just noted that there was a "weapon" called unarmed and that it was used by the quest "c00JorrvaskrFight" and "DGIntimidateQuest"

Could I check to see if any of the participants of the "fight" are on this quest? If so how? Anything outside of magic effect scripting is unknown territory for me :(
User avatar
Miragel Ginza
 
Posts: 3502
Joined: Thu Dec 21, 2006 6:19 am

Post » Tue Jun 19, 2012 5:08 pm

Actualyl, the "unarmed" route seems to be doing the best right now. But for some reason I am getting a compiler error.
actor property selfRef autoweapon property unarmed autoEVENT onHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, bool abBashAttack, bool abHitBlocked)    if (selfref.getEquippedWeapon() == Unarmed ) && \        (akAggressor.getEquippedWeapon() == Unarmed ) && \	    (akAggressor.HasKeyword(ActorTypeNPC))                 debug.messagebox("test")    endifendEVENT

Compiler says this: getEquippedWeapon is not a function or does not exist

I am sure its obvious, but I cant fathom why the function works on one actor (self reference) but not another (the aggressor), yet a little later on in this function a keyword check on the akaggressor compiles :S
User avatar
Kay O'Hara
 
Posts: 3366
Joined: Sun Jan 14, 2007 8:04 pm

Post » Tue Jun 19, 2012 11:53 pm

geteqiuppedweapon function is a member of actor script. so i think akaggressor being objectreference needs to be cast as actor. just a suggestion
User avatar
james tait
 
Posts: 3385
Joined: Fri Jun 22, 2007 6:26 pm

Post » Tue Jun 19, 2012 7:14 pm

That's correct. The compiler can auto-cast an object to a less derived type, like http://www.creationkit.com/Actor_Script to http://www.creationkit.com/ObjectReference_Script, but not the other way around. You need to manually cast that parameter to type Actor, and you should also check that the cast doesn't result in None, which is what would happen if the parameter isn't storing an Actor as an ObjectReference.

Cipscis
User avatar
Chantelle Walker
 
Posts: 3385
Joined: Mon Oct 16, 2006 5:56 am

Post » Wed Jun 20, 2012 1:12 am

aye this seems to do the trick with teh compiler at least.

Whats happening in game seems to be odd though.

When I apply the unarmed check on the selfref and enter a brawl, the message pops up each time the selfref gets hit. (note selfref is the player)

When I apply the unarmed check on selfref and go to a real world fight and unequip my weapon/shield no message pops up.

When I apply the unarmed check on JUST the aggressor, no message pops up.

From what this suggets, unarmed is state for the player only during a brawl encounter? If this is the case, what check should I be performing on the aggressor?

last psot for me, I need sleep!

Cheers for help so far though folks! :)
User avatar
Tessa Mullins
 
Posts: 3354
Joined: Mon Oct 22, 2007 5:17 am

Post » Tue Jun 19, 2012 1:58 pm

Still stuck, pressing the emergency bump button! :(
User avatar
Chica Cheve
 
Posts: 3411
Joined: Sun Aug 27, 2006 10:42 pm

Post » Wed Jun 20, 2012 3:08 am

This is a different rout :P

If I recall correctly, then Brawling is a misc quest. In which both Player & the Brawler are 2 ReferenceAlias, and both are set to be essential/protected.
So if that's the case, to check if Player is in a brawl, check if that Quest isRunning() or not
User avatar
Alexander Lee
 
Posts: 3481
Joined: Sun Nov 04, 2007 9:30 pm

Post » Tue Jun 19, 2012 9:38 pm

hmm! I am at work right now but perhaps I can link this in with "c00JorrvaskrFight" and "DGIntimidateQuest" which both use the unarmed weapon. will take a look-see when I get home!

does the brawl "quest" end when you run away? I need to check this stuff! :D
User avatar
Jessie Rae Brouillette
 
Posts: 3469
Joined: Mon Dec 11, 2006 9:50 am

Post » Wed Jun 20, 2012 1:34 am

cool :) it seems that the brawl quest check works fine! I am gonig to gues the jorvuskar one will to :D

But now I cant for the life of me do the most simple thing ever :S

In a few of my scripts I use AND commands to string together some conditionals to an If statement.

If (property == 2) && (property =="meep")
do stuffs
endif

what do I do if i want to make that an OR instead? the wiki has nothing that I can find!!!
User avatar
jessica sonny
 
Posts: 3531
Joined: Thu Nov 02, 2006 6:27 pm

Post » Wed Jun 20, 2012 5:34 am

You want to use || as specified in the http://www.creationkit.com/Operator_Reference#Logical_Operators.

Cipscis
User avatar
Laura Cartwright
 
Posts: 3483
Joined: Mon Sep 25, 2006 6:12 pm

Post » Wed Jun 20, 2012 4:45 am

*facepalm* i looked at that very page multiple times, how did I not see that! cheers Cipscis!
User avatar
Nims
 
Posts: 3352
Joined: Thu Jun 07, 2007 3:29 pm

Post » Tue Jun 19, 2012 7:27 pm

Use "||" for or. On german keybords that's written by pressing alt + the "<"-key next to left shift. Dunno for englich keybords.
User avatar
GLOW...
 
Posts: 3472
Joined: Thu Aug 03, 2006 10:40 am

Post » Tue Jun 19, 2012 2:28 pm

Hey sniper, glad you seemed to find a work around for this, as I also need to detect when the player is brawling.

In my mod, I make the player essential to control death events, and I worry about conflicting issues for when the player is brawling. Would you mind posting your code that you use? I could of course try and figure it out myself, but It sure would make things easier for me if you could post the check you use.
User avatar
Paula Ramos
 
Posts: 3384
Joined: Sun Jul 16, 2006 5:43 am

Post » Tue Jun 19, 2012 7:29 pm

my code isnt quite working yet. The stuff I psoted at the top is pretty much the jist of what I have now- will update it when I figure out my problems.
User avatar
STEVI INQUE
 
Posts: 3441
Joined: Thu Nov 02, 2006 8:19 pm

Post » Tue Jun 19, 2012 6:42 pm

ok heres my code - why wont it work?
Scriptname modImperialProcEffect extends ActiveMagicEffect  ;see woodelf script for details about how this code workskeyword property ActorTypeNPC autoactor property selfRef auto hiddenfloat property effectChance = 0.05 autospell property PowerEffect autospell property npcPower automagicEffect property Cooldown autoquest property brawlQuest autoquest property fighterQuest autoEVENT OnEffectStart(Actor Target, Actor Caster)	    	    selfRef = caster	    endEVENTEVENT onHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, bool abBashAttack, bool abHitBlocked)    if     (brawlquest.isrunning()) || (fighterQuest.isrunning())        ;donothing    else        if selfref == game.getplayer()            if akAggressor.HasKeyword(ActorTypeNPC)&& \            !(selfRef.hasMagicEffect(Cooldown)) && \            !(selfRef.isdead())                float dice = utility.RandomFloat(0,1)                if dice <= effectChance                    PowerEffect.cast(selfRef, selfRef)                endif            endif        else            if  !(selfRef.hasMagicEffect(Cooldown)) && \                !(selfRef.isdead())                    float dice = utility.RandomFloat(0,1)                    if dice <= effectChance                        npcPower.cast(selfRef, selfRef)                    endif            endif        endif    endifendEVENT

There is a lot of stuff there which works fine, but the bit that i want to focus on is the line regarding the quests and if they are running or not.

The behaviour I see in game is: no abilities are cast at all in or out of a brawl. When I tried to use the NOT operator in front of the isrunning() checks the abilities were cast in a brawl. essentialy, not working :(

I dont get it :S it seems logically soudn to me!
User avatar
Kat Ives
 
Posts: 3408
Joined: Tue Aug 28, 2007 2:11 pm

Post » Tue Jun 19, 2012 10:19 pm

Hmm I have an idea: I am worried that maybe there is jsut too much going on nested in these if sattements and thats causing issues. what if I were to add a little if statement at the satrt of the onHit event which defined a property, and then referenced that property?

so straight on the onHit
 if	 (brawlquest.isrunning()) || (fighterQuest.isrunning())	 questcheckproperty = 1    elsequestcheckproperty = 0endif
and then add a check for the properties value in one of the otehr if statements.

would this help, or is this likely to give me the same problem?
User avatar
Ally Chimienti
 
Posts: 3409
Joined: Fri Jan 19, 2007 6:53 am

Post » Tue Jun 19, 2012 8:38 pm

The behaviour I see in game is: no abilities are cast at all in or out of a brawl. When I tried to use the NOT operator in front of the isrunning() checks the abilities were cast in a brawl. essentialy, not working :(

I dont get it :S it seems logically soudn to me!

From what you say, I can only assume that the brawlquest or the fighterquest is running. That would explain why the rest of your code doesn't work. Check and see if those quests are running even when you're not brawling.
User avatar
Tamara Primo
 
Posts: 3483
Joined: Fri Jul 28, 2006 7:15 am

Post » Wed Jun 20, 2012 3:11 am

Hmm yeah, I am not sure why the script didnt work the first time, the check I am making is the same as in the code below. But becuase I used the check to modify a property in teh below code, and then reference that property- it works. So i present my code for others!

Scriptname brawl Proof of concept extends ActiveMagicEffect  int property questCheck = 0 autoquest property brawlQuest auto ; reference in editor: DGIntimidateQuestquest property fighterQuest auto ; reference in editor: c00JorrvaskrFightEVENT onHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, bool abBashAttack, bool abHitBlocked)	if	 (brawlquest.isrunning()) || (fighterQuest.isrunning())		questcheck = 1	else		questcheck = 0	endif	;debug.messagebox("questcheck is" +questCheck)	; do whatever stuff you want here using the property "questcheck" to do what you want. 0 when not ina  brawl, 1 when in a brawl.endEVENT

this certainly works for normal brawls: need to see if it works on the event when you first enter jorvuskar, as well as the practice fight for companion quest.
User avatar
Rachael
 
Posts: 3412
Joined: Sat Feb 17, 2007 2:10 pm

Post » Tue Jun 19, 2012 3:59 pm

Hmm yeah, I am not sure why the script didnt work the first time, the check I am making is the same as in the code below. But becuase I used the check to modify a property in teh below code, and then reference that property- it works. So i present my code for others!

Scriptname brawl Proof of concept extends ActiveMagicEffect  int property questCheck = 0 autoquest property brawlQuest auto ; reference in editor: DGIntimidateQuestquest property fighterQuest auto ; reference in editor: c00JorrvaskrFightEVENT onHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, bool abBashAttack, bool abHitBlocked)	if	 (brawlquest.isrunning()) || (fighterQuest.isrunning())		questcheck = 1	else		questcheck = 0	endif	;debug.messagebox("questcheck is" +questCheck)	; do whatever stuff you want here using the property "questcheck" to do what you want. 0 when not ina  brawl, 1 when in a brawl.endEVENT

this certainly works for normal brawls: need to see if it works on the event when you first enter jorvuskar, as well as the practice fight for companion quest.
I know it's been a while since you posted, but thanks.
User avatar
Roddy
 
Posts: 3564
Joined: Fri Jun 15, 2007 11:50 pm

Post » Tue Jun 19, 2012 8:23 pm

That code is actually out-of-date, and since just recently, we know it doesn't cover all brawl quests, also the code has been refined to be less overzealous.
User avatar
Kellymarie Heppell
 
Posts: 3456
Joined: Mon Jul 24, 2006 4:37 am

Next

Return to V - Skyrim