Jump to content

Scripting Help: Creature Sub-Types


ThePersyn

Recommended Posts

Greetings,

I'm new to GECK scripting and I'm trying to figure out how to determine the sub-type of a creature.

Determining the main type of a creature is straightforward:

if Target.GetIsCreatureType 0 == 1
ShowMessage TypeAnimal ; Animal: Dog, Vicious Dog
elseif Target.GetIsCreatureType 1 == 1
ShowMessage TypeMutatedAnimal ; Mutated Animal: Brahmin, Mirelurk, Mirelurk King, Molerat, Yao Guai
elseif Target.GetIsCreatureType 2 == 1
ShowMessage TypeMutatedInsect ; Mutated Insect: Blowfly, Giant Ant, Queen Ant, Radroach, Radscorpion, Fire ant, Fire ant soldier, Giant Radscorpion
elseif Target.GetIsCreatureType 3 == 1
ShowMessage TypeAbomination ; Abomination: Centaurs, Deathclaw, Failed FEV Subjects
elseif Target.GetIsCreatureType 4 == 1
ShowMessage TypeSupermutant ; Supermutant: Supermutant, Supermutant Brute, Supermutant Chief, Supermutant Behemoth
elseif Target.GetIsCreatureType 5 == 1
ShowMessage TypeFeralGhoul ; Feral Ghoul: Feral Ghouls, Glowing One
elseif Target.GetIsCreatureType 6 == 1
ShowMessage TypeRobot ; Robot: Eyebot, Turrets, Mister Gutsy, Protectron, Robobrain, Sentrybot
endif
 

The problem I'm having is determining which sub-type a creature is (identifying it as bloatfly or a radroach and not just a Mutated Insect). I've tried using IsInList and GetBaseObject but neither seemed to work. I think the main obstacle is that most of the creatures in the wasteland are dynamically created, and their IDs are all different (verified using GBO in the console).

Is there a way to tell the difference between a molerat and a brahmin, using a script.

Thanks in advance!

Link to comment
Share on other sites

NVSE 3 adds the GetBaseForm function, which works like GetBaseObject but will also return the base form of a leveled actor.

 

Instead of using the IsInList function, which only works properly on references and always returns 0 when used on base objects, use NVSE's ListGetFormIndex and check that the value returned is not -1.

Edited by luthienanarion
Link to comment
Share on other sites

@luthienanarion Thanks for your input.

 

I tried different combinations of GetBaseObject, GetBaseForm, ListGetFormIndex, and IsRefInList. One combination resulted in CTD while the others all had the same result: creatures that can be seen in the GECK are always recognized but creatures that are dynamically created during gameplay are never recognized. Example: a bloatfly with the Form ID 0009189C is always recognized but any bloatfly with a Form ID that starts with FF is never recognized. So my problem remains the same, how to determine the sub-type of a creature.

Link to comment
Share on other sites

Make a formlist for each creature type and add all of the relevant base forms for that type to their list.

 

 

ref targetref
ref targetbase


; set targetref to the reference of the creature using whatever method

set targetbase to targetref.gbf

if(listgetformindex bloatflylist targetbase >= -1)
    messageex "This is a bloatfly."
elseif(listgetformindex radroachlist targetbase >= -1)
    messageex "This is a radroach."
elseif(listgetformindex snowmanlist targetbase >= -1)
    messageex "This is a snowman."
else
    messageex "This is not a known creature."
endif
Link to comment
Share on other sites

I've already been using detailed lists with that same code. The lists only work on creatures that can be viewed in the GECK; the lists do not work on dynamically generated creatures.

There are two basic groups of creatures that appear in the game: static and dynamic. Static creatures can be viewed in the GECK but dynamic creatures are added into the game through levelled lists or scripts. Static creatures use the same form ID for all instances, and can easily be identified using form lists. Dynamic creatures don't have a form ID until they are spawned in the game, and that form ID always has a prefix of FF but the rest of the ID is unique (ex: FF05612C).

 

Eventhough a dynamically generated creature is using the same model that the static ones do, it still appears in-game as completely unique. Commands like GetBaseForm and GetBaseObject, apparently, don't really get the the actual base when used on dynamically generated creatures; they get the unique generated form ID which only exists in the game and not the actual base that is used in the GECK levelled list.

What I'm trying to figure out is how to get a script to recognize a creature regardless of whether it is static or dynamic. The main type is easy to get (as shown in my OP), but getting the creature sub-type has so far been a dead end. I was hoping that there was some command similar to GetIsCreatureType; I'd even settle for something like GetName, but it appears that no such command exists (SetName exists but not GetName).

I've only been learning GECK scripting for the past week, so I might be missing something simple and obvious. But the only solution I've found so far is a workround involving hiding a token on all instances of a creature and then checking for that token with the script. I'm hoping the real solution isn't that messy.

I would greatly appreciate any suggestions.

Link to comment
Share on other sites

Ok, here's the test that I set up. First, I made a gun that outputs 3 lines to the console with information about the target hit with it:

 

 

scn FormIDgunOS
 
ref self
ref base
ref form

begin scripteffectstart

    moddisposition player 10
    stopcombat
    scaonactor player
    set self to getself
    set base to self.gbo
    set form to self.gbf
    printc "REF: %n (%i)%rGBO: %n (%i)%rGBF: %n (%i)%r%r" self self base base form form
    messageex "REF: %n (%i)%rGBO: %n (%i)%rGBF: %n (%i)%r%r" self self base base form form

