Page 2 of 2
Re: Small modding tasks
Posted: June 26th, 2011, 1:43 am
by Drofder2004
F |Madness| U wrote:Well I know there is a function somewhere that allows you to change what you see on the scoreboard. For TDM it is something like
onScoareBoard( score, kills, deaths, assists, kdr ). So if changed `score` to `newscore`and then set up a way to save the players score to newscore, it might work? Although at the moment I have no idea how I would add it to their newscore

to my knowledge, doesnt exist in CoD4.
Re: Small modding tasks
Posted: June 26th, 2011, 11:11 am
by F |Madness| U
On Black Ops, I found a function setScoreBoardColumns ( kills, deaths, assists, kdr ), but as you can see there isn't an option to change the score column :S
Re: Small modding tasks
Posted: June 30th, 2011, 11:59 am
by F |Madness| U
I've got a problem which is probably pretty simple to do, just I have no clue how after trying to find out. Basically I want a certain weapon to do damage on someone, if they go inside a certain trigger at a certain time. I know how to script the trigger prat, I just don't know how to actually hurt the player with this certain weapon when they are inside the trigger. I want to use something like an airstrike, not an actual gun, but I don't need the FX or something, I just want the weaponfile to be applied to that player when they're inside the trigger, if you understand what I mean. -Thanks.
Re: Small modding tasks
Posted: June 30th, 2011, 2:35 pm
by iCYsoldier
You could edit the "Callback_PlayerDamage" function in the "_globallogic_player.gsc" file in maps\mp\gametypes. This is the function that calculates the damage done. One of its parameters is the 'sWeapon' string which, I assume, is the weapon that was used to hurt the player. You can check if this equals some weapon of your choice. You could also get the trigger entity from the map and check if the player is touching it. I think this will work, good luck

Re: Small modding tasks
Posted: June 30th, 2011, 3:56 pm
by F |Madness| U
I don't think you understand

That function is used to check things once they have been damaged isn't it? I want to somehow make somebody be damaged by a certain weapon, not check if they have been damaged by it.
Re: Small modding tasks
Posted: June 30th, 2011, 7:45 pm
by Drofder2004
iCY I believe is correct.
The callback function for player_damage is the function that deals with any damage.
you should be able to call it yourself and insert custom parameters, where sWeapon is the weapon you want to use and iDamage is the amount of damage.
If you don't understand, will actually go look at the syntax (cba atm

) later (or someone else will respond by then).
Re: Small modding tasks
Posted: June 30th, 2011, 8:36 pm
by F |Madness| U
I think I understand it now! I was messing around trying to ge ta knife to do a certain amount of damage, because for some reason the knife damage varies (I think depending on where you hit the person) between about 130-140 damage. Anyway I managed to use the Callback funtion to make the knife damage always do 50, so I think I may be able to know what to do now. If I fail then be ready to see this topic bumped again in a few hours

Re: Small modding tasks
Posted: June 30th, 2011, 10:01 pm
by Drofder2004
Glad for a change not to have to write the code first before an attempt is made

Re: Small modding tasks
Posted: July 19th, 2011, 11:29 am
by F |Madness| U
20 days later and I failed! I tried something like
Code: Select all
for(i=0;i<level.players.size;i++)
    {
        player = level.players[i];
        if(isDefined(minetrigger) && player IsTouching(minetrigger) && player.team == "axis")
        {
            player thread damage(eInflictor, eAttacker, 1000, iDFlags, "MOD_EXPLOSION", "artillery_mp", vPoint, vDir, sHitLoc, timeOffset);
           Â
However I got a load of errors, I'm guessing because of all the unitialised variables. Was this the right way of making the player be damaged by artillery_mp, do I just need to make up a value for each variable?
Also, I have an array of distances (see code below), and was wondering how I can get the largest distance from the array, and relate it back to the corresponding spawnpoint.origin? I tihnk I know how I would get the cooresponding spawnpoint.origin, but I'm just unsure as to how to pick out the largest value from that array.
Code: Select all
    dist_from_zombies = [];
    for(i = 0; i < level.spawnpoints.size; i++)
    {
        spawnpoint = level.spawnpoints[i];
        dist_from_zombies[i] = getclosest(spawnpoint.origin, axis);
    }
Re: Small modding tasks
Posted: July 19th, 2011, 1:20 pm
by iCYsoldier
For the first problem, you do need to make up values for each variable
Second problem, you can just use a standard find maximum value algorithm. I want write the code because I'm lazy and you should do it

What you want to do is create a temp variable to store the maximum value. Loop through each value in the array and do a simple if check to check if the current array item is larger than the temp one. If it is, set temp to the current value. Finally, return temp.
I pretty much just gave you the pseudo code for it :S

Re: Small modding tasks
Posted: July 19th, 2011, 3:30 pm
by F |Madness| U
Edit: Ignore for now.
Re: Small modding tasks
Posted: July 19th, 2011, 7:07 pm
by F |Madness| U
Thankyou for explaining iCYSoldier, I would rather people explain than just write code out for me

I managed to solve the damage problem quickly, and after a few hours managed to get a working code for what I wanted. It basically teleports you to a spawnpoint that is furthest away from a zombie, code is below if anyone is interested or wants to say what I could have improved in the code
Code: Select all
teleport()
{
    self endon("teleported");
    // -- Creates an array of players that are on zombie team
    zombies = [];
    for(i = 0; i < level.players.size; i++)
    {
        if(level.players[i].pers["team"] == "axis")
        {
            zombies = add_to_array(zombies, level.players[i]);
        }
    }
   Â
    // -- For reach spawnpoint, it finds the closest player from zombies array, and adds them into an array, then gets the distance between the spawnpoint and player, and adds the distnace into an array.
    closestzombie = [];
    dist_from_zombies = [];
    for(i = 0; i < level.spawnpoints.size; i++)
    {
        closestzombie[i] = getclosest(level.spawnpoints[i].origin, zombies);
        dist_from_zombies[i] = distance(level.spawnpoints[i].origin, closestzombie[i].origin);
    }
   Â
    // -- For each distance in the array, checks to see if its bigger than the previous, ending variable `furthest` should have the largest distance.
    furthest = dist_from_zombies[0];
    for(i = 1; i < dist_from_zombies.size; i++)
    {
        if(dist_from_zombies[i] > furthest)
            furthest = dist_from_zombies[i];
    }
    // -- Then checks the distance between each spawnpoint, and each closest zombie to that spawn.
    // -- If the distance is the same as the variable above, it puts you at that spawnpoint.
    for(i=0; i<level.spawnpoints.size; i++)
    {
        if(distance(level.spawnpoints[i].origin,closestzombie[i].origin)==furthest)
        {
            self setOrigin(level.spawnpoints[i].origin);
            self notify("teleported");
        }
    }   Â
}