Aller au contenu

Photo

DA2 scripting: Hooking into a level up event


  • Veuillez vous connecter pour répondre
11 réponses à ce sujet

#1
hoorayforicecream

hoorayforicecream
  • Members
  • 3 420 messages
Greetings, folks. I'm a bit new to scripting in the toolset, though I have been programming for a decent amount of time in general. A friend of mine suggested I post here to ask for help, since I am unfamiliar with the nuts and bolts of how to hook into what the game engine does on its own. More specifically, this is intended to work with the DA2 base game, not DAO.

What I am hoping to do is to create an event listener that autoruns on game start, and will call my code whenever the game sends an EVENT_TYPE_PLAYER_LEVELUP. I'm not sure how to go about doing this. From what I understand via reading the wiki, I'd insert this via a PRCSCR, but I'm foggy on the specifics of how the event system actually works. Do I need to create a loop that idles until it receives an event? Can I fork a thread and just put it to sleep until it receives the event? Or is there some other handling method for them?

Thanks in advance.

#2
Proleric

Proleric
  • Members
  • 2 346 messages
In DAO, you'd write an event script which includes the level up event as a case.

That event is normally handled by the player_core script. You can override this by specifying your script in the events 2DA.

Not sure whether this will work in DA2, but it's worth a try.

#3
mesmerizedish

mesmerizedish
  • Members
  • 7 776 messages
I think we tried it as an event override, but it didn't do anything :-/ hoorayforicream would know better.

SetMaxHealth and SetMaxStamina also don't work properly. The health command doesn't do anything at all, and the stamina command sets it to 427(?) no matter what.

Is there a ModMaxHealth command that adds or subtracts from the value instead of just setting the value to a new number?

#4
Proleric

Proleric
  • Members
  • 2 346 messages

ishmaeltheforsaken wrote...

...Is there a ModMaxHealth command that adds or subtracts from the value instead of just setting the value to a new number?


See wiki for an alternative to SetMaxHealth.

Modifié par Proleric1, 15 juin 2011 - 11:44 .


#5
mesmerizedish

mesmerizedish
  • Members
  • 7 776 messages
Actually, I'm looking for an alternative to SetMaxHealth :P

#6
Proleric

Proleric
  • Members
  • 2 346 messages

ishmaeltheforsaken wrote...

Actually, I'm looking for an alternative to SetMaxHealth :P


Yes, that's what the Remark on that page provides.

#7
mesmerizedish

mesmerizedish
  • Members
  • 7 776 messages
Oh, so I see! My bad >.<

I'll definitely have hoorayforicecream look at that, thanks!

#8
hoorayforicecream

hoorayforicecream
  • Members
  • 3 420 messages
So... it works, kind of. For some reason, using calling Chargen_ModifyCreaturePropertyBase will instantly kill the player by making his or her health treated as a 100% sustain. This appears to happen if I try to modify *any* property of the player, not just health.

#9
Proleric

Proleric
  • Members
  • 2 346 messages
lol "the operation was a success but the patient died"...

The following code increases player health by 50:

Chargen_ModifyCreaturePropertyBase(GetHero(),PROPERTY_DEPLETABLE_HEALTH, 50.0);

I have this working in EVENT_TYPE_UNIQUE_POWER, which I use for test biz.

I can easily imagine that conflicts might occur during the level up event. Perhaps you need to adjust the health in a delayed event?

Modifié par Proleric1, 16 juin 2011 - 06:01 .


#10
hoorayforicecream

hoorayforicecream
  • Members
  • 3 420 messages
That's not the problem. I tried using two different values for health (123.0 and 1234.0, in case it was a bounds issue), then tried just setting stamina (PROPERTY_DEPLETABLE_MANA_STAMINA) instead, and both cases caused the hero to keel over and die, due to 100% sustained health. The only difference is that setting the PROPERTY_DEPLETABLE_HEALTH made the health total go up, but was still 100% sustained. Keep in mind that this is DA2, not DAO, so that may explain the oddity.

Also, I wasn't trying to adjust it based on an event. I just had a script with a void main() that adjusted the player's health and stamina that I ran from the console (I wanted to make the script do what I want it to first, then figure out how to call it at the appropriate time once it works). The health value would change, then the hero would keel over.

Modifié par hoorayforicecream, 16 juin 2011 - 07:00 .


#11
Proleric

Proleric
  • Members
  • 2 346 messages
Sounds like a DA2 issue, then.

I found the DAO solution by imitating what Bioware do in sys_autoscale_h.

#12
hoorayforicecream

hoorayforicecream
  • Members
  • 3 420 messages

Proleric1 wrote...

Sounds like a DA2 issue, then.

I found the DAO solution by imitating what Bioware do in sys_autoscale_h.


Yeah, it's a DA2 issue. I tried running the same script in DAO and it works just fine. Back to the drawing board then...