end ; scripteffectstart

 

After setting the console output to log to a text file, I went around to a few different places around the map and shot things with the gun. First, I tested on placed actors, both leveled and unleveled.

 

 

REF: Boone (00096BCE)
GBO: Boone (00092BD2)
GBF: Boone (00092BD2)

REF: Chem Addict (00160844)
GBO: Chem Addict (FF000C6F)
GBF: <no name> (00152E06)

REF: NCR Trooper (000FCEB1)
GBO: NCR Trooper (000FCEB0)
GBF: NCR Trooper (000FCEB0)

REF: Fiend (000FB85B)
GBO: Fiend (FF001230)
GBF: <no name> (000F1C63)

REF: Fiend (000FB85F)
GBO: Fiend (FF001234)
GBF: <no name> (000F1C48)

REF: Fiend (000FB86C)
GBO: Fiend (FF000FA0)
GBF: <no name> (000F1C46)

REF: Night Stalker (00164F3D)
GBO: Night Stalker (00164EF6)
GBF: Night Stalker (00164EF6)

REF: Night Stalker (00164F3D)
GBO: Night Stalker (00164EF6)
GBF: Night Stalker (00164EF6)

REF: Night Stalker (00168A01)
GBO: Night Stalker (001689D7)
GBF: Night Stalker (001689D7)

REF: Cazador (00168BAF)
GBO: Cazador (FF001313)
GBF: <no name> (0015C683)

REF: Young Cazador (00168BA7)
GBO: Young Cazador (FF00132B)
GBF: <no name> (0015C674)

REF: Viper Leader (00168BFA)
GBO: Viper Leader (00168BD4)
GBF: Viper Leader (00168BD4)

REF: Bighorner Calf (00174BB7)
GBO: Bighorner Calf (FF001310)
GBF: <no name> (0015C648)

REF: Bighorner Bull (00174BB3)
GBO: Bighorner Bull (FF00125F)
GBF: <no name> (00159791)

REF: Evolved Centaur (00153432)
GBO: Evolved Centaur (FF001330)
GBF: <no name> (0015677E)

REF: Giant Evolved Centaur (001567D3)
GBO: Giant Evolved Centaur (00156789)
GBF: Giant Evolved Centaur (00156789)

 

Note that GetBaseObject (GBO) returns a useless ID beginning with FF if used on a reference to a leveled actor, and GetBaseForm (GBF) returns the correct ID in both cases. Instances where the GBF lines have no name associated with the form are not mistakes, as these actors are usually templated for leveled lists.

 

For the second part of the test, I needed dynamically-generated actors. Not having any other means of generating them, I used Pokeballs from one of my mods. When used, these summon a creature from a leveled list.

 

 

REF: &PCName;'s Vicious Dog (FF001349)
GBO: &PCName;'s Vicious Dog (0B01D63B)
GBF: &PCName;'s Vicious Dog (0B01D63B)

REF: &PCName;'s Mole Rat (FF00134B)
GBO: &PCName;'s Mole Rat (0B01D926)
GBF: &PCName;'s Mole Rat (0B01D926)

REF: Raven (FF00134D)
GBO: Raven (0B01D63E)
GBF: Raven (0B01D63E)

REF: &PCName;'s Bloatfly (FF00134F)
GBO: &PCName;'s Bloatfly (0B01D639)
GBF: &PCName;'s Bloatfly (0B01D639)

REF: &PCName;'s Giant Rat (FF001352)
GBO: &PCName;'s Giant Rat (0B01D63F)
GBF: &PCName;'s Giant Rat (0B01D63F)

REF: &PCName;'s Spore Carrier (FF00135A)
GBO: &PCName;'s Spore Carrier (0B01D63D)
GBF: &PCName;'s Spore Carrier (0B01D63D)

 

In this section, we have dynamically-generated actors with IDs beginning with FF. Both GetBaseObject and GetBaseForm return the correct ID of the leveled actor's base form. I can attest that these values are correct, because they are forms in my own mod.

 

GetBaseObject in some cases and GetBaseForm in all cases do return the base form from any reference, static or dynamic. Now that we have that bit of fog cleared, perhaps we can find the real source of your troubles.

Link to comment
Share on other sites

@luthienanarion Thank you very much for all your effort.

The problem is that my lists were incomplete. After I looked at your printout, I went back and reexamined the results I was getting and realized I missed a bunch of entries.

My lists were made up of all the creatures listed under their main type in the GECK: Abomination, Animal, Feral Ghoul, etc. I completely missed all of the creatures that are listed under the main category of CREATURES, which is where the levelled creatures are listed. As a result, I only had static creatures in my list and no dynamic ones so, static ones worked everytime and dynamic ones failed everytime. D'Oh!

It's working fine now.

 

    set Target to GetOwnerLastTarget
    set TargetBF to Target.GetBaseForm
    if (ListGetFormIndex CreaturesBloatflies TargetBF != -1)
        messageex "This is a Bloatfly."
    elseif (ListGetFormIndex CreaturesRadroaches TargetBF != -1)
        messageex "This is a Radroach."
    elseif (ListGetFormIndex CreaturesRadscorpions TargetBF != -1)
        messageex "This is a Radscorpion."
    elseif (ListGetFormIndex CreaturesFireAnts TargetBF != -1)
        messageex "This is a Fire Ant."
    endif
 

Again, thanks for all your help.

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...