Jump to content
Qaquabum

Changing the starting positions and Startloot on own server / Startpositionen und Startloot auf eigenen Server ändern

Recommended Posts

Guten Tag

Ich habe einen eigenen Server möchte die Startpositionen und den Startloot für alle Spieler ändern

in der "cfgplayerspawnpoints" hab ich schon alle Coordinaten bis meine ausgewählten gelöscht und trotzdem spawnen wir manchmal ganz woanders wo halt keine Coordinaten hinterlegt sind (Solnichniy)
die selbstausgesuchten Coordinaten (7) liegen alle zwischen Cherno und Elektro
  es scheint jetzt zufunktionieren danke an g4borg

in der "init.c" datei hab ich den startloot geändern leider bekommen wir nicht den eingestellten loot (Hunterbackpack, Hunter Vest, Hunting Jacket, Hunter Pants usw.)

könnte jemand helfen das es so funktioniert wie geplant ?

 

 

Good day

I have my own server want to change the starting positions and the starting slot for all players

in the "cfgplayerspawnpoints" I already deleted all coordinates until my selected ones and still we sometimes spawn somewhere else where no coordinates are stored (Solnichniy)
the self-selected coordinates (7) are all between Cherno and Electro
   its seems to working now  thanks to g4borg

in the "init.c" file I changed the startloot unfortunately we do not get the set loot (Hunterpack, Hunter Vest, Hunting Jacket, Hunter Pants etc.)

could someone help that it work as planned?

 

Edited by Qaquabum

Share this post


Link to post
Share on other sites

Post your init.c and maybe one of the members may spot something, without seeing your code it's hard to tell

 

Share this post


Link to post
Share on other sites

if you change the spawning coordinates in the xml, you also have to delete the compiled spawnpoints.bin in storage_1 for it to take effect.

then at next server start the server will regenerate the spawn points from your xml. only the .bin file is valid. it will not regenerate it simply because you change them in the xml.

starting loot is all in the init.c; there are lots of examples out there for that.

Edited by g4borg
  • Thanks 1
  • Beans 1

Share this post


Link to post
Share on other sites

init.c

void main()

{
    //INIT WEATHER BEFORE ECONOMY INIT------------------------
    Weather weather = g_Game.GetWeather();

    weather.MissionWeather(false);    // false = use weather controller from Weather.c

    weather.GetOvercast().Set( Math.RandomFloatInclusive(0.4, 0.6), 1, 0);
    weather.GetRain().Set( 0, 0, 1);
    weather.GetFog().Set( Math.RandomFloatInclusive(0.05, 0.1), 1, 0);

    //INIT ECONOMY--------------------------------------
    Hive ce = CreateHive();
    if ( ce )
        ce.InitOffline();

    //DATE RESET AFTER ECONOMY INIT-------------------------
    int year, month, day, hour, minute;
    int reset_month = 9, reset_day = 20;
    GetGame().GetWorld().GetDate(year, month, day, hour, minute);

    if ((month == reset_month) && (day < reset_day))
    {
        GetGame().GetWorld().SetDate(year, reset_month, reset_day, hour, minute);
    }
    else
    {
        if ((month == reset_month + 1) && (day > reset_day))
        {
            GetGame().GetWorld().SetDate(year, reset_month, reset_day, hour, minute);
        }
        else
        {
            if ((month < reset_month) || (month > reset_month + 1))
            {
                GetGame().GetWorld().SetDate(year, reset_month, reset_day, hour, minute);
            }
        }
    }
}

class CustomMission: MissionServer
{    
    void SetRandomHealth(EntityAI itemEnt)
    {
        if ( itemEnt )
        {
            int rndHlt = Math.RandomInt(55,100);
            itemEnt.SetHealth("","",rndHlt);
        }
    }

    override PlayerBase CreateCharacter(PlayerIdentity identity, vector pos, ParamsReadContext ctx, string characterName)
    {
        Entity playerEnt;
        playerEnt = GetGame().CreatePlayer(identity, characterName, pos, 0, "NONE");//Creates random player
        Class.CastTo(m_player, playerEnt);
        
        GetGame().SelectPlayer(identity, m_player);
        
        return m_player;
    }
    
