Events to player character

Post » Sun Jun 17, 2012 8:08 pm

Okay, so call me lazy or just plain stupid, but I cannot find a way to add a simple event to a player character... I.e. if I want my characters to take damage in cold climates when not wearing warm clothing, I would think that I'd have to do an event. Like (partly meta-code):

Event OnSomething(ObjectReference actor)
if actor == game.getPlayer() && game.climate(damnCold) && bAintWearingNoFur
game.player.doDamagePerSecond(1)
endif
endEvent

The syntax ain't the issue. I'm not familiar with the this scripting language yet, but like with any language, should be fairly easy to find help about using the correct syntax, functions etc. But triggering the events... Jesus... What are the steps to do it in order to get it even started?

Add script to player character? If so, who is the player character? "Player" in the Actors/Actor/Actor/Male -property? Or something else?

Above all: Which event to use if I want to check what happends to the player character? OnHit is pretty straightforward, but what about if I want to check something when he's being seen? Etc.

I could really appreciate some help here. If I could just receive a little push here, I'm certain I could take it from there. But damn, it's hard to be a beginner again... O_o

Thanks in advance,

Fen
User avatar
leni
 
Posts: 3461
Joined: Tue Jul 17, 2007 3:58 pm

Post » Mon Jun 18, 2012 12:55 am

You'll probably want to use a Quest, with a script extending Quest of course, and look into the http://www.creationkit.com/OnUpdate_-_Form event.

Cipscis
User avatar
Ladymorphine
 
Posts: 3441
Joined: Wed Nov 08, 2006 2:22 pm

Post » Mon Jun 18, 2012 2:24 am

Ah, I see. I actually considered that for a second but then I thought there must be another way. But I'll take your advice and try it from here. If I run into a dead end later, I'll post some more but I'll try to avoid that. Thanks for the quick answer!
User avatar
Baylea Isaacs
 
Posts: 3436
Joined: Mon Dec 25, 2006 11:58 am

Post » Sun Jun 17, 2012 8:30 pm

Actually, please post more if you succeed. I am very interested in working in a continous check for a constant effect. For example, if it's after Xpm, player moves slower (is tired). I dunno, I just made that up. But I know a lot of people are wanting to do things like that. So, any success you have will help.
User avatar
El Goose
 
Posts: 3368
Joined: Sun Dec 02, 2007 12:02 am

Post » Sun Jun 17, 2012 12:56 pm

Hi,

Same problem here. I dont know how to do a constant check for anything... xD

So I tried to begin with a really simple thing : to display a message (a notification) every 4 seconds (the purpose is only to be able to check if my quest script is indeed running every 4 seconds).
In Oblivion a simple way to do that was for example to use a quest script :

scn MyQuestSCR	set fQuestDelayTime to 4	Begin Gamemode		Message "script frame!"	End

If I remember well a Quest Script was running continuously if the quest was started (on the contrary a script attached to a ref was running only if the scripted reference was in the player cell).


So I've tried to create a new quest in the CK (start game enabled checked), and to add this little script to this quest :

Scriptname 00MyQuest extends Quest	Message Property 00MyMessage Auto	Event OnUpdate()		RegisterForUpdate(4)		00MyMessage.show()	EndEvent

No error when I compile it, but I never get my message IG...

Ofc I've created the message 00MyMessage from the object window (with only 2 settings filled : "display time", and "Message texte").
*In the Quest Window \ script properties window, I've linked the message value to 00MyMessage.


How to do this simple thing ?
I'm wondering if OnUpdate is in fact usable in quest scripts ? Or do quest script are continuously running like in Obli ?

Ty very much in advance.
User avatar
Jeremy Kenney
 
Posts: 3293
Joined: Sun Aug 05, 2007 5:36 pm

Post » Sun Jun 17, 2012 7:55 pm

To get OnUpdate to work at all you have to call RegisterForUpdate on that script (which tells it how often to send the OnUpdate event).

You want to be careful with OnUpdate loops since if you make them too frequent you can cause the events to pile up faster than the script can process them. Events are always a better option if they exist for what you're trying to do. If you want to check for events on the player, you can attach a script to the Player actor base object, or create a quest, assign an alias to the player, and put the script on that alias (this is better if you don't always need the script on the player).
User avatar
Alex Blacke
 
