• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

UnitSetVariation does not Change Death Models!

Status
Not open for further replies.
I'm making a multi-map and one of the game modes involves sheep farming...

To make things simple, I like to have one unit per species, having two units results in tons of scripting for my mating system & other parts. I also hate the damned data editor with a passion and want to create a dummy unit for my projectiles system which I can then swap the model of to whatever I like using scripting.

When I use:
JASS:
libNtve_gf_UnitSetVariation(lv_u, "CivilianFemale", RandomInt(1, 2), "");
to change the civilian males model to a female, it works, BUT the death models don't change >_<! I can't figure out how to change them as well.

Actors make me want to go on a murderous rampage trying to figure them out, there's just no tutorials out there that I can find that explain them.

As for my projectiles system, scripting the movement of the projectiles results in lots of choppiness & random crap happening, so I need to make some unit which then just moves forward ignoring everything until it collides with something and dies, in which I would use scripting to apply damage & so on.

I'm guessing I have to use one of these, but I don't know how, and I'm not even sure if these are the right functions...
JASS:
ActorSendTo(ActorFrom("IDK wtf goes here"), "or here", libNtve_gf_ModelSwap(lp_model, lp_percent));

lp_percent is what Blizzard calls their parameter variable "Variation" for some reason. It really should be lp_variation.

mfw
 

Attachments

  • FUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU.jpg
    FUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU.jpg
    32.6 KB · Views: 217
Just make two different civ units.
Have one using the female model, with no variations, and one the male model, with no variations.


I don't think you understand what I'm trying to do & why. Maybe this pic will make you understand.

attachment.php


Also look @ how much bigger it makes my mating script when I have two separate units:
JASS:
if (gv_gender[lv_cv] == gv_gender[lv_cv2]) {
    return true;
} else if ((lv_ut == gv_farmerFemale || lv_ut == gv_farmerMale)&& lv_ut2 == lv_ut) {
    return true;
} else if (lv_ut != lv_ut2 && !(lv_ut == gv_farmerFemale || lv_ut == gv_farmerMale)) {
    return true;
}
if (RandomInt(0, 1) == 0) {
    lv_p3 = lv_p;
} else {
    lv_p3 = lv_p2;
}
if (lv_ut == gv_sheep) {
    UnitCreate(1, gv_sheep, 0, lv_p3, UnitGetPosition(lv_u), RandomFixed(0.0, 360.0));
    lv_u = UnitLastCreated();
    gf_AssignAttributeData(lv_u, gv_sheepInitialSize, lv_g);
    //gf_DebugMsg(StringToText("Mating successful! Offspring goes to Player: " + IntToString(lv_p)));
} else if (lv_ut == gv_farmerFemale) {
    if (lv_g == 0) {
        UnitCreate(1, gv_farmerMale, 0, lv_p3, UnitGetPosition(lv_u), RandomFixed(0.0, 360.0));
    } else {
        UnitCreate(1, gv_farmerFemale, 0, lv_p3, UnitGetPosition(lv_u), RandomFixed(0.0, 360.0));
    }
    lv_u = UnitLastCreated();
    gf_AssignAttributeData(lv_u, gv_humanInitialSize, lv_g);
    //gf_DebugMsg(StringToText("Mating successful! Offspring goes to Player: " + IntToString(lv_p)));
} else if (lv_ut == gv_farmerMale) {
    if (lv_g == 0) {
        UnitCreate(1, gv_farmerMale, 0, lv_p3, UnitGetPosition(lv_u2), RandomFixed(0.0, 360.0));
    } else {
        UnitCreate(1, gv_farmerFemale, 0, lv_p3, UnitGetPosition(lv_u2), RandomFixed(0.0, 360.0));
    }
    lv_u = UnitLastCreated();
    gf_AssignAttributeData(lv_u, gv_humanInitialSize, lv_g);
    //gf_DebugMsg(StringToText("Mating successful! Offspring goes to Player: " + IntToString(lv_p)));
} else {
    gf_DebugMsg(StringToText("Mating attempt failed."));
}