    override void StartingEquipSetup(PlayerBase player, bool clothesChosen)
    {
        EntityAI itemTop;
        EntityAI itemEnt;
        ItemBase itemBs;
        float rand;
        
        itemTop = player.FindAttachmentBySlotName("Body");
        
        if ( itemTop )
        {
            itemEnt = itemTop.GetInventory().CreateInInventory("HuntingBag");
            SetRandomHealth(itemEnt);
                        
            itemEnt = itemTop.GetInventory().CreateInInventory("HuntingJacket_Summer");
            SetRandomHealth(itemEnt);
                        
            itemEnt = itemTop.GetInventory().CreateInInventory("HunterPants_Summer");
            SetRandomHealth(itemEnt);
                        
            itemEnt = itemTop.GetInventory().CreateInInventory("HuntingVest");
            SetRandomHealth(itemEnt);
                        
            itemEnt = itemTop.GetInventory().CreateInInventory("HuntingKnife");
            SetRandomHealth(itemEnt);
                        
            itemEnt = itemTop.GetInventory().CreateInInventory("CombatBoots_Black");
            SetRandomHealth(itemEnt);
                        
            itemEnt = itemTop.GetInventory().CreateInInventory("Headtorch_Black");
            SetRandomHealth(itemEnt);
                        
            itemEnt = itemTop.GetInventory().CreateInInventory("Battery9V");
                itemBs.SetQuantity(2);
            SetRandomHealth(itemEnt);
            
            itemEnt = itemTop.GetInventory().CreateInInventory("Rag");
            if ( Class.CastTo(itemBs, itemEnt ) )
                itemBs.SetQuantity(6);
            SetRandomHealth(itemEnt);
            
            rand = Math.RandomFloatInclusive(0.0, 1.0);
            if ( rand < 0.01 )
                itemEnt = player.GetInventory().CreateInInventory("Apple");
            else if ( rand > 0.01 )
                itemEnt = player.GetInventory().CreateInInventory("Pear");
            else
                itemEnt = player.GetInventory().CreateInInventory("Plum");
        
            SetRandomHealth(itemEnt);
        }
    }
};
 
Mission CreateCustomMission(string path)
{
    return new CustomMission();
}

 

thanks for the help with the spawnpoints its seems to work

Edited by Qaquabum

Share this post


Link to post
Share on other sites
5 hours ago, g4borg said:

if you change the spawning coordinates in the xml, you also have to delete the compiled spawnpoints.bin in storage_1 for it to take effect.

then at next server start the server will regenerate the spawn points from your xml. only the .bin file is valid. it will not regenerate it simply because you change them in the xml.

 

thanks its seems to working now

Share this post


Link to post
Share on other sites

In your code for the Init.C

 

In the subroutine labelled StartingEquipSetup....

 

In the places where you have ItemTop.GetInventory...... It should be ....

 

player.GetInventory....

Like this...

 

    itemEnt = player.GetInventory().CreateInInventory("HuntingBag");
    SetRandomHealth(itemEnt);
                        
    itemEnt = player.GetInventory().CreateInInventory("HuntingJacket_Summer");
    SetRandomHealth(itemEnt);
                        
    itemEnt = player.GetInventory().CreateInInventory("HunterPants_Summer");
    SetRandomHealth(itemEnt);
                        
    itemEnt = player.GetInventory().CreateInInventory("HuntingVest");
    SetRandomHealth(itemEnt);
                        
    itemEnt = player.GetInventory().CreateInInventory("HuntingKnife");
    SetRandomHealth(itemEnt);
                        
    itemEnt = player.GetInventory().CreateInInventory("CombatBoots_Black");
    SetRandomHealth(itemEnt);
                        
    itemEnt = player.GetInventory().CreateInInventory("Headtorch_Black");
    SetRandomHealth(itemEnt);
                        
    itemEnt = player.GetInventory().CreateInInventory("Battery9V");
    itemBs.SetQuantity(2);
    SetRandomHealth(itemEnt);

 

 

Also,

Note that in the original Init.C file

The item is "cast" for each item you create...

Since I don't know C or Java or whatever language it is written in,
I don't know how to explain it better...

 

        EntityAI itemEnt;
        ItemBase itemBs;
        
        itemEnt = player.GetInventory().CreateInInventory("HuntingBag");
        itemBs = ItemBase.Cast(itemEnt);
        SetRandomHealth(itemEnt);
 

        itemEnt = player.GetInventory().CreateInInventory("HuntingJacket_Summer");
        itemBs = ItemBase.Cast(itemEnt);
        SetRandomHealth(itemEnt);
 

