Aller au contenu

Photo

Creature spawn with random weapons


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

#1
EzRemake

EzRemake
  • Members
  • 118 messages
I'm trying to write a script that will give a creature a random weapon (from a list) when they spawn. This should be really easy, but for some reason it just isn't working.

I made a copy of x2_def_spawn for the monsters I want this to apply to, and simply added

ExecuteScript("bones_items", OBJECT_SELF); to it to generate the loot.

bones_items looks like this

void main()
{
    int iRand = d4(1);

    switch (iRand){
      case 1: CreateItemOnObject("waxbt003", OBJECT_SELF); break;
      case 2: CreateItemOnObject("waxbt004", OBJECT_SELF); break;
      case 3: CreateItemOnObject("waxbt005", OBJECT_SELF); break;
      case 4: CreateItemOnObject("waxbt006", OBJECT_SELF); break;
      }

    ActionEquipMostDamagingMelee();
}

The item never seems to be created, as the enemy never seems to switch to it, or drop it when they die. I've tried many different item combinations with NPCs who are able to equip anything.

#2
MagicalMaster

MagicalMaster
  • Members
  • 2 003 messages
Add this line into the script after the switch statement:

SpeakString("Created item " + IntToString(iRand));

Make sure the creature actually says that line -- if you don't see it, your script isn't firing properly.

#3
EzRemake

EzRemake
  • Members
  • 118 messages
I knew it was going to be something small and stupid, turns out in this scenario you have to refer to the tag of the item, not the resref... Seems when dealing with giving items to players it's resref, and to creatures it's tag

The more you know lol

#4
EzRemake

EzRemake
  • Members
  • 118 messages
What I've come up with looks like this

void main()
{
int iRand = d3(1);
object oMainhand;
object oOffhand;

switch (iRand){

case 1: oMainhand = CreateItemOnObject("CeremonialScythe", OBJECT_SELF);
              SetDroppableFlag(oMainhand, FALSE);
              ActionEquipItem(oMainhand, INVENTORY_SLOT_RIGHTHAND);
              break;

case 2: oMainhand = CreateItemOnObject("BoneSword", OBJECT_SELF);
              oOffhand = CreateItemOnObject("BoneShield", OBJECT_SELF);
              SetDroppableFlag(oMainhand, FALSE);
              SetDroppableFlag(oOffhand, FALSE);
              ActionEquipItem(oMainhand, INVENTORY_SLOT_RIGHTHAND);
              ActionEquipItem(oOffhand, INVENTORY_SLOT_LEFTHAND);
              break;

case 3: oMainhand = CreateItemOnObject("BoneSword", OBJECT_SELF);
              oOffhand = CreateItemOnObject("BoneSword", OBJECT_SELF);
              SetDroppableFlag(oMainhand, FALSE);
              SetDroppableFlag(oOffhand, FALSE);
              ActionEquipItem(oMainhand, INVENTORY_SLOT_RIGHTHAND);
              ActionEquipItem(oOffhand, INVENTORY_SLOT_LEFTHAND);
              break;
}

}

I plan to use this in the future, giving certain types of monsters many particular setups, more than just the three listed here. Will this cause instability or lag when multiple creatures are spawning throughout the server with scripts like this tied to them?

Modifié par EzRemake, 03 décembre 2013 - 09:34 .


#5
Cursed Eclipse

Cursed Eclipse
  • Members
  • 70 messages
or you can try this
http://nwvault.ign.c...d=51805&id=2813