Posts: 3460
Joined: Sun Feb 18, 2007 10:46 pm

Post » Sun Jun 17, 2012 8:33 pm

To get OnUpdate to work at all you have to call RegisterForUpdate on that script (which tells it how often to send the OnUpdate event).

You want to be careful with OnUpdate loops since if you make them too frequent you can cause the events to pile up faster than the script can process them. Events are always a better option if they exist for what you're trying to do. If you want to check for events on the player, you can attach a script to the Player actor base object, or create a quest, assign an alias to the player, and put the script on that alias (this is better if you don't always need the script on the player).

Ok...... ! RegisterForUpdate must be called at least one time before OnUpdate.
For ex :
Scriptname 00MyQuest extends Quest	 Message Property 00MyMessage Auto	Event OnInit()			RegisterForUpdate(4)	EndEvent	Event OnUpdate()			00MyMessage.show()	EndEvent

It's working, thank you !
User avatar
Damien Mulvenna
 
Posts: 3498
Joined: Wed Jun 27, 2007 3:33 pm

Post » Sun Jun 17, 2012 12:29 pm

Hell, i was trying to do exactly the same thing, just a simple message in "game mode", and was crawling.

Finally it works. Thanks you very much !
User avatar
M!KkI
 
Posts: 3401
Joined: Sun Jul 16, 2006 7:50 am

Post » Sun Jun 17, 2012 6:59 pm

Yeah, I got it to work by myself and was too busy to check the forums, so you guys found help elsewere - good! :)

Actually, please post more if you succeed. I am very interested in working in a continous check for a constant effect. For example, if it's after Xpm, player moves slower (is tired). I dunno, I just made that up. But I know a lot of people are wanting to do things like that. So, any success you have will help.

I actually did that:
 GlobalVariable property MyGlobalVariable autoEVENT onInit()  RegisterForUpdateGameTime(0.5) ; in game hoursendEVENTEvent OnUpdateGameTime()  if Utility.GetCurrentGameTime() - Utility.GetCurrentGameTime() as int > 0.83 ; i.e. if 6.87 - 6 > 0,83    MyGlobalVariable.SetValue(9999.99)  endifendEvent

The above "IF" checks if the time is after 8pm or so.

But NOW I have a different problem... I cant seem to get to CHANGE the value of a global variable, goddammit...! Yes, I have linked the variable to the correct one, but still nothing. What I did wrong there, anyone?
User avatar
I love YOu
 
Posts: 3505
Joined: Wed Aug 09, 2006 12:05 pm

Post » Sun Jun 17, 2012 12:33 pm

I'd actually look into using Spell Effects as a means to apply damage or effects to players, then simply add the spell to the player (and remove it from the player) when conditions are met in your script. You can have the spell effect be completely invisible to the player, so they won't even know - they will simply see they are taking frost damage.

You can do a surprisingly large number of things with Spell Effects, and certain things like changing speed (if I can figure out why that one isn't working for me... see my threads) will only work via spell effects too since the actor values for speed when done through script not only are absolute changes, but won't take effect until after you have crouched/are sprinting/etc (for things like speed that is).

Spell effects can also be given conditions in which they happen in the spell editor. Look into the list of conditions for spells, and see if there's one that relates to weather type (it can check everything from walking to running, etc from what I've breifly looked at).
User avatar
Alexxxxxx
 
Posts: 3417
Joined: Mon Jul 31, 2006 10:55 am

Post » Sun Jun 17, 2012 2:08 pm

Yeah I got lots of stuff I want to do and that cold damage is just one of them. I haven't even got to that yet... :/ But when I do, I'll try to use a spell first alright.

Right now I'm fixated with this GlobalVariable.SetValue-problem. Forums seem to lack information about it. Gotta keep diggin'... Any help about setting Global Variables appreciated.
User avatar
Donald Richards
 
Posts: 3378
Joined: Sat Jun 30, 2007 3:59 am

Post » Sun Jun 17, 2012 7:47 pm

Ah, got it. I did set the Global Variable right all along, but the game itself updated it right after my script did... O_o Took me awhile to figure it out. Applied Utility.Wait(10) and solved the problem.
User avatar
Mike Plumley
 
Posts: 3392
Joined: Wed Sep 05, 2007 10:45 pm


Return to V - Skyrim