Home » Renegade Discussions » Mod Forum » Can you spot the glitch?
() 1 Vote
Can you spot the glitch? [message #485624] |
Mon, 03 February 2014 20:24 |
Stallion
Messages: 222 Registered: April 2006
Karma: 0
|
Recruit |
|
|
Ok, so I have a script I made (more of reversed engineered and altered). I finally got it to compile and it shows up in level editor, but the spot that is supposed to drop down in the scripts selection section won't show the Get_parameter().
Can you spot the glitch?
*****The intent is to stop a weapon from being able to be used via selection in l.e. scripts drop down setting of "Deployable_Beacon_Preset_Name"
My script:
Stallion.h:
class ST_Deployable_Prevention_Zone : public ScriptImpClass {
void Entered(GameObject *obj,GameObject *enter);
void Timer_Expired(GameObject *obj,int number);
void Remove_Weapon_Safely(GameObject *obj,const char *WeaponName);
};
Stallion.cpp:
#include "general.h"
#include "scripts.h"
#include "engine.h"
#include "VehicleGameObj.h"
#include "Stallion.h"
void ST_Deployable_Prevention_Zone::Entered(GameObject *obj,GameObject *enter)
{
Commands->Start_Timer(obj,this,0.1f,Commands->Get_ID(enter));
}
void ST_Deployable_Prevention_Zone::Timer_Expired(GameObject *obj,int number)
{
const char *i;
i = Get_Parameter("Deployable_Beacon_Preset_Name");
GameObject* checkplayerobj = Commands->Find_Object(number);
if ( IsInsideZone(obj,checkplayerobj))
{
if (Get_Total_Bullets(checkplayerobj, i))
{
const char* currentweapon = Get_Current_Weapon(checkplayerobj);
if (strcmp(currentweapon, i) == 0 && Get_Current_Bullets(checkplayerobj) > 0)
{
Commands->Select_Weapon(checkplayerobj,"");
Commands->Select_Weapon(checkplayerobj,i);
}
Commands->Start_Timer(obj,this,0.5,number);
}
}
}
void ST_Deployable_Prevention_Zone::Remove_Weapon_Safely(GameObject *obj,const char *WeaponName)
{
const char *CurrentWeapon = Get_Current_Weapon(obj);
if (CurrentWeapon)
{
if (!_stricmp(CurrentWeapon,WeaponName))
{
if (Has_Weapon(obj,"Weapon_Pistol_Player"))
{
Commands->Select_Weapon(obj,"Weapon_Pistol_Player");
Remove_Weapon(obj,WeaponName);
Commands->Select_Weapon(obj,"Weapon_Pistol_Player");
}
}
}
}
ScriptRegistrant<ST_Deployable_Prevention_Zone> ST_Deployable_Prevention_Zone_Registrant("ST_Deployable_Prevention_Zone", "");
Level edit is my play ground
|
|
|
Re: Can you spot the glitch? [message #485627 is a reply to message #485624] |
Mon, 03 February 2014 21:01 |
|
Whitedragon
Messages: 832 Registered: February 2003 Location: California
Karma: 1
|
Colonel |
|
|
You have to declare the parameters in the script registrant.
ScriptRegistrant<ST_Deployable_Prevention_Zone> ST_Deployable_Prevention_Zone_Registrant("ST_Deployable_Prevention_Zone", "Deployable_Beacon_Preset_Name:string");
Black-Cell.net
Network Administrator (2003 - )
DragonServ, Renegade's first IRC interface bot
Creator and lead coder (2002 - )
Dragonade, Renegade's first server side modification
Lead coder (2005 - )
|
|
|
|
Re: Can you spot the glitch? [message #485639 is a reply to message #485624] |
Tue, 04 February 2014 05:30 |
|
danpaul88
Messages: 5795 Registered: June 2004 Location: England
Karma: 0
|
General (5 Stars) |
|
|
You should fix the following problems;
GameObject* checkplayerobj = Commands->Find_Object(number);
if ( IsInsideZone(obj,checkplayerobj))
You passed <number> as a timer parameter, so at this point you don't know that the gameobject referenced by that number still exists. Your code will crash if checkplayerobj is NULL after the call to Find_Object. Change it to
GameObject* checkplayerobj = Commands->Find_Object(number);
if ( NULL != checkplayerobj && IsInsideZone(obj,checkplayerobj))
const char* currentweapon = Get_Current_Weapon(checkplayerobj);
if (strcmp(currentweapon, i) == 0 && Get_Current_Bullets(checkplayerobj) > 0)
NULL is a valid return value from Get_Current_Weapon, again leading to a potential crash. Fix it by checking for NULL before using currentweapon
const char* currentweapon = Get_Current_Weapon(checkplayerobj);
if (NULL != currentweapon && strcmp(currentweapon, i) == 0 && Get_Current_Bullets(checkplayerobj) > 0)
Also fix this in your Remove_Weapon_Safely function (which doesn't appear to be called anywhere?)
Commands->Select_Weapon(checkplayerobj,"");
Commands->Select_Weapon(checkplayerobj,i);
This would appear to be redundant, why call Select_Weapon twice?
|
|
|
Re: Can you spot the glitch? [message #485645 is a reply to message #485624] |
Tue, 04 February 2014 14:48 |
Stallion
Messages: 222 Registered: April 2006
Karma: 0
|
Recruit |
|
|
This script is in the process of being reverse engineered from Iran_Beaconing_Prevention_Zone which functions properly for the ions and nukes. It would seem I have a lot to do in order to get it functioning even though I changed so little. I got the registrant worked out so now it'll let me put in the preset, but you guys see some of the other stuff.
I'll look into the stuff you guys put, and see what I can do.
here's a copy of his script:
#include "general.h"
#include "scripts.h"
#include "VehicleGameObj.h"
#include "engine.h"
#include "iran_scripts.h"
void Iran_Beaconing_Prevention_Zone::Entered(GameObject *obj,GameObject *enter)
{
Commands->Start_Timer(obj,this,0.1f,Commands->Get_ID(enter));
}
void Iran_Beaconing_Prevention_Zone::Timer_Expired(GameObject *obj,int number)
{
GameObject* checkplayerobj = Commands->Find_Object(number);
if ( IsInsideZone(obj,checkplayerobj))
{
if (Get_Total_Bullets(checkplayerobj, "CnC_Weapon_NukeBeacon_Player"))
{
const char* currentweapon = Get_Current_Weapon(checkplayerobj);
if (strcmp(currentweapon, "CnC_Weapon_NukeBeacon_Player") == 0 && Get_Current_Bullets(checkplayerobj) > 0)
{
Commands->Select_Weapon(checkplayerobj,"");
Commands->Select_Weapon(checkplayerobj,"CnC_Weapon_NukeBeacon_Player");
}
Commands->Start_Timer(obj,this,0.5,number);
}
else if (Get_Total_Bullets(checkplayerobj, "CnC_Weapon_IonCannonBeacon_Player"))
{
const char* currentweapon = Get_Current_Weapon(checkplayerobj);
if(strcmp(currentweapon,"CnC_Weapon_IonCannonBeacon_Player") == 0 && Get_Current_Bullets(checkplayerobj) > 0)
{
Commands->Select_Weapon(checkplayerobj,"");
Commands->Select_Weapon(checkplayerobj,"CnC_Weapon_IonCannonBeacon_Player");
}
Commands->Start_Timer(obj,this,0.5,number);
}
}
}
void Iran_Beaconing_Prevention_Zone::Remove_Weapon_Safely(GameObject *obj,const char *WeaponName)
{
const char *CurrentWeapon = Get_Current_Weapon(obj);
if (CurrentWeapon)
{
if (!_stricmp(CurrentWeapon,WeaponName))
{
if (Has_Weapon(obj,"Weapon_Pistol_Player"))
{
Commands->Select_Weapon(obj,"Weapon_Pistol_Player");
Remove_Weapon(obj,WeaponName);
Commands->Select_Weapon(obj,"Weapon_Pistol_Player");
}
else
{
Grant_Powerup(obj, "POW_Pistol_Player");
Commands->Select_Weapon(obj,"Weapon_Pistol_Player");
Remove_Weapon(obj,WeaponName);
Commands->Select_Weapon(obj,"Weapon_Pistol_Player");
}
}
}
}
ScriptRegistrant<Iran_Beaconing_Prevention_Zone> Iran_Beaconing_Prevention_Zone_Registrant("Iran_Beaconing_Prevention_Zone", "");
Level edit is my play ground
|
|
|
Re: Can you spot the glitch? [message #485966 is a reply to message #485639] |
Tue, 11 February 2014 12:37 |
|
Jerad2142
Messages: 3811 Registered: July 2006 Location: USA
Karma: 6
|
General (3 Stars) |
|
|
danpaul88 wrote on Tue, 04 February 2014 05:30 |
Commands->Select_Weapon(checkplayerobj,"");
Commands->Select_Weapon(checkplayerobj,i);
This would appear to be redundant, why call Select_Weapon twice?
|
Select weapon is called twice to make it so you can't shoot. It basically relies on the switch time to disable the gun, best way I've found to do it thus far anyways.
Visit Jerad's deer sweat shop
|
|
|
Goto Forum:
Current Time: Thu Nov 28 01:56:13 MST 2024
Total time taken to generate the page: 0.00729 seconds
|