This line is missing in your init.c code, in each of your object instantiation blocks

Maybe another member who knows C better than could explain the meaning ITEMBASE.CAST better!

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Edited by DrZeddy
added extra bit at end

Share this post


Link to post
Share on other sites

The cast to ItemBs is only needed if you want to manipulate the amount on a stacked item or other functions which are part of ItemBase, an ancestor class of EntityAI. It is needed for the expression

itemBs.SetQuantity(2);

Why they have to cast it around, do not ask me. To me that sounds like broken object oriented design. If it is a subclass after all, you should be able to call the methods, nevertheless. I never tried if itemEnt.SetQuantity(2) works, because the examples all use the casting step inbetween.


Otherwise the casting has to be inserted, because of course, like this it won't operate on the object in question. It is the same object, just as an ancestor.

---

To compare, here is a helper function i use to create items (however with full health) to highlight the exact procedure:

   EntityAI EquipItem(PlayerBase player, string itemClass, int amount) {
        EntityAI item = player.GetInventory().CreateInInventory(itemClass);
        item.SetHealth("","",100);
        if (amount > 1) {
            ItemBase itemBase;
            if ( Class.CastTo(itemBase, item ) )
                itemBase.SetQuantity(amount);
        }
        return item;
    }
 
 ...
 
  EquipItem(player, "Rags", 4);
  EquipItem(player, "HuntingBagpack", 1);
	

in the init.c exactly this is done, the variables "itemEnt" and "itemBs" are just recycled after each create (while a helper function like mine has the downside of initializing the variable each time it is called), but I prefer readability over preoptimization.

edit: sorry, the syntax highlighting uses similar colors like the forum layout, but i cant undo it.

Edited by g4borg

Share this post


Link to post
Share on other sites

hey g4borg can you write your lost post in german ?

not the code your explanations

Share this post


Link to post
Share on other sites

@g4borg

