Aller au contenu

Photo

How to change the PC to a creature: a quick guide.


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

#1
FergusM

FergusM
  • Members
  • 460 messages
EDIT: Okay, since I solved this, I decided to turn this into a quick guide!

To make any given creature your party leader and delete the default PC, run the following script:

#include "events_h"
#include "wrappers_h"
#include "utility_h"
#include "core_h"

void main()
{
    object oPC = GetHero();
    event ev = GetCurrentEvent();
    int nEventType = GetEventType(ev);
    switch(nEventType)
    {
        case EVENT_TYPE_ENTER:
         {
             object oLeader = UT_GetNearestCreatureByTag(oPC,"insert_ID_here");
             WR_SetFollowerState(oLeader, FOLLOWER_STATE_ACTIVE);
             SetPartyLeader(oLeader);
             WR_SetFollowerState(oPC, FOLLOWER_STATE_INVALID);
             SetObjectActive(oPC, 0);
             Safe_Destroy_Object(oPC,0);
         }
    }
    HandleEvent(ev, RESOURCE_SCRIPT_AREA_CORE);
}

The event stuff can be changed to any other suitable event. As mentioned below, you can in fact set this as an area script and event_type_enter will run as soon as the area loads.

Where I've put insert_ID_here, put the tag of your creature (in quotes), for example "gen00fl_alistair". You can also use a constant to refer to a creature ID.

object oLeader = etc and object oPC = etc find your creature and the default protagonist respectively in the game world. From there, you use the WR functions to mark your characters as valid/invalid party members. Then you switch the leader to your new party member creature, set the old PC to inactive and delete it.

Modifié par FergusM, 15 janvier 2010 - 09:40 .


#2
FalloutBoy

FalloutBoy
  • Members
  • 580 messages
Could be that the trigger enter event only happens when you cross the trigger boundary. So logging in when you are already in the boundary won't signal the event. That is how it worked in NWN and NWN2 and probably this one too.



I think EVENT_TYPE_MODULE_LOAD in the module script is the one you want to trap.


#3
FergusM

FergusM
  • Members
  • 460 messages
Tried making it smaller just now, but it didn't work. Good idea, though.

I'll try the other one now... I got the preloadexit tag from another script that mentioned this is what to use for 'moving creatures around etc when the loading screen is still up.'

EDIT: I couldn't get that to work, but I'm not sure its what I want anyway because my script references something in the area (the deepstalker). Module start up might be too early.

My primary focus is how to get a script that actually runs from a trigger or from the area script (when the area loads) that I can see working. How to make the PC swap can come later, I'm more concerned that I seemingly can't figure out how to get a trigger/area start to run a script that works.

Modifié par FergusM, 15 janvier 2010 - 06:04 .


#4
FalloutBoy

FalloutBoy
  • Members
  • 580 messages
Put the start waypoint outside of the trigger volume. After the game loads, walk into the trigger. Then the EVENT_TYPE_ENTER event will be sent to the script attached to that trigger.

Also, I don't know if this is the problem but there is no need to put the trigger under the floor. Just put it on the floor.

Modifié par FalloutBoy, 15 janvier 2010 - 07:14 .


#5
FergusM

FergusM
  • Members
  • 460 messages
I've already done that, putting the waypoint outside of the trigger area and walking in. Nothing shows up in the logs though. Maybe it's just the print to log command that isn't working.

Ideally, I would like to figure out how to get it to run as the area is loading as well.

EDIT: Thanks for the help by the way. It's a little frustrating not knowing what is going wrong where, especially since I'm mostly copying exising scripts.

Modifié par FergusM, 15 janvier 2010 - 09:02 .


#6
FergusM

FergusM
  • Members
  • 460 messages
Okay, so it turned out it was just the logs command that wasn't working. I used destroy object and was able to destroy the deepstalker by entering the area. Fun fact, you can use EVENT_TYPE_ENTER as the area script and it will treat the entire area as a trigger and will trigger right away. So that solves that problem!



Now I just have to figure out why SetPartyLeader(oStalker); isn't working.

#7
FergusM

FergusM
  • Members
  • 460 messages
Going back to the Gate Defence script, I found that I had missed a line about setting the state of party members. I decided to put a quick guide in the OP in case anyone else searches the forums looking for how to do this.

#8
Craig Graff

Craig Graff
  • Members
  • 608 messages
This code will likely work fine for a custom campaign but will break the original game if used for an add-in. GetHero and IsHero are used at many different points for plot progression and party handling.
For add-ins you'd be better off using SetAppearanceType(oPC, nAppearance, TRUE);

Modifié par Craig Graff, 15 janvier 2010 - 10:14 .


#9
Adaram

Adaram
  • Members
  • 464 messages

Craig Graff wrote...

This code will likely work fine for a custom campaign but will break the original game if used for an add-in. GetHero and IsHero are used at many different points for plot progression and party handling.
For add-ins you'd be better off using SetAppearanceType(oPC, nAppearance, TRUE);


What goes in the value of nAppearance?

#10
Beerfish

Beerfish
  • Members
  • 23 831 messages
Can you also set the class of the creature in that script? As in can you make the pc whose been changed to level up under dogs level progression?

#11
FergusM

FergusM
  • Members
  • 460 messages

Adaram wrote...