That isn't my only script made really huge by this complication and I can't even hope to do a projectile system either if I have to use the data editor to make a unique projectile for each projectile instead of one dummy projectile I customize through scripts. :sad:
 

Attachments

  • Damned Models & Actors.png
    Damned Models & Actors.png
    46.1 KB · Views: 317

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,258
Try separating the deaths from the unit actor. Maybe make 2 dummy unit actors with the deaths (for male and female respectivly) and then link them so that when the actual unit actor dies (it has no deaths) it then destroys itself and depending on variation makes one of the dummy death actors for it which inturn get killed.

Even if thats a stupid idea, I am sure with the right actor events you can do what you want.

As for your script... I would have to se all of it but there might be room for optimizations.
 
Well, the slot or whatever it is for the actor that does get changed is called "main". If only I knew what the other ones are called...

This is the line I use:
JASS:
libNtve_gf_UnitSetVariation(lv_u, "CivilianFemale", RandomInt(1, 3), "");

That line does the following:
  • Set Unit Model Variation
    • Options: Action
    • Return Type: (None)
    • Parameters
      • Unit = (Triggering unit) <Unit>
      • Model <Game Link - Model>
      • Variation = 0 <Integer>
      • Textures = "" <String>
    • Grammar Text: Set unit Unit model to Model with variation Variation and textures Textures
    • Hint Text: Changes a unit's model to the specified model with the specified variation and can alter the textures with the specified texture props string.
    • Custom Script Code
    • Local Variables
    • Actions
      • Actor - Send actor message (ModelSwap Model Variation) to main actor of unit Unit
      • General - If (Conditions) then do (Actions) else do (Actions)
        • If
          • (Length of Textures) > 0
        • Then
          • Actor - Send actor message (TextureSelectBySlot "main".Default ("BestMatch " + Textures)) to main actor of unit Unit
        • Else
Model Swap is:
  • Model Swap
    • Options: Function
    • Return Type: Actor Message
    • Parameters
      • Model <Game Link - Model>
      • Variation = -1 <Integer>
    • Grammar Text: ModelSwap Model Variation
    • Hint Text: Constructs and returns a ModelSwap actor message. This message will swap the current model of an actor with an model to the specified Model and Variation number.
    • Custom Script Code
    • Local Variables
    • Actions
      • General - Return (Actor Msg 2("ModelSwap", (String(Model)), (String(Variation))))
Edit: I think I've been horribly confused. Except for the death by fire model, all the other models listed there don't change how it dies... so the regular death animation is what I have to change. For some reason despite changing the main model, it reverts back to the original model when the unit dies, which screws everything up for me. x.x

Edit 2: I finally found a way around my problem, I just set the units model again when it dies, and that way it stays the same.

JASS:
gv_portrait[lv_cv] = 0;
if (lv_ut == gv_sheep) {
    lv_b = true;
    gv_sheepCount[lv_p] += -1;
    gv_livestockTotal[lv_p] += -1;
    UnitGroupRemove(gv_livestockGroup[lv_p], lv_u);
    lv_cv = FixedToInt(UnitGetCustomValue(lv_u, gv_CVS));
    if (gv_gender[lv_cv]) {
        gv_sheepMale[lv_p] += -1;
    } else {
        gv_sheepFemale[lv_p] += -1;
    }
    gv_indexerArray[lv_cv] = false;
} else if (lv_ut == gv_tree) {
    gv_treesCount += -1;
} else if (lv_ut == gv_farmerMale) {
    gv_farmersMaleCount[lv_p] += -1;
    libNtve_gf_UnitSetVariation(lv_u, "MarineCorpse", 1, "");
    gv_indexerArray[lv_cv] = false;
} else if (lv_ut == gv_farmerFemale) {
    gv_farmersFemaleCount[lv_p] += -1;
    libNtve_gf_UnitSetVariation(lv_u, "MarineCorpse", 1, "");
    gv_indexerArray[lv_cv] = false;
} else if (lv_ut == gv_human) {
    libNtve_gf_UnitSetVariation(lv_u, "MarineCorpse", 1, "");
}
gf_UpdateMultiboard();
 
Last edited:
Status
Not open for further replies.
Top