Thank you, your explanation helps a lot since I do not know the language (I think it's C..)

And I very much like the helper function you posted.

It does indeed make the code very much more readable. 

 

I had the same problem with the code coloring, in the end I deleted the whole code block
re-inserted it again and chose 'No Syntax Highlighting' in the code format dropdown

Share this post


Link to post
Share on other sites
On 2/19/2019 at 8:59 AM, g4borg said:

The cast to ItemBs is only needed if you want to manipulate the amount on a stacked item or other functions which are part of ItemBase, an ancestor class of EntityAI. It is needed for the expression


itemBs.SetQuantity(2);

Why they have to cast it around, do not ask me. To me that sounds like broken object oriented design. If it is a subclass after all, you should be able to call the methods, nevertheless. I never tried if itemEnt.SetQuantity(2) works, because the examples all use the casting step inbetween.

Der Cast nach ItemBs wird nur gebraucht wenn du die Anzahl eines gestackten Items manipulieren willst, oder eben andere Methoden, die in ItemBase definiert sind (was eine Mutterklasse von EntityAI ist). Du brauchst es für den Ausdruck "itemBs.SetQuantity(2)". Warum die herumcasten, frag mich nicht. Klingt für mich ziemlich broken was Objektorientierung betrifft. Es ist eine Unterklasse, und demnach müsste ich ja alle Methoden der Mutterklasse ohnehin aufrufen können. Ich hab jedoch auch noch nie probiert "itemEnt.SetQuantity(2)" aufzurufen, weil eben alle Beispiele diesen Casting Zwischenschritt haben.

(Casten = das wandeln einer Instanz-Variable einer Klasse in eine andere, von der es vererbt wurde)

On 2/19/2019 at 8:59 AM, g4borg said:

To compare, here is a helper function i use to create items (however with full health) to highlight the exact procedure: ...

in the init.c exactly this is done, the variables "itemEnt" and "itemBs" are just recycled after each create (while a helper function like mine has the downside of initializing the variable each time it is called), but I prefer readability over preoptimization.

Als Vergleich hier ist eine Hilfsfunktion, die ich zum Erstellen von Items verwende (jedoch mit vollem Health Wert), um aufzuzeigen wie der Ablauf tatsächlich ist: ...

In init.c wird genau das auch öfter hintereinadner gemacht, die Variablen "itemEnt" und "itemBs" werden einfach nur wiederverwertet, nach jedem Create (während eine Hilfsfunktion wie die meine den Nachteil hat, dass sie die Hilfsvariablen bei jedem Aufruf neu initialisiert), aber ich bevorzuge Lesbarkeit über frühzeitige Optimisation.

20 hours ago, DrZeddy said:

And I very much like the helper function you posted.

To be honest, all the pain going through learning the ins and outs of Scripting makes it a lot less painful, if someone says thank you 🙂

Myself I have already twice thrown the towel in creating anything in this ecosystem, and returned coding on other Projects in unity, where I have to do a lot more, but at least, I have control over my project, and don't have to deal with a system that defines everything seven times on different positions, packs it in binaries, defines configuration stuff for everything ten times, and that without really making it easier to overload things, because the real stuff you would want to change, is hardcoded after all. And while you could solve stuff with creating mods, the client does not even support loading them on server join. One really asks the painful question, whether it isn't faster to write the whole game yourself faster, than a mod for it...

Share this post


Link to post
Share on other sites

@g4borg  thank you / vielen dank

Edited by Qaquabum

Share this post


Link to post
Share on other sites

@g4borg

muss das " override void StartingEquipSetup(PlayerBase player, bool clothesChosen) " stehen bleiben oder wird ab der zeile dein Code verwendet

also so hier oder doch anders ?

 

override PlayerBase CreateCharacter(PlayerIdentity identity, vector pos, ParamsReadContext ctx, string characterName)
    {
        Entity playerEnt;
        playerEnt = GetGame().CreatePlayer(identity, characterName, pos, 0, "NONE");//Creates random player
        Class.CastTo(m_player, playerEnt);
        
        GetGame().SelectPlayer(identity, m_player);
        
        return m_player;
    }
    
    
    EntityAI EquipItem(PlayerBase player, string itemClass, int amount) {
        
        EntityAI item = player.GetInventory().CreateInInventory(itemClass);
        item.SetHealth("","",100);
        if (amount > 1) {
            ItemBase itemBase;
            if ( Class.CastTo(itemBase, item ) )
                itemBase.SetQuantity(amount);
        }
        return item;
    }
 
 ...
 
            EquipItem(player, "HuntingBagpack", 1);
              
            EquipItem(player, "HuntingJacket_Summer", 1);
              
            EquipItem(player, "HunterPants_Summer", 1);
              
            EquipItem(player, "HuntingVest", 1);
            
            EquipItem(player, "CombatBoots_Green", 1);
            
            EquipItem(player, "Headtorch_Black", 1);
            
            EquipItem(player, "HuntingKnife", 1);

Edited by Qaquabum
  • Like 1

Share this post


Link to post
Share on other sites

Meine Hilfsfunktion ist eine Hilfsfunktion. Die ersetzt grundsätzlich keine der anderen Funktionen. Sie ersetzt was in jener Funktion geschieht, und war dazu gedacht, den Vorgang verständlich zu machen.

Ich hoffe auch mal aufrichtig, du hast nicht einfach "..." in die Datei geschrieben.

Der Aufruf: EquipItem("HuntingJacket_Summer", 1) ersetzt

"itemEnt = itemTop.GetInventory().CreateInInventory("HuntingJacket_Summer");
SetRandomHealth(itemEnt);"

(mit dem Unterschied, dass es statt RandomHealth full-health macht, und optional das casting übernimmt, sowie stack-amount setzt)

es gibt nur zwei wege zu programmieren zu lernen: a) verstehen was jede zeile macht, indem man sich es im kopf vorstellt, b) solange fehler korrigieren bis man versteht wie es geht. es gibt kein c.

Edited by g4borg

Share this post


Link to post
Share on other sites

@g4borg

wenn deine funktion keine ersetzt bleibt aber das problem das man standart klamotten vom spiel bekommt

ich dachte halt das der equipitem die standartklamotten ersetzt

 

könntest du es vllt einrichten mal auf einen ts server zu kommen oder discord server

oder ich komme auf einen deiner wahl

Edited by Qaquabum

Share this post


Link to post
Share on other sites

@g4borg

kann man hier keine dateien anhängen ?

 