What goes in the value of nAppearance?

Open up APR_base.xls (in Dragon Age/tools/source). This lists all the basic appearance types. nAppearance should take the value of the ID column. For example, 6 for Stone Golem.

I imagine there are other commands to change things like head morphs (since just changing to human appearance wouldn't be much help!) or to add abilities. Alas, I do not know these! EDIT: AddAbility() for the abilties. Actually, AddAbilityEx() is a little better.

Beerfish wrote...

Can you also set the class of the
creature in that script? As in can you make the pc whose been changed
to level up under dogs level progression?

I think there is a way to do this with a script, in addition to SetAppearance, but it's worth noting that using SetPartyLeader will preserve things like class, so you can indeed get a party member with Dog's talents as your Leader. However, I have had a problem with getting some talents to work this way, particularly monster talents, but that might just be something special about them.

Modifié par FergusM, 15 janvier 2010 - 08:04 .


#12
FergusM

FergusM
  • Members
  • 460 messages
Okay, so there are functions like AddAbilityEx, SetCreatureProperty (for attributes), SetApperance, SetName, etc.

However, I'm having trouble figuring out how to specify the creature's level? For example, let's say I want my PC to have all these changes (get abilities, new appearance, new name, etc) and I want to specify that he is level 10? I don't want to just add experience and have the player level up via the interface (though I can't figure that out either, setting the SIMPLE_EXPERIENCE property doesn't work), I just want the level shown to be 10.

Also, when using these commands on the default player (without going through character creation), he seems to be eternally stuck in combat and never regenerates stamina (it is always 0). How is that changed? I don't really want the character generation screen to come up.

Modifié par FergusM, 15 janvier 2010 - 10:28 .


#13
shennessy

shennessy
  • Members
  • 29 messages
I really dont see any equations in this game that use level. Its all attack power or spell power or an attribute. So I am pretty sure you can get the same effect as being level 10 by figuring out how much HP, staminia/mana, attackpower/spellpower you want and set it to that. Just be sure to keep track of all the old values so you can reset the player back.

Using SetApperanceType I didnt have the same stuck in combat problem you seem to have.

One issue I ran into. SetApperanceType will modify the attack type and movement speed based on the values in the APR_base.xls. So I have a mage with a staff equiped and he turns into an Arcane Horror. The Arcane horror moves slow, and it has no ranged attack. But the staff damage is done as a melee attack. I know this because using a staff that does fire damage makes my melee hits fire damage of the same damage value.

Modifié par shennessy, 18 janvier 2010 - 06:08 .


#14
Jopon

Jopon
  • Members
  • 17 messages
About the setappearencetype, it is bugged and hard to use in most situtations. When you set "set as original=true" the game attempts to use the face model you selected in character generation and the body of the nAppearance you select, making it useless for permenantly changing a characters appearence.

As for the leveling, try using the Chargen Functions. Here is a simple script I wrote that might have some useful functions for you. It takes any character and makes them a level 13 dwarf warrior with a noble background.
case EVENT_TYPE_USE:
{
//Define original var
object oCharr = GetHero();

//log orignal appearence type to bypass face model bug
int nApperanceId = GetAppearanceType(oCharr);

//Reset character to level 1, make him a dwarf warrior noble

Chargen_InitializeCharacter(oCharr,TRUE);
Chargen_SelectRace(oCharr,RACE_DWARF);
Chargen_SelectCoreclass(oCharr,class_WARRIOR);
Chargen_SelectBackground (oCharr,BACKGROUND_NOBLE);
Chargen_SetupPlotFlags(oCharr);
Chargen_EnableTacticsPresets(oCharr);
ChargenGetBackgroundSkill (RACE_DWARF,BACKGROUND_NOBLE);
Chargen_ApplyclassAbilities(oCharr,class_WARRIOR);



//Reset items
object oChar = GetHero();
int nBackgroundd = GetPlayerBackground(oChar);
int nclass = GetCreatureCoreclass(oChar);
int nRace = GetCreatureRacialType(oChar);
int nEquipIdx = Chargen_GetEquipIndex(nRace, nclass, nBackgroundd);
Chargen_ClearInventory (oChar);
Chargen_InitInventory(oChar,nclass,nEquipIdx);

//Restore orignal appearence after bugged appearence change during race change, set new appearence.

SetAppearanceType(oCharr,nApperanceId,TRUE);
SetAppearanceType(oCharr,3,FALSE);

//Grant Xp needed for level

object oHero = GetHero();
RewardXP(oHero, RW_GetXPNeededForLevel(13), TRUE, TRUE);

Modifié par Jopon, 21 janvier 2010 - 02:29 .


#15
FergusM

FergusM
  • Members
  • 460 messages
I appreciate it, but I am looking for a way to simply set what the level is. I don't want the player to 'level up,' I just want them to start with a certain level. For instance, I noticed that if you use console commands to add all the followers to your party, they all start at level 1, except for the spoiler character, who always starts with at least level 16. You don't have to level him up yourself, though. How do I accomplish that?



If you grant the experience before you add them to the party, do they use the auto level up?

#16
Craig Graff

Craig Graff
  • Members
  • 608 messages
You could start by looking at AL_DoAutoLevelUp in sys_autolevel_h.nss and comparing it with ALLoghain.xls.