ich hoffe das es jetzt richtig ist  

 

    override void StartingEquipSetup(PlayerBase player, bool clothesChosen)
    {
        EntityAI itemTop;
        EntityAI itemEnt;
        ItemBase itemBs;
        float rand;
        
        itemTop = player.FindAttachmentBySlotName("Body");
        
        if ( itemTop )
    
    EntityAI EquipItem(PlayerBase player, string itemClass, int amount)
    {
        
        EntityAI item = player.GetInventory().CreateInInventory(itemClass);
        item.SetHealth("","",100);
        if (amount > 1)
        {
            ItemBase itemBase;
            if ( Class.CastTo(itemBase, item ) )
                itemBase.SetQuantity(amount);
        }
        
        return item;
    }
        {
            EquipItem(player, "HuntingBagpack", 1);
              
            EquipItem(player, "HuntingJacket_Summer", 1);
              
            EquipItem(player, "HunterPants_Summer", 1);
              
            EquipItem(player, "HuntingVest", 1);
            
            EquipItem(player, "CombatBoots_Green", 1);
            
            EquipItem(player, "Headtorch_Black", 1);
            
            EquipItem(player, "HuntingKnife", 1);
            
            EquipItem(player, "CZ527", 1);
            
            EquipItem(player, "Mag_CZ527_5rnd", 2);
            
            EquipItem(player, "AmmoBox_762x39_20Rnd", 1);
            
            EquipItem(player, "HuntingOptic", 1);
            
            EquipItem(player, "CZ75", 1);
                        
            EquipItem(player, "Mag_CZ75_15Rnd", 2);
                          
            EquipItem(player, "AmmoBox_9x19_25rnd", 1);
            
            EquipItem(player, "PistolSuppressor", 1);
            
            EquipItem(player, "ImprovisedSuppressor", 1);
            
            EquipItem(player, "Rags", 6);
            
            EquipItem(player, "Canteen", 2);
            
            EquipItem(player, "CanOpener", 1);
            
              
            EquipItem(player, "Battery9V", 2);


            EquipItem(player, "HuntingKnife", 1);
              

            
        }
    
};

 

 

edit:   der server startet mit den befehlen nicht also müsste ein fehler drin sein leider hab ich keine ahnung von programmieren

Edited by Qaquabum

Share this post


Link to post
Share on other sites

tu die hilfsfunktion über die override funktion. (bzw. korrekt gesagt "daneben" also auf derselben ebene)

du darfst keine funktion innerhalb einer funktion definieren in dieser sprache.

	EntityAI EquipItem(PlayerBase player, string itemClass, int amount)
    {
        
        EntityAI item = player.GetInventory().CreateInInventory(itemClass);
        item.SetHealth("","",100);
        if (amount > 1)
        {
            ItemBase itemBase;
            if ( Class.CastTo(itemBase, item ) )
                itemBase.SetQuantity(amount);
        }
        
        return item;
    }
	  override void StartingEquipSetup(PlayerBase player, bool clothesChosen)
    {
	            EquipItem(player, "HuntingBagpack", 1);
            EquipItem(player, "HuntingJacket_Summer", 1);
            EquipItem(player, "HunterPants_Summer", 1);
            EquipItem(player, "HuntingVest", 1);
            EquipItem(player, "CombatBoots_Green", 1);
            EquipItem(player, "Headtorch_Black", 1);
            EquipItem(player, "HuntingKnife", 1);
            EquipItem(player, "CZ527", 1);
            EquipItem(player, "Mag_CZ527_5rnd", 2);
            EquipItem(player, "AmmoBox_762x39_20Rnd", 1);
            EquipItem(player, "HuntingOptic", 1);
            EquipItem(player, "CZ75", 1);
            EquipItem(player, "Mag_CZ75_15Rnd", 2);
            EquipItem(player, "AmmoBox_9x19_25rnd", 1);
            EquipItem(player, "PistolSuppressor", 1);
            EquipItem(player, "ImprovisedSuppressor", 1);
            EquipItem(player, "Rags", 6);
            EquipItem(player, "Canteen", 2);
            EquipItem(player, "CanOpener", 1);
            EquipItem(player, "Battery9V", 2);
            EquipItem(player, "HuntingKnife", 1);
	 }
	

ich habs nicht probiert. ansonsten von einer cleanen init.c ausgehen und neu einbauen.

 

Edited by g4borg
  • Like 1

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×